thingsboard_client 5.0.0
thingsboard_client: ^5.0.0 copied to clipboard
ThingsBoard REST API client for Flutter. JWT auth, auto-refresh, WebSocket telemetry, typed error handling.
5.0.0 #
ThingsBoard CE and PE are now one product, and thingsboard_client is its single Dart client. It replaces thingsboard_pe_client, which is discontinued: its last version, 5.0.0, only re-exports this package. See MIGRATION.md for upgrading from thingsboard_client 4.x or thingsboard_pe_client 4.4.x.
- Breaking: the client is generated from the ThingsBoard OpenAPI spec (openapi-generator 7.26.0, dart-dio, built_value) instead of being written by hand: 94 API classes and 1071 model types. The 4.x services (
getDeviceService(), ...) are replaced by API classes (getDeviceControllerApi(), ...) with named parameters,Response<T>results, paging bypageSize:/page:and built_value models. See Migrating from 4.x and the service → API table. - Breaking: requires Dart SDK 3.10.0 or later (Flutter 3.38 or later) and ThingsBoard 4.4.0 or later, and depends on
web_socket_channel^3.0.3 anddio^5.7.0. - Breaking: generated API calls throw
DioException, notThingsboardError, and getters no longer returnnullon HTTP 404. New helpers:e.thingsboardError(extensionThingsboardDioException) andnullIfNotFound(() => call()). See Errors. - Breaking: the 4.x CE customer, public and edge assignment methods are not in the ThingsBoard 4.4 API; use
OwnerControllerApiandEntityGroupControllerApi. See Customer, public and edge assignment. - Breaking:
ThingsboardClientno longer hasdioOptions,reInit,sendResetPasswordLink,getAuthUserFromJwtorgetPlatformVersion. The server version is checked whenever a full session is loaded (login, two-factor verification,init()), for every authority; an older server throwsUnsupportedServerVersionErrorand the session is cleared.changePassword,checkTwoFaVerificationCodeandgetLoginDataBySecretKeyare kept, with the same session behaviour as in 4.x. SeeThingsboardClientchanges. - Breaking:
LoginRequest,RefreshTokenRequestandLoginResponseare the generated built_value models, exported by the main library; the wire format is unchanged.Authorityis a single generated type, andAuthUser.authorityisnullfor an anonymous user. See Changes for both. - Breaking:
ThingsboardError.errorCodevalues match the server:subscriptionViolationis 40,entitiesLimitExceeded(41) andsetupIncomplete(47) are new,tenantTrialExpiredis removed. - Breaking:
SortOrdertakes the generatedDirection; the handwrittenDirectionis removed. - Breaking: removed
isSuccessful,AuthUser.fromToken, the top-levelisJwtTokenValid(String?)and theKeyInterceptConfigexport. - Breaking: the telemetry WebSocket API is exported by the main library and uses the generated built_value models; updates are immutable, and a custom
WebsocketCmdmust overrideupdateParser. See Telemetry WebSocket. - Breaking: 21 response fields that the spec marked as required are nullable, because the server can send
nullin them; before, these responses threw on deserialization. Among them:generateTwoFaAccountConfigfor SMS (phoneNumber),getAccountTwoFaSettingsfor a user with backup codes (codes), edges read by a customer user (edgeLicenseKey), the metadata of a new rule chain, and the entities of user, customer and dashboard groups (ShortEntityView.name). See Spec fixes. - Breaking for
thingsboard_pe_client4.4.x: 68 enum constants in 19 enums are renamed (EntityType.oAUTH2CLIENT→OAUTH2_CLIENT, ...),FontWeightandFontStyleare renamed toTbFontWeightandTbFontStyle(they shadowed the Flutter types),DeviceApiControllerApiandSolutionControllerApiare removed, and 11 API classes of ThingsBoard 4.4.0 plusSystemInfoControllerApiare added. See Migrating fromthingsboard_pe_client4.4.x. - Breaking for
thingsboard_pe_client4.4.x: corrected types.claimDevicereturns a typedClaimResult,getPersistedRpcByDeviceaPageDataRpcandexportIntegrationPackagethe ZIP archive asUint8List(all three wereString);assignAlarmandunassignAlarmreturnAlarmInfo, as the server does;pageSizeandpageareintin the 28 operations that typed them asString(entity group, owner, user-scoped list, converter, integration, role and scheduler operations), and so is thelimitofgetTimeseriesHistory. See Spec fixes. - Breaking for
thingsboard_pe_client4.4.x: theproviderof the AI chat model configs (OpenAiChatModelConfig, ...) is theAiProviderenum instead of aString. - New:
apiSerializers(register<Model>), with aregister<Model>function for every model, serializes a single model without pulling every model into the build likestandardSerializersdoes. See Models are built_value. - New:
ThingsboardClient.close()stops a client that the application replaces with a new one on the same storage: it closes the telemetry WebSocket, and the old client no longer writes the storage or callsonUserLoaded, even for a token refresh that was still in flight. - New: most generated subtypes set their discriminator themselves, so
DeviceId((b) => b..id = uuid)andSingleEntityFilter(...)need noentityTypeortype. - New, from ThingsBoard 4.4.1 (not in 4.4.0):
AiResourceControllerApi,AiModelControllerApi.getAiModelInfosandsendChatRequestToAiModel,AiSolutionControllerApi.sendMessage,AiModel.customerAccessEnabled,Operation.INVOKE,BulkImportColumnType.OVERWRITE_ACTIVITY_TIME,BorderType.double_and theborderType,borderWidthandborderColorfields ofCellSettings. - Changed: the client is generated from the API documentation of ThingsBoard 4.4.1, which corrects that of 4.4.0 in the login response (
JwtPair,RefreshTokenRequest), numericThingsboardErrorCode,AliasEntityId, typedNotification.info,getSystemVersionInfoand the fields the server sends as null. The wire format is unchanged, so ThingsBoard 4.4.0 servers work. See Spec fixes. - Changed: each API operation registers only the serializers it needs, so operations an application does not call are tree-shaken together with their models. Likewise, each WebSocket update is parsed by its command's parser: a program with a login and one telemetry subscription compiles to a 2.35 MB AOT snapshot.
- Changed: the HTTP logging of
debugModeand ofgetLoginDataBySecretKey(logging: true)masks credentials: theAuthorizationandX-Authorizationheader values, the QR login secret, and the values of query parameters and JSON body fields named*password,*token,*secretorcredentialsValue. - Changed: the telemetry WebSocket reports its errors through
dart:developerlog()(namethingsboard_client, shown in the DevTools Logging view) instead ofprint(). - Fixed: the
TelemetryObserveStrategyconstants ofthingsboard_pe_client4.4.x had wrong wire values ('SINGLE (0): One resource ...'); 5.0 sendsSINGLE,COMPOSITE_ALLandCOMPOSITE_BY_OBJECT. - Fixed:
LocalFileStorage.getItemreturnsdefaultValuefor an absent key andcontainsKeywaits for the file to load, so a key stored by a previous instance is found. - Fixed: a client created with
apiKeyopens the telemetry WebSocket and authenticates it with the key (AuthCmd.apiKey). Before, the socket never opened and subscriptions received nothing. - Fixed:
logout()and other closes of the telemetry WebSocket no longer throwInvalid argument: 1001, close code must be 1000 or in the range 3000-4999on dart:io; the client closes with 1000 (normal closure). - Fixed: a WebSocket subscription error update without data no longer crashes the parser.
- Fixed:
withTsOffsetof alarm updates shifted unset times: an alarm that was not acknowledged, cleared or ended gotackTs/clearTs/endTsequal to the offset instead of 0. Unset times (0) now stay 0, as in the ThingsBoard web UI. - Fixed: operations that return a
Stringthrew on success when the server answered with JSON (the rule engine and two-way RPC calls); they now return the JSON text. - Fixed: a request retried after a token refresh or a 429 hung when the retry failed too; it now fails with the error of the retry. A request is retried at most once.
- Fixed: a token refresh that finished after
logout(),setUserFromJwtToken()or a new login stored its tokens over the newer session; its result is now dropped, and a request waiting on it is retried with the current session, or fails when there is none.
4.2.1 #
- Fixed
AlarmType.fromJsoncast error when filtering alarms by type
4.2.0 #
- Added
ImageServicefor managing image uploads - Fixed
AlarmComment.commentdeserialization intoAlarmCommentJsonNode - Fixed analyzer warnings (unused imports, deprecation messages, identifier naming)
4.1.0 #
- Thingsboard 4.3.0+ support
- Api key management
- Api key auth support
- 2Fa force support
4.0.0 #
- Changes in TbStorage interface
3.0.1 #
- Adapted to backend changes for version information representation.
3.0.0 #
- Introduced a new API for dynamically configuring via mobile center.
- The minimum supported TB version is 3.9.0 and higher.
2.0.0 #
- Enhanced TbStorage interface for improved usability.
- Introduced a new API for alarm activity management, including support for comments and additional functionalities.
1.3.1 #
- Increased the minimum supported ThingsBoard version to 3.8.0.
1.3.0 #
-
New APIs:
/api/alarm/types- Fetches available alarm types./api/users/info- Retrieves user information.
-
Enhancements:
- Added the ability to log request and response details for improved debugging.
-
Bug Fixes:
- Various minor bug fixes to improve stability and performance.
1.2.0 #
- Introduced the ability to configure access to custom applications using a login with a QR code feature.
- Update API and models according to ThingsBoard platform version 3.7.0
- Fixed the issue with resolving supported platform versions.
- Implemented other minor fixes.
1.1.1 #
- Introduced a NotificationService, which allows you to receive notification data.
1.1.0 #
- Updated the API and models to align with the latest ThingsBoard platform, version 3.6.3
- Introduced support for push notifications
1.0.8 #
1.0.7 #
- Update API and models according to ThingsBoard platform version 3.6.0
- Fixed issue #17: get json attributes when value is array
1.0.6 #
- Fixed incorrect deserializing alarm models
1.0.5 #
- Update API and models according to ThingsBoard platform version 3.5.0
1.0.4 #
- Update API and models according to ThingsBoard platform version 3.4.2
1.0.3 #
- Update API and models according to ThingsBoard platform version 3.4.0
- Added MFA support
- Fix dart analysis issues
1.0.2 #
- Add support for web platform
1.0.1 #
- Improve description
- Improve pubspec: add github links
- Use formatting according to dartfmt
1.0.0 #
- Initial version, created by Igor Kulikov