From 10bf83b1c90438634dee219956495929388c8462 Mon Sep 17 00:00:00 2001 From: guyluz Date: Mon, 29 May 2023 23:01:37 +0300 Subject: [PATCH 01/18] Commented isar code for now as it doesn't support arm --- .idea/misc.xml | 1 - .../isar_old_objects/bindings_isar_model.dart | 18 ++++----- .../isar_old_objects/devices_isar_model.dart | 18 ++++----- .../hub_entity_isar_model.dart | 24 ++++++------ .../lifx_vendor_credentials_isar_model.dart | 32 ++++++++-------- .../remote_pipes_isar_model.dart | 20 +++++----- .../isar_old_objects/rooms_isar_model.dart | 38 +++++++++---------- .../isar_old_objects/routines_isar_model.dart | 18 ++++----- .../isar_old_objects/scenes_isar_model.dart | 18 ++++----- .../tuya_vendor_credentials_isar_model.dart | 32 ++++++++-------- pubspec.yaml | 4 +- 11 files changed, 111 insertions(+), 112 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 1763e153..04f5c25f 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,3 @@ - diff --git a/lib/infrastructure/local_db/isar_old_objects/bindings_isar_model.dart b/lib/infrastructure/local_db/isar_old_objects/bindings_isar_model.dart index 4f8ee607..25439500 100644 --- a/lib/infrastructure/local_db/isar_old_objects/bindings_isar_model.dart +++ b/lib/infrastructure/local_db/isar_old_objects/bindings_isar_model.dart @@ -1,9 +1,9 @@ -import 'package:isar/isar.dart'; - -part 'bindings_isar_model.g.dart'; - -@collection -class BindingsIsarModel { - Id id = Isar.autoIncrement; - late String bindingsStringJson; -} +// import 'package:isar/isar.dart'; +// +// part 'bindings_isar_model.g.dart'; +// +// @collection +// class BindingsIsarModel { +// Id id = Isar.autoIncrement; +// late String bindingsStringJson; +// } diff --git a/lib/infrastructure/local_db/isar_old_objects/devices_isar_model.dart b/lib/infrastructure/local_db/isar_old_objects/devices_isar_model.dart index 95a4fe3c..6d0264c7 100644 --- a/lib/infrastructure/local_db/isar_old_objects/devices_isar_model.dart +++ b/lib/infrastructure/local_db/isar_old_objects/devices_isar_model.dart @@ -1,9 +1,9 @@ -import 'package:isar/isar.dart'; - -part 'devices_isar_model.g.dart'; - -@collection -class DevicesIsarModel { - Id? id = Isar.autoIncrement; - late String deviceStringJson; -} +// import 'package:isar/isar.dart'; +// +// part 'devices_isar_model.g.dart'; +// +// @collection +// class DevicesIsarModel { +// Id? id = Isar.autoIncrement; +// late String deviceStringJson; +// } diff --git a/lib/infrastructure/local_db/isar_old_objects/hub_entity_isar_model.dart b/lib/infrastructure/local_db/isar_old_objects/hub_entity_isar_model.dart index f3fbd788..3373100c 100644 --- a/lib/infrastructure/local_db/isar_old_objects/hub_entity_isar_model.dart +++ b/lib/infrastructure/local_db/isar_old_objects/hub_entity_isar_model.dart @@ -1,12 +1,12 @@ -import 'package:isar/isar.dart'; - -part 'hub_entity_isar_model.g.dart'; - -@collection -class HubEntityIsarModel { - Id id = Isar.autoIncrement; - - late String hubNetworkBssid; - late String networkName; - late String lastKnownIp; -} +// import 'package:isar/isar.dart'; +// +// part 'hub_entity_isar_model.g.dart'; +// +// @collection +// class HubEntityIsarModel { +// Id id = Isar.autoIncrement; +// +// late String hubNetworkBssid; +// late String networkName; +// late String lastKnownIp; +// } diff --git a/lib/infrastructure/local_db/isar_old_objects/lifx_vendor_credentials_isar_model.dart b/lib/infrastructure/local_db/isar_old_objects/lifx_vendor_credentials_isar_model.dart index 4a7674bd..37a98e8a 100644 --- a/lib/infrastructure/local_db/isar_old_objects/lifx_vendor_credentials_isar_model.dart +++ b/lib/infrastructure/local_db/isar_old_objects/lifx_vendor_credentials_isar_model.dart @@ -1,16 +1,16 @@ -import 'package:isar/isar.dart'; - -part 'lifx_vendor_credentials_isar_model.g.dart'; - -@collection -class LifxVendorCredentialsIsarModel { - Id id = Isar.autoIncrement; - - late String? senderUniqueId; - late String lifxApiKey; - late String tuyaUserPassword; - late String tuyaCountryCode; - late String tuyaBizType; - late String tuyaRegion; - late String loginVendor; -} +// import 'package:isar/isar.dart'; +// +// part 'lifx_vendor_credentials_isar_model.g.dart'; +// +// @collection +// class LifxVendorCredentialsIsarModel { +// Id id = Isar.autoIncrement; +// +// late String? senderUniqueId; +// late String lifxApiKey; +// late String tuyaUserPassword; +// late String tuyaCountryCode; +// late String tuyaBizType; +// late String tuyaRegion; +// late String loginVendor; +// } diff --git a/lib/infrastructure/local_db/isar_old_objects/remote_pipes_isar_model.dart b/lib/infrastructure/local_db/isar_old_objects/remote_pipes_isar_model.dart index 8b094470..bb571e68 100644 --- a/lib/infrastructure/local_db/isar_old_objects/remote_pipes_isar_model.dart +++ b/lib/infrastructure/local_db/isar_old_objects/remote_pipes_isar_model.dart @@ -1,10 +1,10 @@ -import 'package:isar/isar.dart'; - -part 'remote_pipes_isar_model.g.dart'; - -@collection -class RemotePipesIsarModel { - Id id = Isar.autoIncrement; - - late String domainName; -} +// import 'package:isar/isar.dart'; +// +// part 'remote_pipes_isar_model.g.dart'; +// +// @collection +// class RemotePipesIsarModel { +// Id id = Isar.autoIncrement; +// +// late String domainName; +// } diff --git a/lib/infrastructure/local_db/isar_old_objects/rooms_isar_model.dart b/lib/infrastructure/local_db/isar_old_objects/rooms_isar_model.dart index 442d6a4a..9284ea8f 100644 --- a/lib/infrastructure/local_db/isar_old_objects/rooms_isar_model.dart +++ b/lib/infrastructure/local_db/isar_old_objects/rooms_isar_model.dart @@ -1,19 +1,19 @@ -import 'package:isar/isar.dart'; - -part 'rooms_isar_model.g.dart'; - -@collection -class RoomsIsarModel { - Id id = Isar.autoIncrement; - - late String roomUniqueId; - late String roomDefaultName; - late List roomDevicesId; - late List roomScenesId; - late List roomRoutinesId; - late List roomBindingsId; - late List roomMostUsedBy; - late List roomPermissions; - late List roomTypes; - late String roomBackground; -} +// import 'package:isar/isar.dart'; +// +// part 'rooms_isar_model.g.dart'; +// +// @collection +// class RoomsIsarModel { +// Id id = Isar.autoIncrement; +// +// late String roomUniqueId; +// late String roomDefaultName; +// late List roomDevicesId; +// late List roomScenesId; +// late List roomRoutinesId; +// late List roomBindingsId; +// late List roomMostUsedBy; +// late List roomPermissions; +// late List roomTypes; +// late String roomBackground; +// } diff --git a/lib/infrastructure/local_db/isar_old_objects/routines_isar_model.dart b/lib/infrastructure/local_db/isar_old_objects/routines_isar_model.dart index 6c645265..8993b81e 100644 --- a/lib/infrastructure/local_db/isar_old_objects/routines_isar_model.dart +++ b/lib/infrastructure/local_db/isar_old_objects/routines_isar_model.dart @@ -1,9 +1,9 @@ -import 'package:isar/isar.dart'; - -part 'routines_isar_model.g.dart'; - -@collection -class RoutinesIsarModel { - Id id = Isar.autoIncrement; - late String routinesStringJson; -} +// import 'package:isar/isar.dart'; +// +// part 'routines_isar_model.g.dart'; +// +// @collection +// class RoutinesIsarModel { +// Id id = Isar.autoIncrement; +// late String routinesStringJson; +// } diff --git a/lib/infrastructure/local_db/isar_old_objects/scenes_isar_model.dart b/lib/infrastructure/local_db/isar_old_objects/scenes_isar_model.dart index d8ef82c4..51d70b6b 100644 --- a/lib/infrastructure/local_db/isar_old_objects/scenes_isar_model.dart +++ b/lib/infrastructure/local_db/isar_old_objects/scenes_isar_model.dart @@ -1,9 +1,9 @@ -import 'package:isar/isar.dart'; - -part 'scenes_isar_model.g.dart'; - -@collection -class ScenesIsarModel { - Id id = Isar.autoIncrement; - late String scenesStringJson; -} +// import 'package:isar/isar.dart'; +// +// part 'scenes_isar_model.g.dart'; +// +// @collection +// class ScenesIsarModel { +// Id id = Isar.autoIncrement; +// late String scenesStringJson; +// } diff --git a/lib/infrastructure/local_db/isar_old_objects/tuya_vendor_credentials_isar_model.dart b/lib/infrastructure/local_db/isar_old_objects/tuya_vendor_credentials_isar_model.dart index 05f0a5f1..6da7a078 100644 --- a/lib/infrastructure/local_db/isar_old_objects/tuya_vendor_credentials_isar_model.dart +++ b/lib/infrastructure/local_db/isar_old_objects/tuya_vendor_credentials_isar_model.dart @@ -1,16 +1,16 @@ -import 'package:isar/isar.dart'; - -part 'tuya_vendor_credentials_isar_model.g.dart'; - -@collection -class TuyaVendorCredentialsIsarModel { - Id id = Isar.autoIncrement; - - late String? senderUniqueId; - late String tuyaUserName; - late String tuyaUserPassword; - late String tuyaCountryCode; - late String tuyaBizType; - late String tuyaRegion; - late String loginVendor; -} +// import 'package:isar/isar.dart'; +// +// part 'tuya_vendor_credentials_isar_model.g.dart'; +// +// @collection +// class TuyaVendorCredentialsIsarModel { +// Id id = Isar.autoIncrement; +// +// late String? senderUniqueId; +// late String tuyaUserName; +// late String tuyaUserPassword; +// late String tuyaCountryCode; +// late String tuyaBizType; +// late String tuyaRegion; +// late String loginVendor; +// } diff --git a/pubspec.yaml b/pubspec.yaml index 5fb6b0f1..1c499a7c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -40,7 +40,7 @@ dependencies: # Utility library that checks for an Active Internet connection internet_connection_checker: ^1.0.0+1 # Extremely fast, easy to use, and fully async NoSQL database. - isar: ^3.0.5 +# isar: ^3.0.5 # Defines the annotations used by json_serializable to create code for JSON serialization and deserialization. json_annotation: ^4.8.0 # Dart Build System builders for handling JSON. @@ -82,7 +82,7 @@ dev_dependencies: # Injectable is a convenient code generator for get_it. injectable_generator: ^2.1.4 # Code generator for the Isar Database. Finds classes annotated with @Collection. - isar_generator: ^3.0.5 +# isar_generator: ^3.0.5 # Collection of lint rules for Dart and Flutter projects lint: ^2.0.1 # Library for mocks From a4cdb23f6eb6fd20941e8357244753c53a123582 Mon Sep 17 00:00:00 2001 From: guyluz Date: Mon, 29 May 2023 23:28:34 +0300 Subject: [PATCH 02/18] Updated packages --- .../tuya_smart_remote_api/cloudtuya.dart | 2 +- lib/injection.config.dart | 8 +++++--- pubspec.yaml | 20 +++++++++---------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/lib/infrastructure/devices/tuya_smart/tuya_smart_remote_api/cloudtuya.dart b/lib/infrastructure/devices/tuya_smart/tuya_smart_remote_api/cloudtuya.dart index 34dee254..26843281 100644 --- a/lib/infrastructure/devices/tuya_smart/tuya_smart_remote_api/cloudtuya.dart +++ b/lib/infrastructure/devices/tuya_smart/tuya_smart_remote_api/cloudtuya.dart @@ -121,7 +121,7 @@ class CloudTuya { return tuyaDeviceList; } - for (final dynamic device in devicesList) { + for (final dynamic device in devicesList as Iterable) { if (device['ha_type'] != 'scene') { final TuyaDeviceAbstract tuyaDevice = TuyaDeviceAbstract.fromInternalLinkedHashMap(device); diff --git a/lib/injection.config.dart b/lib/injection.config.dart index 54ca42bb..56727420 100644 --- a/lib/injection.config.dart +++ b/lib/injection.config.dart @@ -4,6 +4,10 @@ // InjectableConfigGenerator // ************************************************************************** +// ignore_for_file: unnecessary_lambdas +// ignore_for_file: lines_longer_than_80_chars +// coverage:ignore-file + // ignore_for_file: no_leading_underscores_for_library_prefixes import 'package:cbj_hub/domain/app_communication/i_app_communication_repository.dart' as _i8; @@ -74,10 +78,8 @@ import 'package:cbj_hub/infrastructure/shared_variables.dart' as _i31; import 'package:cbj_hub/infrastructure/system_commands/system_commands_manager_d.dart' as _i35; import 'package:get_it/get_it.dart' as _i1; -import 'package:injectable/injectable.dart' - as _i2; // ignore_for_file: unnecessary_lambdas +import 'package:injectable/injectable.dart' as _i2; -// ignore_for_file: lines_longer_than_80_chars extension GetItInjectableX on _i1.GetIt { // initializes the registration of main-scope dependencies inside of GetIt _i1.GetIt init({ diff --git a/pubspec.yaml b/pubspec.yaml index 1c499a7c..58c468c7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -24,7 +24,7 @@ dependencies: # Annotations for freezed freezed_annotation: ^2.2.0 # For the injection, allow accessing an object from anywhere in an App - get_it: ^7.2.0 + get_it: ^7.6.0 # High performance, open-source universal RPC framework grpc: ^3.1.0 # Lightweight and blazing fast key-value database @@ -36,15 +36,15 @@ dependencies: git: url: 'https://github.com/guyluz11/hue_dart.git' # Convenient code generator for get_it - injectable: ^2.1.0 + injectable: ^2.1.1 # Utility library that checks for an Active Internet connection internet_connection_checker: ^1.0.0+1 # Extremely fast, easy to use, and fully async NoSQL database. # isar: ^3.0.5 # Defines the annotations used by json_serializable to create code for JSON serialization and deserialization. - json_annotation: ^4.8.0 + json_annotation: ^4.8.1 # Dart Build System builders for handling JSON. - json_serializable: ^6.6.1 + json_serializable: ^6.7.0 # Port of Kotlin's Kotlin Standard library for Dart/Flutter projects kt_dart: ^1.1.0 # Implementation of the LIFX HTTP API @@ -53,7 +53,7 @@ dependencies: logger: ^1.3.0 # A server and browser based MQTT client for Dart. mi_iot_token: ^1.0.0 - mqtt_client: ^9.8.1 + mqtt_client: ^10.0.0 # Service discovery over multicast DNS (mDNS), Bonjour, and Avahi. multicast_dns: ^0.3.2+3 # Helps you discover open ports, devices on subnet and more. @@ -76,16 +76,16 @@ dev_dependencies: # A generator for injectable library # Code generator for unions/pattern-matching/copy. - freezed: ^2.3.2 + freezed: ^2.3.4 # Automatically generates Hive TypeAdapters to store any class hive_generator: ^2.0.0 # Injectable is a convenient code generator for get_it. - injectable_generator: ^2.1.4 + injectable_generator: ^2.1.5 # Code generator for the Isar Database. Finds classes annotated with @Collection. # isar_generator: ^3.0.5 # Collection of lint rules for Dart and Flutter projects - lint: ^2.0.1 + lint: ^2.1.2 # Library for mocks - mockito: ^5.3.2 + mockito: ^5.4.1 # A full featured library for writing and running Dart tests across platforms. - test: ^1.24.0 + test: ^1.24.3 From 29886c2db74162bacf67ee955ffc226a74bb84da Mon Sep 17 00:00:00 2001 From: Guy Luz Date: Sun, 1 Oct 2023 20:44:35 +0300 Subject: [PATCH 03/18] Solving some of the analysis warnings --- analysis_options.yaml | 3 -- .../device_entity_abstract.dart | 6 ++-- .../cbj_smart_device_entity.dart | 6 ++-- .../esphome_node_red_api.dart | 10 +++--- .../ewelink/ewelink_connector_conjector.dart | 3 +- .../chromecast_node_red_api.dart | 34 +++++++++---------- .../devices/lg/lg_connector_conjector.dart | 2 +- .../philips_hue_api_light.dart | 4 ++- .../switcher_smart_plug_entity.dart | 3 +- .../tasmota_ip_api_components.dart | 4 +-- .../tuya_smart_remote_api/cloudtuya.dart | 2 +- .../xiaomi_io_gpx3021gl_entity.dart | 3 +- .../local_db/local_db_hive_repository.dart | 12 +++++-- .../mqtt_server/mqtt_server_repository.dart | 2 +- .../node_red/node_red_converter.dart | 10 +++--- lib/infrastructure/room/saved_rooms_repo.dart | 4 +-- .../common_bash_commands_d.dart | 5 ++- .../common_batch_commands_d.dart | 2 +- 18 files changed, 63 insertions(+), 52 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 4f9aad47..f8fddfd9 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -32,6 +32,3 @@ linter: avoid_classes_with_only_static_members: false sort_constructors_first: true - - # Good packages document everything - public_member_api_docs: true diff --git a/lib/domain/generic_devices/abstract_device/device_entity_abstract.dart b/lib/domain/generic_devices/abstract_device/device_entity_abstract.dart index 8ca8cb5d..b1f0743b 100644 --- a/lib/domain/generic_devices/abstract_device/device_entity_abstract.dart +++ b/lib/domain/generic_devices/abstract_device/device_entity_abstract.dart @@ -178,7 +178,8 @@ class DeviceEntityNotAbstract extends DeviceEntityAbstract { entityOriginalName: EntityOriginalName('Entity original name is empty'), deviceOriginalName: DeviceOriginalName( - 'Device original name that entity is exists on is empty'), + 'Device original name that entity is exists on is empty', + ), entityTypes: EntityType(EntityTypes.light.toString()), senderDeviceModel: DeviceSenderDeviceModel('a'), senderDeviceOs: DeviceSenderDeviceOs('b'), @@ -194,7 +195,8 @@ class DeviceEntityNotAbstract extends DeviceEntityAbstract { entityKey: EntityKey('entityKey is empty'), requestTimeStamp: RequestTimeStamp('requestTimeStamp is empty'), lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp( - 'lastResponseFromDeviceTimeStamp is empty'), + 'lastResponseFromDeviceTimeStamp is empty', + ), deviceCbjUniqueId: CoreUniqueId(), ); diff --git a/lib/infrastructure/devices/cbj_devices/cbj_smart_device/cbj_smart_device_entity.dart b/lib/infrastructure/devices/cbj_devices/cbj_smart_device/cbj_smart_device_entity.dart index 39c8a706..4464bf02 100644 --- a/lib/infrastructure/devices/cbj_devices/cbj_smart_device/cbj_smart_device_entity.dart +++ b/lib/infrastructure/devices/cbj_devices/cbj_smart_device/cbj_smart_device_entity.dart @@ -37,11 +37,13 @@ class CbjSmartComputerEntity extends GenericSmartComputerDE { required super.smartComputerSuspendState, }) : super( deviceVendor: DeviceVendor( - VendorsAndServices.cyBearJinniAppSmartEntity.toString()), + VendorsAndServices.cyBearJinniAppSmartEntity.toString(), + ), ); factory CbjSmartComputerEntity.fromGeneric( - GenericSmartComputerDE genericDevice) { + GenericSmartComputerDE genericDevice, + ) { return CbjSmartComputerEntity( uniqueId: genericDevice.uniqueId, entityUniqueId: genericDevice.entityUniqueId, diff --git a/lib/infrastructure/devices/esphome/esphome_node_red_api/esphome_node_red_api.dart b/lib/infrastructure/devices/esphome/esphome_node_red_api/esphome_node_red_api.dart index 9305e4ba..4f86db5f 100644 --- a/lib/infrastructure/devices/esphome/esphome_node_red_api/esphome_node_red_api.dart +++ b/lib/infrastructure/devices/esphome/esphome_node_red_api/esphome_node_red_api.dart @@ -82,7 +82,7 @@ class EspHomeNodeRedApi { topic: '$topic/$outputDeviceProperty', name: '$mqttNodeName - $outputDeviceProperty', ); - nodes += ', ${mqttOutNode.toString()}'; + nodes += ', $mqttOutNode'; /// Create an EspHome in node final NodeRedEspHomeInNode nodeRedEspHomeInNode = NodeRedEspHomeInNode( @@ -95,7 +95,7 @@ class EspHomeNodeRedApi { name: 'ESPHome $entityId in type', epsHomeDeviceEntityId: entityId, ); - nodes += ', ${nodeRedEspHomeInNode.toString()}'; + nodes += ', $nodeRedEspHomeInNode'; /// Create an EspHome out node final NodeRedEspHomeOutNode nodeRedEspHomeOutNode = NodeRedEspHomeOutNode( @@ -104,7 +104,7 @@ class EspHomeNodeRedApi { name: 'ESPHome $entityId out type', espHomeEntityId: entityId, ); - nodes += ', ${nodeRedEspHomeOutNode.toString()}'; + nodes += ', $nodeRedEspHomeOutNode'; final NodeRedFunctionNode nodeRedFunctionToJsonNode = NodeRedFunctionNode.inputPayloadToJson( @@ -114,7 +114,7 @@ class EspHomeNodeRedApi { ] ], ); - nodes += ', ${nodeRedFunctionToJsonNode.toString()}'; + nodes += ', $nodeRedFunctionToJsonNode'; /// Mqtt in final NodeRedMqttInNode nodeRedMqttInNode = NodeRedMqttInNode( @@ -127,7 +127,7 @@ class EspHomeNodeRedApi { ] ], ); - nodes += ', ${nodeRedMqttInNode.toString()}'; + nodes += ', $nodeRedMqttInNode'; nodes += '\n]'; diff --git a/lib/infrastructure/devices/ewelink/ewelink_connector_conjector.dart b/lib/infrastructure/devices/ewelink/ewelink_connector_conjector.dart index 1ed3ee67..82ffd4d0 100644 --- a/lib/infrastructure/devices/ewelink/ewelink_connector_conjector.dart +++ b/lib/infrastructure/devices/ewelink/ewelink_connector_conjector.dart @@ -38,7 +38,8 @@ class EwelinkConnectorConjector implements AbstractCompanyConnectorConjector { } on EwelinkOfflineDeviceException { logger.e('device is offline'); } catch (e) { - logger.e('error: ${e.toString()}'); + // ignore: unnecessary_brace_in_string_interps + logger.e('error: $e'); } return 'Success'; } diff --git a/lib/infrastructure/devices/google/chromecast_node_red_api/chromecast_node_red_api.dart b/lib/infrastructure/devices/google/chromecast_node_red_api/chromecast_node_red_api.dart index c1e3dc99..313ea6b9 100644 --- a/lib/infrastructure/devices/google/chromecast_node_red_api/chromecast_node_red_api.dart +++ b/lib/infrastructure/devices/google/chromecast_node_red_api/chromecast_node_red_api.dart @@ -51,12 +51,12 @@ class ChromecastNodeRedApi { topic: '$topic/$outputVideoTopicProperty', name: '$mqttNodeName - $outputVideoTopicProperty', ); - nodes += ', ${mqttNode.toString()}'; + nodes += ', $mqttNode'; /// Cast v2 connection final NodeRedCastV2ConnectionNode nodeRedCastV2ConnectionNode = NodeRedCastV2ConnectionNode(host: deviceIp); - nodes += ', ${nodeRedCastV2ConnectionNode.toString()}'; + nodes += ', $nodeRedCastV2ConnectionNode'; /// Cast v2 sender final NodeRedCastV2SenderNode nodeRedCastV2SenderNode = @@ -68,7 +68,7 @@ class ChromecastNodeRedApi { ] ], ); - nodes += ', ${nodeRedCastV2SenderNode.toString()}'; + nodes += ', $nodeRedCastV2SenderNode'; nodes += ', ${openUrlNodesString( mqttBrokerNode, @@ -146,7 +146,7 @@ class ChromecastNodeRedApi { final NodeRedFunctionNode nodeRedFunctionNode = NodeRedFunctionNode( funcString: functionString, wires: [ - [nextNodeIdToConnectToo] + [nextNodeIdToConnectToo], ], ); nodes += nodeRedFunctionNode.toString(); @@ -157,7 +157,7 @@ class ChromecastNodeRedApi { brokerNodeId: mqttBrokerNode.id, topic: '$topic/$playingVideoTopicProperty', wires: [ - [nodeRedFunctionNode.id] + [nodeRedFunctionNode.id], ], ); return '$nodes,\n$nodeRedMqttInNode'; @@ -177,7 +177,7 @@ class ChromecastNodeRedApi { final NodeRedFunctionNode nodeRedFunctionNode = NodeRedFunctionNode( funcString: functionString, wires: [ - [nextNodeIdToConnectToo] + [nextNodeIdToConnectToo], ], ); nodes += nodeRedFunctionNode.toString(); @@ -188,7 +188,7 @@ class ChromecastNodeRedApi { brokerNodeId: mqttBrokerNode.id, topic: '$topic/$stopVideoTopicProperty', wires: [ - [nodeRedFunctionNode.id] + [nodeRedFunctionNode.id], ], ); return '$nodes,\n$nodeRedMqttInNode'; @@ -208,7 +208,7 @@ class ChromecastNodeRedApi { final NodeRedFunctionNode nodeRedFunctionNode = NodeRedFunctionNode( funcString: functionString, wires: [ - [nextNodeIdToConnectToo] + [nextNodeIdToConnectToo], ], ); nodes += nodeRedFunctionNode.toString(); @@ -219,7 +219,7 @@ class ChromecastNodeRedApi { brokerNodeId: mqttBrokerNode.id, topic: '$topic/$pauseVideoTopicProperty', wires: [ - [nodeRedFunctionNode.id] + [nodeRedFunctionNode.id], ], ); return '$nodes,\n$nodeRedMqttInNode'; @@ -239,7 +239,7 @@ class ChromecastNodeRedApi { final NodeRedFunctionNode nodeRedFunctionNode = NodeRedFunctionNode( funcString: functionString, wires: [ - [nextNodeIdToConnectToo] + [nextNodeIdToConnectToo], ], ); nodes += nodeRedFunctionNode.toString(); @@ -250,7 +250,7 @@ class ChromecastNodeRedApi { brokerNodeId: mqttBrokerNode.id, topic: '$topic/$playVideoTopicProperty', wires: [ - [nodeRedFunctionNode.id] + [nodeRedFunctionNode.id], ], ); return '$nodes,\n$nodeRedMqttInNode'; @@ -270,7 +270,7 @@ class ChromecastNodeRedApi { final NodeRedFunctionNode nodeRedFunctionNode = NodeRedFunctionNode( funcString: functionString, wires: [ - [nextNodeIdToConnectToo] + [nextNodeIdToConnectToo], ], ); nodes += nodeRedFunctionNode.toString(); @@ -281,7 +281,7 @@ class ChromecastNodeRedApi { brokerNodeId: mqttBrokerNode.id, topic: '$topic/$queuePrevVideoTopicProperty', wires: [ - [nodeRedFunctionNode.id] + [nodeRedFunctionNode.id], ], ); return '$nodes,\n$nodeRedMqttInNode'; @@ -301,7 +301,7 @@ class ChromecastNodeRedApi { final NodeRedFunctionNode nodeRedFunctionNode = NodeRedFunctionNode( funcString: functionString, wires: [ - [nextNodeIdToConnectToo] + [nextNodeIdToConnectToo], ], ); nodes += nodeRedFunctionNode.toString(); @@ -312,7 +312,7 @@ class ChromecastNodeRedApi { brokerNodeId: mqttBrokerNode.id, topic: '$topic/$queueNextVideoTopicProperty', wires: [ - [nodeRedFunctionNode.id] + [nodeRedFunctionNode.id], ], ); return '$nodes,\n$nodeRedMqttInNode'; @@ -332,7 +332,7 @@ class ChromecastNodeRedApi { final NodeRedFunctionNode nodeRedFunctionNode = NodeRedFunctionNode( funcString: functionString, wires: [ - [nextNodeIdToConnectToo] + [nextNodeIdToConnectToo], ], ); nodes += nodeRedFunctionNode.toString(); @@ -343,7 +343,7 @@ class ChromecastNodeRedApi { brokerNodeId: mqttBrokerNode.id, topic: '$topic/$closeAppTopicProperty', wires: [ - [nodeRedFunctionNode.id] + [nodeRedFunctionNode.id], ], ); return '$nodes,\n$nodeRedMqttInNode'; diff --git a/lib/infrastructure/devices/lg/lg_connector_conjector.dart b/lib/infrastructure/devices/lg/lg_connector_conjector.dart index 7559d7db..665f8982 100644 --- a/lib/infrastructure/devices/lg/lg_connector_conjector.dart +++ b/lib/infrastructure/devices/lg/lg_connector_conjector.dart @@ -17,7 +17,7 @@ class LgConnectorConjector implements AbstractCompanyConnectorConjector { static const List mdnsTypes = [ '_hap._tcp', '_display._tcp', - '_airplay._tcp' + '_airplay._tcp', ]; /// Add new devices to [companyDevices] if not exist diff --git a/lib/infrastructure/devices/philips_hue/philips_hue_api/philips_hue_api_light.dart b/lib/infrastructure/devices/philips_hue/philips_hue_api/philips_hue_api_light.dart index 64fa3c76..c7434a83 100644 --- a/lib/infrastructure/devices/philips_hue/philips_hue_api/philips_hue_api_light.dart +++ b/lib/infrastructure/devices/philips_hue/philips_hue_api/philips_hue_api_light.dart @@ -56,7 +56,9 @@ class PhilipsHueApiLight { } Future setLightBrightness( - String entityUniqueId, int brightness) async { + String entityUniqueId, + int brightness, + ) async { final List lights = await bridge.lights(); for (final Light light in lights) { diff --git a/lib/infrastructure/devices/switcher/switcher_smart_plug/switcher_smart_plug_entity.dart b/lib/infrastructure/devices/switcher/switcher_smart_plug/switcher_smart_plug_entity.dart index bb7b0f3f..96391c3b 100644 --- a/lib/infrastructure/devices/switcher/switcher_smart_plug/switcher_smart_plug_entity.dart +++ b/lib/infrastructure/devices/switcher/switcher_smart_plug/switcher_smart_plug_entity.dart @@ -53,7 +53,8 @@ class SwitcherSmartPlugEntity extends GenericSmartPlugDE { } factory SwitcherSmartPlugEntity.fromGeneric( - GenericSmartPlugDE genericDevice) { + GenericSmartPlugDE genericDevice, + ) { return SwitcherSmartPlugEntity( uniqueId: genericDevice.uniqueId, entityUniqueId: genericDevice.entityUniqueId, diff --git a/lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_api/tasmota_ip_api_components.dart b/lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_api/tasmota_ip_api_components.dart index 3e85a063..658e253f 100644 --- a/lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_api/tasmota_ip_api_components.dart +++ b/lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_api/tasmota_ip_api_components.dart @@ -22,11 +22,11 @@ Map> gpioOverviewTasmota = { 71: ['Button_n8', 'Button active low, no internal pull-up resistor'], 96: [ 'Button_i1', - 'Button inverted, active high with internal pull-up resistor' + 'Button inverted, active high with internal pull-up resistor', ], 97: [ 'Button_i2', - 'Button inverted, active high with internal pull-up resistor' + 'Button inverted, active high with internal pull-up resistor', ], 160: ['Switch1', 'Switch, internal pull-up resistor'], 192: ['Switch_n1', 'Switch, no pull-up resistor'], diff --git a/lib/infrastructure/devices/tuya_smart/tuya_smart_remote_api/cloudtuya.dart b/lib/infrastructure/devices/tuya_smart/tuya_smart_remote_api/cloudtuya.dart index 26843281..416a8fe4 100644 --- a/lib/infrastructure/devices/tuya_smart/tuya_smart_remote_api/cloudtuya.dart +++ b/lib/infrastructure/devices/tuya_smart/tuya_smart_remote_api/cloudtuya.dart @@ -47,7 +47,7 @@ class CloudTuya { } final Uri uriTemp = Uri.parse('$uri/auth.do'); final Map headers = { - 'Content-Type': 'application/x-www-form-urlencoded' + 'Content-Type': 'application/x-www-form-urlencoded', }; final Map body = { diff --git a/lib/infrastructure/devices/xiaomi_io/xiaomi_io_gpx3021gl/xiaomi_io_gpx3021gl_entity.dart b/lib/infrastructure/devices/xiaomi_io/xiaomi_io_gpx3021gl/xiaomi_io_gpx3021gl_entity.dart index a006f182..b06b2427 100644 --- a/lib/infrastructure/devices/xiaomi_io/xiaomi_io_gpx3021gl/xiaomi_io_gpx3021gl_entity.dart +++ b/lib/infrastructure/devices/xiaomi_io/xiaomi_io_gpx3021gl/xiaomi_io_gpx3021gl_entity.dart @@ -49,7 +49,8 @@ class XiaomiIoGpx4021GlEntity extends GenericRgbwLightDE { ); factory XiaomiIoGpx4021GlEntity.fromGeneric( - GenericRgbwLightDE genericDevice) { + GenericRgbwLightDE genericDevice, + ) { return XiaomiIoGpx4021GlEntity( uniqueId: genericDevice.uniqueId, entityUniqueId: genericDevice.entityUniqueId, diff --git a/lib/infrastructure/local_db/local_db_hive_repository.dart b/lib/infrastructure/local_db/local_db_hive_repository.dart index 375beb94..5e232f05 100644 --- a/lib/infrastructure/local_db/local_db_hive_repository.dart +++ b/lib/infrastructure/local_db/local_db_hive_repository.dart @@ -877,7 +877,9 @@ class HiveRepository extends ILocalDbRepository { if (espHomeVendorCredentialsBox.isNotEmpty) { await espHomeVendorCredentialsBox.putAt( - 0, espHomeVendorCredentialsModel); + 0, + espHomeVendorCredentialsModel, + ); } else { espHomeVendorCredentialsBox.add(espHomeVendorCredentialsModel); } @@ -914,7 +916,9 @@ class HiveRepository extends ILocalDbRepository { if (xiaomiMiVendorCredentialsBox.isNotEmpty) { await xiaomiMiVendorCredentialsBox.putAt( - 0, xiaomiMiVendorCredentialsModel); + 0, + xiaomiMiVendorCredentialsModel, + ); } else { xiaomiMiVendorCredentialsBox.add(xiaomiMiVendorCredentialsModel); } @@ -950,7 +954,9 @@ class HiveRepository extends ILocalDbRepository { if (ewelinkVendorCredentialsBox.isNotEmpty) { await ewelinkVendorCredentialsBox.putAt( - 0, ewelinkVendorCredentialsModel); + 0, + ewelinkVendorCredentialsModel, + ); } else { ewelinkVendorCredentialsBox.add(ewelinkVendorCredentialsModel); } diff --git a/lib/infrastructure/mqtt_server/mqtt_server_repository.dart b/lib/infrastructure/mqtt_server/mqtt_server_repository.dart index 9ff963ad..aeb111cf 100644 --- a/lib/infrastructure/mqtt_server/mqtt_server_repository.dart +++ b/lib/infrastructure/mqtt_server/mqtt_server_repository.dart @@ -215,7 +215,7 @@ class MqttServerRepository extends IMqttServerRepository { final String deviceDeviceTypeThatChanged = topicsSplitted[3]; final Map devicePropertyAndValues = { - deviceDeviceTypeThatChanged: mqttPublishMessage[0].payload + deviceDeviceTypeThatChanged: mqttPublishMessage[0].payload, }; final ISavedDevicesRepo savedDevicesRepo = getIt(); diff --git a/lib/infrastructure/node_red/node_red_converter.dart b/lib/infrastructure/node_red/node_red_converter.dart index e5bd458f..9ce849da 100644 --- a/lib/infrastructure/node_red/node_red_converter.dart +++ b/lib/infrastructure/node_red/node_red_converter.dart @@ -49,9 +49,9 @@ class NodeRedConverter { wires: allNodeRedIdToConnectTo, ); if (nodes.isEmpty) { - nodes = '[${startingSceneNode.value}, ${brokerNode.toString()}]'; + nodes = '[${startingSceneNode.value}, $brokerNode]'; } else { - nodes = '[${startingSceneNode.value}, $nodes, ${brokerNode.toString()}]'; + nodes = '[${startingSceneNode.value}, $nodes, $brokerNode]'; } return SceneCbjEntity( @@ -107,7 +107,7 @@ class NodeRedConverter { minutesToRepeat: minutesToRepeat, ); - nodes = '[${startingRoutineNode.value}, $nodes, ${brokerNode.toString()}]'; + nodes = '[${startingRoutineNode.value}, $nodes, $brokerNode]'; return RoutineCbjEntity( uniqueId: UniqueId(), @@ -163,7 +163,7 @@ class NodeRedConverter { wires: allNodeRedIdToConnectTo, ); - nodes = '[${startingBindingNode.value}, $nodes, ${brokerNode.toString()}]'; + nodes = '[${startingBindingNode.value}, $nodes, $brokerNode]'; return BindingCbjEntity( uniqueId: UniqueId(), @@ -215,7 +215,7 @@ class NodeRedConverter { return MapEntry( functionForNode.id, - '${functionForNode.toString()}, ${mqttNode.toString()}', + '$functionForNode, $mqttNode', ); } diff --git a/lib/infrastructure/room/saved_rooms_repo.dart b/lib/infrastructure/room/saved_rooms_repo.dart index 8344c91f..ada728b7 100644 --- a/lib/infrastructure/room/saved_rooms_repo.dart +++ b/lib/infrastructure/room/saved_rooms_repo.dart @@ -156,7 +156,7 @@ class SavedRoomsRepo extends ISavedRoomsRepo { MapEntry( newRoomEntity.uniqueId.getOrCrash(), newRoomEntity, - ) + ), ]); return newRoomEntity; } @@ -466,7 +466,7 @@ class SavedRoomsRepo extends ISavedRoomsRepo { uniqueId: RoomUniqueId.fromUniqueString(discoveredRoomId), cbjEntityName: RoomDefaultName.discoveredRoomName(), ), - ) + ), ]); } return _allRooms[discoveredRoomId]!; diff --git a/lib/infrastructure/system_commands/bash_commands_d/common_bash_commands_d.dart b/lib/infrastructure/system_commands/bash_commands_d/common_bash_commands_d.dart index 8addb53a..7fe8365b 100644 --- a/lib/infrastructure/system_commands/bash_commands_d/common_bash_commands_d.dart +++ b/lib/infrastructure/system_commands/bash_commands_d/common_bash_commands_d.dart @@ -117,7 +117,7 @@ class CommonBashCommandsD implements SystemCommandsBaseClassD { bool doesExistAndStringContainUuid(String blkid, String driveName) { return blkid.contains(driveName) && - (blkid.substring(blkid.indexOf(driveName))).contains('UUID="'); + blkid.substring(blkid.indexOf(driveName)).contains('UUID="'); } @override @@ -129,8 +129,7 @@ class CommonBashCommandsD implements SystemCommandsBaseClassD { final String? snapCommonEnvironmentVariable = getIt().getSnapCommonEnvironmentVariable(); if (snapCommonEnvironmentVariable == null) { - localDbFolderPath = '/home/${await currentUserName}/' - ''; + localDbFolderPath = '/home/${await currentUserName}/'; } else { // /var/snap/cbj-hub/common/isar localDbFolderPath = snapCommonEnvironmentVariable; diff --git a/lib/infrastructure/system_commands/batch_commands_d/common_batch_commands_d.dart b/lib/infrastructure/system_commands/batch_commands_d/common_batch_commands_d.dart index 550b5eaa..b51221a7 100644 --- a/lib/infrastructure/system_commands/batch_commands_d/common_batch_commands_d.dart +++ b/lib/infrastructure/system_commands/batch_commands_d/common_batch_commands_d.dart @@ -29,7 +29,7 @@ class CommonBatchCommandsD implements SystemCommandsBaseClassD { 'path', 'win32_computersystemproduct', 'get', - 'uuid' + 'uuid', ]).then((ProcessResult result) { return result.stdout.toString(); }); From aed7b89612f22212a7ef0cfd5d6d519d3aa4a8fc Mon Sep 17 00:00:00 2001 From: Guy Luz Date: Sun, 1 Oct 2023 22:54:38 +0300 Subject: [PATCH 04/18] WIP updating packages --- pubspec.yaml | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index 58c468c7..96803a85 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,7 +5,7 @@ homepage: https://cybearjinni.com publish_to: none environment: - sdk: ^2.18.2 + sdk: '>=3.0.0 <4.0.0' dependencies: # Contains utility classes in the style of dart:async to work with asynchronous computations. @@ -17,26 +17,29 @@ dependencies: # Collection of cyclic redundancy check (CRC) routines as Dart converters. crclib: ^3.0.0 # Functional programming thingies, let you use multiple return types - dart_ewelink_api: ^0.0.6 + dart_ewelink_api: + git: + url: 'https://github.com/guyluz11/dart_ewelink_api.git' + ref: 'develop' dartz: ^0.10.1 # Allow returning more than one type of object equatable: ^2.0.5 # Annotations for freezed - freezed_annotation: ^2.2.0 + freezed_annotation: ^2.4.1 # For the injection, allow accessing an object from anywhere in an App - get_it: ^7.6.0 + get_it: ^7.6.4 # High performance, open-source universal RPC framework - grpc: ^3.1.0 + grpc: ^3.2.4 # Lightweight and blazing fast key-value database hive: ^2.2.3 # Library for making HTTP requests. - http: ^0.13.5 + http: ^1.1.0 # Philips Hue API hue_dart: git: url: 'https://github.com/guyluz11/hue_dart.git' # Convenient code generator for get_it - injectable: ^2.1.1 + injectable: ^2.3.0 # Utility library that checks for an Active Internet connection internet_connection_checker: ^1.0.0+1 # Extremely fast, easy to use, and fully async NoSQL database. @@ -44,29 +47,30 @@ dependencies: # Defines the annotations used by json_serializable to create code for JSON serialization and deserialization. json_annotation: ^4.8.1 # Dart Build System builders for handling JSON. - json_serializable: ^6.7.0 + json_serializable: ^6.7.1 # Port of Kotlin's Kotlin Standard library for Dart/Flutter projects kt_dart: ^1.1.0 # Implementation of the LIFX HTTP API - lifx_http_api: ^0.0.16 + lifx_http_api: + git: 'https://github.com/guyluz11/lifx_http_api.git' # Small, easy to use and extensible logger which prints beautiful logs. - logger: ^1.3.0 + logger: ^2.0.2+1 # A server and browser based MQTT client for Dart. - mi_iot_token: ^1.0.0 + mi_iot_token: ^1.1.0 mqtt_client: ^10.0.0 # Service discovery over multicast DNS (mDNS), Bonjour, and Avahi. - multicast_dns: ^0.3.2+3 + multicast_dns: ^0.3.2+4 # Helps you discover open ports, devices on subnet and more. - network_tools: ^3.2.1 + network_tools: ^4.0.1 # Provides runtime support for a Dart implementation of protobufs. - protobuf: ^2.1.0 + protobuf: ^3.1.0 # Python Environment Manager and Executor for dart and flutter python_shell: git: 'https://github.com/guyluz11/python_shell.dart.git' # Extends the capabilities of Dart Streams and StreamControllers. rxdart: ^0.27.7 # Simple, fast generation of RFC4122 UUIDs. - uuid: ^3.0.7 + uuid: ^4.1.0 # Dart library for controlling Yeelight products over LAN. yeedart: ^0.3.2 @@ -76,16 +80,16 @@ dev_dependencies: # A generator for injectable library # Code generator for unions/pattern-matching/copy. - freezed: ^2.3.4 + freezed: ^2.4.1 # Automatically generates Hive TypeAdapters to store any class - hive_generator: ^2.0.0 + hive_generator: ^2.0.1 # Injectable is a convenient code generator for get_it. - injectable_generator: ^2.1.5 + injectable_generator: ^2.4.0 # Code generator for the Isar Database. Finds classes annotated with @Collection. # isar_generator: ^3.0.5 # Collection of lint rules for Dart and Flutter projects lint: ^2.1.2 # Library for mocks - mockito: ^5.4.1 + mockito: ^5.4.2 # A full featured library for writing and running Dart tests across platforms. - test: ^1.24.3 + test: ^1.24.6 From d3b55cb51c308fc2a32edcb4489eb28a305fb52a Mon Sep 17 00:00:00 2001 From: Guy Luz Date: Thu, 5 Oct 2023 17:51:48 +0300 Subject: [PATCH 05/18] Working of moving NodeRED out of the package --- .../esphome_node_red_api.dart | 8 +- .../chrome_cast/chrome_cast_entity.dart | 11 +- .../chromecast_node_red_api.dart | 28 +- .../node_red/node_red_api/node_red_api.dart | 308 ------------------ .../node_red/node_red_converter.dart | 12 +- .../node_red_castv2_connection_node.dart | 41 --- .../node_red_castv2_sender_node.dart | 44 --- .../node_red_esphome_device_node.dart | 49 --- .../node_red_esphome_in_node.dart | 49 --- .../node_red_esphome_out_node.dart | 49 --- .../node_red_nodes/node_red_change_node.dart | 42 --- .../node_red_function_node.dart | 56 ---- .../node_red_nodes/node_red_inject_node.dart | 85 ----- .../node_red_mqtt_broker_node.dart | 46 --- .../node_red_nodes/node_red_mqtt_in_node.dart | 38 --- .../node_red_mqtt_out_node.dart | 36 -- .../node_red_node_abstract.dart | 24 -- .../node_red_visual_node_abstract.dart | 35 -- .../node_red/node_red_repository.dart | 2 +- pubspec.yaml | 2 + 20 files changed, 30 insertions(+), 935 deletions(-) delete mode 100644 lib/infrastructure/node_red/node_red_api/node_red_api.dart delete mode 100644 lib/infrastructure/node_red/node_red_nodes/contrib_castv2_nodes/node_red_castv2_connection_node.dart delete mode 100644 lib/infrastructure/node_red/node_red_nodes/contrib_castv2_nodes/node_red_castv2_sender_node.dart delete mode 100644 lib/infrastructure/node_red/node_red_nodes/contrib_esphome_nodes/node_red_esphome_device_node.dart delete mode 100644 lib/infrastructure/node_red/node_red_nodes/contrib_esphome_nodes/node_red_esphome_in_node.dart delete mode 100644 lib/infrastructure/node_red/node_red_nodes/contrib_esphome_nodes/node_red_esphome_out_node.dart delete mode 100644 lib/infrastructure/node_red/node_red_nodes/node_red_change_node.dart delete mode 100644 lib/infrastructure/node_red/node_red_nodes/node_red_function_node.dart delete mode 100644 lib/infrastructure/node_red/node_red_nodes/node_red_inject_node.dart delete mode 100644 lib/infrastructure/node_red/node_red_nodes/node_red_mqtt_broker_node.dart delete mode 100644 lib/infrastructure/node_red/node_red_nodes/node_red_mqtt_in_node.dart delete mode 100644 lib/infrastructure/node_red/node_red_nodes/node_red_mqtt_out_node.dart delete mode 100644 lib/infrastructure/node_red/node_red_nodes/node_red_node_abstract.dart delete mode 100644 lib/infrastructure/node_red/node_red_nodes/node_red_visual_node_abstract.dart diff --git a/lib/infrastructure/devices/esphome/esphome_node_red_api/esphome_node_red_api.dart b/lib/infrastructure/devices/esphome/esphome_node_red_api/esphome_node_red_api.dart index 4f86db5f..1cf6e212 100644 --- a/lib/infrastructure/devices/esphome/esphome_node_red_api/esphome_node_red_api.dart +++ b/lib/infrastructure/devices/esphome/esphome_node_red_api/esphome_node_red_api.dart @@ -1,15 +1,9 @@ import 'package:cbj_hub/domain/core/value_objects.dart'; import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart'; import 'package:cbj_hub/domain/node_red/i_node_red_repository.dart'; -import 'package:cbj_hub/infrastructure/node_red/node_red_nodes/contrib_esphome_nodes/node_red_esphome_device_node.dart'; -import 'package:cbj_hub/infrastructure/node_red/node_red_nodes/contrib_esphome_nodes/node_red_esphome_in_node.dart'; -import 'package:cbj_hub/infrastructure/node_red/node_red_nodes/contrib_esphome_nodes/node_red_esphome_out_node.dart'; -import 'package:cbj_hub/infrastructure/node_red/node_red_nodes/node_red_function_node.dart'; -import 'package:cbj_hub/infrastructure/node_red/node_red_nodes/node_red_mqtt_broker_node.dart'; -import 'package:cbj_hub/infrastructure/node_red/node_red_nodes/node_red_mqtt_in_node.dart'; -import 'package:cbj_hub/infrastructure/node_red/node_red_nodes/node_red_mqtt_out_node.dart'; import 'package:cbj_hub/injection.dart'; import 'package:cbj_hub/utils.dart'; +import 'package:nodered/nodered.dart'; class EspHomeNodeRedApi { static String module = 'node-red-contrib-esphome'; diff --git a/lib/infrastructure/devices/google/chrome_cast/chrome_cast_entity.dart b/lib/infrastructure/devices/google/chrome_cast/chrome_cast_entity.dart index b10e1019..e2154ab8 100644 --- a/lib/infrastructure/devices/google/chrome_cast/chrome_cast_entity.dart +++ b/lib/infrastructure/devices/google/chrome_cast/chrome_cast_entity.dart @@ -6,6 +6,7 @@ import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_cor import 'package:cbj_hub/domain/generic_devices/generic_smart_tv/generic_smart_tv_entity.dart'; import 'package:cbj_hub/domain/generic_devices/generic_smart_tv/generic_smart_tv_value_objects.dart'; import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart'; +import 'package:cbj_hub/domain/node_red/i_node_red_repository.dart'; import 'package:cbj_hub/infrastructure/devices/google/chromecast_node_red_api/chromecast_node_red_api.dart'; import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_hub/injection.dart'; @@ -90,7 +91,15 @@ class ChromeCastEntity extends GenericSmartTvDE { logger.w('Chromecast last known ip is null'); return; } - chromecastNodeRedApi = ChromecastNodeRedApi(); + + chromecastNodeRedApi = ChromecastNodeRedApi( + nodeRedApiBaseTopic: + getIt().getNodeRedApiBaseTopic(), + nodeRedDevicesTopic: + getIt().getNodeRedDevicesTopicTypeName(), + repository: getIt(), + ); + chromecastNodeRedApi.setNewYoutubeVideoNodes( uniqueId.getOrCrash(), lastKnownIp!.getOrCrash(), diff --git a/lib/infrastructure/devices/google/chromecast_node_red_api/chromecast_node_red_api.dart b/lib/infrastructure/devices/google/chromecast_node_red_api/chromecast_node_red_api.dart index 313ea6b9..76ad69ee 100644 --- a/lib/infrastructure/devices/google/chromecast_node_red_api/chromecast_node_red_api.dart +++ b/lib/infrastructure/devices/google/chromecast_node_red_api/chromecast_node_red_api.dart @@ -1,14 +1,17 @@ -import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart'; import 'package:cbj_hub/domain/node_red/i_node_red_repository.dart'; -import 'package:cbj_hub/infrastructure/node_red/node_red_nodes/contrib_castv2_nodes/node_red_castv2_connection_node.dart'; -import 'package:cbj_hub/infrastructure/node_red/node_red_nodes/contrib_castv2_nodes/node_red_castv2_sender_node.dart'; -import 'package:cbj_hub/infrastructure/node_red/node_red_nodes/node_red_function_node.dart'; -import 'package:cbj_hub/infrastructure/node_red/node_red_nodes/node_red_mqtt_broker_node.dart'; -import 'package:cbj_hub/infrastructure/node_red/node_red_nodes/node_red_mqtt_in_node.dart'; -import 'package:cbj_hub/infrastructure/node_red/node_red_nodes/node_red_mqtt_out_node.dart'; -import 'package:cbj_hub/injection.dart'; +import 'package:nodered/nodered.dart'; class ChromecastNodeRedApi { + ChromecastNodeRedApi({ + required this.nodeRedApiBaseTopic, + required this.nodeRedDevicesTopic, + required this.repository, + }); + + final String nodeRedApiBaseTopic; + final String nodeRedDevicesTopic; + final INodeRedRepository repository; + final String module = 'node-red-contrib-castv2'; final String youtubeVideoTopicProperty = 'youtubeVideo'; @@ -27,12 +30,6 @@ class ChromecastNodeRedApi { ) async { String nodes = '[\n'; - final String nodeRedApiBaseTopic = - getIt().getNodeRedApiBaseTopic(); - - final String nodeRedDevicesTopic = - getIt().getNodeRedDevicesTopicTypeName(); - const String mqttNodeName = 'Chromecast'; final String topic = @@ -122,8 +119,7 @@ class ChromecastNodeRedApi { nodes += '\n]'; /// Setting the flow - final Future settingTheFlowResponse = - getIt().setFlowWithModule( + final Future settingTheFlowResponse = repository.setFlowWithModule( moduleToUse: module, label: 'playYoutubeUrl', nodes: nodes, diff --git a/lib/infrastructure/node_red/node_red_api/node_red_api.dart b/lib/infrastructure/node_red/node_red_api/node_red_api.dart deleted file mode 100644 index da53741f..00000000 --- a/lib/infrastructure/node_red/node_red_api/node_red_api.dart +++ /dev/null @@ -1,308 +0,0 @@ -import 'package:cbj_hub/utils.dart'; -import 'package:http/http.dart'; -import 'package:uuid/uuid.dart'; - -/// Admin API methods for Node-RED -/// https://nodered.org/docs/api/admin/methods/ -class NodeRedAPI { - /// Creates the request url for Nod-RED, use default connection values - /// if not specified otherwise - NodeRedAPI({ - this.address = '127.0.0.1', - this.port = 1880, - }) { - requestsUrl = 'http://$address:$port'; - } - - /// The address of Node-RED to connect to - String address; - - /// The port to connect to of Node-RED - int port; - - /// Requests url to Node-RED, contains the address followed up with the port - late String requestsUrl; - - /// Get the active authentication scheme - Future getAuthLogin() async { - return get(Uri.parse('$requestsUrl/auth/login')); - } - - /// Exchange credentials for access token - Future postAuthToken({ - required String grantType, - required String scope, - required String userName, - required String password, - String clientId = 'node-red-editor', - }) async { - logger.e('postAuthToken Not tested yet'); - final String jsonStringWithFields = ''' - { - "client_id": "$clientId", - "grant_type": "$grantType", - "scope": "$scope", - "username": "$userName", - "password": "$password" - } - '''; - return post( - Uri.parse('$requestsUrl/auth/token'), - headers: {'Content-Type': 'application/json'}, - body: jsonStringWithFields, - ); - } - - /// Revoke an access token - Future postAuthRevoke(String token) async { - logger.e('postAuthRevoke Not tested yet'); - return post( - Uri.parse('$requestsUrl/auth/revoke'), - headers: {'Content-Type': 'application/json'}, - body: token, - ); - } - - /// Get the runtime settings - Future getSettings() async { - return get(Uri.parse('$requestsUrl/settings')); - } - - /// Get the active flow configuration - Future getFlows() async { - return get(Uri.parse('$requestsUrl/flows')); - } - - /// Set the active flow configuration. - Future postFlows({ - required String type, - required String id, - required String label, - int vType = 1, - String? rev, - }) async { - logger.e('postFlows Not tested yet'); - - final String jsonStringWithFields; - - if (vType == 1) { - jsonStringWithFields = ''' - [ - { - "type": "$type", - "id": "$id", - "label": "$label" - } - ] - '''; - } else if (vType == 2 && rev != null) { - jsonStringWithFields = ''' - { - "rev": "$rev", - "flows": [ - { - "type": "$type", - "id": "$id", - "label": "$label" - } - ] - } - '''; - } else { - logger.e('vType is invalid or rev is missing $rev'); - throw 'Error vType is invalid or rev is missing $rev'; - } - return post( - Uri.parse('$requestsUrl/flows'), - headers: {'Content-Type': 'application/json'}, - body: jsonStringWithFields, - ); - } - - // TODO: not working - /// Add a single global node - Future postGlobalNode({ - /// Should be node json string {} - required String nodes, - }) async { - final String jsonStringWithFields = ''' - { - "id": "global", - "configs": [ ], - "subflows": $nodes - } - '''; - return put( - Uri.parse('$requestsUrl/flow/global'), - headers: {'Content-Type': 'application/json'}, - body: jsonStringWithFields, - ); - } - - /// Add a flow to the active configuration - Future postFlow({ - required String label, - - /// Should start as list of jsons [{},{}] - required String nodes, - - /// Flow id will get ignored when creating new flow as mentioned in the doc - /// TODO: check if flow id stopped getting ignored https://discourse.nodered.org/t/make-setting-an-id-in-post-flow-work/67815 - String? flowId, - List? configs, - }) async { - final String idOfTheFlow = flowId ?? const Uuid().v1(); - final List configsList = configs ?? []; - - final String jsonStringWithFields = ''' - { - "id": "$idOfTheFlow", - "label": "$label", - "nodes": $nodes, - "configs": $configsList - } - '''; - return post( - Uri.parse('$requestsUrl/flow'), - headers: {'Content-Type': 'application/json'}, - body: jsonStringWithFields, - ); - } - - /// Get an individual flow configuration - Future getFlowById(String flowId) async { - return get(Uri.parse('$requestsUrl/flow/$flowId')); - } - - /// Update an individual flow configuration - Future putFlowById({ - required String flowId, - required String nodes, - List? configs, - bool normalFlow = true, - String? label, - List? subFlows, - }) async { - final List configsList = configs ?? []; - - logger.e('putFlowById Not tested yet'); - final String jsonStringWithFields; - - if (normalFlow) { - jsonStringWithFields = ''' - { - "id": "$flowId", - "label": "$label", - "nodes": $nodes, - "configs": $configsList - } - '''; - } else { - jsonStringWithFields = ''' - { - "id": "$flowId", - "configs": $configsList, - "subflows": $subFlows - } - '''; - } - - return put( - Uri.parse('$requestsUrl/flow/$flowId'), - headers: {'Content-Type': 'application/json'}, - body: jsonStringWithFields, - ); - } - - /// Delete an individual flow configuration - Future deleteFlowById({ - required String id, - }) async { - return delete( - Uri.parse('$requestsUrl/flow/$id'), - ); - } - - /// Get a list of the installed nodes - Future getNodes() async { - return get(Uri.parse('$requestsUrl/nodes')); - } - - /// Install a new node module - Future postNodes({ - required String module, - }) async { - final String jsonStringWithFields = ''' - { - "module": "$module" - } - '''; - return post( - Uri.parse('$requestsUrl/nodes'), - headers: {'Content-Type': 'application/json'}, - body: jsonStringWithFields, - ); - } - - /// Get a node module’s information - Future getNodesByModule(String moduleId) async { - return get(Uri.parse('$requestsUrl/nodes/$moduleId')); - } - - /// Enable/Disable a node module - Future putNodesByModule({ - required String module, - required bool enableTheModule, - }) async { - logger.e('putNodesByModule Not tested yet'); - final String jsonStringWithFields = ''' - { - "enabled": $enableTheModule - } - '''; - - return put( - Uri.parse('$requestsUrl/nodes/$module'), - headers: {'Content-Type': 'application/json'}, - body: jsonStringWithFields, - ); - } - - /// Remove a node module - Future deleteNodesByModule({ - required String module, - }) async { - logger.e('deleteNodesByModule Not tested yet'); - return delete( - Uri.parse('$requestsUrl/nodes/$module'), - ); - } - - /// Get a node module set information - Future getNodesByModelSetInformation( - String moduleId, - String set, - ) async { - return get(Uri.parse('$requestsUrl/nodes/$moduleId/$set')); - } - - /// Enable/Disable a node set - Future putNodesModuleSetInformation({ - required String module, - required String setName, - required String enableTheModule, - }) async { - logger.e('putNodesModuleSetInformation Not tested yet'); - final String jsonStringWithFields = ''' - { - "enabled": $enableTheModule - } - '''; - - return put( - Uri.parse('$requestsUrl/nodes/$module/$setName'), - headers: {'Content-Type': 'application/json'}, - body: jsonStringWithFields, - ); - } -} diff --git a/lib/infrastructure/node_red/node_red_converter.dart b/lib/infrastructure/node_red/node_red_converter.dart index 9ce849da..83e72d0a 100644 --- a/lib/infrastructure/node_red/node_red_converter.dart +++ b/lib/infrastructure/node_red/node_red_converter.dart @@ -7,11 +7,7 @@ import 'package:cbj_hub/domain/routine/value_objects_routine_cbj.dart'; import 'package:cbj_hub/domain/scene/scene_cbj_entity.dart'; import 'package:cbj_hub/domain/scene/value_objects_scene_cbj.dart'; import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbenum.dart'; -import 'package:cbj_hub/infrastructure/node_red/node_red_nodes/node_red_function_node.dart'; -import 'package:cbj_hub/infrastructure/node_red/node_red_nodes/node_red_inject_node.dart'; -import 'package:cbj_hub/infrastructure/node_red/node_red_nodes/node_red_mqtt_broker_node.dart'; -import 'package:cbj_hub/infrastructure/node_red/node_red_nodes/node_red_mqtt_in_node.dart'; -import 'package:cbj_hub/infrastructure/node_red/node_red_nodes/node_red_mqtt_out_node.dart'; +import 'package:nodered/nodered.dart'; import 'package:uuid/uuid.dart'; class NodeRedConverter { @@ -249,9 +245,9 @@ class NodeRedConverter { name: nodeName, wires: [wires], tempId: injectNodeId, - daysToRepeat: daysToRepeat, - hourToRepeat: hourToRepeat, - minutesToRepeat: minutesToRepeat, + daysToRepeat: daysToRepeat.getOrCrash(), + hourToRepeat: hourToRepeat.getOrCrash(), + minutesToRepeat: minutesToRepeat.getOrCrash(), ); return MapEntry(nodeRedInjectNode.id, nodeRedInjectNode.toString()); } diff --git a/lib/infrastructure/node_red/node_red_nodes/contrib_castv2_nodes/node_red_castv2_connection_node.dart b/lib/infrastructure/node_red/node_red_nodes/contrib_castv2_nodes/node_red_castv2_connection_node.dart deleted file mode 100644 index b2de2bf1..00000000 --- a/lib/infrastructure/node_red/node_red_nodes/contrib_castv2_nodes/node_red_castv2_connection_node.dart +++ /dev/null @@ -1,41 +0,0 @@ -import 'package:cbj_hub/infrastructure/node_red/node_red_nodes/node_red_visual_node_abstract.dart'; - -/// Class for Node-Red castv2 node -/// https://flows.nodered.org/node/node-red-contrib-castv2 -class NodeRedCastV2ConnectionNode extends NodeRedVisualNodeAbstract { - NodeRedCastV2ConnectionNode({ - required this.host, - super.wires, - super.name, - }) : super( - type: 'castv2-connection', - ); - - factory NodeRedCastV2ConnectionNode.passOnlyNewAction({ - required String host, - List>? wires, - String? name, - }) { - return NodeRedCastV2ConnectionNode( - wires: wires, - name: name, - host: host, - ); - } - - String host; - - @override - String toString() { - return ''' - { - "id": "$id", - "type": "$type", - "name": "$name", - "target": "", - "host": "$host", - "port": "8009" - } -'''; - } -} diff --git a/lib/infrastructure/node_red/node_red_nodes/contrib_castv2_nodes/node_red_castv2_sender_node.dart b/lib/infrastructure/node_red/node_red_nodes/contrib_castv2_nodes/node_red_castv2_sender_node.dart deleted file mode 100644 index e4ec6eb3..00000000 --- a/lib/infrastructure/node_red/node_red_nodes/contrib_castv2_nodes/node_red_castv2_sender_node.dart +++ /dev/null @@ -1,44 +0,0 @@ -import 'package:cbj_hub/infrastructure/node_red/node_red_nodes/node_red_visual_node_abstract.dart'; - -/// Class for Node-Red castv2 node -/// https://flows.nodered.org/node/node-red-contrib-castv2 -class NodeRedCastV2SenderNode extends NodeRedVisualNodeAbstract { - NodeRedCastV2SenderNode({ - required this.connectionId, - super.wires, - super.name, - }) : super( - type: 'castv2-sender', - ); - - /// Take castv2 action node id and pass it down as property and set it up, also pass wires to define the next node to connect to - factory NodeRedCastV2SenderNode.passOnlyNewAction({ - required String connectionId, - List>? wires, - String? name, - }) { - return NodeRedCastV2SenderNode( - wires: wires, - name: name, - connectionId: connectionId, - ); - } - - String connectionId; - - @override - String toString() { - return ''' - { - "id": "$id", - "type": "$type", - "z": "cc525388a451891a", - "name": "$name", - "connection": "$connectionId", - "x": 640, - "y": 260, - "wires": ${fixWiresForNodeRed()} - } -'''; - } -} diff --git a/lib/infrastructure/node_red/node_red_nodes/contrib_esphome_nodes/node_red_esphome_device_node.dart b/lib/infrastructure/node_red/node_red_nodes/contrib_esphome_nodes/node_red_esphome_device_node.dart deleted file mode 100644 index c9172114..00000000 --- a/lib/infrastructure/node_red/node_red_nodes/contrib_esphome_nodes/node_red_esphome_device_node.dart +++ /dev/null @@ -1,49 +0,0 @@ -import 'package:cbj_hub/infrastructure/node_red/node_red_nodes/node_red_visual_node_abstract.dart'; - -class NodeRedEspHomeDeviceNode extends NodeRedVisualNodeAbstract { - NodeRedEspHomeDeviceNode({ - required this.host, - required this.password, - super.tempId, - super.wires, - super.name, - }) : super( - type: 'esphome-device', - ); - - factory NodeRedEspHomeDeviceNode.passOnlyNewAction({ - required String host, - required String password, - List>? wires, - String? name, - String? tempId, - }) { - return NodeRedEspHomeDeviceNode( - tempId: tempId, - wires: wires, - name: name, - host: host, - password: password, - ); - } - - String host; - String password; - - @override - String toString() { - return ''' - { - "id": "$id", - "type": "$type", - "name": "$name", - "target": "", - "host": "$host", - "port": "6053", - "credentials": { - "password": "$password" - } - } -'''; - } -} diff --git a/lib/infrastructure/node_red/node_red_nodes/contrib_esphome_nodes/node_red_esphome_in_node.dart b/lib/infrastructure/node_red/node_red_nodes/contrib_esphome_nodes/node_red_esphome_in_node.dart deleted file mode 100644 index 75d44d54..00000000 --- a/lib/infrastructure/node_red/node_red_nodes/contrib_esphome_nodes/node_red_esphome_in_node.dart +++ /dev/null @@ -1,49 +0,0 @@ -import 'package:cbj_hub/infrastructure/node_red/node_red_nodes/node_red_visual_node_abstract.dart'; - -/// Class for Node-Red ESPHome node -/// https://flows.nodered.org/node/node-red-contrib-esphome -class NodeRedEspHomeInNode extends NodeRedVisualNodeAbstract { - NodeRedEspHomeInNode({ - required this.espHomeNodeDeviceId, - required this.epsHomeDeviceEntityId, - super.wires, - super.name, - }) : super( - type: 'esphome-in', - ); - - /// Take esphome-device node id and pass it down as property and set it up, also pass wires to define the next node to connect to - factory NodeRedEspHomeInNode.passOnlyNewAction({ - required String espHomeNodeDeviceId, - required String epsHomeDeviceEntityId, - List>? wires, - String? name, - }) { - return NodeRedEspHomeInNode( - wires: wires, - name: name, - espHomeNodeDeviceId: espHomeNodeDeviceId, - epsHomeDeviceEntityId: epsHomeDeviceEntityId, - ); - } - - String espHomeNodeDeviceId; - String epsHomeDeviceEntityId; - - @override - String toString() { - return ''' - { - "id": "$id", - "type": "$type", - "z": "cc525388a451891a", - "name": "$name", - "device": "$espHomeNodeDeviceId", - "entity": "$epsHomeDeviceEntityId", - "x": 680, - "y": 500, - "wires": ${fixWiresForNodeRed()} - } -'''; - } -} diff --git a/lib/infrastructure/node_red/node_red_nodes/contrib_esphome_nodes/node_red_esphome_out_node.dart b/lib/infrastructure/node_red/node_red_nodes/contrib_esphome_nodes/node_red_esphome_out_node.dart deleted file mode 100644 index 9629eb30..00000000 --- a/lib/infrastructure/node_red/node_red_nodes/contrib_esphome_nodes/node_red_esphome_out_node.dart +++ /dev/null @@ -1,49 +0,0 @@ -import 'package:cbj_hub/infrastructure/node_red/node_red_nodes/node_red_visual_node_abstract.dart'; - -/// Class for Node-Red ESPHome node -/// https://flows.nodered.org/node/node-red-contrib-esphome -class NodeRedEspHomeOutNode extends NodeRedVisualNodeAbstract { - NodeRedEspHomeOutNode({ - required this.espHomeNodeDeviceId, - required this.espHomeEntityId, - super.wires, - super.name, - }) : super( - type: 'esphome-out', - ); - - /// Take esphome-device node id and pass it down as property and set it up, also pass wires to define the next node to connect to - factory NodeRedEspHomeOutNode.passOnlyNewAction({ - required String espHomeNodeDeviceId, - required String espHomeEntityId, - List>? wires, - String? name, - }) { - return NodeRedEspHomeOutNode( - wires: wires, - name: name, - espHomeNodeDeviceId: espHomeNodeDeviceId, - espHomeEntityId: espHomeEntityId, - ); - } - - String espHomeNodeDeviceId; - String espHomeEntityId; - - @override - String toString() { - return ''' - { - "id": "$id", - "type": "$type", - "z": "cc525388a451891a", - "name": "$name", - "device": "$espHomeNodeDeviceId", - "entity": "$espHomeEntityId", - "x": 1200, - "y": 500, - "wires": [[]] - } -'''; - } -} diff --git a/lib/infrastructure/node_red/node_red_nodes/node_red_change_node.dart b/lib/infrastructure/node_red/node_red_nodes/node_red_change_node.dart deleted file mode 100644 index 46270f93..00000000 --- a/lib/infrastructure/node_red/node_red_nodes/node_red_change_node.dart +++ /dev/null @@ -1,42 +0,0 @@ -import 'package:cbj_hub/infrastructure/node_red/node_red_nodes/node_red_visual_node_abstract.dart'; - -//TODO: Test that this node works -/// Class for Node-Red change node -/// https://nodered.org/docs/user-guide/nodes#change -class NodeRedChangeNode extends NodeRedVisualNodeAbstract { - NodeRedChangeNode({ - super.wires, - super.name, - }) : super( - type: 'change', - ); - - @override - String toString() { - return ''' - { - "id": "$id", - "type": "$type", - "name": "$name", - "z": "cc525388a451891a", - "rules": [ - { - "t": "set", - "p": "payload", - "pt": "msg", - "to": "{\\"app\\":\\"YouTube\\",\\"type\\":\\"MEDIA\\",\\"videoId\\":\\"I9rc23oxvsw\\"}", - "tot": "json" - } - ], - "action": "", - "property": "", - "from": "", - "to": "", - "reg": false, - "x": 380, - "y": 260, - "wires": ${fixWiresForNodeRed()} - } -'''; - } -} diff --git a/lib/infrastructure/node_red/node_red_nodes/node_red_function_node.dart b/lib/infrastructure/node_red/node_red_nodes/node_red_function_node.dart deleted file mode 100644 index 891945f1..00000000 --- a/lib/infrastructure/node_red/node_red_nodes/node_red_function_node.dart +++ /dev/null @@ -1,56 +0,0 @@ -import 'package:cbj_hub/infrastructure/node_red/node_red_nodes/node_red_visual_node_abstract.dart'; - -/// Class for Node-Red function node -/// https://nodered.org/docs/user-guide/writing-functions -class NodeRedFunctionNode extends NodeRedVisualNodeAbstract { - NodeRedFunctionNode({ - required this.funcString, - super.wires, - super.name, - }) : super( - type: 'function', - ); - - /// Take action and pass it down as property for the next node - factory NodeRedFunctionNode.passOnlyNewAction({ - required String action, - List>? wires, - String? name, - }) { - final String function = '''msg.payload=\\"$action\\"; return msg;'''; - return NodeRedFunctionNode(funcString: function, wires: wires, name: name); - } - - /// Gets input string and parse the payload as json to the next node - factory NodeRedFunctionNode.inputPayloadToJson({ - List>? wires, - }) { - const String function = - '''msg.payload = JSON.parse(msg.payload); return msg;'''; - return NodeRedFunctionNode( - funcString: function, - wires: wires, - name: 'Input to json', - ); - } - - String funcString; - - @override - String toString() { - return ''' - { - "id": "$id", - "type": "$type", - "name": "$name", - "func": "$funcString", - "outputs": 1, - "noerr": 0, - "x": 400, - "y": 1000, - "initialize": "", - "finalize": "", - "wires": ${fixWiresForNodeRed()} - }'''; - } -} diff --git a/lib/infrastructure/node_red/node_red_nodes/node_red_inject_node.dart b/lib/infrastructure/node_red/node_red_nodes/node_red_inject_node.dart deleted file mode 100644 index 24f07637..00000000 --- a/lib/infrastructure/node_red/node_red_nodes/node_red_inject_node.dart +++ /dev/null @@ -1,85 +0,0 @@ -import 'package:cbj_hub/domain/routine/value_objects_routine_cbj.dart'; -import 'package:cbj_hub/infrastructure/node_red/node_red_nodes/node_red_visual_node_abstract.dart'; -import 'package:cbj_hub/utils.dart'; - -/// -class NodeRedInjectAtASpecificTimeNode extends NodeRedVisualNodeAbstract { - NodeRedInjectAtASpecificTimeNode({ - required this.daysToRepeat, - required this.hourToRepeat, - required this.minutesToRepeat, - super.tempId, - super.name, - super.wires, - }) : super( - type: 'inject', - ); - - RoutineCbjRepeatDateDays daysToRepeat; - RoutineCbjRepeatDateHour hourToRepeat; - RoutineCbjRepeatDateMinute minutesToRepeat; - - @override - String toString() { - final String crontab = - '${minutesToRepeat.getOrCrash()} ${hourToRepeat.getOrCrash()} * * ${daysToRepeatAsCornTabRequire()}'; - return ''' - { - "id": "$id", - "type": "$type", - "name": "$name", - "props": [ - { - "p": "payload" - }, - { - "p": "topic", - "vt": "str" - } - ], - "repeat": "", - "crontab": "$crontab", - "once": false, - "onceDelay": 0.1, - "x": 400, - "y": 800, - "topic": "", - "payload": "", - "payloadType": "date", - "wires": ${fixWiresForNodeRed()} - }'''; - } - - String daysToRepeatAsCornTabRequire() { - if (daysToRepeat.getOrCrash()!.length >= 7) { - return '*'; - } - String daysToRepeatTemp = ''; - - for (final String dayToRepeat in daysToRepeat.getOrCrash()!) { - if (daysToRepeatTemp != '') { - daysToRepeatTemp += ','; - } - - if (dayToRepeat == 'sunday') { - daysToRepeatTemp += '0'; - } else if (dayToRepeat == 'monday') { - daysToRepeatTemp += '1'; - } else if (dayToRepeat == 'tuesday') { - daysToRepeatTemp += '2'; - } else if (dayToRepeat == 'wednesday') { - daysToRepeatTemp += '3'; - } else if (dayToRepeat == 'thursday') { - daysToRepeatTemp += '4'; - } else if (dayToRepeat == 'friday') { - daysToRepeatTemp += '5'; - } else if (dayToRepeat == 'saturday') { - daysToRepeatTemp += '6'; - } else { - daysToRepeatTemp += 'Error'; - logger.e('Day does not exist'); - } - } - return daysToRepeatTemp; - } -} diff --git a/lib/infrastructure/node_red/node_red_nodes/node_red_mqtt_broker_node.dart b/lib/infrastructure/node_red/node_red_nodes/node_red_mqtt_broker_node.dart deleted file mode 100644 index 5e2e51bc..00000000 --- a/lib/infrastructure/node_red/node_red_nodes/node_red_mqtt_broker_node.dart +++ /dev/null @@ -1,46 +0,0 @@ -import 'package:cbj_hub/infrastructure/node_red/node_red_nodes/node_red_node_abstract.dart'; - -class NodeRedMqttBrokerNode extends NodeRedNodeAbstract { - NodeRedMqttBrokerNode({ - this.brokerAddress = '127.0.0.1', - this.port = '1883', - this.qos, - this.datatype, - super.name, - }) : super( - type: 'mqtt-broker', - ); - - /// Mqtt broker node id - String brokerAddress; - String port; - String? clientid = ''; - String? qos = '2'; - String? datatype = 'auto'; - - @override - String toString() { - return ''' - { - "id": "$id", - "type": "$type", - "name": "$name", - "broker": "$brokerAddress", - "port": "$port", - "clientid": "", - "usetls": false, - "compatmode": false, - "keepalive": "60", - "cleansession": true, - "birthTopic": "", - "birthQos": "0", - "birthPayload": "", - "closeTopic": "", - "closeQos": "0", - "closePayload": "", - "willTopic": "", - "willQos": "0", - "willPayload": "" - }'''; - } -} diff --git a/lib/infrastructure/node_red/node_red_nodes/node_red_mqtt_in_node.dart b/lib/infrastructure/node_red/node_red_nodes/node_red_mqtt_in_node.dart deleted file mode 100644 index 11ee0e80..00000000 --- a/lib/infrastructure/node_red/node_red_nodes/node_red_mqtt_in_node.dart +++ /dev/null @@ -1,38 +0,0 @@ -import 'package:cbj_hub/infrastructure/node_red/node_red_nodes/node_red_visual_node_abstract.dart'; - -class NodeRedMqttInNode extends NodeRedVisualNodeAbstract { - NodeRedMqttInNode({ - required this.brokerNodeId, - required this.topic, - super.tempId, - super.name, - super.wires, - this.qos, - this.datatype, - }) : super( - type: 'mqtt in', - ); - - /// Mqtt broker node id - String brokerNodeId; - String topic; - String? qos = '2'; - String? datatype = 'auto'; - - @override - String toString() { - return ''' - { - "id": "$id", - "type": "$type", - "name": "$name", - "topic": "$topic", - "qos": "$qos", - "x": 600, - "y": 400, - "datatype": "$datatype", - "broker": "$brokerNodeId", - "wires": ${fixWiresForNodeRed()} - }'''; - } -} diff --git a/lib/infrastructure/node_red/node_red_nodes/node_red_mqtt_out_node.dart b/lib/infrastructure/node_red/node_red_nodes/node_red_mqtt_out_node.dart deleted file mode 100644 index dfbcca48..00000000 --- a/lib/infrastructure/node_red/node_red_nodes/node_red_mqtt_out_node.dart +++ /dev/null @@ -1,36 +0,0 @@ -import 'package:cbj_hub/infrastructure/node_red/node_red_nodes/node_red_visual_node_abstract.dart'; - -class NodeRedMqttOutNode extends NodeRedVisualNodeAbstract { - NodeRedMqttOutNode({ - required this.brokerNodeId, - required this.topic, - this.qos, - this.datatype, - super.name, - }) : super( - type: 'mqtt out', - ); - - /// Mqtt broker node id [NodeRedMqttBrokerNode] - String brokerNodeId; - String topic; - String? qos = '2'; - String? datatype = 'auto'; - - @override - String toString() { - return ''' - { - "id": "$id", - "type": "$type", - "name": "$name", - "topic": "$topic", - "x": 600, - "y": 300, - "qos": "$qos", - "retain": "", - "broker": "$brokerNodeId", - "wires": ${fixWiresForNodeRed()} - }'''; - } -} diff --git a/lib/infrastructure/node_red/node_red_nodes/node_red_node_abstract.dart b/lib/infrastructure/node_red/node_red_nodes/node_red_node_abstract.dart deleted file mode 100644 index b9333fc6..00000000 --- a/lib/infrastructure/node_red/node_red_nodes/node_red_node_abstract.dart +++ /dev/null @@ -1,24 +0,0 @@ -import 'package:cbj_hub/utils.dart'; -import 'package:uuid/uuid.dart'; - -class NodeRedNodeAbstract { - NodeRedNodeAbstract({ - required this.type, - String? tempId, - this.name, - }) { - id = tempId ?? const Uuid().v1(); - } - - String type; - - /// The id of the node, will create one for you if not given - late String id; - String? name; - - @override - String toString() { - logger.e('Abstract class does not support to string'); - throw 'Abstract class does not support to string'; - } -} diff --git a/lib/infrastructure/node_red/node_red_nodes/node_red_visual_node_abstract.dart b/lib/infrastructure/node_red/node_red_nodes/node_red_visual_node_abstract.dart deleted file mode 100644 index a8235bad..00000000 --- a/lib/infrastructure/node_red/node_red_nodes/node_red_visual_node_abstract.dart +++ /dev/null @@ -1,35 +0,0 @@ -import 'package:cbj_hub/infrastructure/node_red/node_red_nodes/node_red_node_abstract.dart'; - -/// Abstract calss for all the nodes that can be connected on the dashboard - -class NodeRedVisualNodeAbstract extends NodeRedNodeAbstract { - NodeRedVisualNodeAbstract({ - required super.type, - super.tempId, - super.name, - this.wires, - }); - - // Does not exists in all nodes, maybe we will move it to another abstract class - List>? wires = []; - - List> fixWiresForNodeRed() { - final List> wiresTemp = []; - - // '"${mqttNode.id}"' - if (wires != null) { - for (final List tempWire in wires!) { - final List fixedWireList = []; - for (final String tempId in tempWire) { - if (!tempId.contains('"')) { - fixedWireList.add('"$tempId"'); - } else { - fixedWireList.add(tempId); - } - } - wiresTemp.add(fixedWireList); - } - } - return wiresTemp; - } -} diff --git a/lib/infrastructure/node_red/node_red_repository.dart b/lib/infrastructure/node_red/node_red_repository.dart index 389cefce..676c4193 100644 --- a/lib/infrastructure/node_red/node_red_repository.dart +++ b/lib/infrastructure/node_red/node_red_repository.dart @@ -4,10 +4,10 @@ import 'package:cbj_hub/domain/binding/binding_cbj_entity.dart'; import 'package:cbj_hub/domain/node_red/i_node_red_repository.dart'; import 'package:cbj_hub/domain/routine/routine_cbj_entity.dart'; import 'package:cbj_hub/domain/scene/scene_cbj_entity.dart'; -import 'package:cbj_hub/infrastructure/node_red/node_red_api/node_red_api.dart'; import 'package:cbj_hub/utils.dart'; import 'package:http/src/response.dart'; import 'package:injectable/injectable.dart'; +import 'package:nodered/nodered.dart'; /// Control Node-RED, create scenes and more @LazySingleton(as: INodeRedRepository) diff --git a/pubspec.yaml b/pubspec.yaml index 96803a85..70e09898 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -60,6 +60,8 @@ dependencies: mqtt_client: ^10.0.0 # Service discovery over multicast DNS (mDNS), Bonjour, and Avahi. multicast_dns: ^0.3.2+4 + nodered: + path: ../nodered # Helps you discover open ports, devices on subnet and more. network_tools: ^4.0.1 # Provides runtime support for a Dart implementation of protobufs. From 76c5597675eca2907eb999019b37045f94c1ad89 Mon Sep 17 00:00:00 2001 From: Guy Luz Date: Thu, 5 Oct 2023 18:47:03 +0300 Subject: [PATCH 06/18] Moved NodeRED out as a package --- .../node_red/i_node_red_repository.dart | 40 -- .../bindings/binding_repository.dart | 4 +- .../devices/esphome/esphome_helpers.dart | 25 +- .../esphome_light/esphome_light_entity.dart | 2 +- .../esphome_node_red_api.dart | 138 ------- .../esphome_node_red_server_api_calls.dart | 114 ------ .../esphome_switch/esphome_switch_entity.dart | 2 +- .../chrome_cast/chrome_cast_entity.dart | 7 +- .../chromecast_node_red_api.dart | 347 ------------------ .../node_red/node_red_repository.dart | 10 +- .../routines/routine_repository.dart | 4 +- .../scenes/scene_repository.dart | 8 +- lib/injection.config.dart | 107 +++--- 13 files changed, 93 insertions(+), 715 deletions(-) delete mode 100644 lib/domain/node_red/i_node_red_repository.dart delete mode 100644 lib/infrastructure/devices/esphome/esphome_node_red_api/esphome_node_red_api.dart delete mode 100644 lib/infrastructure/devices/esphome/esphome_node_red_api/esphome_node_red_server_api_calls.dart delete mode 100644 lib/infrastructure/devices/google/chromecast_node_red_api/chromecast_node_red_api.dart diff --git a/lib/domain/node_red/i_node_red_repository.dart b/lib/domain/node_red/i_node_red_repository.dart deleted file mode 100644 index 3827ab04..00000000 --- a/lib/domain/node_red/i_node_red_repository.dart +++ /dev/null @@ -1,40 +0,0 @@ -import 'package:cbj_hub/domain/binding/binding_cbj_entity.dart'; -import 'package:cbj_hub/domain/routine/routine_cbj_entity.dart'; -import 'package:cbj_hub/domain/scene/scene_cbj_entity.dart'; - -/// Class to define all Node RED repo functions -abstract class INodeRedRepository { - /// Function to create new scene in Node-RED - Future createNewNodeRedScene(SceneCbjEntity sceneCbj); - - // /// Replace existing scene with new one - // Future replaceSceneWithNewNodeRedScene(SceneCbjEntity sceneCbj); - - /// Function to create new routine in Node-RED - Future createNewNodeRedRoutine(RoutineCbjEntity routineCbj); - - /// Function to create new binding in Node-RED - Future createNewNodeRedBinding(BindingCbjEntity bindingCbj); - - /// Install node module if not exist and set a new flow for that api - /// Label is name of the flow - Future setFlowWithModule({ - required String moduleToUse, - required String label, - required String nodes, - required String flowId, - }); - - /// Update existing flow with more nodes - Future updateFlowNodes({ - required String nodes, - required String flowId, - }); - - /// Install node module if needed and set one global node - /// Label is name of the flow - Future setGlobalNodes({ - required String? moduleToUse, - required String nodes, - }); -} diff --git a/lib/infrastructure/bindings/binding_repository.dart b/lib/infrastructure/bindings/binding_repository.dart index 4d0b22ab..dc707e93 100644 --- a/lib/infrastructure/bindings/binding_repository.dart +++ b/lib/infrastructure/bindings/binding_repository.dart @@ -5,9 +5,9 @@ import 'package:cbj_hub/domain/binding/value_objects_routine_cbj.dart'; import 'package:cbj_hub/domain/local_db/i_local_db_repository.dart'; import 'package:cbj_hub/domain/local_db/local_db_failures.dart'; import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart'; -import 'package:cbj_hub/domain/node_red/i_node_red_repository.dart'; import 'package:cbj_hub/domain/rooms/i_saved_rooms_repo.dart'; import 'package:cbj_hub/domain/saved_devices/i_saved_devices_repo.dart'; +import 'package:cbj_hub/infrastructure/node_red/node_red_repository.dart'; import 'package:cbj_hub/injection.dart'; import 'package:dartz/dartz.dart'; import 'package:injectable/injectable.dart'; @@ -64,7 +64,7 @@ class BindingCbjRepository implements IBindingCbjRepository { await getIt().saveAndActivateSmartDevicesToDb(); getIt() .addBindingToRoomDiscoveredIfNotExist(tempBindingCbj); - final String bindingNodeRedFlowId = await getIt() + final String bindingNodeRedFlowId = await getIt() .createNewNodeRedBinding(tempBindingCbj); if (bindingNodeRedFlowId.isNotEmpty) { tempBindingCbj = tempBindingCbj.copyWith( diff --git a/lib/infrastructure/devices/esphome/esphome_helpers.dart b/lib/infrastructure/devices/esphome/esphome_helpers.dart index 87d87909..4c4ee3f5 100644 --- a/lib/infrastructure/devices/esphome/esphome_helpers.dart +++ b/lib/infrastructure/devices/esphome/esphome_helpers.dart @@ -3,13 +3,14 @@ import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abs import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; import 'package:cbj_hub/domain/generic_devices/generic_light_device/generic_light_value_objects.dart'; import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_value_objects.dart'; +import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart'; import 'package:cbj_hub/infrastructure/devices/esphome/esphome_connector_conjector.dart'; import 'package:cbj_hub/infrastructure/devices/esphome/esphome_light/esphome_light_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/esphome/esphome_node_red_api/esphome_node_red_api.dart'; -import 'package:cbj_hub/infrastructure/devices/esphome/esphome_node_red_api/esphome_node_red_server_api_calls.dart'; import 'package:cbj_hub/infrastructure/devices/esphome/esphome_switch/esphome_switch_entity.dart'; import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; +import 'package:cbj_hub/infrastructure/node_red/node_red_repository.dart'; import 'package:cbj_hub/injection.dart'; +import 'package:nodered/nodered.dart'; class EspHomeHelpers { /// Will create new espHome device node in NodeRed if does not exist. @@ -33,7 +34,15 @@ class EspHomeHelpers { final String tempEspHomeNodeDeviceId = espHomeNodeDeviceId ?? UniqueId().getOrCrash(); - await EspHomeNodeRedApi.setNewGlobalEspHomeDeviceNode( + final EspHomeNodeRedApi espHomeNodeRedApi = EspHomeNodeRedApi( + repository: getIt(), + nodeRedApiBaseTopic: + getIt().getNodeRedApiBaseTopic(), + nodeRedDevicesTopic: + getIt().getNodeRedDevicesTopicTypeName(), + nodeRedMqttBrokerNodeName: 'Cbj NodeRed plugs Api Broker'); + + await espHomeNodeRedApi.setNewGlobalEspHomeDeviceNode( deviceMdnsName: mDnsName, password: devicePassword, espHomeDeviceId: tempEspHomeNodeDeviceId, @@ -101,13 +110,21 @@ class EspHomeHelpers { final List deviceEntityList = []; + final EspHomeNodeRedApi espHomeNodeRedApi = EspHomeNodeRedApi( + repository: getIt(), + nodeRedApiBaseTopic: + getIt().getNodeRedApiBaseTopic(), + nodeRedDevicesTopic: + getIt().getNodeRedDevicesTopicTypeName(), + nodeRedMqttBrokerNodeName: 'Cbj NodeRed plugs Api Broker'); + for (final EspHomeDeviceEntityObject espHomeDeviceEntityObject in entitiesList) { final String flowId = UniqueId().getOrCrash(); final String deviceKey = espHomeDeviceEntityObject.key.toString(); - await EspHomeNodeRedApi.setNewStateNodes( + await espHomeNodeRedApi.setNewStateNodes( espHomeDeviceId: espHomeDeviceNodeId, flowId: flowId, entityId: deviceKey, diff --git a/lib/infrastructure/devices/esphome/esphome_light/esphome_light_entity.dart b/lib/infrastructure/devices/esphome/esphome_light/esphome_light_entity.dart index 35a7ba4e..6dd6c085 100644 --- a/lib/infrastructure/devices/esphome/esphome_light/esphome_light_entity.dart +++ b/lib/infrastructure/devices/esphome/esphome_light/esphome_light_entity.dart @@ -5,11 +5,11 @@ import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; import 'package:cbj_hub/domain/generic_devices/generic_light_device/generic_light_entity.dart'; import 'package:cbj_hub/domain/generic_devices/generic_light_device/generic_light_value_objects.dart'; import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart'; -import 'package:cbj_hub/infrastructure/devices/esphome/esphome_node_red_api/esphome_node_red_api.dart'; import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_hub/injection.dart'; import 'package:cbj_hub/utils.dart'; import 'package:dartz/dartz.dart'; +import 'package:nodered/nodered.dart'; class EspHomeLightEntity extends GenericLightDE { EspHomeLightEntity({ diff --git a/lib/infrastructure/devices/esphome/esphome_node_red_api/esphome_node_red_api.dart b/lib/infrastructure/devices/esphome/esphome_node_red_api/esphome_node_red_api.dart deleted file mode 100644 index 1cf6e212..00000000 --- a/lib/infrastructure/devices/esphome/esphome_node_red_api/esphome_node_red_api.dart +++ /dev/null @@ -1,138 +0,0 @@ -import 'package:cbj_hub/domain/core/value_objects.dart'; -import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart'; -import 'package:cbj_hub/domain/node_red/i_node_red_repository.dart'; -import 'package:cbj_hub/injection.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:nodered/nodered.dart'; - -class EspHomeNodeRedApi { - static String module = 'node-red-contrib-esphome'; - - static String deviceStateProperty = 'deviceStateProperty'; - static String inputDeviceProperty = 'inputDeviceProperty'; - static String outputDeviceProperty = 'outputDeviceProperty'; - - // Returns the espHome device node id - static Future setNewGlobalEspHomeDeviceNode({ - required String deviceMdnsName, - required String password, - String? espHomeDeviceId, - }) async { - String nodes = '[\n'; - - final String espHomeDeviceIdTemp = - espHomeDeviceId ?? UniqueId().getOrCrash(); - - /// Device connection - final NodeRedEspHomeDeviceNode nodeRedEspHomeDeviceNode = - NodeRedEspHomeDeviceNode( - tempId: espHomeDeviceIdTemp, - host: '$deviceMdnsName.local', - name: 'ESPHome $deviceMdnsName device id $espHomeDeviceIdTemp', - password: password, - ); - nodes += nodeRedEspHomeDeviceNode.toString(); - - nodes += '\n]'; - - /// Setting the flow - final String response = await getIt().setGlobalNodes( - moduleToUse: module, - nodes: nodes, - ); - if (response != 'ok') { - logger.e('Error setting ESPHome device node\n$response'); - } - } - - static Future setNewStateNodes({ - required String flowId, - required String entityId, - required String espHomeDeviceId, - }) async { - String nodes = '[\n'; - - final String nodeRedApiBaseTopic = - getIt().getNodeRedApiBaseTopic(); - - final String nodeRedDevicesTopic = - getIt().getNodeRedDevicesTopicTypeName(); - - const String mqttNodeName = 'Esphome'; - - final String topic = - '$nodeRedApiBaseTopic/$nodeRedDevicesTopic/$entityId/$deviceStateProperty'; - - /// Mqtt broker - final NodeRedMqttBrokerNode mqttBrokerNode = - NodeRedMqttBrokerNode(name: 'Cbj NodeRed plugs Api Broker'); - - nodes += mqttBrokerNode.toString(); - - /// Mqtt out - - final NodeRedMqttOutNode mqttOutNode = NodeRedMqttOutNode( - brokerNodeId: mqttBrokerNode.id, - topic: '$topic/$outputDeviceProperty', - name: '$mqttNodeName - $outputDeviceProperty', - ); - nodes += ', $mqttOutNode'; - - /// Create an EspHome in node - final NodeRedEspHomeInNode nodeRedEspHomeInNode = NodeRedEspHomeInNode( - wires: [ - [ - mqttOutNode.id, - ] - ], - espHomeNodeDeviceId: espHomeDeviceId, - name: 'ESPHome $entityId in type', - epsHomeDeviceEntityId: entityId, - ); - nodes += ', $nodeRedEspHomeInNode'; - - /// Create an EspHome out node - final NodeRedEspHomeOutNode nodeRedEspHomeOutNode = NodeRedEspHomeOutNode( - wires: [[]], - espHomeNodeDeviceId: espHomeDeviceId, - name: 'ESPHome $entityId out type', - espHomeEntityId: entityId, - ); - nodes += ', $nodeRedEspHomeOutNode'; - - final NodeRedFunctionNode nodeRedFunctionToJsonNode = - NodeRedFunctionNode.inputPayloadToJson( - wires: [ - [ - nodeRedEspHomeOutNode.id, - ] - ], - ); - nodes += ', $nodeRedFunctionToJsonNode'; - - /// Mqtt in - final NodeRedMqttInNode nodeRedMqttInNode = NodeRedMqttInNode( - name: '$mqttNodeName - $inputDeviceProperty', - brokerNodeId: mqttBrokerNode.id, - topic: '$topic/$inputDeviceProperty', - wires: [ - [ - nodeRedFunctionToJsonNode.id, - ] - ], - ); - nodes += ', $nodeRedMqttInNode'; - - nodes += '\n]'; - - /// Setting the flow - final Future settingTheFlowResponse = - getIt().setFlowWithModule( - label: 'Setting device $entityId', - moduleToUse: module, - nodes: nodes, - flowId: flowId, - ); - return settingTheFlowResponse; - } -} diff --git a/lib/infrastructure/devices/esphome/esphome_node_red_api/esphome_node_red_server_api_calls.dart b/lib/infrastructure/devices/esphome/esphome_node_red_api/esphome_node_red_server_api_calls.dart deleted file mode 100644 index d50aa7fa..00000000 --- a/lib/infrastructure/devices/esphome/esphome_node_red_api/esphome_node_red_server_api_calls.dart +++ /dev/null @@ -1,114 +0,0 @@ -import 'dart:convert'; - -import 'package:cbj_hub/utils.dart'; -import 'package:http/http.dart'; - -class EspHomeNodeRedServerApiCalls { - static Future> getAllEspHomeDevices() async { - final Response discoveredDevices = await post( - Uri.parse('http://localhost:1880/esphome/discovery'), - encoding: Encoding.getByName('utf-8'), - headers: { - "Content-Type": "application/x-www-form-urlencoded", - }, - body: {}, - ); - - final List> allDevices = - (jsonDecode(discoveredDevices.body) as List) - .map((e) => e as Map) - .toList(); - - final List listOfDevices = []; - - for (final Map device in allDevices) { - final EspHomeDeviceObject espHomeDeviceObject = EspHomeDeviceObject( - port: device['port'] as int, - board: device['board'] as String, - platform: device['platform'] as String, - mac: device['mac'] as String, - version: device['version'] as String, - host: device['host'] as String, - address: device['address'] as String, - family: device['family'] as String, - ); - listOfDevices.add(espHomeDeviceObject); - } - - logger.i(listOfDevices); - return listOfDevices; - } - - static Future> getEspHomeDeviceEntities( - String espHomeDeviceId, - ) async { - final Response entitiesOfDevice = await post( - Uri.parse('http://localhost:1880/esphome/entities'), - encoding: Encoding.getByName('utf-8'), - headers: { - "Content-Type": "application/x-www-form-urlencoded", - }, - body: { - 'deviceNode': espHomeDeviceId, - }, - ); - - final List> espHomeDeviceEntities = - (jsonDecode(entitiesOfDevice.body) as List) - .map((e) => e as Map) - .toList(); - - final List entityList = []; - - for (final Map entity in espHomeDeviceEntities) { - final EspHomeDeviceEntityObject espHomeDeviceEntityObject = - EspHomeDeviceEntityObject.fromMap(entity); - entityList.add(espHomeDeviceEntityObject); - } - return entityList; - } -} - -class EspHomeDeviceObject { - EspHomeDeviceObject({ - required this.port, - required this.board, - required this.platform, - required this.mac, - required this.version, - required this.host, - required this.address, - required this.family, - }); - - int port; - String board; - String platform; - String mac; - String version; - String host; - String address; - String family; -} - -class EspHomeDeviceEntityObject { - EspHomeDeviceEntityObject({ - required this.key, - required this.type, - required this.name, - required this.config, - }); - - factory EspHomeDeviceEntityObject.fromMap(Map entityMap) { - return EspHomeDeviceEntityObject( - key: entityMap['key'] as int, - type: entityMap['type'] as String, - name: entityMap['name'] as String, - config: entityMap['config'] as Map, - ); - } - int key; - String type; - String name; - Map config; -} diff --git a/lib/infrastructure/devices/esphome/esphome_switch/esphome_switch_entity.dart b/lib/infrastructure/devices/esphome/esphome_switch/esphome_switch_entity.dart index 23ff46bc..f49a8dfb 100644 --- a/lib/infrastructure/devices/esphome/esphome_switch/esphome_switch_entity.dart +++ b/lib/infrastructure/devices/esphome/esphome_switch/esphome_switch_entity.dart @@ -5,11 +5,11 @@ import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_entity.dart'; import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_value_objects.dart'; import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart'; -import 'package:cbj_hub/infrastructure/devices/esphome/esphome_node_red_api/esphome_node_red_api.dart'; import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_hub/injection.dart'; import 'package:cbj_hub/utils.dart'; import 'package:dartz/dartz.dart'; +import 'package:nodered/nodered.dart'; class EspHomeSwitchEntity extends GenericSwitchDE { EspHomeSwitchEntity({ diff --git a/lib/infrastructure/devices/google/chrome_cast/chrome_cast_entity.dart b/lib/infrastructure/devices/google/chrome_cast/chrome_cast_entity.dart index e2154ab8..24cd657f 100644 --- a/lib/infrastructure/devices/google/chrome_cast/chrome_cast_entity.dart +++ b/lib/infrastructure/devices/google/chrome_cast/chrome_cast_entity.dart @@ -6,12 +6,12 @@ import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_cor import 'package:cbj_hub/domain/generic_devices/generic_smart_tv/generic_smart_tv_entity.dart'; import 'package:cbj_hub/domain/generic_devices/generic_smart_tv/generic_smart_tv_value_objects.dart'; import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart'; -import 'package:cbj_hub/domain/node_red/i_node_red_repository.dart'; -import 'package:cbj_hub/infrastructure/devices/google/chromecast_node_red_api/chromecast_node_red_api.dart'; import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; +import 'package:cbj_hub/infrastructure/node_red/node_red_repository.dart'; import 'package:cbj_hub/injection.dart'; import 'package:cbj_hub/utils.dart'; import 'package:dartz/dartz.dart'; +import 'package:nodered/nodered.dart'; class ChromeCastEntity extends GenericSmartTvDE { ChromeCastEntity({ @@ -93,11 +93,12 @@ class ChromeCastEntity extends GenericSmartTvDE { } chromecastNodeRedApi = ChromecastNodeRedApi( + repository: getIt(), nodeRedApiBaseTopic: getIt().getNodeRedApiBaseTopic(), nodeRedDevicesTopic: getIt().getNodeRedDevicesTopicTypeName(), - repository: getIt(), + nodeRedMqttBrokerNodeName: 'Cbj NodeRed plugs Api Broker', ); chromecastNodeRedApi.setNewYoutubeVideoNodes( diff --git a/lib/infrastructure/devices/google/chromecast_node_red_api/chromecast_node_red_api.dart b/lib/infrastructure/devices/google/chromecast_node_red_api/chromecast_node_red_api.dart deleted file mode 100644 index 76ad69ee..00000000 --- a/lib/infrastructure/devices/google/chromecast_node_red_api/chromecast_node_red_api.dart +++ /dev/null @@ -1,347 +0,0 @@ -import 'package:cbj_hub/domain/node_red/i_node_red_repository.dart'; -import 'package:nodered/nodered.dart'; - -class ChromecastNodeRedApi { - ChromecastNodeRedApi({ - required this.nodeRedApiBaseTopic, - required this.nodeRedDevicesTopic, - required this.repository, - }); - - final String nodeRedApiBaseTopic; - final String nodeRedDevicesTopic; - final INodeRedRepository repository; - - final String module = 'node-red-contrib-castv2'; - - final String youtubeVideoTopicProperty = 'youtubeVideo'; - final String playingVideoTopicProperty = 'playingVideo'; - final String pauseVideoTopicProperty = 'pauseVideo'; - final String stopVideoTopicProperty = 'stopVideo'; - final String playVideoTopicProperty = 'playVideo'; - final String queuePrevVideoTopicProperty = 'queuePrevVideo'; - final String queueNextVideoTopicProperty = 'queueNextVideo'; - final String closeAppTopicProperty = 'closeApp'; - final String outputVideoTopicProperty = 'outputVideo'; - - Future setNewYoutubeVideoNodes( - String entityUniqueId, - String deviceIp, - ) async { - String nodes = '[\n'; - - const String mqttNodeName = 'Chromecast'; - - final String topic = - '$nodeRedApiBaseTopic/$nodeRedDevicesTopic/$entityUniqueId/$youtubeVideoTopicProperty'; - - /// Mqtt broker - final NodeRedMqttBrokerNode mqttBrokerNode = - NodeRedMqttBrokerNode(name: 'Cbj NodeRed plugs Api Broker'); - - nodes += mqttBrokerNode.toString(); - - /// Mqtt out - - final NodeRedMqttOutNode mqttNode = NodeRedMqttOutNode( - brokerNodeId: mqttBrokerNode.id, - topic: '$topic/$outputVideoTopicProperty', - name: '$mqttNodeName - $outputVideoTopicProperty', - ); - nodes += ', $mqttNode'; - - /// Cast v2 connection - final NodeRedCastV2ConnectionNode nodeRedCastV2ConnectionNode = - NodeRedCastV2ConnectionNode(host: deviceIp); - nodes += ', $nodeRedCastV2ConnectionNode'; - - /// Cast v2 sender - final NodeRedCastV2SenderNode nodeRedCastV2SenderNode = - NodeRedCastV2SenderNode( - connectionId: nodeRedCastV2ConnectionNode.id, - wires: [ - [ - mqttNode.id, - ] - ], - ); - nodes += ', $nodeRedCastV2SenderNode'; - - nodes += ', ${openUrlNodesString( - mqttBrokerNode, - nodeRedCastV2SenderNode.id, - mqttNodeName, - topic, - )}'; - - nodes += ', ${stopVideoNodesString( - mqttBrokerNode, - nodeRedCastV2SenderNode.id, - mqttNodeName, - topic, - )}'; - - nodes += ', ${pauseVideoNodesString( - mqttBrokerNode, - nodeRedCastV2SenderNode.id, - mqttNodeName, - topic, - )}'; - - nodes += ', ${playVideoNodesString( - mqttBrokerNode, - nodeRedCastV2SenderNode.id, - mqttNodeName, - topic, - )}'; - - nodes += ', ${queuePrevVideoNodesString( - mqttBrokerNode, - nodeRedCastV2SenderNode.id, - mqttNodeName, - topic, - )}'; - - nodes += ', ${queueNextVideoNodesString( - mqttBrokerNode, - nodeRedCastV2SenderNode.id, - mqttNodeName, - topic, - )}'; - - nodes += ', ${closeVideoNodesString( - mqttBrokerNode, - nodeRedCastV2SenderNode.id, - mqttNodeName, - topic, - )}'; - - nodes += '\n]'; - - /// Setting the flow - final Future settingTheFlowResponse = repository.setFlowWithModule( - moduleToUse: module, - label: 'playYoutubeUrl', - nodes: nodes, - flowId: '$entityUniqueId-YoutubeVideo', - ); - return settingTheFlowResponse; - } - - String openUrlNodesString( - NodeRedMqttBrokerNode mqttBrokerNode, - String nextNodeIdToConnectToo, - String mqttNodeName, - String topic, - ) { - String nodes = ''; - - /// Function node - const String functionString = - '''msg.payload = JSON.parse(\\"{\\\\\\"app\\\\\\": \\\\\\"YouTube\\\\\\", \\\\\\"type\\\\\\": \\\\\\"MEDIA\\\\\\",\\\\\\"videoId\\\\\\": \\\\\\"\\" + msg.payload + \\"\\\\\\"}\\"); return msg;'''; - final NodeRedFunctionNode nodeRedFunctionNode = NodeRedFunctionNode( - funcString: functionString, - wires: [ - [nextNodeIdToConnectToo], - ], - ); - nodes += nodeRedFunctionNode.toString(); - - /// Mqtt in - final NodeRedMqttInNode nodeRedMqttInNode = NodeRedMqttInNode( - name: '$mqttNodeName - $playingVideoTopicProperty', - brokerNodeId: mqttBrokerNode.id, - topic: '$topic/$playingVideoTopicProperty', - wires: [ - [nodeRedFunctionNode.id], - ], - ); - return '$nodes,\n$nodeRedMqttInNode'; - } - - String stopVideoNodesString( - NodeRedMqttBrokerNode mqttBrokerNode, - String nextNodeIdToConnectToo, - String mqttNodeName, - String topic, - ) { - String nodes = ''; - - /// Function node - const String functionString = - '''msg.payload = JSON.parse(\\"{\\\\\\"type\\\\\\": \\\\\\"STOP\\\\\\"}\\"); return msg;'''; - final NodeRedFunctionNode nodeRedFunctionNode = NodeRedFunctionNode( - funcString: functionString, - wires: [ - [nextNodeIdToConnectToo], - ], - ); - nodes += nodeRedFunctionNode.toString(); - - /// Mqtt in - final NodeRedMqttInNode nodeRedMqttInNode = NodeRedMqttInNode( - name: '$mqttNodeName - $stopVideoTopicProperty', - brokerNodeId: mqttBrokerNode.id, - topic: '$topic/$stopVideoTopicProperty', - wires: [ - [nodeRedFunctionNode.id], - ], - ); - return '$nodes,\n$nodeRedMqttInNode'; - } - - String pauseVideoNodesString( - NodeRedMqttBrokerNode mqttBrokerNode, - String nextNodeIdToConnectToo, - String mqttNodeName, - String topic, - ) { - String nodes = ''; - - /// Function node - const String functionString = - '''msg.payload = JSON.parse(\\"{\\\\\\"type\\\\\\": \\\\\\"PAUSE\\\\\\"}\\"); return msg;'''; - final NodeRedFunctionNode nodeRedFunctionNode = NodeRedFunctionNode( - funcString: functionString, - wires: [ - [nextNodeIdToConnectToo], - ], - ); - nodes += nodeRedFunctionNode.toString(); - - /// Mqtt in - final NodeRedMqttInNode nodeRedMqttInNode = NodeRedMqttInNode( - name: '$mqttNodeName - $pauseVideoTopicProperty', - brokerNodeId: mqttBrokerNode.id, - topic: '$topic/$pauseVideoTopicProperty', - wires: [ - [nodeRedFunctionNode.id], - ], - ); - return '$nodes,\n$nodeRedMqttInNode'; - } - - String playVideoNodesString( - NodeRedMqttBrokerNode mqttBrokerNode, - String nextNodeIdToConnectToo, - String mqttNodeName, - String topic, - ) { - String nodes = ''; - - /// Function node - const String functionString = - '''msg.payload = JSON.parse(\\"{\\\\\\"type\\\\\\": \\\\\\"PLAY\\\\\\"}\\"); return msg;'''; - final NodeRedFunctionNode nodeRedFunctionNode = NodeRedFunctionNode( - funcString: functionString, - wires: [ - [nextNodeIdToConnectToo], - ], - ); - nodes += nodeRedFunctionNode.toString(); - - /// Mqtt in - final NodeRedMqttInNode nodeRedMqttInNode = NodeRedMqttInNode( - name: '$mqttNodeName - $playVideoTopicProperty', - brokerNodeId: mqttBrokerNode.id, - topic: '$topic/$playVideoTopicProperty', - wires: [ - [nodeRedFunctionNode.id], - ], - ); - return '$nodes,\n$nodeRedMqttInNode'; - } - - String queuePrevVideoNodesString( - NodeRedMqttBrokerNode mqttBrokerNode, - String nextNodeIdToConnectToo, - String mqttNodeName, - String topic, - ) { - String nodes = ''; - - /// Function node - const String functionString = - '''msg.payload = JSON.parse(\\"{\\\\\\"type\\\\\\": \\\\\\"QUEUE_PREV\\\\\\"}\\"); return msg;'''; - final NodeRedFunctionNode nodeRedFunctionNode = NodeRedFunctionNode( - funcString: functionString, - wires: [ - [nextNodeIdToConnectToo], - ], - ); - nodes += nodeRedFunctionNode.toString(); - - /// Mqtt in - final NodeRedMqttInNode nodeRedMqttInNode = NodeRedMqttInNode( - name: '$mqttNodeName - $queuePrevVideoTopicProperty', - brokerNodeId: mqttBrokerNode.id, - topic: '$topic/$queuePrevVideoTopicProperty', - wires: [ - [nodeRedFunctionNode.id], - ], - ); - return '$nodes,\n$nodeRedMqttInNode'; - } - - String queueNextVideoNodesString( - NodeRedMqttBrokerNode mqttBrokerNode, - String nextNodeIdToConnectToo, - String mqttNodeName, - String topic, - ) { - String nodes = ''; - - /// Function node - const String functionString = - '''msg.payload = JSON.parse(\\"{\\\\\\"type\\\\\\": \\\\\\"QUEUE_NEXT\\\\\\"}\\"); return msg;'''; - final NodeRedFunctionNode nodeRedFunctionNode = NodeRedFunctionNode( - funcString: functionString, - wires: [ - [nextNodeIdToConnectToo], - ], - ); - nodes += nodeRedFunctionNode.toString(); - - /// Mqtt in - final NodeRedMqttInNode nodeRedMqttInNode = NodeRedMqttInNode( - name: '$mqttNodeName - $queueNextVideoTopicProperty', - brokerNodeId: mqttBrokerNode.id, - topic: '$topic/$queueNextVideoTopicProperty', - wires: [ - [nodeRedFunctionNode.id], - ], - ); - return '$nodes,\n$nodeRedMqttInNode'; - } - - String closeVideoNodesString( - NodeRedMqttBrokerNode mqttBrokerNode, - String nextNodeIdToConnectToo, - String mqttNodeName, - String topic, - ) { - String nodes = ''; - - /// Function node - const String functionString = - '''msg.payload = JSON.parse(\\"{\\\\\\"type\\\\\\": \\\\\\"CLOSE\\\\\\"}\\"); return msg;'''; - final NodeRedFunctionNode nodeRedFunctionNode = NodeRedFunctionNode( - funcString: functionString, - wires: [ - [nextNodeIdToConnectToo], - ], - ); - nodes += nodeRedFunctionNode.toString(); - - /// Mqtt in - final NodeRedMqttInNode nodeRedMqttInNode = NodeRedMqttInNode( - name: '$mqttNodeName - $closeAppTopicProperty', - brokerNodeId: mqttBrokerNode.id, - topic: '$topic/$closeAppTopicProperty', - wires: [ - [nodeRedFunctionNode.id], - ], - ); - return '$nodes,\n$nodeRedMqttInNode'; - } -} diff --git a/lib/infrastructure/node_red/node_red_repository.dart b/lib/infrastructure/node_red/node_red_repository.dart index 676c4193..d1ed0d1e 100644 --- a/lib/infrastructure/node_red/node_red_repository.dart +++ b/lib/infrastructure/node_red/node_red_repository.dart @@ -1,16 +1,16 @@ import 'dart:convert'; import 'package:cbj_hub/domain/binding/binding_cbj_entity.dart'; -import 'package:cbj_hub/domain/node_red/i_node_red_repository.dart'; import 'package:cbj_hub/domain/routine/routine_cbj_entity.dart'; import 'package:cbj_hub/domain/scene/scene_cbj_entity.dart'; import 'package:cbj_hub/utils.dart'; import 'package:http/src/response.dart'; import 'package:injectable/injectable.dart'; import 'package:nodered/nodered.dart'; +import 'package:nodered/src/node_red_nodes/external_nodes/chromecast_node_red_api/i_node_red_repository.dart'; /// Control Node-RED, create scenes and more -@LazySingleton(as: INodeRedRepository) +@LazySingleton() class NodeRedRepository extends INodeRedRepository { static NodeRedAPI nodeRedApi = NodeRedAPI(); @@ -23,7 +23,7 @@ class NodeRedRepository extends INodeRedRepository { // /// List of all the bindings JSONs in Node-RED // List bindingsList = []; - @override + /// Function to create new scene in Node-RED Future createNewNodeRedScene(SceneCbjEntity sceneCbj) async { // final String flowId = sceneCbj.uniqueId.getOrCrash(); @@ -63,7 +63,7 @@ class NodeRedRepository extends INodeRedRepository { return ""; } - @override + /// Function to create new routine in Node-RED Future createNewNodeRedRoutine(RoutineCbjEntity routineCbj) async { // await _deviceIsReadyToSendInternetRequests; // final String flowId = routineCbj.uniqueId.getOrCrash(); @@ -102,7 +102,7 @@ class NodeRedRepository extends INodeRedRepository { return ""; } - @override + /// Function to create new binding in Node-RED Future createNewNodeRedBinding(BindingCbjEntity bindingCbj) async { try { // if (bindingsList.contains(bindingCbj.uniqueId.getOrCrash())) { diff --git a/lib/infrastructure/routines/routine_repository.dart b/lib/infrastructure/routines/routine_repository.dart index e4b1e237..d57454f4 100644 --- a/lib/infrastructure/routines/routine_repository.dart +++ b/lib/infrastructure/routines/routine_repository.dart @@ -1,13 +1,13 @@ import 'package:cbj_hub/domain/local_db/i_local_db_repository.dart'; import 'package:cbj_hub/domain/local_db/local_db_failures.dart'; import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart'; -import 'package:cbj_hub/domain/node_red/i_node_red_repository.dart'; import 'package:cbj_hub/domain/rooms/i_saved_rooms_repo.dart'; import 'package:cbj_hub/domain/routine/i_routine_cbj_repository.dart'; import 'package:cbj_hub/domain/routine/routine_cbj_entity.dart'; import 'package:cbj_hub/domain/routine/routine_cbj_failures.dart'; import 'package:cbj_hub/domain/routine/value_objects_routine_cbj.dart'; import 'package:cbj_hub/domain/saved_devices/i_saved_devices_repo.dart'; +import 'package:cbj_hub/infrastructure/node_red/node_red_repository.dart'; import 'package:cbj_hub/injection.dart'; import 'package:dartz/dartz.dart'; import 'package:injectable/injectable.dart'; @@ -63,7 +63,7 @@ class RoutineCbjRepository implements IRoutineCbjRepository { getIt() .addRoutineToRoomDiscoveredIfNotExist(tempRoutineCbj); - final String routineNodeRedFlowId = await getIt() + final String routineNodeRedFlowId = await getIt() .createNewNodeRedRoutine(tempRoutineCbj); if (routineNodeRedFlowId.isNotEmpty) { tempRoutineCbj = tempRoutineCbj.copyWith( diff --git a/lib/infrastructure/scenes/scene_repository.dart b/lib/infrastructure/scenes/scene_repository.dart index d5479874..d8301c84 100644 --- a/lib/infrastructure/scenes/scene_repository.dart +++ b/lib/infrastructure/scenes/scene_repository.dart @@ -5,7 +5,6 @@ import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abs import 'package:cbj_hub/domain/local_db/i_local_db_repository.dart'; import 'package:cbj_hub/domain/local_db/local_db_failures.dart'; import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart'; -import 'package:cbj_hub/domain/node_red/i_node_red_repository.dart'; import 'package:cbj_hub/domain/rooms/i_saved_rooms_repo.dart'; import 'package:cbj_hub/domain/saved_devices/i_saved_devices_repo.dart'; import 'package:cbj_hub/domain/scene/i_scene_cbj_repository.dart'; @@ -15,6 +14,7 @@ import 'package:cbj_hub/domain/scene/value_objects_scene_cbj.dart'; import 'package:cbj_hub/infrastructure/app_communication/app_communication_repository.dart'; import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_hub/infrastructure/node_red/node_red_converter.dart'; +import 'package:cbj_hub/infrastructure/node_red/node_red_repository.dart'; import 'package:cbj_hub/infrastructure/room/saved_rooms_repo.dart'; import 'package:cbj_hub/infrastructure/scenes/area_types_scientific_presets/area_type_with_device_type_preset.dart'; import 'package:cbj_hub/injection.dart'; @@ -88,7 +88,7 @@ class SceneCbjRepository implements ISceneCbjRepository { tempSceneCbj.automationString.getOrCrash() != existingScene.automationString.getOrCrash()) { sceneNodeRedFlowId = - await getIt().createNewNodeRedScene(tempSceneCbj); + await getIt().createNewNodeRedScene(tempSceneCbj); } if (sceneNodeRedFlowId.isNotEmpty) { @@ -163,7 +163,7 @@ class SceneCbjRepository implements ISceneCbjRepository { sceneCbjEntityTemp = sceneCbjEntityTemp.copyWith(nodeRedFlowId: tempScene.nodeRedFlowId); - nodeRedFlowId = await getIt() + nodeRedFlowId = await getIt() .createNewNodeRedScene(sceneCbjEntityTemp); sceneCbjEntityTemp = sceneCbjEntityTemp.copyWith( @@ -396,7 +396,7 @@ class SceneCbjRepository implements ISceneCbjRepository { scene = scene.copyWith(nodeRedFlowId: tempScene.nodeRedFlowId); nodeRedFlowId = - await getIt().createNewNodeRedScene(scene); + await getIt().createNewNodeRedScene(scene); scene = scene.copyWith(nodeRedFlowId: SceneCbjNodeRedFlowId(nodeRedFlowId)); diff --git a/lib/injection.config.dart b/lib/injection.config.dart index 56727420..ca28f191 100644 --- a/lib/injection.config.dart +++ b/lib/injection.config.dart @@ -17,11 +17,10 @@ import 'package:cbj_hub/domain/cbj_web_server/i_cbj_web_server_repository.dart' import 'package:cbj_hub/domain/local_db/i_local_db_repository.dart' as _i14; import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart' as _i16; -import 'package:cbj_hub/domain/node_red/i_node_red_repository.dart' as _i18; -import 'package:cbj_hub/domain/rooms/i_saved_rooms_repo.dart' as _i24; -import 'package:cbj_hub/domain/routine/i_routine_cbj_repository.dart' as _i20; -import 'package:cbj_hub/domain/saved_devices/i_saved_devices_repo.dart' as _i22; -import 'package:cbj_hub/domain/scene/i_scene_cbj_repository.dart' as _i26; +import 'package:cbj_hub/domain/rooms/i_saved_rooms_repo.dart' as _i22; +import 'package:cbj_hub/domain/routine/i_routine_cbj_repository.dart' as _i18; +import 'package:cbj_hub/domain/saved_devices/i_saved_devices_repo.dart' as _i20; +import 'package:cbj_hub/domain/scene/i_scene_cbj_repository.dart' as _i24; import 'package:cbj_hub/infrastructure/app_communication/app_communication_repository.dart' as _i9; import 'package:cbj_hub/infrastructure/bindings/binding_repository.dart' @@ -39,49 +38,49 @@ import 'package:cbj_hub/infrastructure/devices/google/google_connector_conjector import 'package:cbj_hub/infrastructure/devices/hp/hp_connector_conjector.dart' as _i7; import 'package:cbj_hub/infrastructure/devices/lg/lg_connector_conjector.dart' - as _i28; + as _i26; import 'package:cbj_hub/infrastructure/devices/lifx/lifx_connector_conjector.dart' - as _i29; + as _i27; import 'package:cbj_hub/infrastructure/devices/philips_hue/philips_hue_connector_conjector.dart' - as _i30; + as _i29; import 'package:cbj_hub/infrastructure/devices/shelly/shelly_connector_conjector.dart' - as _i32; + as _i31; import 'package:cbj_hub/infrastructure/devices/sonoff_diy/sonoff_diy_connector_conjector.dart' - as _i33; + as _i32; import 'package:cbj_hub/infrastructure/devices/switcher/switcher_connector_conjector.dart' - as _i34; + as _i33; import 'package:cbj_hub/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_connector_conjector.dart' - as _i36; + as _i35; import 'package:cbj_hub/infrastructure/devices/tasmota/tasmota_mqtt/tasmota_mqtt_connector_conjector.dart' - as _i37; + as _i36; import 'package:cbj_hub/infrastructure/devices/tuya_smart/tuya_smart_connector_conjector.dart' - as _i38; + as _i37; import 'package:cbj_hub/infrastructure/devices/wiz/wiz_connector_conjector.dart' - as _i39; + as _i38; import 'package:cbj_hub/infrastructure/devices/xiaomi_io/xiaomi_io_connector_conjector.dart' - as _i40; + as _i39; import 'package:cbj_hub/infrastructure/devices/yeelight/yeelight_connector_conjector.dart' - as _i41; + as _i40; import 'package:cbj_hub/infrastructure/local_db/local_db_hive_repository.dart' as _i15; import 'package:cbj_hub/infrastructure/mqtt_server/mqtt_server_repository.dart' as _i17; import 'package:cbj_hub/infrastructure/node_red/node_red_repository.dart' - as _i19; -import 'package:cbj_hub/infrastructure/room/saved_rooms_repo.dart' as _i25; + as _i28; +import 'package:cbj_hub/infrastructure/room/saved_rooms_repo.dart' as _i23; import 'package:cbj_hub/infrastructure/routines/routine_repository.dart' - as _i21; + as _i19; import 'package:cbj_hub/infrastructure/saved_devices/saved_devices_repo.dart' - as _i23; -import 'package:cbj_hub/infrastructure/scenes/scene_repository.dart' as _i27; -import 'package:cbj_hub/infrastructure/shared_variables.dart' as _i31; + as _i21; +import 'package:cbj_hub/infrastructure/scenes/scene_repository.dart' as _i25; +import 'package:cbj_hub/infrastructure/shared_variables.dart' as _i30; import 'package:cbj_hub/infrastructure/system_commands/system_commands_manager_d.dart' - as _i35; + as _i34; import 'package:get_it/get_it.dart' as _i1; import 'package:injectable/injectable.dart' as _i2; extension GetItInjectableX on _i1.GetIt { - // initializes the registration of main-scope dependencies inside of GetIt +// initializes the registration of main-scope dependencies inside of GetIt _i1.GetIt init({ String? environment, _i2.EnvironmentFilter? environmentFilter, @@ -108,35 +107,35 @@ extension GetItInjectableX on _i1.GetIt { gh.lazySingleton<_i14.ILocalDbRepository>(() => _i15.HiveRepository()); gh.lazySingleton<_i16.IMqttServerRepository>( () => _i17.MqttServerRepository()); - gh.lazySingleton<_i18.INodeRedRepository>(() => _i19.NodeRedRepository()); - gh.lazySingleton<_i20.IRoutineCbjRepository>( - () => _i21.RoutineCbjRepository()); - gh.lazySingleton<_i22.ISavedDevicesRepo>(() => _i23.SavedDevicesRepo()); - gh.lazySingleton<_i24.ISavedRoomsRepo>(() => _i25.SavedRoomsRepo()); - gh.lazySingleton<_i26.ISceneCbjRepository>(() => _i27.SceneCbjRepository()); - gh.singleton<_i28.LgConnectorConjector>(_i28.LgConnectorConjector()); - gh.singleton<_i29.LifxConnectorConjector>(_i29.LifxConnectorConjector()); - gh.singleton<_i30.PhilipsHueConnectorConjector>( - _i30.PhilipsHueConnectorConjector()); - gh.singleton<_i31.SharedVariables>(_i31.SharedVariables()); - gh.singleton<_i32.ShellyConnectorConjector>( - _i32.ShellyConnectorConjector()); - gh.singleton<_i33.SonoffDiyConnectorConjector>( - _i33.SonoffDiyConnectorConjector()); - gh.singleton<_i34.SwitcherConnectorConjector>( - _i34.SwitcherConnectorConjector()); - gh.singleton<_i35.SystemCommandsManager>(_i35.SystemCommandsManager()); - gh.singleton<_i36.TasmotaIpConnectorConjector>( - _i36.TasmotaIpConnectorConjector()); - gh.singleton<_i37.TasmotaMqttConnectorConjector>( - _i37.TasmotaMqttConnectorConjector()); - gh.singleton<_i38.TuyaSmartConnectorConjector>( - _i38.TuyaSmartConnectorConjector()); - gh.singleton<_i39.WizConnectorConjector>(_i39.WizConnectorConjector()); - gh.singleton<_i40.XiaomiIoConnectorConjector>( - _i40.XiaomiIoConnectorConjector()); - gh.singleton<_i41.YeelightConnectorConjector>( - _i41.YeelightConnectorConjector()); + gh.lazySingleton<_i18.IRoutineCbjRepository>( + () => _i19.RoutineCbjRepository()); + gh.lazySingleton<_i20.ISavedDevicesRepo>(() => _i21.SavedDevicesRepo()); + gh.lazySingleton<_i22.ISavedRoomsRepo>(() => _i23.SavedRoomsRepo()); + gh.lazySingleton<_i24.ISceneCbjRepository>(() => _i25.SceneCbjRepository()); + gh.singleton<_i26.LgConnectorConjector>(_i26.LgConnectorConjector()); + gh.singleton<_i27.LifxConnectorConjector>(_i27.LifxConnectorConjector()); + gh.lazySingleton<_i28.NodeRedRepository>(() => _i28.NodeRedRepository()); + gh.singleton<_i29.PhilipsHueConnectorConjector>( + _i29.PhilipsHueConnectorConjector()); + gh.singleton<_i30.SharedVariables>(_i30.SharedVariables()); + gh.singleton<_i31.ShellyConnectorConjector>( + _i31.ShellyConnectorConjector()); + gh.singleton<_i32.SonoffDiyConnectorConjector>( + _i32.SonoffDiyConnectorConjector()); + gh.singleton<_i33.SwitcherConnectorConjector>( + _i33.SwitcherConnectorConjector()); + gh.singleton<_i34.SystemCommandsManager>(_i34.SystemCommandsManager()); + gh.singleton<_i35.TasmotaIpConnectorConjector>( + _i35.TasmotaIpConnectorConjector()); + gh.singleton<_i36.TasmotaMqttConnectorConjector>( + _i36.TasmotaMqttConnectorConjector()); + gh.singleton<_i37.TuyaSmartConnectorConjector>( + _i37.TuyaSmartConnectorConjector()); + gh.singleton<_i38.WizConnectorConjector>(_i38.WizConnectorConjector()); + gh.singleton<_i39.XiaomiIoConnectorConjector>( + _i39.XiaomiIoConnectorConjector()); + gh.singleton<_i40.YeelightConnectorConjector>( + _i40.YeelightConnectorConjector()); return this; } } From 2464cc586fbcee21417e73ad6598abcb062907fa Mon Sep 17 00:00:00 2001 From: Guy Luz Date: Sat, 7 Oct 2023 15:41:33 +0300 Subject: [PATCH 07/18] Moving shelly package out --- .gitignore | 5 +- bin/cbj_hub.dart | 2 + .../companies_connector_conjector.dart | 2 +- .../devices/esphome/esphome_helpers.dart | 17 +- .../ewelink/ewelink_connector_conjector.dart | 24 +- .../shelly_api/shelly_api_color_bulb.dart | 124 ---- .../shelly_api_device_abstract.dart | 24 - .../shelly_api/shelly_api_relay_switch.dart | 27 - .../shelly/shelly_connector_conjector.dart | 6 +- .../devices/shelly/shelly_helpers.dart | 16 +- .../shelly_light/shelly_light_entity.dart | 6 +- .../shelly_relay_switch_entity.dart | 2 +- .../switcher_api/switcher_api_object.dart | 678 ------------------ .../switcher_api/switcher_discover.dart | 50 -- .../switcher_api/switcher_packets.dart | 51 -- .../switcher_connector_conjector.dart | 2 +- .../devices/switcher/switcher_helpers.dart | 2 +- .../switcher_runner_entity.dart | 2 +- .../switcher_smart_plug_entity.dart | 2 +- .../switcher_v2/switcher_v2_entity.dart | 2 +- pubspec.yaml | 21 +- 21 files changed, 64 insertions(+), 1001 deletions(-) delete mode 100644 lib/infrastructure/devices/shelly/shelly_api/shelly_api_color_bulb.dart delete mode 100644 lib/infrastructure/devices/shelly/shelly_api/shelly_api_device_abstract.dart delete mode 100644 lib/infrastructure/devices/shelly/shelly_api/shelly_api_relay_switch.dart delete mode 100644 lib/infrastructure/devices/switcher/switcher_api/switcher_api_object.dart delete mode 100644 lib/infrastructure/devices/switcher/switcher_api/switcher_discover.dart delete mode 100644 lib/infrastructure/devices/switcher/switcher_api/switcher_packets.dart diff --git a/.gitignore b/.gitignore index 8bc7012e..08f3134d 100644 --- a/.gitignore +++ b/.gitignore @@ -90,4 +90,7 @@ saved_cast_state.json lib/infrastructure/core/constant_credentials.dart # Web related -lib/generated_plugin_registrant.dart \ No newline at end of file +lib/generated_plugin_registrant.dart + +# Network tools +network_tools_db/* \ No newline at end of file diff --git a/bin/cbj_hub.dart b/bin/cbj_hub.dart index 1d18d266..96590e6c 100644 --- a/bin/cbj_hub.dart +++ b/bin/cbj_hub.dart @@ -6,9 +6,11 @@ import 'package:cbj_hub/infrastructure/shared_variables.dart'; import 'package:cbj_hub/infrastructure/system_commands/device_pin_manager.dart'; import 'package:cbj_hub/injection.dart'; import 'package:cbj_hub/utils.dart'; +import 'package:network_tools/network_tools.dart'; Future main(List arguments) async { // arguments[0] is the location of the project + configureNetworkTools('network_tools_db'); configureInjection(Env.prod); try { diff --git a/lib/infrastructure/devices/companies_connector_conjector.dart b/lib/infrastructure/devices/companies_connector_conjector.dart index ea983398..86ad5723 100644 --- a/lib/infrastructure/devices/companies_connector_conjector.dart +++ b/lib/infrastructure/devices/companies_connector_conjector.dart @@ -21,7 +21,6 @@ import 'package:cbj_hub/infrastructure/devices/lifx/lifx_connector_conjector.dar import 'package:cbj_hub/infrastructure/devices/philips_hue/philips_hue_connector_conjector.dart'; import 'package:cbj_hub/infrastructure/devices/shelly/shelly_connector_conjector.dart'; import 'package:cbj_hub/infrastructure/devices/sonoff_diy/sonoff_diy_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/switcher/switcher_api/switcher_discover.dart'; import 'package:cbj_hub/infrastructure/devices/switcher/switcher_connector_conjector.dart'; import 'package:cbj_hub/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_connector_conjector.dart'; import 'package:cbj_hub/infrastructure/devices/tuya_smart/tuya_smart_connector_conjector.dart'; @@ -35,6 +34,7 @@ import 'package:cbj_hub/injection.dart'; import 'package:cbj_hub/utils.dart'; import 'package:internet_connection_checker/internet_connection_checker.dart'; import 'package:network_tools/network_tools.dart'; +import 'package:switcher_dart/switcher_dart.dart'; class CompaniesConnectorConjector { static void updateAllDevicesReposWithDeviceChanges( diff --git a/lib/infrastructure/devices/esphome/esphome_helpers.dart b/lib/infrastructure/devices/esphome/esphome_helpers.dart index 4c4ee3f5..4b23282c 100644 --- a/lib/infrastructure/devices/esphome/esphome_helpers.dart +++ b/lib/infrastructure/devices/esphome/esphome_helpers.dart @@ -52,7 +52,7 @@ class EspHomeHelpers { return tempEspHomeNodeDeviceId; } - static Future> retreveOnlyNewEntities({ + static Future> retrieveOnlyNewEntities({ required String mDnsName, required String devicePassword, String? espHomeDeviceNodeId, @@ -98,7 +98,7 @@ class EspHomeHelpers { /// Make sure we add only new entities final List entitiesList = - await retreveOnlyNewEntities( + await retrieveOnlyNewEntities( mDnsName: mDnsName, devicePassword: devicePassword, espHomeDeviceNodeId: espHomeDeviceNodeId, @@ -111,12 +111,13 @@ class EspHomeHelpers { final List deviceEntityList = []; final EspHomeNodeRedApi espHomeNodeRedApi = EspHomeNodeRedApi( - repository: getIt(), - nodeRedApiBaseTopic: - getIt().getNodeRedApiBaseTopic(), - nodeRedDevicesTopic: - getIt().getNodeRedDevicesTopicTypeName(), - nodeRedMqttBrokerNodeName: 'Cbj NodeRed plugs Api Broker'); + repository: getIt(), + nodeRedApiBaseTopic: + getIt().getNodeRedApiBaseTopic(), + nodeRedDevicesTopic: + getIt().getNodeRedDevicesTopicTypeName(), + nodeRedMqttBrokerNodeName: 'Cbj NodeRed plugs Api Broker', + ); for (final EspHomeDeviceEntityObject espHomeDeviceEntityObject in entitiesList) { diff --git a/lib/infrastructure/devices/ewelink/ewelink_connector_conjector.dart b/lib/infrastructure/devices/ewelink/ewelink_connector_conjector.dart index 82ffd4d0..f70f50f2 100644 --- a/lib/infrastructure/devices/ewelink/ewelink_connector_conjector.dart +++ b/lib/infrastructure/devices/ewelink/ewelink_connector_conjector.dart @@ -22,7 +22,7 @@ class EwelinkConnectorConjector implements AbstractCompanyConnectorConjector { @override Map companyDevices = {}; - Future accountLogin( + Future accountLogin( GenericEwelinkLoginDE loginDE, ) async { try { @@ -32,27 +32,31 @@ class EwelinkConnectorConjector implements AbstractCompanyConnectorConjector { ); await ewelink!.getCredentials(); - discoverNewDevices(activeHost: null); } on EwelinkInvalidAccessToken { logger.e('invalid access token'); + return false; } on EwelinkOfflineDeviceException { logger.e('device is offline'); + return false; } catch (e) { - // ignore: unnecessary_brace_in_string_interps - logger.e('error: $e'); + logger.e('EweLink error: $e'); + return false; } - return 'Success'; + return true; } Future discoverNewDevices({ required ActiveHost? activeHost, }) async { if (ewelink == null) { - await accountLogin(GenericEwelinkLoginDE.empty()); - logger.w( - 'eWeLink device got found but missing a email and password, please add ' - 'it in the app'); - // return; + final bool lastRequest = + await accountLogin(GenericEwelinkLoginDE.empty()); + if (!lastRequest) { + logger.w( + 'eWeLink device got found but missing a email and password, please add ' + 'it in the app'); + return; + } } final List devices = await ewelink!.getDevices(); diff --git a/lib/infrastructure/devices/shelly/shelly_api/shelly_api_color_bulb.dart b/lib/infrastructure/devices/shelly/shelly_api/shelly_api_color_bulb.dart deleted file mode 100644 index 38a0e58c..00000000 --- a/lib/infrastructure/devices/shelly/shelly_api/shelly_api_color_bulb.dart +++ /dev/null @@ -1,124 +0,0 @@ -import 'dart:io'; - -import 'package:cbj_hub/infrastructure/devices/shelly/shelly_api/shelly_api_device_abstract.dart'; - -class ShellyApiColorBulb extends ShellyApiDeviceAbstract { - ShellyApiColorBulb({ - required super.lastKnownIp, - required super.mDnsName, - required super.hostName, - this.bulbeMode = ShellyBulbeMode.white, - }); - - // The mod of the bulb, an be white or color - ShellyBulbeMode bulbeMode; - - Future turnOn() async { - final HttpClientRequest httpClientRequest = - await HttpClient().getUrl(Uri.parse('$url/color/0?turn=on')); - final HttpClientResponse response = await httpClientRequest.close(); - - return response.reasonPhrase; - } - - Future turnOff() async { - final HttpClientRequest httpClientRequest = - await HttpClient().getUrl(Uri.parse('$url/color/0?turn=off')); - final HttpClientResponse response = await httpClientRequest.close(); - - return response.reasonPhrase; - } - - Future changeModeToWhite() async { - bulbeMode = ShellyBulbeMode.white; - final HttpClientRequest httpClientRequest = - await HttpClient().getUrl(Uri.parse('$url/settings/?mode=white')); - final HttpClientResponse response = await httpClientRequest.close(); - - return response.reasonPhrase; - } - - Future changeModeToColor() async { - bulbeMode = ShellyBulbeMode.colore; - final HttpClientRequest httpClientRequest = - await HttpClient().getUrl(Uri.parse('$url/settings/?mode=color')); - final HttpClientResponse response = await httpClientRequest.close(); - - return response.reasonPhrase; - } - - /// Changing brightness alone called gain and it is 0-100. - /// I think works only on color mode - Future changeBrightnessColorGain(String brightness) async { - final HttpClientRequest httpClientRequest = await HttpClient() - .getUrl(Uri.parse('$url/color/0?turn=on&gain=$brightness')); - final HttpClientResponse response = await httpClientRequest.close(); - return response.reasonPhrase; - } - - /// Change temperature - Future changTemperature({ - required String temperature, - }) async { - if (bulbeMode != ShellyBulbeMode.white) { - await changeModeToWhite(); - } - - final HttpClientRequest httpClientRequest = await HttpClient().getUrl( - Uri.parse( - '$url/color/0?turn=on&temp=$temperature', - ), - ); - final HttpClientResponse response = await httpClientRequest.close(); - return response.reasonPhrase; - } - - /// Chang brightness - Future changBrightness({ - required String brightness, - }) async { - HttpClientRequest httpClientRequest; - - switch (bulbeMode) { - case ShellyBulbeMode.white: - httpClientRequest = await HttpClient().getUrl( - Uri.parse( - '$url/color/0?turn=on&brightness=$brightness', - ), - ); - break; - case ShellyBulbeMode.colore: - httpClientRequest = await HttpClient().getUrl( - Uri.parse( - '$url/color/0?turn=on&gain=$brightness', - ), - ); - break; - } - - final HttpClientResponse response = await httpClientRequest.close(); - return response.reasonPhrase; - } - - /// Change color of the bulb, I think will also change to color mode - Future changeColor({ - required String red, - required String green, - required String blue, - String white = "0", - }) async { - if (bulbeMode != ShellyBulbeMode.colore) { - await changeModeToColor(); - } - - final HttpClientRequest httpClientRequest = await HttpClient().getUrl( - Uri.parse( - '$url/color/0?turn=on&red=$red&green=$green&blue=$blue&white=$white', - ), - ); - final HttpClientResponse response = await httpClientRequest.close(); - return response.reasonPhrase; - } -} - -enum ShellyBulbeMode { white, colore } diff --git a/lib/infrastructure/devices/shelly/shelly_api/shelly_api_device_abstract.dart b/lib/infrastructure/devices/shelly/shelly_api/shelly_api_device_abstract.dart deleted file mode 100644 index b9fed522..00000000 --- a/lib/infrastructure/devices/shelly/shelly_api/shelly_api_device_abstract.dart +++ /dev/null @@ -1,24 +0,0 @@ -import 'package:http/http.dart'; - -abstract class ShellyApiDeviceAbstract { - ShellyApiDeviceAbstract({ - required this.lastKnownIp, - required this.mDnsName, - required this.hostName, - this.name, - }) { - url = 'http://$lastKnownIp'; - } - - String lastKnownIp; - String mDnsName; - String hostName; - String? name; - late String url; - - Future getStatus() async { - final Response response = await get(Uri.parse('$url/status')); - - return response.body; - } -} diff --git a/lib/infrastructure/devices/shelly/shelly_api/shelly_api_relay_switch.dart b/lib/infrastructure/devices/shelly/shelly_api/shelly_api_relay_switch.dart deleted file mode 100644 index a20c27ee..00000000 --- a/lib/infrastructure/devices/shelly/shelly_api/shelly_api_relay_switch.dart +++ /dev/null @@ -1,27 +0,0 @@ -import 'dart:io'; - -import 'package:cbj_hub/infrastructure/devices/shelly/shelly_api/shelly_api_device_abstract.dart'; - -class ShellyApiRelaySwitch extends ShellyApiDeviceAbstract { - ShellyApiRelaySwitch({ - required super.lastKnownIp, - required super.mDnsName, - required super.hostName, - }); - - Future turnOn() async { - final HttpClientRequest httpClientRequest = - await HttpClient().getUrl(Uri.parse('$url/relay/0?turn=on')); - final HttpClientResponse response = await httpClientRequest.close(); - - return response.reasonPhrase; - } - - Future turnOff() async { - final HttpClientRequest httpClientRequest = - await HttpClient().getUrl(Uri.parse('$url/relay/0?turn=off')); - final HttpClientResponse response = await httpClientRequest.close(); - - return response.reasonPhrase; - } -} diff --git a/lib/infrastructure/devices/shelly/shelly_connector_conjector.dart b/lib/infrastructure/devices/shelly/shelly_connector_conjector.dart index 50d4f8fa..84f04444 100644 --- a/lib/infrastructure/devices/shelly/shelly_connector_conjector.dart +++ b/lib/infrastructure/devices/shelly/shelly_connector_conjector.dart @@ -45,7 +45,7 @@ class ShellyConnectorConjector implements AbstractCompanyConnectorConjector { } } - final List espDevice = + final List shellyDevice = await ShellyHelpers.addDiscoverdDevice( mDnsName: mDnsName, ip: ip, @@ -53,11 +53,11 @@ class ShellyConnectorConjector implements AbstractCompanyConnectorConjector { uniqueDeviceId: tempCoreUniqueId, ); - if (espDevice.isEmpty) { + if (shellyDevice.isEmpty) { return; } - for (final DeviceEntityAbstract entityAsDevice in espDevice) { + for (final DeviceEntityAbstract entityAsDevice in shellyDevice) { final DeviceEntityAbstract deviceToAdd = CompaniesConnectorConjector.addDiscoverdDeviceToHub(entityAsDevice); diff --git a/lib/infrastructure/devices/shelly/shelly_helpers.dart b/lib/infrastructure/devices/shelly/shelly_helpers.dart index 415b9086..d7ddbc88 100644 --- a/lib/infrastructure/devices/shelly/shelly_helpers.dart +++ b/lib/infrastructure/devices/shelly/shelly_helpers.dart @@ -4,12 +4,12 @@ import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abs import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; import 'package:cbj_hub/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_value_objects.dart'; import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_value_objects.dart'; -import 'package:cbj_hub/infrastructure/devices/shelly/shelly_api/shelly_api_color_bulb.dart'; import 'package:cbj_hub/infrastructure/devices/shelly/shelly_light/shelly_light_entity.dart'; import 'package:cbj_hub/infrastructure/devices/shelly/shelly_relay_switch/shelly_relay_switch_entity.dart'; import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbenum.dart'; import 'package:cbj_hub/utils.dart'; import 'package:color/color.dart'; +import 'package:shelly/shelly.dart'; class ShellyHelpers { static Future> addDiscoverdDevice({ @@ -28,7 +28,7 @@ class ShellyHelpers { final List deviceEntityList = []; try { - // TODO: shelly duo bulbe needs type that as the time of writing is + // TODO: shelly duo bulb needs type that as the time of writing is // not supported, bulb + brightness + white temperature (not rgb). // Lets create new type and add it. if (mDnsName.contains('colorbulb')) { @@ -46,14 +46,14 @@ class ShellyHelpers { dynamic bulbLightProp = responseAsJson['lights'][0]; final String bulbMod = bulbLightProp['mode'] as String; - shellyApiDeviceAbstract.bulbeMode = - bulbMod == 'color' ? ShellyBulbeMode.colore : ShellyBulbeMode.white; + shellyApiDeviceAbstract.bulbMode = + bulbMod == 'color' ? ShellyBulbMode.colore : ShellyBulbMode.white; final int brightness = bulbLightProp['brightness'] as int; final int gain = bulbLightProp['gain'] as int; // Brightness for color mod final int currentBrightness = - shellyApiDeviceAbstract.bulbeMode == ShellyBulbeMode.colore + shellyApiDeviceAbstract.bulbMode == ShellyBulbMode.colore ? gain : brightness; final int temp = bulbLightProp['temp'] as int; @@ -95,7 +95,7 @@ class ShellyHelpers { deviceHostName: DeviceHostName(mDnsName.toLowerCase()), deviceMdns: DeviceMdns(mDnsName), deviceLastKnownIp: DeviceLastKnownIp(ip), - bulbeMode: shellyApiDeviceAbstract, + bulbMode: shellyApiDeviceAbstract, deviceUniqueId: DeviceUniqueId('0'), devicesMacAddress: DevicesMacAddress('0'), entityKey: EntityKey('0'), @@ -118,7 +118,7 @@ class ShellyHelpers { dynamic bulbLightProp = responseAsJson['lights'][0]; - shellyApiDeviceAbstract.bulbeMode = ShellyBulbeMode.white; + shellyApiDeviceAbstract.bulbMode = ShellyBulbMode.white; final int brightness = bulbLightProp['brightness'] as int; @@ -155,7 +155,7 @@ class ShellyHelpers { deviceHostName: DeviceHostName(mDnsName.toLowerCase()), deviceMdns: DeviceMdns(mDnsName), deviceLastKnownIp: DeviceLastKnownIp(ip), - bulbeMode: shellyApiDeviceAbstract, + bulbMode: shellyApiDeviceAbstract, deviceUniqueId: DeviceUniqueId('0'), devicesMacAddress: DevicesMacAddress('0'), entityKey: EntityKey('0'), diff --git a/lib/infrastructure/devices/shelly/shelly_light/shelly_light_entity.dart b/lib/infrastructure/devices/shelly/shelly_light/shelly_light_entity.dart index a8ca0693..c832b82d 100644 --- a/lib/infrastructure/devices/shelly/shelly_light/shelly_light_entity.dart +++ b/lib/infrastructure/devices/shelly/shelly_light/shelly_light_entity.dart @@ -4,11 +4,11 @@ import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_cor import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; import 'package:cbj_hub/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_entity.dart'; import 'package:cbj_hub/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_value_objects.dart'; -import 'package:cbj_hub/infrastructure/devices/shelly/shelly_api/shelly_api_color_bulb.dart'; import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_hub/utils.dart'; import 'package:color/color.dart'; import 'package:dartz/dartz.dart'; +import 'package:shelly/shelly.dart'; class ShellyColorLightEntity extends GenericRgbwLightDE { ShellyColorLightEntity({ @@ -41,11 +41,11 @@ class ShellyColorLightEntity extends GenericRgbwLightDE { required super.lightColorSaturation, required super.lightColorValue, required super.lightBrightness, - ShellyApiColorBulb? bulbeMode, + ShellyApiColorBulb? bulbMode, }) : super( deviceVendor: DeviceVendor(VendorsAndServices.shelly.toString()), ) { - shellyColorBulb = bulbeMode ?? + shellyColorBulb = bulbMode ?? ShellyApiColorBulb( lastKnownIp: deviceLastKnownIp.getOrCrash(), mDnsName: deviceMdns.getOrCrash(), diff --git a/lib/infrastructure/devices/shelly/shelly_relay_switch/shelly_relay_switch_entity.dart b/lib/infrastructure/devices/shelly/shelly_relay_switch/shelly_relay_switch_entity.dart index 7c60fc5c..92eb26e5 100644 --- a/lib/infrastructure/devices/shelly/shelly_relay_switch/shelly_relay_switch_entity.dart +++ b/lib/infrastructure/devices/shelly/shelly_relay_switch/shelly_relay_switch_entity.dart @@ -6,10 +6,10 @@ import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_cor import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_entity.dart'; import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_value_objects.dart'; -import 'package:cbj_hub/infrastructure/devices/shelly/shelly_api/shelly_api_relay_switch.dart'; import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_hub/utils.dart'; import 'package:dartz/dartz.dart'; +import 'package:shelly/shelly.dart'; class ShellyRelaySwitchEntity extends GenericSwitchDE { ShellyRelaySwitchEntity({ diff --git a/lib/infrastructure/devices/switcher/switcher_api/switcher_api_object.dart b/lib/infrastructure/devices/switcher/switcher_api/switcher_api_object.dart deleted file mode 100644 index ce1cda29..00000000 --- a/lib/infrastructure/devices/switcher/switcher_api/switcher_api_object.dart +++ /dev/null @@ -1,678 +0,0 @@ -import 'dart:convert'; -import 'dart:io'; -import 'dart:typed_data'; - -import 'package:cbj_hub/utils.dart'; -import 'package:crclib/crclib.dart'; - -class SwitcherApiObject { - SwitcherApiObject({ - required this.deviceType, - required this.deviceId, - required this.switcherIp, - required this.switcherName, - required this.powerConsumption, - required this.macAddress, - this.deviceState = SwitcherDeviceState.cantGetState, - this.deviceDirection = SwitcherDeviceDirection.cantGetState, - this.devicePass = '00000000', - this.phoneId = '0000', - this.statusSocket, - this.log, - this.port = switcherTcpPort, - this.lastShutdownRemainingSecondsValue, - this.remainingTimeForExecution, - }); - - factory SwitcherApiObject.createWithBytes(Datagram datagram) { - final Uint8List data = datagram.data; - - final List messageBuffer = intListToHex(data); - - final List hexSeparatedLetters = []; - - for (final String hexValue in messageBuffer) { - for (final element in hexValue.runes) { - hexSeparatedLetters.add(String.fromCharCode(element)); - } - } - - if (!isSwitcherMessage(data, hexSeparatedLetters) && - !isSwitcherMessageNew(data, hexSeparatedLetters)) { - logger.w('Not a switcher message arrived to here'); - } - - final SwitcherDevicesTypes sDeviceType = getDeviceType(messageBuffer); - final String deviceId = extractDeviceId(hexSeparatedLetters); - // final String switcherIp = extractIpAddr(hexSeparatedLetters); - final String switcherIp = datagram.address.address; - final String switcherMac = extractMac(hexSeparatedLetters); - final String powerConsumption = - extractPowerConsumption(hexSeparatedLetters); - - final String switcherName = extractDeviceName(data); - - final String getRemaining = - extractRemainingTimeForExecution(hexSeparatedLetters); - final String lastShutdownRemainingSecondsValue = - extractShutdownRemainingSeconds(hexSeparatedLetters); - - if (sDeviceType == SwitcherDevicesTypes.switcherRunner || - sDeviceType == SwitcherDevicesTypes.switcherRunnerMini) { - if (!isSwitcherMessageNew(data, hexSeparatedLetters)) { - logger.v('Not new switcher device!'); - } - - final SwitcherDeviceDirection switcherDeviceDirection = - extractSwitchDirection(hexSeparatedLetters); - - return SwitcherApiObject( - deviceType: sDeviceType, - deviceId: deviceId, - switcherIp: switcherIp, - deviceDirection: switcherDeviceDirection, - switcherName: switcherName, - macAddress: switcherMac, - powerConsumption: powerConsumption, - port: switcherTcpPort2, - ); - } - - if (!isSwitcherMessage(data, hexSeparatedLetters)) { - logger.v('Not old switcher device!'); - } - - final SwitcherDeviceState switcherDeviceState = - extractSwitchState(hexSeparatedLetters); - - return SwitcherApiObject( - deviceType: sDeviceType, - deviceId: deviceId, - switcherIp: switcherIp, - deviceState: switcherDeviceState, - switcherName: switcherName, - macAddress: switcherMac, - lastShutdownRemainingSecondsValue: lastShutdownRemainingSecondsValue, - powerConsumption: powerConsumption, - remainingTimeForExecution: getRemaining, - ); - } - - String deviceId; - String switcherIp; - SwitcherDevicesTypes deviceType; - SwitcherDeviceState deviceState; - SwitcherDeviceDirection deviceDirection; - int port; - String switcherName; - String phoneId; - String powerConsumption; - String devicePass; - String macAddress; - String? remainingTimeForExecution; - String? log; - String? statusSocket; - String? lastShutdownRemainingSecondsValue; - - Socket? _socket; - - String? pSession; - - static const switcherTcpPort = 9957; - static const switcherTcpPort2 = 10000; - - static const pSessionValue = '00000000'; - static const pKey = '00000000000000000000000000000000'; - - static const statusEvent = 'status'; - static const readyEvent = 'ready'; - static const errorEvent = 'error'; - static const stateChangedEvent = 'state'; - - static const switcherUdpIp = '0.0.0.0'; - static const switcherUdpPort = 20002; - - static const offValue = '0'; - static const onValue = '1'; - - static bool isSwitcherMessage( - Uint8List data, - List hexSeparatedLetters, - ) { - // Verify the broadcast message had originated from a switcher device. - return hexSeparatedLetters.sublist(0, 4).join() == 'fef0' && - data.length == 165; - } - - static bool isSwitcherMessageNew( - Uint8List data, - List hexSeparatedLetters, - ) { - // Verify the broadcast message had originated from a switcher device. - return hexSeparatedLetters.sublist(0, 4).join() == 'fef0' && - data.length == 159; - } - - static SwitcherDevicesTypes getDeviceType(List messageBuffer) { - SwitcherDevicesTypes sDevicesTypes = SwitcherDevicesTypes.notRecognized; - - final String hexModel = messageBuffer.sublist(75, 76)[0]; - - if (hexModel == '0f') { - sDevicesTypes = SwitcherDevicesTypes.switcherMini; - } else if (hexModel == 'a8') { - sDevicesTypes = SwitcherDevicesTypes.switcherPowerPlug; - } else if (hexModel == '0b') { - sDevicesTypes = SwitcherDevicesTypes.switcherTouch; - } else if (hexModel == 'a7') { - sDevicesTypes = SwitcherDevicesTypes.switcherV2Esp; - } else if (hexModel == 'a1') { - sDevicesTypes = SwitcherDevicesTypes.switcherV2qualcomm; - } else if (hexModel == '17') { - sDevicesTypes = SwitcherDevicesTypes.switcherV4; - } else if (hexModel == '01') { - sDevicesTypes = SwitcherDevicesTypes.switcherRunner; - } else if (hexModel == '02') { - sDevicesTypes = SwitcherDevicesTypes.switcherRunnerMini; - } else { - logger.w('New device type? hexModel:$hexModel'); - } - - return sDevicesTypes; - } - - Future turnOn({int duration = 0}) async { - final String offCommand = '${onValue}00${_timerValue(duration)}'; - - await _runPowerCommand(offCommand); - } - - Future turnOff() async { - const String offCommand = '${offValue}0000000000'; - await _runPowerCommand(offCommand); - } - - Future _runPowerCommand(String commandType) async { - pSession = await _login(); - if (pSession == 'B') { - logger.e('Switcher run power command error'); - return; - } - var data = - 'fef05d0002320102${pSession!}340001000000000000000000${_getTimeStamp()}' - '00000000000000000000f0fe${deviceId}00${phoneId}0000$devicePass' - '000000000000000000000000000000000000000000000000000000000106000' - '$commandType'; - - data = await _crcSignFullPacketComKey(data, pKey); - - _socket = await getSocket(); - _socket!.add(hexStringToDecimalList(data)); - await _socket?.close(); - _socket = null; - } - - /// Stops the blinds - Future stopBlinds() async { - if (deviceType != SwitcherDevicesTypes.switcherRunner && - deviceType != SwitcherDevicesTypes.switcherRunnerMini) { - logger.v('Stop blinds support only for blinds'); - return; - } - - pSession = await _login2(); - if (pSession == 'B') { - logger.e('Switcher run position command error'); - return; - } - var data = - 'fef0590003050102${pSession!}232301000000000000000000${_getTimeStamp()}' - '00000000000000000000f0fe${deviceId}00${phoneId}0000$devicePass' - '000000000000000000000000000000000000000000000000000000370202000000'; - - data = await _crcSignFullPacketComKey(data, pKey); - - _socket = await getSocket(); - _socket!.add(hexStringToDecimalList(data)); - await _socket?.close(); - _socket = null; - } - - /// Sets the position of the blinds, 0 is down 100 is up - Future setPosition({int pos = 0}) async { - if (deviceType != SwitcherDevicesTypes.switcherRunner && - deviceType != SwitcherDevicesTypes.switcherRunnerMini) { - logger.v('Set position support only blinds'); - return; - } - - final String positionCommand = _getHexPos(pos: pos); - _runPositionCommand(positionCommand); - } - - String _getHexPos({int pos = 0}) { - String posAsHex = intListToHex([pos]).join(); - if (posAsHex.length < 2) { - posAsHex = '0$posAsHex'; - } - return posAsHex; - } - - Future _runPositionCommand(String positionCommand) async { - // final int pos = int.parse(positionCommand, radix: 16); - pSession = await _login2(); - if (pSession == 'B') { - logger.e('Switcher run position command error'); - return; - } - var data = - 'fef0580003050102${pSession!}290401000000000000000000${_getTimeStamp()}' - '00000000000000000000f0fe${deviceId}00${phoneId}0000$devicePass' - '00000000000000000000000000000000000000000000000000000037010100' - '$positionCommand'; - - data = await _crcSignFullPacketComKey(data, pKey); - - _socket = await getSocket(); - _socket!.add(hexStringToDecimalList(data)); - await _socket?.close(); - _socket = null; - } - - /// Used for sending actions to the device - void sendState({required SwitcherDeviceState command, int minutes = 0}) { - _getFullState(); - } - - /// Used for sending the get state packet to the device. - /// Returns a tuple of hex timestamp, - /// session id and an instance of SwitcherStateResponse - Future _getFullState() async { - return _login(); - } - - /// Used for sending the login packet to the device. - Future _login() async { - try { - String data = 'fef052000232a100${pSessionValue}340001000000000000000000' - '${_getTimeStamp()}00000000000000000000f0fe1c00${phoneId}0000' - '$devicePass' - '00000000000000000000000000000000000000000000000000000000'; - - data = await _crcSignFullPacketComKey(data, pKey); - _socket = await getSocket(); - if (_socket == null) { - throw 'Error'; - } - - _socket!.add(hexStringToDecimalList(data)); - - final Uint8List firstData = await _socket!.first; - final String resultSession = - substrLikeInJavaScript(intListToHex(firstData).join(), 16, 8); - - return resultSession; - } catch (error) { - logger.e('Switcher login failed due to an error\n$error'); - pSession = 'B'; - } - return pSession!; - } - - /// Used for sending the login packet to switcher runner. - Future _login2() async { - // if (pSession != null) return pSession!; - - try { - String data = 'fef030000305a600${pSessionValue}ff0301000000$phoneId' - '00000000${_getTimeStamp()}00000000000000000000f0fe${deviceId}00'; - - data = await _crcSignFullPacketComKey(data, pKey); - _socket = await getSocket(); - if (_socket == null) { - throw 'Error'; - } - - _socket!.add(hexStringToDecimalList(data)); - - final Uint8List firstData = await _socket!.first; - - final String resultSession = - substrLikeInJavaScript(intListToHex(firstData).join(), 16, 8); - - return resultSession; - } catch (error) { - logger.e('login2 failed due to an error\n$error'); - pSession = 'B'; - } - return pSession!; - } - - static Future _crcSignFullPacketComKey( - String pData, - String pKey, - ) async { - String pDataTemp = pData; - final List bufferHex = hexStringToDecimalList(pDataTemp); - - String crc = intListToHex( - packBigEndian( - int.parse(Crc16XmodemWith0x1021().convert(bufferHex).toString()), - ), - ).join(); - - pDataTemp = pDataTemp + - substrLikeInJavaScript(crc, 6, 2) + - substrLikeInJavaScript(crc, 4, 2); - - crc = substrLikeInJavaScript(crc, 6, 2) + - substrLikeInJavaScript(crc, 4, 2) + - getUtf8Encoded(pKey); - - crc = intListToHex( - packBigEndian( - int.parse( - Crc16XmodemWith0x1021() - .convert(hexStringToDecimalList(crc)) - .toString(), - ), - ), - ).join(); - - return pDataTemp + - substrLikeInJavaScript(crc, 6, 2) + - substrLikeInJavaScript(crc, 4, 2); - } - - static String _getTimeStamp() { - final int timeInSeconds = DateTime.now().millisecondsSinceEpoch ~/ 1000; - - final List timeInBytes = packLittleEndian(timeInSeconds); - - return intListToHex(timeInBytes).join(); - } - - /// Same as Buffer.from(value, 'hex') in JavaScript - static List hexStringToDecimalList(String hex) { - final List decimalIntList = []; - String twoNumbers = ''; - - for (int i = 0; i < hex.length; i++) { - if (twoNumbers == '') { - twoNumbers = twoNumbers + hex[i]; - continue; - } else { - twoNumbers = twoNumbers + hex[i]; - decimalIntList.add(int.parse(twoNumbers, radix: 16)); - twoNumbers = ''; - } - } - return decimalIntList; - } - - /// Convert number to unsigned integer as little-endian sequence of bytes - /// Same as struct.pack(' packLittleEndian(int valueToConvert) { - final ByteData sendValueBytes = ByteData(8); - - try { - sendValueBytes.setUint64(0, valueToConvert, Endian.little); - } on Exception { - sendValueBytes.setUint32(0, valueToConvert, Endian.little); - } - - final Uint8List timeInBytes = sendValueBytes.buffer.asUint8List(); - return timeInBytes.sublist(0, timeInBytes.length - 4); - } - - /// Convert number to unsigned integer as big-endian sequence of bytes - /// Same as struct.pack('>I', value) in JavaScript - static List packBigEndian(int valueToConvert) { - final ByteData sendValueBytes = ByteData(8); - - try { - sendValueBytes.setUint64(0, valueToConvert); - } on Exception { - sendValueBytes.setUint32(0, valueToConvert); - } - - final Uint8List timeInBytes = sendValueBytes.buffer.asUint8List(); - return timeInBytes.sublist(4); - } - - /// Convert list of bytes/integers into their hex 16 value with padding 2 of 0 - /// Same as .toString('hex'); in JavaScript - static List intListToHex(List bytes) { - final List messageBuffer = []; - - for (final int unit8 in bytes) { - messageBuffer.add(unit8.toRadixString(16).padLeft(2, '0')); - } - return messageBuffer; - } - - /// Generate hexadecimal representation of the current timestamp. - /// Return: Hexadecimal representation of the current - /// unix time retrieved by ``time.time``. - String currentTimestampToHexadecimal() { - final String currentTimeSinceEpoch = - DateTime.now().millisecondsSinceEpoch.toString(); - final String currentTimeRounded = - currentTimeSinceEpoch.substring(0, currentTimeSinceEpoch.length - 3); - - final int currentTimeInt = int.parse(currentTimeRounded); - - return currentTimeInt.toRadixString(16).padLeft(2, '0'); - } - - /// Extract the IP address from the broadcast message. - static String extractIpAddr(List hexSeparatedLetters) { - final String ipAddrSection = - substrLikeInJavaScript(hexSeparatedLetters.join(), 152, 8); - - final int ipAddrInt = int.parse( - substrLikeInJavaScript(ipAddrSection, 0, 2) + - substrLikeInJavaScript(ipAddrSection, 2, 2) + - substrLikeInJavaScript(ipAddrSection, 4, 2) + - substrLikeInJavaScript(ipAddrSection, 6, 2), - radix: 16, - ); - return ipAddrInt.toString(); - } - - static String extractPowerConsumption(List hexSeparatedLetters) { - // final List hexPowerConsumption = - // hexSeparatedLetters.sublist(270, 278); - // TODO: fix this method does not return number, hexPowerConsumption.join() - // return the value 64000000 - // return hexPowerConsumption.join(); - return '0'; - } - - /// Extract the time remains for the current execution. - static String extractRemainingTimeForExecution( - List hexSeparatedLetters, - ) { - final List hexPowerConsumption = - hexSeparatedLetters.sublist(294, 302); - try { - final int sum = int.parse(hexPowerConsumption.sublist(6, 8).join()) + - int.parse(hexPowerConsumption.sublist(4, 6).join()) + - int.parse(hexPowerConsumption.sublist(2, 4).join()) + - int.parse(hexPowerConsumption.sublist(0, 2).join()); - return sum.toString(); - } catch (e) { - return hexPowerConsumption.join(); - } - } - - /// Substring like in JavaScript - /// If first index is bigger than second index than it will cut until the - /// first and will get the second index number of characters from there - static String substrLikeInJavaScript( - String text, - int firstIndex, - int secondIndex, - ) { - String tempText = text; - if (firstIndex > secondIndex) { - tempText = tempText.substring(firstIndex); - tempText = tempText.substring(0, secondIndex); - } else { - tempText = tempText.substring(firstIndex, secondIndex); - } - return tempText; - } - - static String extractMac(List hexSeparatedLetters) { - final String macNoColon = - hexSeparatedLetters.sublist(160, 172).join().toUpperCase(); - final String macAddress = '${macNoColon.substring(0, 2)}:' - '${macNoColon.substring(2, 4)}:${macNoColon.substring(4, 6)}:' - '${macNoColon.substring(6, 8)}:${macNoColon.substring(8, 10)}:' - '${macNoColon.substring(10, 12)}'; - - return macAddress; - } - - static String extractDeviceName(List data) { - return utf8.decode(data.sublist(42, 74)).replaceAll('\u0000', ''); - // Maybe better name handling will be - // this.data_str.substr(38, 32).replace(/[^0-9a-zA-Z_\s]/g, '').replace(/\0/g, '') - } - - /// Same as Buffer.from(value) in javascript - /// Not to be confused with Buffer.from(value, 'hex') - static String getUtf8Encoded(String list) { - final List encoded = utf8.encode(list); - - return intListToHex(encoded).join(); - } - - static String extractShutdownRemainingSeconds( - List hexSeparatedLetters, - ) { - // final String hexAutoShutdownVal = - // hexSeparatedLetters.sublist(310, 318).join(); - final String timeLeftSeconds = - substrLikeInJavaScript(hexSeparatedLetters.join(), 294, 8); - - return int.parse( - substrLikeInJavaScript(timeLeftSeconds, 6, 8) + - substrLikeInJavaScript(timeLeftSeconds, 4, 6) + - substrLikeInJavaScript(timeLeftSeconds, 2, 4) + - substrLikeInJavaScript(timeLeftSeconds, 0, 2), - radix: 16, - ).toString(); - } - - static String extractDeviceId(List hexSeparatedLetters) { - return hexSeparatedLetters.sublist(36, 42).join(); - } - - static SwitcherDeviceState extractSwitchState( - List hexSeparatedLetters, - ) { - SwitcherDeviceState switcherDeviceState = SwitcherDeviceState.cantGetState; - - final String hexModel = - substrLikeInJavaScript(hexSeparatedLetters.join(), 266, 4); - - if (hexModel == '0100') { - switcherDeviceState = SwitcherDeviceState.on; - } else if (hexModel == '0000') { - switcherDeviceState = SwitcherDeviceState.off; - } else { - logger.w('Switcher state is not recognized: $hexModel'); - } - return switcherDeviceState; - } - - static SwitcherDeviceDirection extractSwitchDirection( - List hexSeparatedLetters, - ) { - SwitcherDeviceDirection switcherDeviceState = - SwitcherDeviceDirection.cantGetState; - - final String hexModel = - substrLikeInJavaScript(hexSeparatedLetters.join(), 274, 4); - - if (hexModel == '0000') { - switcherDeviceState = SwitcherDeviceDirection.stop; - } else if (hexModel == '0100') { - switcherDeviceState = SwitcherDeviceDirection.up; - } else if (hexModel == '0001') { - switcherDeviceState = SwitcherDeviceDirection.down; - } else { - logger.w('Switcher direction is not recognized: $hexModel'); - } - return switcherDeviceState; - } - - Future getSocket() async { - if (_socket != null) { - return _socket!; - } - - try { - final Socket socket = await _connect(switcherIp, port); - return socket; - } catch (e) { - _socket = null; - logger.e('Error connecting to socket for switcher device: $e'); - rethrow; - } - } - - Future _connect(String ip, int port) async { - return Socket.connect(ip, port); - } - - String _timerValue(int minutes) { - if (minutes == 0) { - // when duration set to zero, Switcher sends regular on command - return '00000000'; - } - final seconds = minutes * 60; - return intListToHex(packLittleEndian(seconds)).join(); - } -} - -class Crc16XmodemWith0x1021 extends ParametricCrc { - Crc16XmodemWith0x1021() - : super( - 16, - 0x1021, - 0x1021, - 0x0000, - inputReflected: false, - outputReflected: false, - ); -} - -enum SwitcherDeviceDirection { - cantGetState, - stop, // '0000' - up, // '0100' - down, // '0001' -} - -/// Enum class representing the device's state. -enum SwitcherDeviceState { - cantGetState, - on, // '0100' - off, // '0000' -} - -/// Enum for relaying the type of the switcher devices. -enum SwitcherDevicesTypes { - notRecognized, - switcherMini, // MINI = "Switcher Mini", "0f", DeviceCategory.WATER_HEATER - switcherPowerPlug, // POWER_PLUG = "Switcher Power Plug", "a8", DeviceCategory.POWER_PLUG - switcherTouch, // TOUCH = "Switcher Touch", "0b", DeviceCategory.WATER_HEATER - switcherV2Esp, // V2_ESP = "Switcher V2 (esp)", "a7", DeviceCategory.WATER_HEATER - switcherV2qualcomm, // V2_QCA = "Switcher V2 (qualcomm)", "a1", DeviceCategory.WATER_HEATER - switcherV4, // V4 = "Switcher V4", "17", DeviceCategory.WATER_HEATER - switcherRunner, // runner = "Switcher Runner", "01", DeviceCategory.Blinds - switcherRunnerMini, // runner_mini = "Switcher Runner Mini", "02", DeviceCategory.Blinds -} diff --git a/lib/infrastructure/devices/switcher/switcher_api/switcher_discover.dart b/lib/infrastructure/devices/switcher/switcher_api/switcher_discover.dart deleted file mode 100644 index 3ca4179e..00000000 --- a/lib/infrastructure/devices/switcher/switcher_api/switcher_discover.dart +++ /dev/null @@ -1,50 +0,0 @@ -import 'dart:io'; - -import 'package:cbj_hub/infrastructure/devices/switcher/switcher_api/switcher_api_object.dart'; -import 'package:cbj_hub/utils.dart'; - -class SwitcherDiscover { - static const switcherUdpPort = 20002; - static const switcherUdpPort2 = 20003; - - static Stream discover20002Devices() async* { - try { - final RawDatagramSocket socket20002 = await RawDatagramSocket.bind( - InternetAddress.anyIPv4, - switcherUdpPort, - ); - - await for (final event in socket20002) { - final Datagram? datagram = socket20002.receive(); - if (datagram == null) continue; - final SwitcherApiObject switcherApiObject = - SwitcherApiObject.createWithBytes(datagram); - - yield switcherApiObject; - } - } catch (e) { - logger.e('Switcher discover devices got and exception: $e'); - } - } - - /// Blinds 20003 includes blinds for example - static Stream discover20003Devices() async* { - try { - final RawDatagramSocket socket20003 = await RawDatagramSocket.bind( - InternetAddress.anyIPv4, - switcherUdpPort2, - ); - - await for (final event in socket20003) { - final Datagram? datagram = socket20003.receive(); - if (datagram == null) continue; - final SwitcherApiObject switcherApiObject = - SwitcherApiObject.createWithBytes(datagram); - - yield switcherApiObject; - } - } catch (e) { - logger.e('Switcher discover devices got and exception: $e'); - } - } -} diff --git a/lib/infrastructure/devices/switcher/switcher_api/switcher_packets.dart b/lib/infrastructure/devices/switcher/switcher_api/switcher_packets.dart deleted file mode 100644 index 8be0fe98..00000000 --- a/lib/infrastructure/devices/switcher/switcher_api/switcher_packets.dart +++ /dev/null @@ -1,51 +0,0 @@ -class SwitcherPackets { - ///Switcher integration TCP socket API packet formats./// - - /// weekdays sum, start-time timestamp, end-time timestamp - static const scheduleCreateDataFormat = '01{}01{}{}'; - - static const noTimerRequested = '00000000'; - - static const nonRecurringSchedule = '00'; - - /// format values are local session id, timestamp - static const requestFormat = - '{}340001000000000000000000{}00000000000000000000f0fe'; - - static const pad74Zeros = - '000000000000000000000000000000000000000000000000000000000000000000000' - '0000'; - - /// format value just timestamp (initial session id is '00000000') - static String loginPacket = - 'fef052000232a10000000000${requestFormat.substring(2)}1c$pad74Zeros'; - - /// format values are local session id, timestamp, device id - static const getStatePacket = 'fef0300002320103$requestFormat{}00'; - - /// format values are local session id, timestamp, device id, command, timer - static const sendControlPacket = - 'fef05d0002320102$requestFormat{}${pad74Zeros}0106000{}00{}'; - - /// format values are local session id, timestamp, device id, auto-off seconds - static const setAutoOffSetPacket = - 'fef05b0002320102$requestFormat{}${pad74Zeros}040400{}'; - - /// format values are local session id, timestamp, device id, name - static const updateDeviceNamePacket = - 'fef0740002320202$requestFormat{}$pad74Zeros{}'; - - /// format values are local session id, timestamp, device id - static const getSchedulesPacket = - 'fef0570002320102$requestFormat{}${pad74Zeros}060000'; - - /// format values are local session id, timestamp, device id, schedule id - static const deleteSchedulePacket = - 'fef0580002320102$requestFormat{}${pad74Zeros}0801000{}'; - - /// format values are local session id, timestamp, device id, -// schedule data = -// (on_off + week + timstate + start_time + end_time) - static const createSchedulePacket = - 'fef0630002320102$requestFormat{}${pad74Zeros}030c00ff{}'; -} diff --git a/lib/infrastructure/devices/switcher/switcher_connector_conjector.dart b/lib/infrastructure/devices/switcher/switcher_connector_conjector.dart index 6ae30e63..6473f988 100644 --- a/lib/infrastructure/devices/switcher/switcher_connector_conjector.dart +++ b/lib/infrastructure/devices/switcher/switcher_connector_conjector.dart @@ -6,7 +6,6 @@ import 'package:cbj_hub/domain/generic_devices/generic_blinds_device/generic_bli import 'package:cbj_hub/domain/generic_devices/generic_boiler_device/generic_boiler_entity.dart'; import 'package:cbj_hub/domain/generic_devices/generic_smart_plug_device/generic_smart_plug_entity.dart'; import 'package:cbj_hub/infrastructure/devices/companies_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/switcher/switcher_api/switcher_api_object.dart'; import 'package:cbj_hub/infrastructure/devices/switcher/switcher_helpers.dart'; import 'package:cbj_hub/infrastructure/devices/switcher/switcher_runner/switcher_runner_entity.dart'; import 'package:cbj_hub/infrastructure/devices/switcher/switcher_smart_plug/switcher_smart_plug_entity.dart'; @@ -14,6 +13,7 @@ import 'package:cbj_hub/infrastructure/devices/switcher/switcher_v2/switcher_v2_ import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/abstract_company_connector_conjector.dart'; import 'package:cbj_hub/utils.dart'; import 'package:injectable/injectable.dart'; +import 'package:switcher_dart/switcher_dart.dart'; @singleton class SwitcherConnectorConjector implements AbstractCompanyConnectorConjector { diff --git a/lib/infrastructure/devices/switcher/switcher_helpers.dart b/lib/infrastructure/devices/switcher/switcher_helpers.dart index 07ab752e..e2804ccc 100644 --- a/lib/infrastructure/devices/switcher/switcher_helpers.dart +++ b/lib/infrastructure/devices/switcher/switcher_helpers.dart @@ -3,12 +3,12 @@ import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_cor import 'package:cbj_hub/domain/generic_devices/generic_blinds_device/generic_blinds_value_objects.dart'; import 'package:cbj_hub/domain/generic_devices/generic_boiler_device/generic_boiler_value_objects.dart'; import 'package:cbj_hub/domain/generic_devices/generic_smart_plug_device/generic_smart_plug_value_objects.dart'; -import 'package:cbj_hub/infrastructure/devices/switcher/switcher_api/switcher_api_object.dart'; import 'package:cbj_hub/infrastructure/devices/switcher/switcher_runner/switcher_runner_entity.dart'; import 'package:cbj_hub/infrastructure/devices/switcher/switcher_smart_plug/switcher_smart_plug_entity.dart'; import 'package:cbj_hub/infrastructure/devices/switcher/switcher_v2/switcher_v2_entity.dart'; import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_hub/utils.dart'; +import 'package:switcher_dart/switcher_dart.dart'; class SwitcherHelpers { static DeviceEntityAbstract? addDiscoverdDevice({ diff --git a/lib/infrastructure/devices/switcher/switcher_runner/switcher_runner_entity.dart b/lib/infrastructure/devices/switcher/switcher_runner/switcher_runner_entity.dart index 6bac9364..f36aeb9d 100644 --- a/lib/infrastructure/devices/switcher/switcher_runner/switcher_runner_entity.dart +++ b/lib/infrastructure/devices/switcher/switcher_runner/switcher_runner_entity.dart @@ -7,11 +7,11 @@ import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; import 'package:cbj_hub/domain/generic_devices/generic_blinds_device/generic_blinds_entity.dart'; import 'package:cbj_hub/domain/generic_devices/generic_blinds_device/generic_blinds_value_objects.dart'; import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart'; -import 'package:cbj_hub/infrastructure/devices/switcher/switcher_api/switcher_api_object.dart'; import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_hub/injection.dart'; import 'package:cbj_hub/utils.dart'; import 'package:dartz/dartz.dart'; +import 'package:switcher_dart/switcher_dart.dart'; class SwitcherRunnerEntity extends GenericBlindsDE { SwitcherRunnerEntity({ diff --git a/lib/infrastructure/devices/switcher/switcher_smart_plug/switcher_smart_plug_entity.dart b/lib/infrastructure/devices/switcher/switcher_smart_plug/switcher_smart_plug_entity.dart index 96391c3b..8e584a84 100644 --- a/lib/infrastructure/devices/switcher/switcher_smart_plug/switcher_smart_plug_entity.dart +++ b/lib/infrastructure/devices/switcher/switcher_smart_plug/switcher_smart_plug_entity.dart @@ -7,11 +7,11 @@ import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; import 'package:cbj_hub/domain/generic_devices/generic_smart_plug_device/generic_smart_plug_entity.dart'; import 'package:cbj_hub/domain/generic_devices/generic_smart_plug_device/generic_smart_plug_value_objects.dart'; import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart'; -import 'package:cbj_hub/infrastructure/devices/switcher/switcher_api/switcher_api_object.dart'; import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_hub/injection.dart'; import 'package:cbj_hub/utils.dart'; import 'package:dartz/dartz.dart'; +import 'package:switcher_dart/switcher_dart.dart'; class SwitcherSmartPlugEntity extends GenericSmartPlugDE { SwitcherSmartPlugEntity({ diff --git a/lib/infrastructure/devices/switcher/switcher_v2/switcher_v2_entity.dart b/lib/infrastructure/devices/switcher/switcher_v2/switcher_v2_entity.dart index 1478f097..f4b73d19 100644 --- a/lib/infrastructure/devices/switcher/switcher_v2/switcher_v2_entity.dart +++ b/lib/infrastructure/devices/switcher/switcher_v2/switcher_v2_entity.dart @@ -7,11 +7,11 @@ import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; import 'package:cbj_hub/domain/generic_devices/generic_boiler_device/generic_boiler_entity.dart'; import 'package:cbj_hub/domain/generic_devices/generic_boiler_device/generic_boiler_value_objects.dart'; import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart'; -import 'package:cbj_hub/infrastructure/devices/switcher/switcher_api/switcher_api_object.dart'; import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_hub/injection.dart'; import 'package:cbj_hub/utils.dart'; import 'package:dartz/dartz.dart'; +import 'package:switcher_dart/switcher_dart.dart'; class SwitcherV2Entity extends GenericBoilerDE { SwitcherV2Entity({ diff --git a/pubspec.yaml b/pubspec.yaml index 70e09898..877c1232 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,6 +2,7 @@ name: cbj_hub description: Easy to use open source Hub to control your smart devices from one app. version: 1.3.0+6 homepage: https://cybearjinni.com +issue_tracker: https://github.com/osociety/network_tools/issues publish_to: none environment: @@ -16,11 +17,12 @@ dependencies: compute: ^1.0.2 # Collection of cyclic redundancy check (CRC) routines as Dart converters. crclib: ^3.0.0 - # Functional programming thingies, let you use multiple return types + # Interact directly with eWeLink API dart_ewelink_api: git: url: 'https://github.com/guyluz11/dart_ewelink_api.git' ref: 'develop' + # Functional programming thingies, let you use multiple return types dartz: ^0.10.1 # Allow returning more than one type of object equatable: ^2.0.5 @@ -36,8 +38,9 @@ dependencies: http: ^1.1.0 # Philips Hue API hue_dart: - git: - url: 'https://github.com/guyluz11/hue_dart.git' + path: ../hue_dart +# git: +# url: 'https://github.com/guyluz11/hue_dart.git' # Convenient code generator for get_it injectable: ^2.3.0 # Utility library that checks for an Active Internet connection @@ -51,19 +54,19 @@ dependencies: # Port of Kotlin's Kotlin Standard library for Dart/Flutter projects kt_dart: ^1.1.0 # Implementation of the LIFX HTTP API - lifx_http_api: - git: 'https://github.com/guyluz11/lifx_http_api.git' + lifx_http_api: ^0.0.17 # Small, easy to use and extensible logger which prints beautiful logs. logger: ^2.0.2+1 # A server and browser based MQTT client for Dart. mi_iot_token: ^1.1.0 + # Server and browser based MQTT client mqtt_client: ^10.0.0 # Service discovery over multicast DNS (mDNS), Bonjour, and Avahi. multicast_dns: ^0.3.2+4 - nodered: - path: ../nodered # Helps you discover open ports, devices on subnet and more. network_tools: ^4.0.1 + # Interact directly with NodeRED API + nodered: ^1.0.1+1 # Provides runtime support for a Dart implementation of protobufs. protobuf: ^3.1.0 # Python Environment Manager and Executor for dart and flutter @@ -73,6 +76,10 @@ dependencies: rxdart: ^0.27.7 # Simple, fast generation of RFC4122 UUIDs. uuid: ^4.1.0 + # Communicate with Shelly smart devices + shelly: ^1.0.0 + # Control Switcher smart home accessories + switcher_dart: ^1.0.0 # Dart library for controlling Yeelight products over LAN. yeedart: ^0.3.2 From 4c62a8527f6da5bca04fa3b8131a0c1695f0a384 Mon Sep 17 00:00:00 2001 From: Guy Luz Date: Sat, 7 Oct 2023 16:16:09 +0300 Subject: [PATCH 08/18] Fixed crash when eweLink user changed password --- bin/cbj_hub.dart | 2 +- .../generic_dimmable_light_value_objects.dart | 2 +- .../app_communication_repository.dart | 4 +- .../app_communication/hub_app_server.dart | 2 +- .../cbj_devices_connector_conjector.dart | 2 +- .../cbj_smart_device_api_object.dart | 8 +- .../companies_connector_conjector.dart | 2 +- .../esphome_api/esphome_api_client.dart | 176 +++++++++--------- .../esphome_python_api.dart | 8 +- .../esphome_python_json_objects_type.dart | 2 +- .../ewelink/ewelink_connector_conjector.dart | 21 ++- .../shelly/shelly_connector_conjector.dart | 2 +- .../shelly_light/shelly_light_entity.dart | 4 +- .../shelly_relay_switch_entity.dart | 4 +- .../sonoff_diy_mod_wall_switch_entity.dart | 4 +- .../sonoff_diy_connector_conjector.dart | 2 +- .../switcher_connector_conjector.dart | 2 +- .../tasmota_ip_connector_conjector.dart | 2 +- .../tasmota_mqtt_connector_conjector.dart | 2 +- .../tuya_smart_remote_api/cloudtuya.dart | 2 +- .../devices/wiz/wiz_connector_conjector.dart | 2 +- .../xiaomi_io_connector_conjector.dart | 6 +- .../device_entity_dto_abstract.dart | 6 +- .../login_entity_dto_abstract.dart | 6 +- .../mqtt_server/mqtt_server_repository.dart | 18 +- .../node_red/node_red_repository.dart | 1 - .../remote_pipes/remote_pipes_client.dart | 2 +- .../bed_room_area_actions.dart | 7 - .../outside_area_actions.dart | 6 - .../study_room_area_actions.dart | 4 - .../video_games_area_actions.dart | 7 +- .../work_room_area_actions.dart | 5 - .../area_type_with_device_type_preset.dart | 27 --- lib/infrastructure/shared_variables.dart | 2 +- .../bash_commands_for_raspberry_pi_d.dart | 2 +- .../common_bash_commands_d.dart | 2 +- .../system_commands/device_pin_manager.dart | 4 +- .../system_commands_manager_d.dart | 4 +- pubspec.yaml | 8 +- 39 files changed, 165 insertions(+), 207 deletions(-) diff --git a/bin/cbj_hub.dart b/bin/cbj_hub.dart index 96590e6c..391d69e3 100644 --- a/bin/cbj_hub.dart +++ b/bin/cbj_hub.dart @@ -28,7 +28,7 @@ Future main(List arguments) async { await getIt().initializeDb(); - logger.v(''); + logger.t(''); await BootUp.setup(); } diff --git a/lib/domain/generic_devices/generic_dimmable_light_device/generic_dimmable_light_value_objects.dart b/lib/domain/generic_devices/generic_dimmable_light_device/generic_dimmable_light_value_objects.dart index 08bb442f..2048d722 100644 --- a/lib/domain/generic_devices/generic_dimmable_light_device/generic_dimmable_light_value_objects.dart +++ b/lib/domain/generic_devices/generic_dimmable_light_device/generic_dimmable_light_value_objects.dart @@ -24,7 +24,7 @@ class GenericDimmableLightSwitchState extends ValueObjectCore { class GenericDimmableLightBrightness extends ValueObjectCore { factory GenericDimmableLightBrightness(String? input) { assert(input != null); - String tempInput = input!; + final String tempInput = input!; return GenericDimmableLightBrightness._( validateGenericDimmableLightNotEmpty(tempInput), diff --git a/lib/infrastructure/app_communication/app_communication_repository.dart b/lib/infrastructure/app_communication/app_communication_repository.dart index 40e1b992..b643a649 100644 --- a/lib/infrastructure/app_communication/app_communication_repository.dart +++ b/lib/infrastructure/app_communication/app_communication_repository.dart @@ -51,7 +51,7 @@ class AppCommunicationRepository extends IAppCommunicationRepository { late int hubPort; Future startLocalServer() async { - final server = Server([HubAppServer()]); + final server = Server.create(services: [HubAppServer()]); await server.serve(port: hubPort); logger.i('Hub Server listening for apps clients on port ${server.port}...'); } @@ -217,7 +217,7 @@ class AppCommunicationRepository extends IAppCommunicationRepository { } }).onError((error) { if (error is GrpcError && error.code == 1) { - logger.v('Client have disconnected'); + logger.t('Client have disconnected'); } else if (error is GrpcError && error.code == 14) { final String errorMessage = error.message!; diff --git a/lib/infrastructure/app_communication/hub_app_server.dart b/lib/infrastructure/app_communication/hub_app_server.dart index 59763e33..f3cb6947 100644 --- a/lib/infrastructure/app_communication/hub_app_server.dart +++ b/lib/infrastructure/app_communication/hub_app_server.dart @@ -26,7 +26,7 @@ class HubAppServer extends CbjHubServiceBase { Stream request, ) async* { try { - logger.v('Got new Client'); + logger.t('Got new Client'); getIt().getFromApp( request: request, diff --git a/lib/infrastructure/devices/cbj_devices/cbj_devices_connector_conjector.dart b/lib/infrastructure/devices/cbj_devices/cbj_devices_connector_conjector.dart index 711d18f0..ac7f0033 100644 --- a/lib/infrastructure/devices/cbj_devices/cbj_devices_connector_conjector.dart +++ b/lib/infrastructure/devices/cbj_devices/cbj_devices_connector_conjector.dart @@ -54,7 +54,7 @@ class CbjDevicesConnectorConjector companyDevices.addEntries([deviceAsEntry]); - logger.v( + logger.t( 'New Cbj Smart Device name:${entityAsDevice.cbjEntityName.getOrCrash()}', ); } diff --git a/lib/infrastructure/devices/cbj_devices/cbj_smart_device_api/cbj_smart_device_api_object.dart b/lib/infrastructure/devices/cbj_devices/cbj_smart_device_api/cbj_smart_device_api_object.dart index 99cdd1e1..f40fa647 100644 --- a/lib/infrastructure/devices/cbj_devices/cbj_smart_device_api/cbj_smart_device_api_object.dart +++ b/lib/infrastructure/devices/cbj_devices/cbj_smart_device_api/cbj_smart_device_api_object.dart @@ -60,7 +60,7 @@ class CbjDevicesApiObject { if (sDeviceType == CbjDevicesDevicesTypes.cbjDevicesRunner || sDeviceType == CbjDevicesDevicesTypes.cbjDevicesRunnerMini) { if (!isCbjDevicesMessageNew(data, hexSeparatedLetters)) { - logger.v('Not new cbjDevices device!'); + logger.t('Not new cbjDevices device!'); } final CbjDevicesDeviceDirection cbjDevicesDeviceDirection = @@ -79,7 +79,7 @@ class CbjDevicesApiObject { } if (!isCbjDevicesMessage(data, hexSeparatedLetters)) { - logger.v('Not old cbjDevices device!'); + logger.t('Not old cbjDevices device!'); } final CbjDevicesDeviceState cbjDevicesDeviceState = @@ -216,7 +216,7 @@ class CbjDevicesApiObject { Future stopBlinds() async { if (deviceType != CbjDevicesDevicesTypes.cbjDevicesRunner && deviceType != CbjDevicesDevicesTypes.cbjDevicesRunnerMini) { - logger.v('Stop blinds support only for blinds'); + logger.t('Stop blinds support only for blinds'); return; } @@ -242,7 +242,7 @@ class CbjDevicesApiObject { Future setPosition({int pos = 0}) async { if (deviceType != CbjDevicesDevicesTypes.cbjDevicesRunner && deviceType != CbjDevicesDevicesTypes.cbjDevicesRunnerMini) { - logger.v('Set position support only blinds'); + logger.t('Set position support only blinds'); return; } diff --git a/lib/infrastructure/devices/companies_connector_conjector.dart b/lib/infrastructure/devices/companies_connector_conjector.dart index 86ad5723..aa6a5134 100644 --- a/lib/infrastructure/devices/companies_connector_conjector.dart +++ b/lib/infrastructure/devices/companies_connector_conjector.dart @@ -260,7 +260,7 @@ class CompaniesConnectorConjector { port: mdnsPort, ); } else { - logger.v( + logger.t( 'mDNS service type ${hostMdnsInfo.mdnsServiceType} is not supported\n IP: ${activeHost.address}, Port: ${hostMdnsInfo.mdnsPort}, ServiceType: ${hostMdnsInfo.mdnsServiceType}, MdnsName: ${hostMdnsInfo.getOnlyTheStartOfMdnsName()}', ); } diff --git a/lib/infrastructure/devices/esphome/esphome_api/esphome_api_client.dart b/lib/infrastructure/devices/esphome/esphome_api/esphome_api_client.dart index 42fceba4..deb74734 100644 --- a/lib/infrastructure/devices/esphome/esphome_api/esphome_api_client.dart +++ b/lib/infrastructure/devices/esphome/esphome_api/esphome_api_client.dart @@ -54,12 +54,12 @@ class EspHomeApiClient { /// HelloRequest if (responseType == 1) { - logger.v('responseType is HelloRequest'); + logger.t('responseType is HelloRequest'); } /// HelloResponse else if (responseType == 2) { - logger.v('responseType is HelloResponse'); + logger.t('responseType is HelloResponse'); final HelloResponse? helloResponseData = bytesToHelloResponse(data); if (helloResponseData != null) { deviceResponseStream.add( @@ -70,311 +70,311 @@ class EspHomeApiClient { ), ); } - logger.v('HelloResponse data: ${helloResponseData?.serverInfo}'); - logger.v(''); + logger.t('HelloResponse data: ${helloResponseData?.serverInfo}'); + logger.t(''); } /// ConnectRequest else if (responseType == 3) { - logger.v('responseType is ConnectRequest'); + logger.t('responseType is ConnectRequest'); } /// ConnectResponse else if (responseType == 4) { - logger.v('responseType is ConnectResponse'); - logger.v( + logger.t('responseType is ConnectResponse'); + logger.t( 'ConnectResponse data: ${utf8.decode(data.sublist(3), allowMalformed: true)}', ); - logger.v('Data: $data'); + logger.t('Data: $data'); if (data.length > 3) { - logger.v('Password is wrong'); + logger.t('Password is wrong'); devicePass = null; } else { - logger.v('Correct password'); + logger.t('Correct password'); } - logger.v(''); + logger.t(''); } /// DisconnectRequest else if (responseType == 5) { - logger.v('responseType is DisconnectRequest'); + logger.t('responseType is DisconnectRequest'); } /// DisconnectResponse else if (responseType == 6) { - logger.v('responseType is DisconnectResponse'); + logger.t('responseType is DisconnectResponse'); } /// PingRequest else if (responseType == 7) { - logger.v('responseType is PingRequest'); - logger.v('PingRequest data: ${utf8.decode(data.sublist(3))}'); - logger.v(''); + logger.t('responseType is PingRequest'); + logger.t('PingRequest data: ${utf8.decode(data.sublist(3))}'); + logger.t(''); } /// PingResponse else if (responseType == 8) { - logger.v('responseType is PingResponse'); - logger.v('PingResponse data: ${utf8.decode(data.sublist(3))}'); - logger.v(''); + logger.t('responseType is PingResponse'); + logger.t('PingResponse data: ${utf8.decode(data.sublist(3))}'); + logger.t(''); } /// DeviceInfoRequest else if (responseType == 9) { - logger.v('responseType is DeviceInfoRequest'); + logger.t('responseType is DeviceInfoRequest'); } /// DeviceInfoResponse else if (responseType == 10) { - logger.v('responseType is DeviceInfoResponse'); - logger.v('DeviceInfoResponse data: $data'); - logger.v(''); + logger.t('responseType is DeviceInfoResponse'); + logger.t('DeviceInfoResponse data: $data'); + logger.t(''); } /// ListEntitiesRequest else if (responseType == 11) { - logger.v('responseType is ListEntitiesRequest'); + logger.t('responseType is ListEntitiesRequest'); } /// ListEntitiesBinarySensorResponse else if (responseType == 12) { - logger.v('responseType is ListEntitiesBinarySensorResponse'); + logger.t('responseType is ListEntitiesBinarySensorResponse'); } /// ListEntitiesCoverResponse else if (responseType == 13) { - logger.v('responseType is ListEntitiesCoverResponse'); + logger.t('responseType is ListEntitiesCoverResponse'); } /// ListEntitiesFanResponse else if (responseType == 14) { - logger.v('responseType is ListEntitiesFanResponse'); + logger.t('responseType is ListEntitiesFanResponse'); } /// ListEntitiesLightResponse else if (responseType == 15) { - logger.v('responseType is ListEntitiesLightResponse'); + logger.t('responseType is ListEntitiesLightResponse'); } /// ListEntitiesSensorResponse else if (responseType == 16) { - logger.v('responseType is ListEntitiesSensorResponse'); + logger.t('responseType is ListEntitiesSensorResponse'); } /// ListEntitiesSwitchResponse else if (responseType == 17) { - logger.v('responseType is ListEntitiesSwitchResponse'); + logger.t('responseType is ListEntitiesSwitchResponse'); String dataPayload = ''; try { dataPayload = data.length > 3 ? utf8.decode(data.sublist(3)) : ''; - logger.v( + logger.t( 'ListEntitiesSwitchResponse data payload:' ' $dataPayload', ); } catch (e) { - logger.v( + logger.t( 'ListEntitiesSwitchResponse data bytes:' ' $data', ); } - logger.v(''); + logger.t(''); } /// ListEntitiesTextSensorResponse else if (responseType == 18) { - logger.v('responseType is ListEntitiesTextSensorResponse'); + logger.t('responseType is ListEntitiesTextSensorResponse'); } /// dsaDoneResponse else if (responseType == 19) { - logger.v('responseType is ListEntitiesDoneResponse'); - logger.v( + logger.t('responseType is ListEntitiesDoneResponse'); + logger.t( 'ListEntitiesDoneResponse data: ${utf8.decode(data.sublist(3))}', ); - logger.v(''); + logger.t(''); } /// SubscribeStatesRequest else if (responseType == 20) { - logger.v('responseType is SubscribeStatesRequest'); + logger.t('responseType is SubscribeStatesRequest'); } /// BinarySensorStateResponse else if (responseType == 21) { - logger.v('responseType is BinarySensorStateResponse'); + logger.t('responseType is BinarySensorStateResponse'); } /// CoverStateResponse else if (responseType == 22) { - logger.v('responseType is CoverStateResponse'); + logger.t('responseType is CoverStateResponse'); } /// FanStateResponse else if (responseType == 23) { - logger.v('responseType is FanStateResponse'); + logger.t('responseType is FanStateResponse'); } /// LightStateResponse else if (responseType == 24) { - logger.v('responseType is LightStateResponse'); + logger.t('responseType is LightStateResponse'); } /// SensorStateResponse else if (responseType == 25) { - logger.v('responseType is SensorStateResponse'); + logger.t('responseType is SensorStateResponse'); } /// SwitchStateResponse else if (responseType == 26) { - logger.v('responseType is SwitchStateResponse'); - logger.v('SwitchStateResponse data: $data}'); - logger.v(''); + logger.t('responseType is SwitchStateResponse'); + logger.t('SwitchStateResponse data: $data}'); + logger.t(''); } /// TextSensorStateResponse else if (responseType == 27) { - logger.v('responseType is TextSensorStateResponse'); + logger.t('responseType is TextSensorStateResponse'); } /// SubscribeLogsRequest else if (responseType == 28) { - logger.v('responseType is SubscribeLogsRequest'); + logger.t('responseType is SubscribeLogsRequest'); } /// SubscribeLogsResponse else if (responseType == 29) { - logger.v('responseType is SubscribeLogsResponse'); + logger.t('responseType is SubscribeLogsResponse'); } /// CoverCommandRequest else if (responseType == 30) { - logger.v('responseType is CoverCommandRequest'); + logger.t('responseType is CoverCommandRequest'); } /// FanCommandRequest else if (responseType == 31) { - logger.v('responseType is FanCommandRequest'); + logger.t('responseType is FanCommandRequest'); } /// LightCommandRequest else if (responseType == 32) { - logger.v('responseType is LightCommandRequest'); + logger.t('responseType is LightCommandRequest'); } /// SwitchCommandRequest else if (responseType == 33) { - logger.v('responseType is SwitchCommandRequest'); + logger.t('responseType is SwitchCommandRequest'); } /// SubscribeHomeassistantServicesRequest else if (responseType == 34) { - logger.v('responseType is SubscribeHomeassistantServicesRequest'); + logger.t('responseType is SubscribeHomeassistantServicesRequest'); } /// HomeassistantServiceResponse else if (responseType == 35) { - logger.v('responseType is HomeassistantServiceResponse'); + logger.t('responseType is HomeassistantServiceResponse'); } /// GetTimeRequest else if (responseType == 36) { - logger.v('responseType is GetTimeRequest'); + logger.t('responseType is GetTimeRequest'); } /// GetTimeResponse else if (responseType == 37) { - logger.v('responseType is GetTimeResponse'); + logger.t('responseType is GetTimeResponse'); } /// SubscribeHomeAssistantStatesRequest else if (responseType == 38) { - logger.v('responseType is SubscribeHomeAssistantStatesRequest'); + logger.t('responseType is SubscribeHomeAssistantStatesRequest'); } /// SubscribeHomeAssistantStateResponse else if (responseType == 39) { - logger.v('responseType is SubscribeHomeAssistantStateResponse'); + logger.t('responseType is SubscribeHomeAssistantStateResponse'); } /// HomeAssistantStateResponse else if (responseType == 40) { - logger.v('responseType is HomeAssistantStateResponse'); + logger.t('responseType is HomeAssistantStateResponse'); } /// ListEntitiesServicesResponse else if (responseType == 41) { - logger.v('responseType is ListEntitiesServicesResponse'); + logger.t('responseType is ListEntitiesServicesResponse'); } /// ExecuteServiceRequest else if (responseType == 42) { - logger.v('responseType is ExecuteServiceRequest'); + logger.t('responseType is ExecuteServiceRequest'); } /// ListEntitiesCameraResponse else if (responseType == 43) { - logger.v('responseType is ListEntitiesCameraResponse'); + logger.t('responseType is ListEntitiesCameraResponse'); } /// CameraImageResponse else if (responseType == 44) { - logger.v('responseType is CameraImageResponse'); + logger.t('responseType is CameraImageResponse'); } /// CameraImageRequest else if (responseType == 45) { - logger.v('responseType is CameraImageRequest'); + logger.t('responseType is CameraImageRequest'); } /// ListEntitiesClimateResponse else if (responseType == 46) { - logger.v('responseType is ListEntitiesClimateResponse'); + logger.t('responseType is ListEntitiesClimateResponse'); } /// ClimateStateResponse else if (responseType == 47) { - logger.v('responseType is ClimateStateResponse'); + logger.t('responseType is ClimateStateResponse'); } /// ClimateCommandRequest else if (responseType == 48) { - logger.v('responseType is ClimateCommandRequest'); + logger.t('responseType is ClimateCommandRequest'); } /// ListEntitiesNumberResponse else if (responseType == 49) { - logger.v('responseType is ListEntitiesNumberResponse'); + logger.t('responseType is ListEntitiesNumberResponse'); } /// NumberStateResponse else if (responseType == 50) { - logger.v('responseType is NumberStateResponse'); + logger.t('responseType is NumberStateResponse'); } /// NumberCommandRequest else if (responseType == 51) { - logger.v('responseType is NumberCommandRequest'); + logger.t('responseType is NumberCommandRequest'); } /// ListEntitiesSelectResponse else if (responseType == 52) { - logger.v('responseType is ListEntitiesSelectResponse'); + logger.t('responseType is ListEntitiesSelectResponse'); } /// SelectStateResponse else if (responseType == 53) { - logger.v('responseType is SelectStateResponse'); + logger.t('responseType is SelectStateResponse'); } /// SelectCommandRequest else if (responseType == 54) { - logger.v('responseType is SelectCommandRequest'); + logger.t('responseType is SelectCommandRequest'); } else { - logger.v('responseType is else'); - logger.v('Listen to data $data'); - logger.v(''); + logger.t('responseType is else'); + logger.t('Listen to data $data'); + logger.t(''); } }, @@ -386,7 +386,7 @@ class EspHomeApiClient { // handle server ending connection onDone: () { - logger.v('Server left.'); + logger.t('Server left.'); socket.destroy(); }, ); @@ -531,7 +531,7 @@ class EspHomeApiClient { Future ping() async { // connect to the socket server final socket = await getSocket(); - logger.v( + logger.t( 'Connected request to: ' '${socket.remoteAddress.address}:${socket.remotePort}', ); @@ -566,7 +566,7 @@ class EspHomeApiClient { Future deviceInfoRequestToEsp() async { // connect to the socket server final socket = await getSocket(); - logger.v( + logger.t( 'Connected request to:' ' ${socket.remoteAddress.address}:${socket.remotePort}', ); @@ -601,7 +601,7 @@ class EspHomeApiClient { Future subscribeStatesRequest() async { // connect to the socket server final socket = await getSocket(); - logger.v( + logger.t( 'Connected request to:' ' ${socket.remoteAddress.address}:${socket.remotePort}', ); @@ -635,12 +635,12 @@ class EspHomeApiClient { Future switchCommandRequest(int deviceKey, bool changeTostate) async { if (devicePass == null) { - logger.v('Please call sendConnect, password is missing'); + logger.t('Please call sendConnect, password is missing'); return; } // connect to the socket server final socket = await getSocket(); - logger.v( + logger.t( 'Connected request to:' ' ${socket.remoteAddress.address}:${socket.remotePort}', ); @@ -673,7 +673,7 @@ class EspHomeApiClient { final ByteData byteData = ByteData.view(message.buffer); - logger.v(myHexKeyList); + logger.t(myHexKeyList); /// A zero byte. byteData.setUint8(0, 0x00); @@ -691,7 +691,7 @@ class EspHomeApiClient { byteData.setUint8(a, myHexKeyList[a - numOfByteBeforeData]); } - logger.v('switchCommandRequest message: $message'); + logger.t('switchCommandRequest message: $message'); // * The message object encoded as a ProtoBuf message socket.add(message); @@ -700,12 +700,12 @@ class EspHomeApiClient { Future listEntitiesRequest() async { if (devicePass == null) { - logger.v('Please call sendConnect, password is missing'); + logger.t('Please call sendConnect, password is missing'); return; } // connect to the socket server final socket = await getSocket(); - logger.v( + logger.t( 'Connected request to:' ' ${socket.remoteAddress.address}:${socket.remotePort}', ); @@ -730,7 +730,7 @@ class EspHomeApiClient { /// * VarInt denoting the type of message. byteData.setUint8(2, 11); - logger.v('ListEntitiesRequest message: $message'); + logger.t('ListEntitiesRequest message: $message'); // * The message object encoded as a ProtoBuf message socket.add(message); diff --git a/lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_api.dart b/lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_api.dart index b50c2d25..e0dc93c1 100644 --- a/lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_api.dart +++ b/lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_api.dart @@ -58,10 +58,10 @@ // } // }, // onComplete: () { -// logger.v('EspHome get all entities scan done'); +// logger.t('EspHome get all entities scan done'); // }, // onError: (object, stackTrace) { -// logger.v('EspHome device scan error $object\n$stackTrace'); +// logger.t('EspHome device scan error $object\n$stackTrace'); // }, // ); // @@ -96,7 +96,7 @@ // .v('EspHome turn lights on or off action completed successfully'); // }, // onError: (object, stackTrace) { -// logger.v('EspHome device scan error $object\n$stackTrace'); +// logger.t('EspHome device scan error $object\n$stackTrace'); // }, // ); // @@ -130,7 +130,7 @@ // .v('EspHome turn switch on or off action completed successfully'); // }, // onError: (object, stackTrace) { -// logger.v('EspHome device scan error $object\n$stackTrace'); +// logger.t('EspHome device scan error $object\n$stackTrace'); // }, // ); // diff --git a/lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_json_objects_type.dart b/lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_json_objects_type.dart index 695c12cd..47a8fdf8 100644 --- a/lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_json_objects_type.dart +++ b/lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_json_objects_type.dart @@ -37,7 +37,7 @@ // // ); // // } // // else if (currentType == 'BinarySensorInfo') { -// // logger.v('Esphome BinarySensorInfo is currently not supported'); +// // logger.t('Esphome BinarySensorInfo is currently not supported'); // // } // else { // logger diff --git a/lib/infrastructure/devices/ewelink/ewelink_connector_conjector.dart b/lib/infrastructure/devices/ewelink/ewelink_connector_conjector.dart index f70f50f2..a54eb84e 100644 --- a/lib/infrastructure/devices/ewelink/ewelink_connector_conjector.dart +++ b/lib/infrastructure/devices/ewelink/ewelink_connector_conjector.dart @@ -32,6 +32,7 @@ class EwelinkConnectorConjector implements AbstractCompanyConnectorConjector { ); await ewelink!.getCredentials(); + discoverNewDevices(activeHost: null); } on EwelinkInvalidAccessToken { logger.e('invalid access token'); return false; @@ -45,20 +46,32 @@ class EwelinkConnectorConjector implements AbstractCompanyConnectorConjector { return true; } + Future? didRequestLogin; Future discoverNewDevices({ required ActiveHost? activeHost, }) async { + if (didRequestLogin != null) { + return; + } + if (ewelink == null) { - final bool lastRequest = - await accountLogin(GenericEwelinkLoginDE.empty()); - if (!lastRequest) { + didRequestLogin = accountLogin(GenericEwelinkLoginDE.empty()); + if (!await didRequestLogin!) { + didRequestLogin = null; logger.w( 'eWeLink device got found but missing a email and password, please add ' 'it in the app'); return; } } - final List devices = await ewelink!.getDevices(); + didRequestLogin = null; + + List devices; + try { + devices = await ewelink!.getDevices(); + } catch (e) { + return; + } for (final EwelinkDevice ewelinkDevice in devices) { // Getting device by id adds additional info in the result diff --git a/lib/infrastructure/devices/shelly/shelly_connector_conjector.dart b/lib/infrastructure/devices/shelly/shelly_connector_conjector.dart index 84f04444..aaa301da 100644 --- a/lib/infrastructure/devices/shelly/shelly_connector_conjector.dart +++ b/lib/infrastructure/devices/shelly/shelly_connector_conjector.dart @@ -66,7 +66,7 @@ class ShellyConnectorConjector implements AbstractCompanyConnectorConjector { companyDevices.addEntries([deviceAsEntry]); } - logger.v('New shelly devices name:$mDnsName'); + logger.t('New shelly devices name:$mDnsName'); } @override diff --git a/lib/infrastructure/devices/shelly/shelly_light/shelly_light_entity.dart b/lib/infrastructure/devices/shelly/shelly_light/shelly_light_entity.dart index c832b82d..9e2033fa 100644 --- a/lib/infrastructure/devices/shelly/shelly_light/shelly_light_entity.dart +++ b/lib/infrastructure/devices/shelly/shelly_light/shelly_light_entity.dart @@ -205,7 +205,7 @@ class ShellyColorLightEntity extends GenericRgbwLightDE { lightSwitchState = GenericRgbwLightSwitchState(EntityActions.on.toString()); try { - logger.v('Turn on Shelly device'); + logger.t('Turn on Shelly device'); shellyColorBulb.turnOn(); return right(unit); } catch (e) { @@ -219,7 +219,7 @@ class ShellyColorLightEntity extends GenericRgbwLightDE { GenericRgbwLightSwitchState(EntityActions.off.toString()); try { - logger.v('Turn off Shelly device'); + logger.t('Turn off Shelly device'); await shellyColorBulb.turnOff(); return right(unit); } catch (exception) { diff --git a/lib/infrastructure/devices/shelly/shelly_relay_switch/shelly_relay_switch_entity.dart b/lib/infrastructure/devices/shelly/shelly_relay_switch/shelly_relay_switch_entity.dart index 92eb26e5..75c1f297 100644 --- a/lib/infrastructure/devices/shelly/shelly_relay_switch/shelly_relay_switch_entity.dart +++ b/lib/infrastructure/devices/shelly/shelly_relay_switch/shelly_relay_switch_entity.dart @@ -113,7 +113,7 @@ class ShellyRelaySwitchEntity extends GenericSwitchDE { switchState = GenericSwitchSwitchState(EntityActions.on.toString()); try { - logger.v('Turn on Shelly device'); + logger.t('Turn on Shelly device'); shellyRelaySwitch.turnOn(); return right(unit); } catch (e) { @@ -126,7 +126,7 @@ class ShellyRelaySwitchEntity extends GenericSwitchDE { switchState = GenericSwitchSwitchState(EntityActions.off.toString()); try { - logger.v('Turn off Shelly device'); + logger.t('Turn off Shelly device'); await shellyRelaySwitch.turnOff(); return right(unit); } catch (exception) { diff --git a/lib/infrastructure/devices/sonoff_diy/sonoff__diy_wall_switch/sonoff_diy_mod_wall_switch_entity.dart b/lib/infrastructure/devices/sonoff_diy/sonoff__diy_wall_switch/sonoff_diy_mod_wall_switch_entity.dart index a18dea76..f4a37485 100644 --- a/lib/infrastructure/devices/sonoff_diy/sonoff__diy_wall_switch/sonoff_diy_mod_wall_switch_entity.dart +++ b/lib/infrastructure/devices/sonoff_diy/sonoff__diy_wall_switch/sonoff_diy_mod_wall_switch_entity.dart @@ -113,7 +113,7 @@ class SonoffDiyRelaySwitchEntity extends GenericSwitchDE { switchState = GenericSwitchSwitchState(EntityActions.on.toString()); try { - logger.v('Turn on Sonoff diy device'); + logger.t('Turn on Sonoff diy device'); sonoffDiyRelaySwitch.switchOn(); return right(unit); } catch (e) { @@ -126,7 +126,7 @@ class SonoffDiyRelaySwitchEntity extends GenericSwitchDE { switchState = GenericSwitchSwitchState(EntityActions.off.toString()); try { - logger.v('Turn off Sonoff diy device'); + logger.t('Turn off Sonoff diy device'); await sonoffDiyRelaySwitch.switchOff(); return right(unit); } catch (exception) { diff --git a/lib/infrastructure/devices/sonoff_diy/sonoff_diy_connector_conjector.dart b/lib/infrastructure/devices/sonoff_diy/sonoff_diy_connector_conjector.dart index 4feeab90..d7fa406d 100644 --- a/lib/infrastructure/devices/sonoff_diy/sonoff_diy_connector_conjector.dart +++ b/lib/infrastructure/devices/sonoff_diy/sonoff_diy_connector_conjector.dart @@ -62,7 +62,7 @@ class SonoffDiyConnectorConjector implements AbstractCompanyConnectorConjector { companyDevices.addEntries([deviceAsEntry]); } - logger.v('New Sonoff diy devices name:$mDnsName'); + logger.t('New Sonoff diy devices name:$mDnsName'); } @override diff --git a/lib/infrastructure/devices/switcher/switcher_connector_conjector.dart b/lib/infrastructure/devices/switcher/switcher_connector_conjector.dart index 6473f988..af68b314 100644 --- a/lib/infrastructure/devices/switcher/switcher_connector_conjector.dart +++ b/lib/infrastructure/devices/switcher/switcher_connector_conjector.dart @@ -64,7 +64,7 @@ class SwitcherConnectorConjector implements AbstractCompanyConnectorConjector { companyDevices.addEntries([deviceAsEntry]); - // logger.v('New switcher devices name:${switcherApiObject.switcherName}'); + // logger.t('New switcher devices name:${switcherApiObject.switcherName}'); } @override diff --git a/lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_connector_conjector.dart b/lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_connector_conjector.dart index 3652b123..ce456bc4 100644 --- a/lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_connector_conjector.dart +++ b/lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_connector_conjector.dart @@ -72,7 +72,7 @@ class TasmotaIpConnectorConjector implements AbstractCompanyConnectorConjector { companyDevices.addEntries([deviceAsEntry]); - logger.v( + logger.t( 'New Tasmota Ip device name:${entityAsDevice.cbjEntityName.getOrCrash()}', ); } diff --git a/lib/infrastructure/devices/tasmota/tasmota_mqtt/tasmota_mqtt_connector_conjector.dart b/lib/infrastructure/devices/tasmota/tasmota_mqtt/tasmota_mqtt_connector_conjector.dart index 728cb9d8..b903d7d2 100644 --- a/lib/infrastructure/devices/tasmota/tasmota_mqtt/tasmota_mqtt_connector_conjector.dart +++ b/lib/infrastructure/devices/tasmota/tasmota_mqtt/tasmota_mqtt_connector_conjector.dart @@ -86,7 +86,7 @@ class TasmotaMqttConnectorConjector MapEntry(deviceToAdd.uniqueId.getOrCrash(), deviceToAdd); companyDevices.addEntries([deviceAsEntry]); - logger.v('Adding Tasmota mqtt device'); + logger.t('Adding Tasmota mqtt device'); }); } diff --git a/lib/infrastructure/devices/tuya_smart/tuya_smart_remote_api/cloudtuya.dart b/lib/infrastructure/devices/tuya_smart/tuya_smart_remote_api/cloudtuya.dart index 416a8fe4..94c4b7e1 100644 --- a/lib/infrastructure/devices/tuya_smart/tuya_smart_remote_api/cloudtuya.dart +++ b/lib/infrastructure/devices/tuya_smart/tuya_smart_remote_api/cloudtuya.dart @@ -163,7 +163,7 @@ class CloudTuya { final dynamic a = json.decode(responseBody); final dynamic scenesList = a['payload']['scenes']; - logger.v('Scenes:\n$scenesList'); + logger.t('Scenes:\n$scenesList'); return scenesList; } diff --git a/lib/infrastructure/devices/wiz/wiz_connector_conjector.dart b/lib/infrastructure/devices/wiz/wiz_connector_conjector.dart index b3544017..9c66ecf3 100644 --- a/lib/infrastructure/devices/wiz/wiz_connector_conjector.dart +++ b/lib/infrastructure/devices/wiz/wiz_connector_conjector.dart @@ -62,7 +62,7 @@ class WizConnectorConjector implements AbstractCompanyConnectorConjector { // // companyDevices.addEntries([deviceAsEntry]); // - // logger.v( + // logger.t( // 'New Wiz Ip device name:${entityAsDevice.cbjEntityName.getOrCrash()}', // ); // } diff --git a/lib/infrastructure/devices/xiaomi_io/xiaomi_io_connector_conjector.dart b/lib/infrastructure/devices/xiaomi_io/xiaomi_io_connector_conjector.dart index 53836d13..cb63d3eb 100644 --- a/lib/infrastructure/devices/xiaomi_io/xiaomi_io_connector_conjector.dart +++ b/lib/infrastructure/devices/xiaomi_io/xiaomi_io_connector_conjector.dart @@ -76,7 +76,7 @@ class XiaomiIoConnectorConjector implements AbstractCompanyConnectorConjector { // // // await for (final tup.Tuple2 miDevice // // in MiIO.instance.discover(internetAddress)) { - // // logger.v('miDevice devices $miDevice'); + // // logger.t('miDevice devices $miDevice'); // // // MiIO.inst ance.send(address, packet); // // } // @@ -84,7 +84,7 @@ class XiaomiIoConnectorConjector implements AbstractCompanyConnectorConjector { // // // // MiIOPacket miIoPacket = await MiIO.instance.hello(internetAddress); // // MiIOPacket ab = await MiIO.instance.send(internetAddress, miIoPacket); - // // logger.v('This is mi packets $miIoPacket'); + // // logger.t('This is mi packets $miIoPacket'); // } on MiIOError catch (e) { // logger.e( // 'Command failed with error from xiaomi device:\n' @@ -94,7 +94,7 @@ class XiaomiIoConnectorConjector implements AbstractCompanyConnectorConjector { // } on Exception catch (e) { // logger.e('Xiaomi command failed with exception:\n$e'); // } catch (e) { - // logger.v('All else'); + // logger.t('All else'); // } } diff --git a/lib/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart b/lib/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart index 2d1e0911..d3eb3ddb 100644 --- a/lib/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart +++ b/lib/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart @@ -19,7 +19,7 @@ class DeviceEntityDtoAbstract { DeviceEntityDtoAbstract(); factory DeviceEntityDtoAbstract.fromDomain() { - logger.v('DeviceEntityDtoAbstract.fromDomain'); + logger.t('DeviceEntityDtoAbstract.fromDomain'); return DeviceEntityDtoAbstract(); } @@ -79,12 +79,12 @@ class DeviceEntityDtoAbstract { final String deviceDtoClassInstance = (DeviceEntityDtoAbstract).toString(); Map toJson() { - logger.v('DeviceEntityDtoAbstract to Json'); + logger.t('DeviceEntityDtoAbstract to Json'); return {}; } DeviceEntityAbstract toDomain() { - logger.v('ToDomain'); + logger.t('ToDomain'); return DeviceEntityNotAbstract(); } } diff --git a/lib/infrastructure/generic_vendors_login/generic_login_abstract/login_entity_dto_abstract.dart b/lib/infrastructure/generic_vendors_login/generic_login_abstract/login_entity_dto_abstract.dart index 5d3e39ca..c3c8ca56 100644 --- a/lib/infrastructure/generic_vendors_login/generic_login_abstract/login_entity_dto_abstract.dart +++ b/lib/infrastructure/generic_vendors_login/generic_login_abstract/login_entity_dto_abstract.dart @@ -11,7 +11,7 @@ class LoginEntityDtoAbstract { LoginEntityDtoAbstract(); factory LoginEntityDtoAbstract.fromDomain() { - logger.v('LoginEntityDtoAbstract.fromDomain'); + logger.t('LoginEntityDtoAbstract.fromDomain'); return LoginEntityDtoAbstract(); } @@ -41,12 +41,12 @@ class LoginEntityDtoAbstract { final String loginDtoClassInstance = (LoginEntityDtoAbstract).toString(); Map toJson() { - logger.v('LoginEntityDtoAbstract to Json'); + logger.t('LoginEntityDtoAbstract to Json'); return {}; } LoginEntityAbstract toDomain() { - logger.v('ToDomain'); + logger.t('ToDomain'); return LoginEntityEmpty(); } } diff --git a/lib/infrastructure/mqtt_server/mqtt_server_repository.dart b/lib/infrastructure/mqtt_server/mqtt_server_repository.dart index aeb111cf..36f8f69c 100644 --- a/lib/infrastructure/mqtt_server/mqtt_server_repository.dart +++ b/lib/infrastructure/mqtt_server/mqtt_server_repository.dart @@ -120,7 +120,7 @@ class MqttServerRepository extends IMqttServerRepository { .startClean() .withWillQos(MqttQos.atLeastOnce); - logger.v('Client connecting'); + logger.t('Client connecting'); client.connectionMessage = connMessage; try { await client.connect(); @@ -299,7 +299,7 @@ class MqttServerRepository extends IMqttServerRepository { mqttClientTopic.updates.asBroadcastStream(); // myValueStream.listen((event) { - // logger.v(event); + // logger.t(event); // }); // final List> result = // await myValueStream.first; @@ -311,32 +311,32 @@ class MqttServerRepository extends IMqttServerRepository { /// Callback function for connection succeeded void onConnected() { - logger.v('Connected'); + logger.t('Connected'); } /// Unconnected void onDisconnected() { - logger.v('Disconnected'); + logger.t('Disconnected'); } /// subscribe to topic succeeded void onSubscribed(String topic) { - logger.v('Subscribed topic: $topic'); + logger.t('Subscribed topic: $topic'); } /// subscribe to topic failed void onSubscribeFail(String topic) { - logger.v('Failed to subscribe $topic'); + logger.t('Failed to subscribe $topic'); } /// unsubscribe succeeded void onUnsubscribed(String? topic) { - logger.v('Unsubscribed topic: $topic'); + logger.t('Unsubscribed topic: $topic'); } /// PING response received void pong() { - logger.v('Ping response MQTT client callback invoked'); + logger.t('Ping response MQTT client callback invoked'); } /// Convert device entity properties to mqtt topic and massage @@ -375,7 +375,7 @@ class MqttServerRepository extends IMqttServerRepository { } final List? a = await readingFromMqttOnce('$pathToDeviceTopic/type'); - logger.v('This is a $a'); + logger.t('This is a $a'); return DeviceEntityDtoAbstract(); } diff --git a/lib/infrastructure/node_red/node_red_repository.dart b/lib/infrastructure/node_red/node_red_repository.dart index d1ed0d1e..e16e44a0 100644 --- a/lib/infrastructure/node_red/node_red_repository.dart +++ b/lib/infrastructure/node_red/node_red_repository.dart @@ -7,7 +7,6 @@ import 'package:cbj_hub/utils.dart'; import 'package:http/src/response.dart'; import 'package:injectable/injectable.dart'; import 'package:nodered/nodered.dart'; -import 'package:nodered/src/node_red_nodes/external_nodes/chromecast_node_red_api/i_node_red_repository.dart'; /// Control Node-RED, create scenes and more @LazySingleton() diff --git a/lib/infrastructure/remote_pipes/remote_pipes_client.dart b/lib/infrastructure/remote_pipes/remote_pipes_client.dart index 7edf4335..5e6d3a8c 100644 --- a/lib/infrastructure/remote_pipes/remote_pipes_client.dart +++ b/lib/infrastructure/remote_pipes/remote_pipes_client.dart @@ -93,7 +93,7 @@ class RemotePipesClient { grpcKeepAlive?.cancel(); final GenericPingDE genericEmptyDE = GenericPingDE.empty(); grpcKeepAlive = Timer.periodic(const Duration(minutes: 9), (Timer t) { - logger.v('Ping device to Remote Pipes'); + logger.t('Ping device to Remote Pipes'); sendRequest.add(genericEmptyDE.toInfrastructure()); }); } diff --git a/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/bed_room_area_actions.dart b/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/bed_room_area_actions.dart index 0e89e85a..977a6339 100644 --- a/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/bed_room_area_actions.dart +++ b/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/bed_room_area_actions.dart @@ -31,7 +31,6 @@ class BedRoomAreaAction { brokerNodeId, ), ]); - break; case EntityTypes.boiler: break; case EntityTypes.browserApp: @@ -74,7 +73,6 @@ class BedRoomAreaAction { brokerNodeId, ), ]); - break; case EntityTypes.lightSensor: // TODO: Handle this case. break; @@ -115,7 +113,6 @@ class BedRoomAreaAction { brokerNodeId, ), ]); - break; case EntityTypes.scanner: // TODO: Handle this case. break; @@ -129,7 +126,6 @@ class BedRoomAreaAction { brokerNodeId, ), ]); - break; case EntityTypes.smartSpeakers: // TODO: Handle this case. break; @@ -140,7 +136,6 @@ class BedRoomAreaAction { brokerNodeId, ), ]); - break; case EntityTypes.smartWatch: // TODO: Handle this case. break; @@ -163,7 +158,6 @@ class BedRoomAreaAction { brokerNodeId, ), ]); - break; case EntityTypes.teapot: // TODO: Turn off. break; @@ -195,7 +189,6 @@ class BedRoomAreaAction { brokerNodeId, ), ]); - break; case EntityTypes.playerEntity: // TODO: Handle this case. break; diff --git a/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/outside_area_actions.dart b/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/outside_area_actions.dart index 7d3c543f..17fc2c15 100644 --- a/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/outside_area_actions.dart +++ b/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/outside_area_actions.dart @@ -31,7 +31,6 @@ class OutsideAreaAction { brokerNodeId, ), ]); - break; case EntityTypes.boiler: break; case EntityTypes.browserApp: @@ -74,7 +73,6 @@ class OutsideAreaAction { brokerNodeId, ), ]); - break; case EntityTypes.lightSensor: // TODO: Handle this case. break; @@ -115,7 +113,6 @@ class OutsideAreaAction { brokerNodeId, ), ]); - break; case EntityTypes.scanner: // TODO: Handle this case. break; @@ -129,7 +126,6 @@ class OutsideAreaAction { brokerNodeId, ), ]); - break; case EntityTypes.smartSpeakers: // TODO: Handle this case. break; @@ -140,7 +136,6 @@ class OutsideAreaAction { brokerNodeId, ), ]); - break; case EntityTypes.smartWatch: // TODO: Handle this case. break; @@ -163,7 +158,6 @@ class OutsideAreaAction { brokerNodeId, ), ]); - break; case EntityTypes.teapot: // TODO: Handle this case. break; diff --git a/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/study_room_area_actions.dart b/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/study_room_area_actions.dart index a58a29dc..399fc679 100644 --- a/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/study_room_area_actions.dart +++ b/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/study_room_area_actions.dart @@ -32,7 +32,6 @@ class StudyRoomAreaAction { brokerNodeId, ), ]); - break; case EntityTypes.boiler: break; case EntityTypes.browserApp: @@ -75,7 +74,6 @@ class StudyRoomAreaAction { brokerNodeId, ), ]); - break; case EntityTypes.lightSensor: // TODO: Handle this case. break; @@ -147,7 +145,6 @@ class StudyRoomAreaAction { brokerNodeId, ), ]); - break; case EntityTypes.smartWatch: // TODO: Handle this case. break; @@ -170,7 +167,6 @@ class StudyRoomAreaAction { brokerNodeId, ), ]); - break; case EntityTypes.teapot: // TODO: Handle this case. break; diff --git a/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/video_games_area_actions.dart b/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/video_games_area_actions.dart index 0e561d74..0a4a4d52 100644 --- a/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/video_games_area_actions.dart +++ b/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/video_games_area_actions.dart @@ -33,7 +33,6 @@ class VideoGamesAreaAction { brokerNodeId, ), ]); - break; case EntityTypes.boiler: break; case EntityTypes.browserApp: @@ -76,7 +75,6 @@ class VideoGamesAreaAction { brokerNodeId, ), ]); - break; case EntityTypes.lightSensor: // TODO: Handle this case. break; @@ -129,8 +127,7 @@ class VideoGamesAreaAction { brokerNodeId, ), ]); - // TODO: add light color changing in cycles - break; + // TODO: add light color changing in cycles case EntityTypes.scanner: // TODO: Handle this case. break; @@ -149,7 +146,6 @@ class VideoGamesAreaAction { brokerNodeId, ), ]); - break; case EntityTypes.smartWatch: // TODO: Handle this case. break; @@ -172,7 +168,6 @@ class VideoGamesAreaAction { brokerNodeId, ), ]); - break; case EntityTypes.teapot: // TODO: Handle this case. break; diff --git a/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/work_room_area_actions.dart b/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/work_room_area_actions.dart index 448db0e6..f5160ae7 100644 --- a/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/work_room_area_actions.dart +++ b/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/work_room_area_actions.dart @@ -32,7 +32,6 @@ class WorkRoomAreaAction { brokerNodeId, ), ]); - break; case EntityTypes.boiler: break; case EntityTypes.browserApp: @@ -75,7 +74,6 @@ class WorkRoomAreaAction { brokerNodeId, ), ]); - break; case EntityTypes.lightSensor: // TODO: Handle this case. break; @@ -128,7 +126,6 @@ class WorkRoomAreaAction { brokerNodeId, ), ]); - break; case EntityTypes.scanner: // TODO: Handle this case. break; @@ -147,7 +144,6 @@ class WorkRoomAreaAction { brokerNodeId, ), ]); - break; case EntityTypes.smartWatch: // TODO: Handle this case. break; @@ -170,7 +166,6 @@ class WorkRoomAreaAction { brokerNodeId, ), ]); - break; case EntityTypes.teapot: // TODO: Handle this case. break; diff --git a/lib/infrastructure/scenes/area_types_scientific_presets/area_type_with_device_type_preset.dart b/lib/infrastructure/scenes/area_types_scientific_presets/area_type_with_device_type_preset.dart index 371de21e..509e7f88 100644 --- a/lib/infrastructure/scenes/area_types_scientific_presets/area_type_with_device_type_preset.dart +++ b/lib/infrastructure/scenes/area_types_scientific_presets/area_type_with_device_type_preset.dart @@ -123,85 +123,58 @@ class AreaTypeWithDeviceTypePreset { switch (areaPurposeType) { case AreaPurposesTypes.attic: color = Colors.amberAccent; - break; case AreaPurposesTypes.bathtub: color = Colors.lightBlue; - break; case AreaPurposesTypes.bedroom: color = Colors.cyan; - break; case AreaPurposesTypes.boardGames: color = Colors.brown; - break; case AreaPurposesTypes.childrenRoom: color = Colors.lightBlueAccent; - break; case AreaPurposesTypes.cinemaRoom: color = Colors.pink; - break; case AreaPurposesTypes.diningRoom: color = Colors.amber; - break; case AreaPurposesTypes.holidayCabin: color = Colors.lightGreen; - break; case AreaPurposesTypes.kitchen: color = Colors.redAccent; - break; case AreaPurposesTypes.laundryRoom: color = Colors.white12; - break; case AreaPurposesTypes.livingRoom: color = Colors.orangeAccent; - break; case AreaPurposesTypes.meditation: color = Colors.purple; - break; case AreaPurposesTypes.outside: color = Colors.green; - break; case AreaPurposesTypes.outsideNotPrimary: color = Colors.greenAccent; - break; case AreaPurposesTypes.outsidePrimary: color = Colors.lightGreenAccent; - break; case AreaPurposesTypes.protectedSpace: color = Colors.blueGrey; - break; case AreaPurposesTypes.romantic: color = Colors.pinkAccent; - break; case AreaPurposesTypes.safeRoom: color = Colors.indigo; - break; case AreaPurposesTypes.shower: color = Colors.blueAccent; - break; case AreaPurposesTypes.stairsInside: color = Colors.brown; - break; case AreaPurposesTypes.stairsOutside: color = Colors.brown; - break; case AreaPurposesTypes.studyRoom: color = Colors.deepPurpleAccent; - break; case AreaPurposesTypes.toiletRoom: color = Colors.green; - break; case AreaPurposesTypes.trainingRoom: color = Colors.redAccent; - break; case AreaPurposesTypes.tvRoom: color = Colors.deepPurple; - break; case AreaPurposesTypes.videoGames: color = Colors.tealAccent; - break; case AreaPurposesTypes.workRoom: color = Colors.blue; - break; } return color.value; } diff --git a/lib/infrastructure/shared_variables.dart b/lib/infrastructure/shared_variables.dart index 64e684c8..2472c19b 100644 --- a/lib/infrastructure/shared_variables.dart +++ b/lib/infrastructure/shared_variables.dart @@ -7,7 +7,7 @@ import 'package:injectable/injectable.dart'; class SharedVariables { Future asyncConstractor(String projectRootDirectoryPath) async { _projectRootDirectoryPath = projectRootDirectoryPath; - logger.v('PATH: $_projectRootDirectoryPath'); + logger.t('PATH: $_projectRootDirectoryPath'); } /// Save the location of all the files that were created during the snapcraft diff --git a/lib/infrastructure/system_commands/bash_commands_d/bash_commands_for_raspberry_pi_d.dart b/lib/infrastructure/system_commands/bash_commands_d/bash_commands_for_raspberry_pi_d.dart index 48dbff3b..44cff4bc 100644 --- a/lib/infrastructure/system_commands/bash_commands_d/bash_commands_for_raspberry_pi_d.dart +++ b/lib/infrastructure/system_commands/bash_commands_d/bash_commands_for_raspberry_pi_d.dart @@ -14,7 +14,7 @@ class BashCommandsForRaspberryPi { } piVersion = piVersion.substring(piVersion.indexOf('Model')); - logger.v('This is the Pi Version: $piVersion'); + logger.t('This is the Pi Version: $piVersion'); piVersion = piVersion.substring(piVersion.indexOf(':') + 2); diff --git a/lib/infrastructure/system_commands/bash_commands_d/common_bash_commands_d.dart b/lib/infrastructure/system_commands/bash_commands_d/common_bash_commands_d.dart index 7fe8365b..8b348066 100644 --- a/lib/infrastructure/system_commands/bash_commands_d/common_bash_commands_d.dart +++ b/lib/infrastructure/system_commands/bash_commands_d/common_bash_commands_d.dart @@ -65,7 +65,7 @@ class CommonBashCommandsD implements SystemCommandsBaseClassD { // String hostName = result.stdout; // hostName = hostName.substring( // 0, hostName.length - 1); // Removes the invisible new line at the end -// logger.v('Host name: ' + hostName); +// logger.t('Host name: ' + hostName); return result.stdout.toString(); }); return hostName.trim(); diff --git a/lib/infrastructure/system_commands/device_pin_manager.dart b/lib/infrastructure/system_commands/device_pin_manager.dart index 9d09ff40..de12b5d5 100644 --- a/lib/infrastructure/system_commands/device_pin_manager.dart +++ b/lib/infrastructure/system_commands/device_pin_manager.dart @@ -47,7 +47,7 @@ class DevicePinListManager extends DevicePinListManagerAbstract { ); deviceHostName = deviceHostName.substring(deviceHostName.indexOf('=') + 1); - logger.v(deviceHostName); + logger.t(deviceHostName); deviceHostName = deviceHostName.replaceAll('-', '').replaceAll(' ', ''); physicalDeviceType = @@ -66,7 +66,7 @@ class DevicePinListManager extends DevicePinListManagerAbstract { physicalDeviceType = PhysicalDeviceType.raspberryPi; } - logger.v('phys type is $physicalDeviceType'); + logger.t('phys type is $physicalDeviceType'); } catch (e) { logger.w('Board type does not exist'); } diff --git a/lib/infrastructure/system_commands/system_commands_manager_d.dart b/lib/infrastructure/system_commands/system_commands_manager_d.dart index 481a51e5..f09304e2 100644 --- a/lib/infrastructure/system_commands/system_commands_manager_d.dart +++ b/lib/infrastructure/system_commands/system_commands_manager_d.dart @@ -11,10 +11,10 @@ import 'package:injectable/injectable.dart'; class SystemCommandsManager { SystemCommandsManager() { if (Platform.isLinux) { - logger.v('Linux platform detected in SystemCommandsManager'); + logger.t('Linux platform detected in SystemCommandsManager'); systemCommandsBaseClassD = CommonBashCommandsD(); } else if (Platform.isWindows) { - logger.v('Windows platform detected in SystemCommandsManager'); + logger.t('Windows platform detected in SystemCommandsManager'); systemCommandsBaseClassD = CommonBatchCommandsD(); } else if (Platform.isMacOS) { logger.w('Mac os is currently not supported in SystemCommandsManager'); diff --git a/pubspec.yaml b/pubspec.yaml index 877c1232..ab36be9d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -42,7 +42,7 @@ dependencies: # git: # url: 'https://github.com/guyluz11/hue_dart.git' # Convenient code generator for get_it - injectable: ^2.3.0 + injectable: ^2.3.1 # Utility library that checks for an Active Internet connection internet_connection_checker: ^1.0.0+1 # Extremely fast, easy to use, and fully async NoSQL database. @@ -74,12 +74,12 @@ dependencies: git: 'https://github.com/guyluz11/python_shell.dart.git' # Extends the capabilities of Dart Streams and StreamControllers. rxdart: ^0.27.7 - # Simple, fast generation of RFC4122 UUIDs. - uuid: ^4.1.0 # Communicate with Shelly smart devices shelly: ^1.0.0 # Control Switcher smart home accessories switcher_dart: ^1.0.0 + # Simple, fast generation of RFC4122 UUIDs. + uuid: ^4.1.0 # Dart library for controlling Yeelight products over LAN. yeedart: ^0.3.2 @@ -101,4 +101,4 @@ dev_dependencies: # Library for mocks mockito: ^5.4.2 # A full featured library for writing and running Dart tests across platforms. - test: ^1.24.6 + test: ^1.24.7 From fda0964105528d2535330b8f2bc49f5eb5ba7ba8 Mon Sep 17 00:00:00 2001 From: Guy Luz Date: Sat, 7 Oct 2023 16:26:54 +0300 Subject: [PATCH 09/18] Reverted package from local path to remote --- pubspec.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index ab36be9d..b53fe5c7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -38,9 +38,8 @@ dependencies: http: ^1.1.0 # Philips Hue API hue_dart: - path: ../hue_dart -# git: -# url: 'https://github.com/guyluz11/hue_dart.git' + git: + url: 'https://github.com/guyluz11/hue_dart.git' # Convenient code generator for get_it injectable: ^2.3.1 # Utility library that checks for an Active Internet connection From 3a68c6fa31dcdb19f803a104a2aa3fb4c2abbf4a Mon Sep 17 00:00:00 2001 From: Guy Luz Date: Sat, 7 Oct 2023 16:38:07 +0300 Subject: [PATCH 10/18] Removed some warnings --- .../esphome/esphome_api/esphome_api_client.dart | 10 +++++----- .../esphome/esphome_api/esphome_frame_helper.dart | 2 +- .../devices/esphome/esphome_helpers.dart | 13 +++++++------ .../devices/shelly/shelly_helpers.dart | 8 ++++---- .../sonoff_diy_api_device_abstract.dart | 3 ++- .../sonoff_diy_api/sonoff_diy_api_wall_switch.dart | 5 +++-- .../tasmota_ip_api/tasmota_ip_api_components.dart | 6 +++--- .../tuya_smart/tuya_smart_remote_api/cloudtuya.dart | 3 --- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/lib/infrastructure/devices/esphome/esphome_api/esphome_api_client.dart b/lib/infrastructure/devices/esphome/esphome_api/esphome_api_client.dart index deb74734..0434f188 100644 --- a/lib/infrastructure/devices/esphome/esphome_api/esphome_api_client.dart +++ b/lib/infrastructure/devices/esphome/esphome_api/esphome_api_client.dart @@ -536,7 +536,7 @@ class EspHomeApiClient { '${socket.remoteAddress.address}:${socket.remotePort}', ); - final PingRequest pingRequest = PingRequest(); + PingRequest(); const int numOfByteBeforeData = 3; @@ -571,7 +571,7 @@ class EspHomeApiClient { ' ${socket.remoteAddress.address}:${socket.remotePort}', ); - final DeviceInfoRequest deviceInfoRequest = DeviceInfoRequest(); + DeviceInfoRequest(); const int numOfByteBeforeData = 3; @@ -606,7 +606,7 @@ class EspHomeApiClient { ' ${socket.remoteAddress.address}:${socket.remotePort}', ); - final SubscribeStatesRequest subscribeStateReq = SubscribeStatesRequest(); + SubscribeStatesRequest(); const int numOfByteBeforeData = 3; @@ -710,7 +710,7 @@ class EspHomeApiClient { ' ${socket.remoteAddress.address}:${socket.remotePort}', ); - final ListEntitiesRequest listEntitiesRequest = ListEntitiesRequest(); + ListEntitiesRequest(); const int numOfByteBeforeData = 3; @@ -754,7 +754,7 @@ class EspHomeApiClient { /// fName = _connect_init_frame_helper /// Step 3 in connect process: initialize the frame helper and init read loop. Future connectInitFrameHelper() async { - final Socket socket = await getSocket(); + await getSocket(); await listenToResponses(); } diff --git a/lib/infrastructure/devices/esphome/esphome_api/esphome_frame_helper.dart b/lib/infrastructure/devices/esphome/esphome_api/esphome_frame_helper.dart index ccf6f139..22e95cf7 100644 --- a/lib/infrastructure/devices/esphome/esphome_api/esphome_frame_helper.dart +++ b/lib/infrastructure/devices/esphome/esphome_api/esphome_frame_helper.dart @@ -1,4 +1,4 @@ -/// data class from _frame_helper.py in aioesphomeapi +// data class from _frame_helper.py in aioesphomeapi /// aioesphomeapi: /// cName = Packet diff --git a/lib/infrastructure/devices/esphome/esphome_helpers.dart b/lib/infrastructure/devices/esphome/esphome_helpers.dart index 4b23282c..fffff82a 100644 --- a/lib/infrastructure/devices/esphome/esphome_helpers.dart +++ b/lib/infrastructure/devices/esphome/esphome_helpers.dart @@ -35,12 +35,13 @@ class EspHomeHelpers { espHomeNodeDeviceId ?? UniqueId().getOrCrash(); final EspHomeNodeRedApi espHomeNodeRedApi = EspHomeNodeRedApi( - repository: getIt(), - nodeRedApiBaseTopic: - getIt().getNodeRedApiBaseTopic(), - nodeRedDevicesTopic: - getIt().getNodeRedDevicesTopicTypeName(), - nodeRedMqttBrokerNodeName: 'Cbj NodeRed plugs Api Broker'); + repository: getIt(), + nodeRedApiBaseTopic: + getIt().getNodeRedApiBaseTopic(), + nodeRedDevicesTopic: + getIt().getNodeRedDevicesTopicTypeName(), + nodeRedMqttBrokerNodeName: 'Cbj NodeRed plugs Api Broker', + ); await espHomeNodeRedApi.setNewGlobalEspHomeDeviceNode( deviceMdnsName: mDnsName, diff --git a/lib/infrastructure/devices/shelly/shelly_helpers.dart b/lib/infrastructure/devices/shelly/shelly_helpers.dart index d7ddbc88..19ed5dfd 100644 --- a/lib/infrastructure/devices/shelly/shelly_helpers.dart +++ b/lib/infrastructure/devices/shelly/shelly_helpers.dart @@ -39,11 +39,11 @@ class ShellyHelpers { ); final String status = await shellyApiDeviceAbstract.getStatus(); - dynamic responseAsJson = json.decode(status); + final dynamic responseAsJson = json.decode(status); final String mac = responseAsJson['mac'] as String; - dynamic bulbLightProp = responseAsJson['lights'][0]; + final dynamic bulbLightProp = responseAsJson['lights'][0]; final String bulbMod = bulbLightProp['mode'] as String; shellyApiDeviceAbstract.bulbMode = @@ -112,11 +112,11 @@ class ShellyHelpers { ); final String status = await shellyApiDeviceAbstract.getStatus(); - dynamic responseAsJson = json.decode(status); + final dynamic responseAsJson = json.decode(status); final String mac = responseAsJson['mac'] as String; - dynamic bulbLightProp = responseAsJson['lights'][0]; + final dynamic bulbLightProp = responseAsJson['lights'][0]; shellyApiDeviceAbstract.bulbMode = ShellyBulbMode.white; diff --git a/lib/infrastructure/devices/sonoff_diy/sonoff_diy_api/sonoff_diy_api_device_abstract.dart b/lib/infrastructure/devices/sonoff_diy/sonoff_diy_api/sonoff_diy_api_device_abstract.dart index 680a9413..15088474 100644 --- a/lib/infrastructure/devices/sonoff_diy/sonoff_diy_api/sonoff_diy_api_device_abstract.dart +++ b/lib/infrastructure/devices/sonoff_diy/sonoff_diy_api/sonoff_diy_api_device_abstract.dart @@ -1,5 +1,6 @@ import 'dart:convert'; +import 'package:cbj_hub/utils.dart'; import 'package:http/http.dart' as http; abstract class SonoffApiDeviceAbstract { @@ -45,7 +46,7 @@ abstract class SonoffApiDeviceAbstract { final http.Response response = await http.post(url, body: body, headers: headers); final String responseJson = json.decode(response.body).toString(); - print(responseJson); + logger.t(responseJson); return responseJson; } diff --git a/lib/infrastructure/devices/sonoff_diy/sonoff_diy_api/sonoff_diy_api_wall_switch.dart b/lib/infrastructure/devices/sonoff_diy/sonoff_diy_api/sonoff_diy_api_wall_switch.dart index d0008c7b..52c7c62e 100644 --- a/lib/infrastructure/devices/sonoff_diy/sonoff_diy_api/sonoff_diy_api_wall_switch.dart +++ b/lib/infrastructure/devices/sonoff_diy/sonoff_diy_api/sonoff_diy_api_wall_switch.dart @@ -1,6 +1,7 @@ import 'dart:convert'; import 'package:cbj_hub/infrastructure/devices/sonoff_diy/sonoff_diy_api/sonoff_diy_api_device_abstract.dart'; +import 'package:cbj_hub/utils.dart'; import 'package:http/http.dart' as http; class SonoffDiyApiWallSwitch extends SonoffApiDeviceAbstract { @@ -29,7 +30,7 @@ class SonoffDiyApiWallSwitch extends SonoffApiDeviceAbstract { final http.Response response = await http.post(url, body: body, headers: headers); final String responseJson = json.decode(response.body).toString(); - print(responseJson); + logger.t(responseJson); return responseJson; } @@ -53,7 +54,7 @@ class SonoffDiyApiWallSwitch extends SonoffApiDeviceAbstract { final http.Response response = await http.post(url, body: body, headers: headers); final String responseJson = json.decode(response.body).toString(); - print(responseJson); + logger.t(responseJson); return responseJson; } diff --git a/lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_api/tasmota_ip_api_components.dart b/lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_api/tasmota_ip_api_components.dart index 658e253f..dad8f61f 100644 --- a/lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_api/tasmota_ip_api_components.dart +++ b/lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_api/tasmota_ip_api_components.dart @@ -1,6 +1,6 @@ -/// Values from here https://tasmota.github.io/docs/Components/ -/// Stored in the following way. -/// MapEntry(Number label: [UI Label, Comment]) +// Values from here https://tasmota.github.io/docs/Components/ +// Stored in the following way. +// MapEntry(Number label: [UI Label, Comment]) Map> gpioOverviewTasmota = { 0: ['None', 'Not used'], diff --git a/lib/infrastructure/devices/tuya_smart/tuya_smart_remote_api/cloudtuya.dart b/lib/infrastructure/devices/tuya_smart/tuya_smart_remote_api/cloudtuya.dart index 94c4b7e1..74973edf 100644 --- a/lib/infrastructure/devices/tuya_smart/tuya_smart_remote_api/cloudtuya.dart +++ b/lib/infrastructure/devices/tuya_smart/tuya_smart_remote_api/cloudtuya.dart @@ -109,7 +109,6 @@ class CloudTuya { final Response response = await consistentRequest(uriTemp, headers: headers, body: data); - final int statusCode = response.statusCode; final String responseBody = response.body; final dynamic a = json.decode(responseBody); @@ -158,7 +157,6 @@ class CloudTuya { final Response response = await consistentRequest(uriTemp, headers: headers, body: data); - final int statusCode = response.statusCode; final String responseBody = response.body; final dynamic a = json.decode(responseBody); @@ -221,7 +219,6 @@ class CloudTuya { final Response response = await consistentRequest(uriTemp, headers: headers, body: data); - final int statusCode = response.statusCode; final String responseBody = response.body; final dynamic responseDecoded = json.decode(responseBody); From 64d1d4dff8c83cd59c59d46d59f51cf0f0d5f025 Mon Sep 17 00:00:00 2001 From: Guy Luz Date: Fri, 13 Oct 2023 23:11:24 +0300 Subject: [PATCH 11/18] Moved controlling device logic to new repo --- bin/cbj_hub.dart | 32 +- lib/application/boot_up/boot_up.dart | 54 +- lib/application/connector/connector.dart | 41 +- .../i_app_communication_repository.dart | 8 +- lib/domain/binding/binding_cbj_entity.dart | 2 +- .../binding/binding_cbj_validators.dart | 2 +- .../binding/i_binding_cbj_repository.dart | 2 +- .../i_cbj_web_server_repository.dart | 6 + lib/domain/core/errors.dart | 18 - lib/domain/core/failures.dart | 40 - lib/domain/core/value_objects.dart | 52 - .../abstract_device/core_errors.dart | 14 - .../abstract_device/core_failures.dart | 33 - .../abstract_device/core_validators.dart | 101 - .../device_entity_abstract.dart | 281 - .../abstract_device/value_objects_core.dart | 394 -- .../generic_devices/device_type_enums.dart | 108 - .../generic_blinds_entity.dart | 199 - .../generic_blinds_validators.dart | 18 - .../generic_blinds_value_objects.dart | 22 - .../generic_boiler_entity.dart | 189 - .../generic_boiler_validators.dart | 17 - .../generic_boiler_value_objects.dart | 22 - .../generic_dimmable_light_entity.dart | 207 - .../generic_dimmable_light_validators.dart | 23 - .../generic_dimmable_light_value_objects.dart | 84 - .../generic_empty_entity.dart | 190 - .../generic_empty_validators.dart | 16 - .../generic_empty_value_objects.dart | 23 - .../generic_light_entity.dart | 188 - .../generic_light_validators.dart | 17 - .../generic_light_value_objects.dart | 22 - .../generic_ping_entity.dart | 190 - .../generic_ping_validators.dart | 16 - .../generic_ping_value_objects.dart | 23 - .../generic_printer_entity.dart | 190 - .../generic_printer_validators.dart | 17 - .../generic_printer_value_objects.dart | 22 - .../generic_rgbw_light_entity.dart | 276 - .../generic_rgbw_light_validators.dart | 50 - .../generic_rgbw_light_value_objects.dart | 131 - .../generic_smart_computer_entity.dart | 204 - .../generic_smart_computer_validators.dart | 18 - .../generic_smart_computer_value_objects.dart | 40 - .../generic_smart_plug_entity.dart | 188 - .../generic_smart_plug_validators.dart | 17 - .../generic_smart_plug_value_objects.dart | 23 - .../generic_smart_tv_entity.dart | 286 - .../generic_smart_tv_validators.dart | 46 - .../generic_smart_tv_value_objects.dart | 99 - ...neric_smart_type_not_supported_entity.dart | 176 - ...c_smart_type_not_supported_validators.dart | 14 - ...mart_type_not_supported_value_objects.dart | 17 - .../generic_switch_entity.dart | 188 - .../generic_switch_validators.dart | 17 - .../generic_switch_value_objects.dart | 23 - .../local_db/i_local_db_repository.dart | 161 - lib/domain/local_db/local_db_entity.dart | 30 - lib/domain/local_db/local_db_errors.dart | 14 - lib/domain/local_db/local_db_failures.dart | 20 - lib/domain/local_db/local_db_validators.dart | 30 - .../local_db/local_db_value_objects.dart | 129 - lib/domain/matirial_colors/colors.dart | 49 - .../mqtt_server/i_mqtt_server_repository.dart | 90 - lib/domain/rooms/i_saved_rooms_repo.dart | 10 +- .../routine/i_routine_cbj_repository.dart | 2 +- lib/domain/routine/routine_cbj_entity.dart | 2 +- .../routine/routine_cbj_validators.dart | 2 +- .../saved_devices/i_saved_devices_repo.dart | 38 - lib/domain/scene/i_scene_cbj_repository.dart | 6 +- lib/domain/scene/scene_cbj_entity.dart | 2 +- lib/domain/scene/scene_cbj_validators.dart | 2 +- .../generic_esphome_login_entity.dart | 62 - .../generic_esphome_login_validators.dart | 9 - .../generic_esphome_login_value_objects.dart | 18 - .../generic_ewelink_login_entity.dart | 68 - .../generic_ewelink_login_validators.dart | 8 - .../generic_ewelink_login_value_objects.dart | 32 - .../lifx_login/generic_lifx_login_entity.dart | 62 - .../generic_lifx_login_validators.dart | 8 - .../generic_lifx_login_value_objects.dart | 18 - .../login_abstract/core_login_errors.dart | 14 - .../login_abstract/core_login_failures.dart | 23 - .../login_abstract/core_login_validators.dart | 23 - .../login_abstract/login_entity_abstract.dart | 110 - .../value_login_objects_core.dart | 67 - .../tuya_login/generic_tuya_login_entity.dart | 90 - .../generic_tuya_login_validators.dart | 8 - .../generic_tuya_login_value_objects.dart | 74 - lib/domain/vendors/vendor_errors.dart | 14 - lib/domain/vendors/vendor_failures.dart | 63 - lib/domain/vendors/vendor_validators.dart | 14 - lib/domain/vendors/vendor_value_objects.dart | 50 - .../wiz_login/generic_wiz_login_entity.dart | 62 - .../generic_wiz_login_validators.dart | 8 - .../generic_wiz_login_value_objects.dart | 18 - .../generic_xiaomi_mi_login_entity.dart | 68 - .../generic_xiaomi_mi_login_validators.dart | 8 - ...generic_xiaomi_mi_login_value_objects.dart | 32 - .../app_communication_repository.dart | 72 +- .../app_communication/hub_app_server.dart | 11 +- .../bindings/binding_cbj_dtos.dart | 2 +- .../bindings/binding_repository.dart | 61 +- .../cbj_web_server_repository.dart | 13 +- .../cbj_devices_connector_conjector.dart | 116 - .../cbj_devices_device_validators.dart | 18 - .../cbj_devices_device_value_objects.dart | 34 - .../cbj_devices/cbj_devices_helpers.dart | 79 - .../cbj_smart_device_entity.dart | 184 - .../cbj_smart_device_api_object.dart | 679 --- .../cbj_smart_device_discover.dart | 50 - .../cbj_smart_device_packets.dart | 51 - .../cbj_smart_device_client.dart | 124 - .../companies_connector_conjector.dart | 421 -- .../devices/device_helper/device_helper.dart | 62 - .../esphome_api/esphome_api_client.dart | 781 --- .../esphome_api_plaintext_frame_helper.dart | 1 - .../esphome/esphome_api/esphome_client.dart | 1 - .../esphome_api/esphome_frame_helper.dart | 58 - .../esphome_objects_as_dart_objects.dart | 10 - .../esphome/esphome_api/esphome_util.dart | 70 - .../esphome/esphome_connector_conjector.dart | 111 - .../esphome/esphome_device_validators.dart | 12 - .../esphome/esphome_device_value_objects.dart | 1 - .../devices/esphome/esphome_helpers.dart | 215 - .../esphome_light/esphome_light_entity.dart | 166 - .../esphome_python_api.dart | 173 - ...ome_python_api_light_info_object_type.dart | 65 - ...me_python_api_switch_info_object_type.dart | 57 - .../get_esphome_entities.py | 43 - ...urn_on_off_light_entity_esphome_devices.py | 34 - ...rn_on_off_switch_entity_esphome_devices.py | 34 - .../esphome_python_json_objects_type.dart | 54 - .../esphome_switch/esphome_switch_entity.dart | 166 - .../ewelink/ewelink_connector_conjector.dart | 160 - .../ewelink/ewelink_device_validators.dart | 12 - .../devices/ewelink/ewelink_helpers.dart | 120 - .../ewelink_switch/ewelink_switch_entity.dart | 159 - .../chrome_cast/chrome_cast_entity.dart | 378 -- .../google/google_connector_conjector.dart | 106 - .../google/google_device_validators.dart | 10 - .../devices/google/google_helpers.dart | 54 - .../devices/hp/hp_connector_conjector.dart | 95 - .../devices/hp/hp_device_validators.dart | 12 - .../devices/hp/hp_device_value_objects.dart | 1 - lib/infrastructure/devices/hp/hp_helpers.dart | 51 - .../hp/hp_printer/hp_printer_entity.dart | 98 - .../devices/lg/lg_connector_conjector.dart | 90 - .../devices/lg/lg_device_validators.dart | 10 - .../devices/lg/lg_device_value_objects.dart | 19 - lib/infrastructure/devices/lg/lg_helpers.dart | 42 - .../lg/lg_webos_tv/lg_webos_tv_entity.dart | 116 - .../lifx/lifx_connector_conjector.dart | 117 - .../devices/lifx/lifx_device_validators.dart | 10 - .../devices/lifx/lifx_helpers.dart | 61 - .../lifx/lifx_white/lifx_white_entity.dart | 213 - .../philips_hue_api_light.dart | 96 - .../philips_hue_connector_conjector.dart | 106 - .../philips_hue_device_validators.dart | 12 - .../philips_hue_e26_entity.dart | 219 - .../philips_hue/philips_hue_helpers.dart | 93 - .../shelly/shelly_connector_conjector.dart | 105 - .../shelly/shelly_device_validators.dart | 12 - .../shelly/shelly_device_value_objects.dart | 1 - .../devices/shelly/shelly_helpers.dart | 204 - .../shelly_light/shelly_light_entity.dart | 331 -- .../shelly_relay_switch_entity.dart | 136 - .../sonoff_diy_mod_wall_switch_entity.dart | 136 - .../sonoff_device_value_objects.dart | 1 - .../sonoff_diy_api_device_abstract.dart | 53 - .../sonoff_diy_api_wall_switch.dart | 61 - .../sonoff_diy_connector_conjector.dart | 84 - .../sonoff_diy_device_validators.dart | 14 - .../sonoff_diy/sonoff_diy_helpers.dart | 63 - .../switcher_connector_conjector.dart | 121 - .../switcher/switcher_device_validators.dart | 16 - .../devices/switcher/switcher_helpers.dart | 156 - .../switcher_runner_entity.dart | 193 - .../switcher_smart_plug_entity.dart | 187 - .../switcher_v2/switcher_v2_entity.dart | 185 - .../tasmota_ip_api_components.dart | 45 - .../tasmota_ip_connector_conjector.dart | 158 - .../tasmota_ip_device_validators.dart | 20 - .../tasmota_ip/tasmota_ip_helpers.dart | 136 - .../tasmota_ip_led/tasmota_ip_led_entity.dart | 172 - .../tasmota_ip_switch_entity.dart | 186 - .../tasmota_mqtt_connector_conjector.dart | 109 - .../tasmota_mqtt_device_validators.dart | 14 - .../tasmota_mqtt_device_value_objects.dart | 19 - .../tasmota_mqtt/tasmota_mqtt_helpers.dart | 103 - .../tasmota_mqtt_led_entity.dart | 135 - .../tuya_smart_connector_conjector.dart | 160 - .../tuya_smart_device_validators.dart | 23 - .../tuya_smart_device_value_objects.dart | 19 - .../tuya_smart/tuya_smart_helpers.dart | 152 - .../tuya_smart_jbt_a70_rgbcw_wf_entity.dart | 261 - .../tuya_smart_switch_entity.dart | 133 - .../tuya_smart_remote_api/cloudtuya.dart | 287 - .../tuya_device_abstract.dart | 32 - .../tuya_smart_remote_api/tuya_light.dart | 35 - .../tuya_smart_remote_api/tuya_switch.dart | 25 - .../tuya_smart_switch_entity.dart | 134 - .../devices/wiz/wiz_connector_conjector.dart | 146 - .../devices/wiz/wiz_device_validators.dart | 10 - .../devices/wiz/wiz_device_value_objects.dart | 19 - .../devices/wiz/wiz_helpers.dart | 43 - .../wiz/wiz_white/wiz_white_entity.dart | 144 - .../xiaomi_io_connector_conjector.dart | 132 - .../xiaomi_io_device_validators.dart | 12 - .../xiaomi_io_gpx3021gl_entity.dart | 210 - .../devices/xiaomi_io/xiaomi_io_helpers.dart | 69 - ...bulb_essential_white_and_color_entity.dart | 37 - .../yeelight_1se/yeelight_1se_entity.dart | 551 -- .../yeelight_connector_conjector.dart | 117 - .../yeelight/yeelight_device_validators.dart | 10 - .../devices/yeelight/yeelight_helpers.dart | 76 - .../gen/aioesphomeapi/proto_gen_date.dart | 1 - .../protoc_as_dart/aioesphomeapi/api.pb.dart | 5232 ----------------- .../aioesphomeapi/api.pbenum.dart | 282 - .../aioesphomeapi/api.pbjson.dart | 1058 ---- .../aioesphomeapi/api.pbserver.dart | 93 - .../aioesphomeapi/api_options.pb.dart | 63 - .../aioesphomeapi/api_options.pbenum.dart | 28 - .../aioesphomeapi/api_options.pbjson.dart | 29 - .../aioesphomeapi/api_options.pbserver.dart | 9 - .../gen/cbj_hub_server/proto_gen_date.dart | 1 - .../protoc_as_dart/cbj_hub_server.pb.dart | 1258 ---- .../protoc_as_dart/cbj_hub_server.pbenum.dart | 498 -- .../protoc_as_dart/cbj_hub_server.pbgrpc.dart | 103 - .../protoc_as_dart/cbj_hub_server.pbjson.dart | 465 -- .../proto_gen_date.dart | 1 - .../cbj_smart_device_server.pb.dart | 1032 ---- .../cbj_smart_device_server.pbenum.dart | 139 - .../cbj_smart_device_server.pbgrpc.dart | 436 -- .../cbj_smart_device_server.pbjson.dart | 246 - .../abstract_company_connector_conjector.dart | 17 - .../device_entity_dto_abstract.dart | 90 - .../generic_blinds_device_dtos.dart | 116 - .../generic_boiler_device_dtos.dart | 116 - .../generic_dimmable_light_device_dtos.dart | 122 - .../generic_empty_device_dtos.dart | 116 - .../generic_light_device_dtos.dart | 116 - .../generic_ping_device_dtos.dart | 116 - .../generic_printer_device_dtos.dart | 120 - .../generic_rgbw_light_device_dtos.dart | 138 - .../generic_smart_computer_device_dtos.dart | 126 - .../generic_smart_plug_device_dtos.dart | 118 - .../generic_smart_tv_device_dtos.dart | 132 - ..._smart_type_not_supported_device_dtos.dart | 119 - .../generic_switch_device_dtos.dart | 116 - .../generic_esphome_login_dtos.dart | 59 - .../generic_ewelink_login_dtos.dart | 63 - .../generic_lifx_login_dtos.dart | 57 - .../login_entity_dto_abstract.dart | 52 - .../generic_tuya_login_dtos.dart | 70 - .../generic_wiz_login_dtos.dart | 57 - .../generic_xiaomi_mi_login_dtos.dart | 63 - .../generic_vendors_login/vendor_helper.dart | 62 - .../hive_objects/bindings_hive_model.dart | 9 - .../hive_objects/devices_hive_model.dart | 9 - ...esphome_vendor_credentials_hive_model.dart | 11 - ...ewelink_vendor_credentials_hive_model.dart | 13 - .../hive_objects/hub_entity_hive_model.dart | 15 - .../lifx_vendor_credentials_hive_model.dart | 11 - .../hive_objects/remote_pipes_hive_model.dart | 9 - .../hive_objects/rooms_hive_model.dart | 27 - .../hive_objects/routines_hive_model.dart | 9 - .../hive_objects/scenes_hive_model.dart | 9 - .../tuya_vendor_credentials_hive_model.dart | 21 - ...aomi_mi_vendor_credentials_hive_model.dart | 13 - .../isar_old_objects/bindings_isar_model.dart | 9 - .../isar_old_objects/devices_isar_model.dart | 9 - .../hub_entity_isar_model.dart | 12 - .../lifx_vendor_credentials_isar_model.dart | 16 - .../remote_pipes_isar_model.dart | 10 - .../isar_old_objects/rooms_isar_model.dart | 19 - .../isar_old_objects/routines_isar_model.dart | 9 - .../isar_old_objects/scenes_isar_model.dart | 9 - .../tuya_vendor_credentials_isar_model.dart | 16 - .../local_db/local_db_hive_repository.dart | 1183 ---- .../local_db_isar_repository_old.dart | 812 --- .../mqtt_server/mqtt_server_repository.dart | 42 +- .../node_red/node_red_converter.dart | 6 +- .../remote_pipes/remote_pipes_client.dart | 13 +- lib/infrastructure/room/saved_rooms_repo.dart | 74 +- .../routines/routine_cbj_dtos.dart | 2 +- .../routines/routine_repository.dart | 65 +- .../saved_devices/saved_devices_repo.dart | 149 - .../bed_room_area_actions.dart | 4 +- .../outside_area_actions.dart | 4 +- .../study_room_area_actions.dart | 4 +- .../video_games_area_actions.dart | 4 +- .../work_room_area_actions.dart | 4 +- .../area_type_with_device_type_preset.dart | 14 +- ...on_devices_scenes_presets_for_devices.dart | 20 +- lib/infrastructure/scenes/scene_cbj_dtos.dart | 2 +- .../scenes/scene_repository.dart | 63 +- .../bash_commands_for_raspberry_pi_d.dart | 25 - .../common_bash_commands_d.dart | 165 - .../common_batch_commands_d.dart | 141 - .../system_commands/device_pin_manager.dart | 97 - .../system_commands_base_class_d.dart | 29 - .../system_commands_manager_d.dart | 73 - lib/injection.config.dart | 140 +- lib/injection.dart | 46 +- pubspec.yaml | 9 +- 306 files changed, 386 insertions(+), 35000 deletions(-) delete mode 100644 lib/domain/core/errors.dart delete mode 100644 lib/domain/core/failures.dart delete mode 100644 lib/domain/core/value_objects.dart delete mode 100644 lib/domain/generic_devices/abstract_device/core_errors.dart delete mode 100644 lib/domain/generic_devices/abstract_device/core_failures.dart delete mode 100644 lib/domain/generic_devices/abstract_device/core_validators.dart delete mode 100644 lib/domain/generic_devices/abstract_device/device_entity_abstract.dart delete mode 100644 lib/domain/generic_devices/abstract_device/value_objects_core.dart delete mode 100644 lib/domain/generic_devices/device_type_enums.dart delete mode 100644 lib/domain/generic_devices/generic_blinds_device/generic_blinds_entity.dart delete mode 100644 lib/domain/generic_devices/generic_blinds_device/generic_blinds_validators.dart delete mode 100644 lib/domain/generic_devices/generic_blinds_device/generic_blinds_value_objects.dart delete mode 100644 lib/domain/generic_devices/generic_boiler_device/generic_boiler_entity.dart delete mode 100644 lib/domain/generic_devices/generic_boiler_device/generic_boiler_validators.dart delete mode 100644 lib/domain/generic_devices/generic_boiler_device/generic_boiler_value_objects.dart delete mode 100644 lib/domain/generic_devices/generic_dimmable_light_device/generic_dimmable_light_entity.dart delete mode 100644 lib/domain/generic_devices/generic_dimmable_light_device/generic_dimmable_light_validators.dart delete mode 100644 lib/domain/generic_devices/generic_dimmable_light_device/generic_dimmable_light_value_objects.dart delete mode 100644 lib/domain/generic_devices/generic_empty_device/generic_empty_entity.dart delete mode 100644 lib/domain/generic_devices/generic_empty_device/generic_empty_validators.dart delete mode 100644 lib/domain/generic_devices/generic_empty_device/generic_empty_value_objects.dart delete mode 100644 lib/domain/generic_devices/generic_light_device/generic_light_entity.dart delete mode 100644 lib/domain/generic_devices/generic_light_device/generic_light_validators.dart delete mode 100644 lib/domain/generic_devices/generic_light_device/generic_light_value_objects.dart delete mode 100644 lib/domain/generic_devices/generic_ping_device/generic_ping_entity.dart delete mode 100644 lib/domain/generic_devices/generic_ping_device/generic_ping_validators.dart delete mode 100644 lib/domain/generic_devices/generic_ping_device/generic_ping_value_objects.dart delete mode 100644 lib/domain/generic_devices/generic_printer_device/generic_printer_entity.dart delete mode 100644 lib/domain/generic_devices/generic_printer_device/generic_printer_validators.dart delete mode 100644 lib/domain/generic_devices/generic_printer_device/generic_printer_value_objects.dart delete mode 100644 lib/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_entity.dart delete mode 100644 lib/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_validators.dart delete mode 100644 lib/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_value_objects.dart delete mode 100644 lib/domain/generic_devices/generic_smart_computer_device/generic_smart_computer_entity.dart delete mode 100644 lib/domain/generic_devices/generic_smart_computer_device/generic_smart_computer_validators.dart delete mode 100644 lib/domain/generic_devices/generic_smart_computer_device/generic_smart_computer_value_objects.dart delete mode 100644 lib/domain/generic_devices/generic_smart_plug_device/generic_smart_plug_entity.dart delete mode 100644 lib/domain/generic_devices/generic_smart_plug_device/generic_smart_plug_validators.dart delete mode 100644 lib/domain/generic_devices/generic_smart_plug_device/generic_smart_plug_value_objects.dart delete mode 100644 lib/domain/generic_devices/generic_smart_tv/generic_smart_tv_entity.dart delete mode 100644 lib/domain/generic_devices/generic_smart_tv/generic_smart_tv_validators.dart delete mode 100644 lib/domain/generic_devices/generic_smart_tv/generic_smart_tv_value_objects.dart delete mode 100644 lib/domain/generic_devices/generic_smart_type_not_supported_device/generic_smart_type_not_supported_entity.dart delete mode 100644 lib/domain/generic_devices/generic_smart_type_not_supported_device/generic_smart_type_not_supported_validators.dart delete mode 100644 lib/domain/generic_devices/generic_smart_type_not_supported_device/generic_smart_type_not_supported_value_objects.dart delete mode 100644 lib/domain/generic_devices/generic_switch_device/generic_switch_entity.dart delete mode 100644 lib/domain/generic_devices/generic_switch_device/generic_switch_validators.dart delete mode 100644 lib/domain/generic_devices/generic_switch_device/generic_switch_value_objects.dart delete mode 100644 lib/domain/local_db/i_local_db_repository.dart delete mode 100644 lib/domain/local_db/local_db_entity.dart delete mode 100644 lib/domain/local_db/local_db_errors.dart delete mode 100644 lib/domain/local_db/local_db_failures.dart delete mode 100644 lib/domain/local_db/local_db_validators.dart delete mode 100644 lib/domain/local_db/local_db_value_objects.dart delete mode 100644 lib/domain/matirial_colors/colors.dart delete mode 100644 lib/domain/mqtt_server/i_mqtt_server_repository.dart delete mode 100644 lib/domain/saved_devices/i_saved_devices_repo.dart delete mode 100644 lib/domain/vendors/esphome_login/generic_esphome_login_entity.dart delete mode 100644 lib/domain/vendors/esphome_login/generic_esphome_login_validators.dart delete mode 100644 lib/domain/vendors/esphome_login/generic_esphome_login_value_objects.dart delete mode 100644 lib/domain/vendors/ewelink_login/generic_ewelink_login_entity.dart delete mode 100644 lib/domain/vendors/ewelink_login/generic_ewelink_login_validators.dart delete mode 100644 lib/domain/vendors/ewelink_login/generic_ewelink_login_value_objects.dart delete mode 100644 lib/domain/vendors/lifx_login/generic_lifx_login_entity.dart delete mode 100644 lib/domain/vendors/lifx_login/generic_lifx_login_validators.dart delete mode 100644 lib/domain/vendors/lifx_login/generic_lifx_login_value_objects.dart delete mode 100644 lib/domain/vendors/login_abstract/core_login_errors.dart delete mode 100644 lib/domain/vendors/login_abstract/core_login_failures.dart delete mode 100644 lib/domain/vendors/login_abstract/core_login_validators.dart delete mode 100644 lib/domain/vendors/login_abstract/login_entity_abstract.dart delete mode 100644 lib/domain/vendors/login_abstract/value_login_objects_core.dart delete mode 100644 lib/domain/vendors/tuya_login/generic_tuya_login_entity.dart delete mode 100644 lib/domain/vendors/tuya_login/generic_tuya_login_validators.dart delete mode 100644 lib/domain/vendors/tuya_login/generic_tuya_login_value_objects.dart delete mode 100644 lib/domain/vendors/vendor_errors.dart delete mode 100644 lib/domain/vendors/vendor_failures.dart delete mode 100644 lib/domain/vendors/vendor_validators.dart delete mode 100644 lib/domain/vendors/vendor_value_objects.dart delete mode 100644 lib/domain/vendors/wiz_login/generic_wiz_login_entity.dart delete mode 100644 lib/domain/vendors/wiz_login/generic_wiz_login_validators.dart delete mode 100644 lib/domain/vendors/wiz_login/generic_wiz_login_value_objects.dart delete mode 100644 lib/domain/vendors/xiaomi_mi_login/generic_xiaomi_mi_login_entity.dart delete mode 100644 lib/domain/vendors/xiaomi_mi_login/generic_xiaomi_mi_login_validators.dart delete mode 100644 lib/domain/vendors/xiaomi_mi_login/generic_xiaomi_mi_login_value_objects.dart delete mode 100644 lib/infrastructure/devices/cbj_devices/cbj_devices_connector_conjector.dart delete mode 100644 lib/infrastructure/devices/cbj_devices/cbj_devices_device_validators.dart delete mode 100644 lib/infrastructure/devices/cbj_devices/cbj_devices_device_value_objects.dart delete mode 100644 lib/infrastructure/devices/cbj_devices/cbj_devices_helpers.dart delete mode 100644 lib/infrastructure/devices/cbj_devices/cbj_smart_device/cbj_smart_device_entity.dart delete mode 100644 lib/infrastructure/devices/cbj_devices/cbj_smart_device_api/cbj_smart_device_api_object.dart delete mode 100644 lib/infrastructure/devices/cbj_devices/cbj_smart_device_api/cbj_smart_device_discover.dart delete mode 100644 lib/infrastructure/devices/cbj_devices/cbj_smart_device_api/cbj_smart_device_packets.dart delete mode 100644 lib/infrastructure/devices/cbj_devices/cbj_smart_device_client/cbj_smart_device_client.dart delete mode 100644 lib/infrastructure/devices/companies_connector_conjector.dart delete mode 100644 lib/infrastructure/devices/device_helper/device_helper.dart delete mode 100644 lib/infrastructure/devices/esphome/esphome_api/esphome_api_client.dart delete mode 100644 lib/infrastructure/devices/esphome/esphome_api/esphome_api_plaintext_frame_helper.dart delete mode 100644 lib/infrastructure/devices/esphome/esphome_api/esphome_client.dart delete mode 100644 lib/infrastructure/devices/esphome/esphome_api/esphome_frame_helper.dart delete mode 100644 lib/infrastructure/devices/esphome/esphome_api/esphome_objects_as_dart_objects.dart delete mode 100644 lib/infrastructure/devices/esphome/esphome_api/esphome_util.dart delete mode 100644 lib/infrastructure/devices/esphome/esphome_connector_conjector.dart delete mode 100644 lib/infrastructure/devices/esphome/esphome_device_validators.dart delete mode 100644 lib/infrastructure/devices/esphome/esphome_device_value_objects.dart delete mode 100644 lib/infrastructure/devices/esphome/esphome_helpers.dart delete mode 100644 lib/infrastructure/devices/esphome/esphome_light/esphome_light_entity.dart delete mode 100644 lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_api.dart delete mode 100644 lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_api_device_types/esphome_python_api_light_info_object_type.dart delete mode 100644 lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_api_device_types/esphome_python_api_switch_info_object_type.dart delete mode 100644 lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_files/get_esphome_entities.py delete mode 100644 lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_files/turn_on_off_light_entity_esphome_devices.py delete mode 100644 lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_files/turn_on_off_switch_entity_esphome_devices.py delete mode 100644 lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_json_objects_type.dart delete mode 100644 lib/infrastructure/devices/esphome/esphome_switch/esphome_switch_entity.dart delete mode 100644 lib/infrastructure/devices/ewelink/ewelink_connector_conjector.dart delete mode 100644 lib/infrastructure/devices/ewelink/ewelink_device_validators.dart delete mode 100644 lib/infrastructure/devices/ewelink/ewelink_helpers.dart delete mode 100644 lib/infrastructure/devices/ewelink/ewelink_switch/ewelink_switch_entity.dart delete mode 100644 lib/infrastructure/devices/google/chrome_cast/chrome_cast_entity.dart delete mode 100644 lib/infrastructure/devices/google/google_connector_conjector.dart delete mode 100644 lib/infrastructure/devices/google/google_device_validators.dart delete mode 100644 lib/infrastructure/devices/google/google_helpers.dart delete mode 100644 lib/infrastructure/devices/hp/hp_connector_conjector.dart delete mode 100644 lib/infrastructure/devices/hp/hp_device_validators.dart delete mode 100644 lib/infrastructure/devices/hp/hp_device_value_objects.dart delete mode 100644 lib/infrastructure/devices/hp/hp_helpers.dart delete mode 100644 lib/infrastructure/devices/hp/hp_printer/hp_printer_entity.dart delete mode 100644 lib/infrastructure/devices/lg/lg_connector_conjector.dart delete mode 100644 lib/infrastructure/devices/lg/lg_device_validators.dart delete mode 100644 lib/infrastructure/devices/lg/lg_device_value_objects.dart delete mode 100644 lib/infrastructure/devices/lg/lg_helpers.dart delete mode 100644 lib/infrastructure/devices/lg/lg_webos_tv/lg_webos_tv_entity.dart delete mode 100644 lib/infrastructure/devices/lifx/lifx_connector_conjector.dart delete mode 100644 lib/infrastructure/devices/lifx/lifx_device_validators.dart delete mode 100644 lib/infrastructure/devices/lifx/lifx_helpers.dart delete mode 100644 lib/infrastructure/devices/lifx/lifx_white/lifx_white_entity.dart delete mode 100644 lib/infrastructure/devices/philips_hue/philips_hue_api/philips_hue_api_light.dart delete mode 100644 lib/infrastructure/devices/philips_hue/philips_hue_connector_conjector.dart delete mode 100644 lib/infrastructure/devices/philips_hue/philips_hue_device_validators.dart delete mode 100644 lib/infrastructure/devices/philips_hue/philips_hue_e26/philips_hue_e26_entity.dart delete mode 100644 lib/infrastructure/devices/philips_hue/philips_hue_helpers.dart delete mode 100644 lib/infrastructure/devices/shelly/shelly_connector_conjector.dart delete mode 100644 lib/infrastructure/devices/shelly/shelly_device_validators.dart delete mode 100644 lib/infrastructure/devices/shelly/shelly_device_value_objects.dart delete mode 100644 lib/infrastructure/devices/shelly/shelly_helpers.dart delete mode 100644 lib/infrastructure/devices/shelly/shelly_light/shelly_light_entity.dart delete mode 100644 lib/infrastructure/devices/shelly/shelly_relay_switch/shelly_relay_switch_entity.dart delete mode 100644 lib/infrastructure/devices/sonoff_diy/sonoff__diy_wall_switch/sonoff_diy_mod_wall_switch_entity.dart delete mode 100644 lib/infrastructure/devices/sonoff_diy/sonoff_device_value_objects.dart delete mode 100644 lib/infrastructure/devices/sonoff_diy/sonoff_diy_api/sonoff_diy_api_device_abstract.dart delete mode 100644 lib/infrastructure/devices/sonoff_diy/sonoff_diy_api/sonoff_diy_api_wall_switch.dart delete mode 100644 lib/infrastructure/devices/sonoff_diy/sonoff_diy_connector_conjector.dart delete mode 100644 lib/infrastructure/devices/sonoff_diy/sonoff_diy_device_validators.dart delete mode 100644 lib/infrastructure/devices/sonoff_diy/sonoff_diy_helpers.dart delete mode 100644 lib/infrastructure/devices/switcher/switcher_connector_conjector.dart delete mode 100644 lib/infrastructure/devices/switcher/switcher_device_validators.dart delete mode 100644 lib/infrastructure/devices/switcher/switcher_helpers.dart delete mode 100644 lib/infrastructure/devices/switcher/switcher_runner/switcher_runner_entity.dart delete mode 100644 lib/infrastructure/devices/switcher/switcher_smart_plug/switcher_smart_plug_entity.dart delete mode 100644 lib/infrastructure/devices/switcher/switcher_v2/switcher_v2_entity.dart delete mode 100644 lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_api/tasmota_ip_api_components.dart delete mode 100644 lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_connector_conjector.dart delete mode 100644 lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_device_validators.dart delete mode 100644 lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_helpers.dart delete mode 100644 lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_led/tasmota_ip_led_entity.dart delete mode 100644 lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_switch/tasmota_ip_switch_entity.dart delete mode 100644 lib/infrastructure/devices/tasmota/tasmota_mqtt/tasmota_mqtt_connector_conjector.dart delete mode 100644 lib/infrastructure/devices/tasmota/tasmota_mqtt/tasmota_mqtt_device_validators.dart delete mode 100644 lib/infrastructure/devices/tasmota/tasmota_mqtt/tasmota_mqtt_device_value_objects.dart delete mode 100644 lib/infrastructure/devices/tasmota/tasmota_mqtt/tasmota_mqtt_helpers.dart delete mode 100644 lib/infrastructure/devices/tasmota/tasmota_mqtt/tasmota_mqtt_led/tasmota_mqtt_led_entity.dart delete mode 100644 lib/infrastructure/devices/tuya_smart/tuya_smart_connector_conjector.dart delete mode 100644 lib/infrastructure/devices/tuya_smart/tuya_smart_device_validators.dart delete mode 100644 lib/infrastructure/devices/tuya_smart/tuya_smart_device_value_objects.dart delete mode 100644 lib/infrastructure/devices/tuya_smart/tuya_smart_helpers.dart delete mode 100644 lib/infrastructure/devices/tuya_smart/tuya_smart_jbt_a70_rgbcw_wf/tuya_smart_jbt_a70_rgbcw_wf_entity.dart delete mode 100644 lib/infrastructure/devices/tuya_smart/tuya_smart_plug/tuya_smart_switch_entity.dart delete mode 100644 lib/infrastructure/devices/tuya_smart/tuya_smart_remote_api/cloudtuya.dart delete mode 100644 lib/infrastructure/devices/tuya_smart/tuya_smart_remote_api/tuya_device_abstract.dart delete mode 100644 lib/infrastructure/devices/tuya_smart/tuya_smart_remote_api/tuya_light.dart delete mode 100644 lib/infrastructure/devices/tuya_smart/tuya_smart_remote_api/tuya_switch.dart delete mode 100644 lib/infrastructure/devices/tuya_smart/tuya_smart_switch/tuya_smart_switch_entity.dart delete mode 100644 lib/infrastructure/devices/wiz/wiz_connector_conjector.dart delete mode 100644 lib/infrastructure/devices/wiz/wiz_device_validators.dart delete mode 100644 lib/infrastructure/devices/wiz/wiz_device_value_objects.dart delete mode 100644 lib/infrastructure/devices/wiz/wiz_helpers.dart delete mode 100644 lib/infrastructure/devices/wiz/wiz_white/wiz_white_entity.dart delete mode 100644 lib/infrastructure/devices/xiaomi_io/xiaomi_io_connector_conjector.dart delete mode 100644 lib/infrastructure/devices/xiaomi_io/xiaomi_io_device_validators.dart delete mode 100644 lib/infrastructure/devices/xiaomi_io/xiaomi_io_gpx3021gl/xiaomi_io_gpx3021gl_entity.dart delete mode 100644 lib/infrastructure/devices/xiaomi_io/xiaomi_io_helpers.dart delete mode 100644 lib/infrastructure/devices/xiaomi_io/xiaomi_led_smart_bulb_essential_white_and_color/xiaomi_led_smart_bulb_essential_white_and_color_entity.dart delete mode 100644 lib/infrastructure/devices/yeelight/yeelight_1se/yeelight_1se_entity.dart delete mode 100644 lib/infrastructure/devices/yeelight/yeelight_connector_conjector.dart delete mode 100644 lib/infrastructure/devices/yeelight/yeelight_device_validators.dart delete mode 100644 lib/infrastructure/devices/yeelight/yeelight_helpers.dart delete mode 100644 lib/infrastructure/gen/aioesphomeapi/proto_gen_date.dart delete mode 100644 lib/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api.pb.dart delete mode 100644 lib/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api.pbenum.dart delete mode 100644 lib/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api.pbjson.dart delete mode 100644 lib/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api.pbserver.dart delete mode 100644 lib/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api_options.pb.dart delete mode 100644 lib/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api_options.pbenum.dart delete mode 100644 lib/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api_options.pbjson.dart delete mode 100644 lib/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api_options.pbserver.dart delete mode 100644 lib/infrastructure/gen/cbj_hub_server/proto_gen_date.dart delete mode 100644 lib/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pb.dart delete mode 100644 lib/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbenum.dart delete mode 100644 lib/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart delete mode 100644 lib/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbjson.dart delete mode 100644 lib/infrastructure/gen/cbj_smart_device_server/proto_gen_date.dart delete mode 100644 lib/infrastructure/gen/cbj_smart_device_server/protoc_as_dart/cbj_smart_device_server.pb.dart delete mode 100644 lib/infrastructure/gen/cbj_smart_device_server/protoc_as_dart/cbj_smart_device_server.pbenum.dart delete mode 100644 lib/infrastructure/gen/cbj_smart_device_server/protoc_as_dart/cbj_smart_device_server.pbgrpc.dart delete mode 100644 lib/infrastructure/gen/cbj_smart_device_server/protoc_as_dart/cbj_smart_device_server.pbjson.dart delete mode 100644 lib/infrastructure/generic_devices/abstract_device/abstract_company_connector_conjector.dart delete mode 100644 lib/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart delete mode 100644 lib/infrastructure/generic_devices/generic_blinds_device/generic_blinds_device_dtos.dart delete mode 100644 lib/infrastructure/generic_devices/generic_boiler_device/generic_boiler_device_dtos.dart delete mode 100644 lib/infrastructure/generic_devices/generic_dimmable_light_device/generic_dimmable_light_device_dtos.dart delete mode 100644 lib/infrastructure/generic_devices/generic_empty_device/generic_empty_device_dtos.dart delete mode 100644 lib/infrastructure/generic_devices/generic_light_device/generic_light_device_dtos.dart delete mode 100644 lib/infrastructure/generic_devices/generic_ping_device/generic_ping_device_dtos.dart delete mode 100644 lib/infrastructure/generic_devices/generic_printer_device/generic_printer_device_dtos.dart delete mode 100644 lib/infrastructure/generic_devices/generic_rgbw_light_device/generic_rgbw_light_device_dtos.dart delete mode 100644 lib/infrastructure/generic_devices/generic_smart_computer_device/generic_smart_computer_device_dtos.dart delete mode 100644 lib/infrastructure/generic_devices/generic_smart_plug_device/generic_smart_plug_device_dtos.dart delete mode 100644 lib/infrastructure/generic_devices/generic_smart_tv_device/generic_smart_tv_device_dtos.dart delete mode 100644 lib/infrastructure/generic_devices/generic_smart_type_type_not_supported_device/generic_smart_type_not_supported_device_dtos.dart delete mode 100644 lib/infrastructure/generic_devices/generic_switch_device/generic_switch_device_dtos.dart delete mode 100644 lib/infrastructure/generic_vendors_login/generic_esphome_login/generic_esphome_login_dtos.dart delete mode 100644 lib/infrastructure/generic_vendors_login/generic_ewelink_login/generic_ewelink_login_dtos.dart delete mode 100644 lib/infrastructure/generic_vendors_login/generic_lifx_login/generic_lifx_login_dtos.dart delete mode 100644 lib/infrastructure/generic_vendors_login/generic_login_abstract/login_entity_dto_abstract.dart delete mode 100644 lib/infrastructure/generic_vendors_login/generic_tuya_login/generic_tuya_login_dtos.dart delete mode 100644 lib/infrastructure/generic_vendors_login/generic_wiz_login/generic_wiz_login_dtos.dart delete mode 100644 lib/infrastructure/generic_vendors_login/generic_xiaomi_mi_login/generic_xiaomi_mi_login_dtos.dart delete mode 100644 lib/infrastructure/generic_vendors_login/vendor_helper.dart delete mode 100644 lib/infrastructure/local_db/hive_objects/bindings_hive_model.dart delete mode 100644 lib/infrastructure/local_db/hive_objects/devices_hive_model.dart delete mode 100644 lib/infrastructure/local_db/hive_objects/esphome_vendor_credentials_hive_model.dart delete mode 100644 lib/infrastructure/local_db/hive_objects/ewelink_vendor_credentials_hive_model.dart delete mode 100644 lib/infrastructure/local_db/hive_objects/hub_entity_hive_model.dart delete mode 100644 lib/infrastructure/local_db/hive_objects/lifx_vendor_credentials_hive_model.dart delete mode 100644 lib/infrastructure/local_db/hive_objects/remote_pipes_hive_model.dart delete mode 100644 lib/infrastructure/local_db/hive_objects/rooms_hive_model.dart delete mode 100644 lib/infrastructure/local_db/hive_objects/routines_hive_model.dart delete mode 100644 lib/infrastructure/local_db/hive_objects/scenes_hive_model.dart delete mode 100644 lib/infrastructure/local_db/hive_objects/tuya_vendor_credentials_hive_model.dart delete mode 100644 lib/infrastructure/local_db/hive_objects/xiaomi_mi_vendor_credentials_hive_model.dart delete mode 100644 lib/infrastructure/local_db/isar_old_objects/bindings_isar_model.dart delete mode 100644 lib/infrastructure/local_db/isar_old_objects/devices_isar_model.dart delete mode 100644 lib/infrastructure/local_db/isar_old_objects/hub_entity_isar_model.dart delete mode 100644 lib/infrastructure/local_db/isar_old_objects/lifx_vendor_credentials_isar_model.dart delete mode 100644 lib/infrastructure/local_db/isar_old_objects/remote_pipes_isar_model.dart delete mode 100644 lib/infrastructure/local_db/isar_old_objects/rooms_isar_model.dart delete mode 100644 lib/infrastructure/local_db/isar_old_objects/routines_isar_model.dart delete mode 100644 lib/infrastructure/local_db/isar_old_objects/scenes_isar_model.dart delete mode 100644 lib/infrastructure/local_db/isar_old_objects/tuya_vendor_credentials_isar_model.dart delete mode 100644 lib/infrastructure/local_db/local_db_hive_repository.dart delete mode 100644 lib/infrastructure/local_db/local_db_isar_repository_old.dart delete mode 100644 lib/infrastructure/saved_devices/saved_devices_repo.dart delete mode 100644 lib/infrastructure/system_commands/bash_commands_d/bash_commands_for_raspberry_pi_d.dart delete mode 100644 lib/infrastructure/system_commands/bash_commands_d/common_bash_commands_d.dart delete mode 100644 lib/infrastructure/system_commands/batch_commands_d/common_batch_commands_d.dart delete mode 100644 lib/infrastructure/system_commands/device_pin_manager.dart delete mode 100644 lib/infrastructure/system_commands/system_commands_base_class_d.dart delete mode 100644 lib/infrastructure/system_commands/system_commands_manager_d.dart diff --git a/bin/cbj_hub.dart b/bin/cbj_hub.dart index 391d69e3..e94b882c 100644 --- a/bin/cbj_hub.dart +++ b/bin/cbj_hub.dart @@ -1,34 +1,12 @@ -import 'dart:io'; - import 'package:cbj_hub/application/boot_up/boot_up.dart'; -import 'package:cbj_hub/domain/local_db/i_local_db_repository.dart'; -import 'package:cbj_hub/infrastructure/shared_variables.dart'; -import 'package:cbj_hub/infrastructure/system_commands/device_pin_manager.dart'; -import 'package:cbj_hub/injection.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:network_tools/network_tools.dart'; +import 'package:cbj_integrations_controller/initialize_integrations_controller.dart'; +import 'package:cbj_integrations_controller/injection.dart'; +import 'package:network_tools/network_tools.dart' as network; Future main(List arguments) async { // arguments[0] is the location of the project - configureNetworkTools('network_tools_db'); - configureInjection(Env.prod); - - try { - if (arguments.length > 1) { - await getIt().asyncConstractor(arguments[0]); - } else { - await getIt().asyncConstractor(Directory.current.path); - } - } catch (error) { - logger.w('Path/argument 1 is not specified\n$error'); - } - - // Setting device model and checking if configuration for this model exist - await DevicePinListManager().setPhysicalDeviceType(); - - await getIt().initializeDb(); - - logger.t(''); + network.configureNetworkTools('network_tools_db'); + await initializeIntegrationsController(arguments: arguments, env: Env.prod); await BootUp.setup(); } diff --git a/lib/application/boot_up/boot_up.dart b/lib/application/boot_up/boot_up.dart index e79498e1..aff965c0 100644 --- a/lib/application/boot_up/boot_up.dart +++ b/lib/application/boot_up/boot_up.dart @@ -1,12 +1,8 @@ import 'package:cbj_hub/application/connector/connector.dart'; -import 'package:cbj_hub/domain/cbj_web_server/i_cbj_web_server_repository.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart'; -import 'package:cbj_hub/domain/rooms/i_saved_rooms_repo.dart'; -import 'package:cbj_hub/domain/saved_devices/i_saved_devices_repo.dart'; -import 'package:cbj_hub/domain/scene/i_scene_cbj_repository.dart'; -import 'package:cbj_hub/infrastructure/devices/companies_connector_conjector.dart'; -import 'package:cbj_hub/injection.dart'; +import 'package:cbj_hub/infrastructure/cbj_web_server/cbj_web_server_repository.dart'; +import 'package:cbj_hub/infrastructure/mqtt_server/mqtt_server_repository.dart'; +import 'package:cbj_hub/infrastructure/room/saved_rooms_repo.dart'; +import 'package:cbj_integrations_controller/initialize_integrations_controller.dart'; class BootUp { BootUp() { @@ -15,35 +11,25 @@ class BootUp { static Future setup() async { // Return all saved rooms - final ISavedRoomsRepo savedRoomsRepo = getIt(); - final ISceneCbjRepository savedScenesRepo = getIt(); + // TODO: Fix after new cbj_integrations_controller + // final ISavedRoomsRepo savedRoomsRepo = ISavedRoomsRepo.instance; + // TODO: Fix after new cbj_integrations_controller + // final ISceneCbjRepository savedScenesRepo = getItCbj(); - await savedRoomsRepo.getAllRooms(); + // await savedRoomsRepo.getAllRooms(); + // + // await savedScenesRepo.getAllScenesAsMap(); + setInstancesOfRepos(); - await savedScenesRepo.getAllScenesAsMap(); - - // Return all saved devices - final ISavedDevicesRepo savedDevicesRepo = getIt(); - - final Map allDevices = - await savedDevicesRepo.getAllDevices(); - - CompaniesConnectorConjector.addAllDevicesToItsRepos(allDevices); - - CompaniesConnectorConjector.searchAllMdnsDevicesAndSetThemUp(); - - CompaniesConnectorConjector.searchPingableDevicesAndSetThemUpByHostName(); - - CompaniesConnectorConjector.searchDevicesByBindingIntoSockets(); - - CompaniesConnectorConjector.searchDevicesByMqttPath(); - - CompaniesConnectorConjector.notImplementedDevicesSearch(); - - await getIt().asyncConstractor(); - - getIt(); + await setupIntegrationsController(); Connector.startConnector(); } + + /// All instances of Repos + static void setInstancesOfRepos() { + MqttServerRepository(); + CbjWebServerRepository(); + SavedRoomsRepo(); + } } diff --git a/lib/application/connector/connector.dart b/lib/application/connector/connector.dart index 5a47ea38..c31e15cf 100644 --- a/lib/application/connector/connector.dart +++ b/lib/application/connector/connector.dart @@ -1,19 +1,18 @@ import 'dart:async'; import 'dart:convert'; -import 'package:cbj_hub/domain/app_communication/i_app_communication_repository.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart'; import 'package:cbj_hub/domain/room/room_entity.dart'; import 'package:cbj_hub/domain/room/value_objects_room.dart'; import 'package:cbj_hub/domain/rooms/i_saved_rooms_repo.dart'; -import 'package:cbj_hub/domain/saved_devices/i_saved_devices_repo.dart'; import 'package:cbj_hub/infrastructure/app_communication/app_communication_repository.dart'; -import 'package:cbj_hub/infrastructure/devices/companies_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:cbj_hub/injection.dart'; -import 'package:cbj_hub/utils.dart'; +import 'package:cbj_integrations_controller/domain/mqtt_server/i_mqtt_server_repository.dart'; +import 'package:cbj_integrations_controller/domain/saved_devices/i_saved_devices_repo.dart'; +import 'package:cbj_integrations_controller/infrastructure/devices/companies_connector_conjector.dart'; +import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; +import 'package:cbj_integrations_controller/injection.dart'; +import 'package:cbj_integrations_controller/utils.dart'; import 'package:mqtt_client/mqtt_client.dart'; import 'package:rxdart/rxdart.dart'; @@ -24,7 +23,7 @@ class Connector { /// Data will probably arrive to the function /// updateAllDevicesReposWithDeviceChanges where we listen to request from /// the mqtt with this path - await getIt() + await IMqttServerRepository.instance .publishDeviceEntity(entityForMqtt.value as DeviceEntityAbstract); } else if (entityForMqtt.value is RoomEntity) { // TODO: Create MQTT support for rooms @@ -34,7 +33,7 @@ class Connector { } }); - final ISavedDevicesRepo savedDevicesRepo = getIt(); + final ISavedDevicesRepo savedDevicesRepo = getItCbj(); final Map allDevices = await savedDevicesRepo.getAllDevices(); @@ -48,13 +47,12 @@ class Connector { } Future.delayed(const Duration(milliseconds: 3000)).whenComplete(() { - // final IAppCommunicationRepository appCommunication = - getIt(); + AppCommunicationRepository(); }); - getIt().allHubDevicesSubscriptions(); + IMqttServerRepository.instance.allHubDevicesSubscriptions(); - getIt().sendToApp(); + IMqttServerRepository.instance.sendToApp(); CompaniesConnectorConjector.updateAllDevicesReposWithDeviceChanges( ConnectorDevicesStreamFromMqtt.fromMqttStream, @@ -68,7 +66,7 @@ class Connector { static Future updateDevicesFromMqttDeviceChange( MapEntry> deviceChangeFromMqtt, ) async { - final ISavedDevicesRepo savedDevicesRepo = getIt(); + final ISavedDevicesRepo savedDevicesRepo = getItCbj(); final Map allDevices = await savedDevicesRepo.getAllDevices(); @@ -113,12 +111,17 @@ class Connector { if (property == 'entityStateGRPC' && propertyValueString == EntityStateGRPC.ack.toString()) { final Map rooms = - await getIt().getAllRooms(); + await ISavedRoomsRepo.instance.getAllRooms(); HubRequestsToApp.streamRequestsToApp.sink .add(savedDeviceWithSameIdAsMqtt.toInfrastructure()); - if (rooms[RoomUniqueId.discoveredRoomId().getOrCrash()]! - .roomDevicesId + final RoomEntity? discoverRoom = + rooms[RoomUniqueId.discoveredRoomId().getOrCrash()]; + if (discoverRoom == null) { + continue; + } + + if (discoverRoom.roomDevicesId .getOrCrash() .contains(savedDeviceWithSameIdAsMqtt.uniqueId.getOrCrash())) { HubRequestsToApp.streamRequestsToApp.sink.add( diff --git a/lib/domain/app_communication/i_app_communication_repository.dart b/lib/domain/app_communication/i_app_communication_repository.dart index 6da74b57..e726f147 100644 --- a/lib/domain/app_communication/i_app_communication_repository.dart +++ b/lib/domain/app_communication/i_app_communication_repository.dart @@ -1,7 +1,13 @@ -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; +import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:mqtt_client/mqtt_client.dart'; abstract class IAppCommunicationRepository { + IAppCommunicationRepository() { + instance = this; + } + + static late IAppCommunicationRepository instance; + Future getFromApp({ required Stream request, required String requestUrl, diff --git a/lib/domain/binding/binding_cbj_entity.dart b/lib/domain/binding/binding_cbj_entity.dart index 1dbc9101..b6d62cd6 100644 --- a/lib/domain/binding/binding_cbj_entity.dart +++ b/lib/domain/binding/binding_cbj_entity.dart @@ -1,6 +1,6 @@ import 'package:cbj_hub/domain/binding/value_objects_routine_cbj.dart'; -import 'package:cbj_hub/domain/core/value_objects.dart'; import 'package:cbj_hub/infrastructure/bindings/binding_cbj_dtos.dart'; +import 'package:cbj_integrations_controller/domain/core/value_objects.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; part 'binding_cbj_entity.freezed.dart'; diff --git a/lib/domain/binding/binding_cbj_validators.dart b/lib/domain/binding/binding_cbj_validators.dart index 75f09e07..241d4f1e 100644 --- a/lib/domain/binding/binding_cbj_validators.dart +++ b/lib/domain/binding/binding_cbj_validators.dart @@ -1,5 +1,5 @@ import 'package:cbj_hub/domain/binding/binding_cbj_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/device_type_enums.dart'; import 'package:dartz/dartz.dart'; Either, String> validateBindingNotEmpty( diff --git a/lib/domain/binding/i_binding_cbj_repository.dart b/lib/domain/binding/i_binding_cbj_repository.dart index ea91aa9c..36b101dd 100644 --- a/lib/domain/binding/i_binding_cbj_repository.dart +++ b/lib/domain/binding/i_binding_cbj_repository.dart @@ -1,6 +1,6 @@ import 'package:cbj_hub/domain/binding/binding_cbj_entity.dart'; import 'package:cbj_hub/domain/binding/binding_cbj_failures.dart'; -import 'package:cbj_hub/domain/local_db/local_db_failures.dart'; +import 'package:cbj_integrations_controller/domain/local_db/local_db_failures.dart'; import 'package:dartz/dartz.dart'; abstract class IBindingCbjRepository { diff --git a/lib/domain/cbj_web_server/i_cbj_web_server_repository.dart b/lib/domain/cbj_web_server/i_cbj_web_server_repository.dart index 56ab11df..d08dcb9a 100644 --- a/lib/domain/cbj_web_server/i_cbj_web_server_repository.dart +++ b/lib/domain/cbj_web_server/i_cbj_web_server_repository.dart @@ -2,6 +2,12 @@ /// well as website to change devices state locally on the network without /// the need of installing any app. abstract class ICbjWebServerRepository { + ICbjWebServerRepository() { + instance = this; + } + + static late ICbjWebServerRepository instance; + /// Start the web server Future startWebServer(); diff --git a/lib/domain/core/errors.dart b/lib/domain/core/errors.dart deleted file mode 100644 index 1ba30ffa..00000000 --- a/lib/domain/core/errors.dart +++ /dev/null @@ -1,18 +0,0 @@ -import 'package:cbj_hub/domain/core/failures.dart'; - -class NotAuthenticatedError extends Error {} - -class MissingCurrentHomeError extends Error {} - -class UnexpectedValueError extends Error { - UnexpectedValueError(this.authValueFailure); - - final AuthValueFailure authValueFailure; - - @override - String toString() { - const explanation = - 'Encountered a ValueFailure at an unrecoverable point. Terminating.'; - return Error.safeToString('$explanation Failure was: $authValueFailure'); - } -} diff --git a/lib/domain/core/failures.dart b/lib/domain/core/failures.dart deleted file mode 100644 index bb50a24e..00000000 --- a/lib/domain/core/failures.dart +++ /dev/null @@ -1,40 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'failures.freezed.dart'; - -/// Example how to use multiple failures types in one class -@freezed -class ValueFailure with _$ValueFailure { - const factory ValueFailure.auth(AuthValueFailure f) = _Auth; - - const factory ValueFailure.devices(AuthValueFailure f) = _Devices; -} - -/// If multiple failures is not needed just call a specific failure class -@freezed -class AuthValueFailure with _$AuthValueFailure { - const factory AuthValueFailure.invalidEmail({ - required String failedValue, - }) = InvalidEmail; - - const factory AuthValueFailure.invalidPassword({ - required String failedValue, - }) = InvalidPassword; - - const factory AuthValueFailure.shortPassword({ - required String failedValue, - }) = ShortPassword; - - const factory AuthValueFailure.containsSpace({ - required String failedValue, - }) = ContainsSpace; - - const factory AuthValueFailure.empty({ - required String failedValue, - }) = Empty; - - const factory AuthValueFailure.listTooLong({ - required T failedValue, - required int max, - }) = ListTooLong; -} diff --git a/lib/domain/core/value_objects.dart b/lib/domain/core/value_objects.dart deleted file mode 100644 index c2a82e68..00000000 --- a/lib/domain/core/value_objects.dart +++ /dev/null @@ -1,52 +0,0 @@ -import 'package:cbj_hub/domain/core/errors.dart'; -import 'package:cbj_hub/domain/core/failures.dart'; -import 'package:dartz/dartz.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:uuid/uuid.dart'; - -@immutable -abstract class ValueObject { - const ValueObject(); - - Either, T> get value; - - /// Throws [UnexpectedValueError] containing the [AuthValueFailure] - T getOrCrash() { - // id = identity - same as writing (right) => right - return value.fold((f) => throw UnexpectedValueError(f), id); - } - - Either, Unit> get failureOrUnit { - return value.fold((l) => left(l), (r) => right(unit)); - } - - bool isValid() => value.isRight(); - - @override - String toString() => 'Value($value)'; - - @override - @nonVirtual - bool operator ==(Object o) { - if (identical(this, o)) return true; - return o is ValueObject && o.value == value; - } - - @override - int get hashCode => value.hashCode; -} - -class UniqueId extends ValueObject { - factory UniqueId() { - return UniqueId._(right(const Uuid().v1())); - } - - factory UniqueId.fromUniqueString(String uniqueId) { - return UniqueId._(right(uniqueId)); - } - - const UniqueId._(this.value); - - @override - final Either, String> value; -} diff --git a/lib/domain/generic_devices/abstract_device/core_errors.dart b/lib/domain/generic_devices/abstract_device/core_errors.dart deleted file mode 100644 index 73c2769b..00000000 --- a/lib/domain/generic_devices/abstract_device/core_errors.dart +++ /dev/null @@ -1,14 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; - -class CoreUnexpectedValueError extends Error { - CoreUnexpectedValueError(this.deviceValueFailure); - - final CoreFailure deviceValueFailure; - - @override - String toString() { - const explanation = - 'Encountered a ValueFailure at an unrecoverable point. Terminating.'; - return Error.safeToString('$explanation Failure was: $deviceValueFailure'); - } -} diff --git a/lib/domain/generic_devices/abstract_device/core_failures.dart b/lib/domain/generic_devices/abstract_device/core_failures.dart deleted file mode 100644 index 5dcb8c54..00000000 --- a/lib/domain/generic_devices/abstract_device/core_failures.dart +++ /dev/null @@ -1,33 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'core_failures.freezed.dart'; - -@freezed -class CoreFailure { - const factory CoreFailure.empty({ - required T failedValue, - }) = _Empty; - - const factory CoreFailure.actionExcecuter({ - required T failedValue, - }) = _ActionExcecuter; - - const factory CoreFailure.exceedingLength({ - required T failedValue, - required int max, - }) = _ExceedingLength; - - const factory CoreFailure.unexpected() = _Unexpected; - - const factory CoreFailure.insufficientPermission() = _InsufficientPermission; - - const factory CoreFailure.unableToUpdate() = _UnableToUpdate; - - const factory CoreFailure.powerConsumptionIsNotNumber() = - _PowerConsumptionIsNotNumber; - - const factory CoreFailure.deviceActionDoesNotExist() = - _DeviceActionDoesNotExist; - - const factory CoreFailure.deviceTypeDoesNotExist() = _DeviceTypeDoesNotExist; -} diff --git a/lib/domain/generic_devices/abstract_device/core_validators.dart b/lib/domain/generic_devices/abstract_device/core_validators.dart deleted file mode 100644 index 22d4d11b..00000000 --- a/lib/domain/generic_devices/abstract_device/core_validators.dart +++ /dev/null @@ -1,101 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateNotEmpty(String input) { - if (input.isNotEmpty) { - return right(input); - } else { - return left( - CoreFailure.empty( - failedValue: input, - ), - ); - } -} - -Either, String> validateLastKnownIpNotEmpty(String input) { - // if (input.isNotEmpty) { - return right(input); - // } else { - // return left( - // CoreFailure.empty( - // failedValue: input, - // ), - // ); - // } -} - -Either, String> validatePowerConsumptionNotEmpty( - String input, -) { - if (double.tryParse(input) != null) { - return right(input); - } else { - return left(const CoreFailure.powerConsumptionIsNotNumber()); - } -} - -Either, String> validateRoomNameNotEmpty(String input) { - return right(input); -} - -Either, String> validateMdnsNameNotEmpty(String input) { - return right(input); -} - -Either, String> validateWiFiNameNotEmpty(String input) { - return right(input); -} - -Either, String> validatePortNotEmpty(String input) { - return right(input); -} - -Either, String> validateKeyNotEmpty(String input) { - return right(input); -} - -Either, String> validateMaxNameLength( - String input, - int maxLength, -) { - if (input.length <= maxLength) { - return right(input); - } else { - return left( - CoreFailure.exceedingLength( - failedValue: input, - max: maxLength, - ), - ); - } -} - -Either, String> validateDeviceStateExist(String input) { - if (EnumHelperCbj.stringToDeviceState(input) != null) { - return right(input); - } - return left(const CoreFailure.deviceActionDoesNotExist()); -} - -Either, String> validateDeviceActionExist(String input) { - if (EnumHelperCbj.stringToDeviceAction(input) != null) { - return right(input); - } - return left(const CoreFailure.deviceActionDoesNotExist()); -} - -Either, String> validateDeviceTypeExist(String input) { - if (EnumHelperCbj.stringToDt(input) != null) { - return right(input); - } - return left(const CoreFailure.deviceTypeDoesNotExist()); -} - -Either, String> validateDeviceVendorExist(String input) { - if (EnumHelperCbj.stringToDeviceVendor(input) != null) { - return right(input); - } - return left(const CoreFailure.deviceTypeDoesNotExist()); -} diff --git a/lib/domain/generic_devices/abstract_device/device_entity_abstract.dart b/lib/domain/generic_devices/abstract_device/device_entity_abstract.dart deleted file mode 100644 index b1f0743b..00000000 --- a/lib/domain/generic_devices/abstract_device/device_entity_abstract.dart +++ /dev/null @@ -1,281 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:dartz/dartz.dart'; -import 'package:uuid/uuid.dart'; - -/// We are using the term entity to describe individual integrations on a single device -/// So for example switch with three buttons will have three entities -abstract class DeviceEntityAbstract { - DeviceEntityAbstract({ - required this.uniqueId, - required this.entityUniqueId, - required this.deviceVendor, - required this.entityTypes, - required this.cbjEntityName, - required this.stateMassage, - required this.senderDeviceOs, - required this.senderDeviceModel, - required this.senderId, - required this.compUuid, - required this.entityStateGRPC, - required this.entityOriginalName, - required this.deviceOriginalName, - required this.powerConsumption, - required this.deviceUniqueId, - required this.devicePort, - required this.deviceLastKnownIp, - required this.deviceHostName, - required this.deviceMdns, - required this.devicesMacAddress, - required this.entityKey, - required this.requestTimeStamp, - required this.lastResponseFromDeviceTimeStamp, - required this.deviceCbjUniqueId, - }); - - /// The unique id that CyBear Jinni Hub gave the device - CoreUniqueId uniqueId; - - /// The unique id that each company gave their device - EntityUniqueId entityUniqueId; - - /// The name to show in cbj app, can be changed by the use - CbjEntityName cbjEntityName; - - /// The name of the entity from the vendor api, user should only view it - EntityOriginalName entityOriginalName; - - /// The name of the device that the entity exist on from the api, user should only view it - DeviceOriginalName deviceOriginalName; - - /// Did the massage arrived or was it just sent. - /// Will be 'set' (need change) or 'ack' for acknowledge - EntityState entityStateGRPC; - - /// If state didn't change the error description will be found here. - DeviceStateMassage stateMassage; - - /// Sender GenericLight os type, example: android, iphone, browser - DeviceSenderDeviceOs senderDeviceOs; - - /// The sender GenericLight model; example: onePlus 3T - DeviceSenderDeviceModel senderDeviceModel; - - /// Last GenericLight sender id that activated the action - DeviceSenderId senderId; - - /// The smart entity type - EntityType entityTypes; - - /// The smart GenericLight type - DeviceVendor deviceVendor; - - /// Unique id of the computer - DeviceCompUuid compUuid; - - /// Power consumption of the device - DevicePowerConsumption powerConsumption; - - /// Unique id of the device that the entity exists on - DeviceUniqueId deviceUniqueId; - - /// Port of the device - DevicePort devicePort; - - /// Last known ip - DeviceLastKnownIp deviceLastKnownIp; - - /// Device Host name - DeviceHostName deviceHostName; - - /// Device Mdns - DeviceMdns deviceMdns; - - /// Mac address of the device - DevicesMacAddress devicesMacAddress; - - /// Some entities will use key to transmit the states via the api - EntityKey entityKey; - - /// Time that the action got sent from the app - RequestTimeStamp requestTimeStamp; - - /// Time of the last response from the device - LastResponseFromDeviceTimeStamp lastResponseFromDeviceTimeStamp; - - /// Unique id that cbj creates for the device that the entity is stored on - CoreUniqueId deviceCbjUniqueId; - - String getDeviceId(); - - /// Copy with device state to waiting or ack - DeviceEntityAbstract copyWithDeviceState(EntityStateGRPC entityStateGRPC) { - return this; - } - - /// Copy with device action - DeviceEntityAbstract copyWithDeviceAction(EntityActions deviceActions) { - return this; - } - - /// Copy with stateMassage - DeviceEntityAbstract copyWithStateMassage(String stateMassage) { - return this; - } - - /// Copy with senderDeviceOs - DeviceEntityAbstract copyWithSenderDeviceOs(String senderDeviceOs) { - return this; - } - - /// Copy with deviceSenderDeviceModel - DeviceEntityAbstract copyWithDeviceSenderDeviceModel( - String deviceSenderDeviceModel, - ) { - return this; - } - - /// Copy with currentUserId - DeviceEntityAbstract copyWithSenderId(String userId) { - return this; - } - - /// Convert the device to the a dtos object in the infrastructure layer - DeviceEntityDtoAbstract toInfrastructure() { - return DeviceEntityDtoAbstract(); - } - - /// Please override the following methods - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }); - - /// Return a list of all valid actions for this device - List getAllValidActions(); - - /// Will replace action field with new action if it exists inside the object - bool replaceActionIfExist(String action); - - /// List of all the properties that their value can be change when creating a - /// scene for that device - List getListOfPropertiesToChange(); -} - -class DeviceEntityNotAbstract extends DeviceEntityAbstract { - DeviceEntityNotAbstract() - : super( - uniqueId: CoreUniqueId(), - entityUniqueId: EntityUniqueId('Entity unique id is empty'), - deviceVendor: DeviceVendor( - VendorsAndServices.vendorsAndServicesNotSupported.toString(), - ), - entityStateGRPC: - EntityState(EntityTypes.smartTypeNotSupported.toString()), - compUuid: DeviceCompUuid(const Uuid().v1()), - cbjEntityName: CbjEntityName('Cbj entity Name is empty'), - entityOriginalName: - EntityOriginalName('Entity original name is empty'), - deviceOriginalName: DeviceOriginalName( - 'Device original name that entity is exists on is empty', - ), - entityTypes: EntityType(EntityTypes.light.toString()), - senderDeviceModel: DeviceSenderDeviceModel('a'), - senderDeviceOs: DeviceSenderDeviceOs('b'), - senderId: DeviceSenderId(), - stateMassage: DeviceStateMassage('go'), - powerConsumption: DevicePowerConsumption('0'), - deviceUniqueId: DeviceUniqueId('Device unique id is empty'), - devicePort: DevicePort('1'), - deviceLastKnownIp: DeviceLastKnownIp('1.1.1.1'), - deviceHostName: DeviceHostName('deviceHostName is empty'), - deviceMdns: DeviceMdns('deviceMdns is empty'), - devicesMacAddress: DevicesMacAddress('devicesMacAddress is empty'), - entityKey: EntityKey('entityKey is empty'), - requestTimeStamp: RequestTimeStamp('requestTimeStamp is empty'), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp( - 'lastResponseFromDeviceTimeStamp is empty', - ), - deviceCbjUniqueId: CoreUniqueId(), - ); - - @override - DeviceEntityDtoAbstract toInfrastructure() { - return DeviceEntityDtoAbstract(); - } - - @override - String getDeviceId() { - throw UnimplementedError(); - } - - /// Return a list of all valid actions for this device - @override - List getAllValidActions() { - return []; - } - - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) { - // TODO: implement executeDeviceAction - throw UnimplementedError(); - } - - @override - bool replaceActionIfExist(String action) { - return false; - } - - @override - List getListOfPropertiesToChange() { - return []; - } -} - -// -// part 'device_entity_abstract.freezed.dart'; -// -// /// Abstract smart device that exist inside a computer, the implementations will -// /// be actual device like blinds lights and more -// @freezed -// abstract class DeviceEntityAbstract implements _$DeviceEntityAbstract { -// /// All public field of device entity -// const factory DeviceEntityAbstract({ -// /// The smart device id -// required EntityUniqueId? id, -// -// /// The default name of the device -// required CbjEntityName? cbjEntityName, -// }) = _DeviceEntityAbstract; -// -// const DeviceEntityAbstract._(); -// -// /// Empty instance of DeviceEntity -// factory DeviceEntityAbstract.empty() => DeviceEntityAbstract( -// id: EntityUniqueId(), -// cbjEntityName: CbjEntityName(''), -// ); -// -// /// Will return failure if any of the fields failed or return unit if fields -// /// have legit values -// Option> get failureOption { -// return cbjEntityName!.value.fold((f) => some(f), (_) => none()); -// // -// // return body.failureOrUnit -// // .andThen(todos.failureOrUnit) -// // .andThen( -// // todos -// // .getOrCrash() -// // // Getting the failureOption from the TodoItem ENTITY - NOT a failureOrUnit from a VALUE OBJECT -// // .map((todoItem) => todoItem.failureOption) -// // .filter((o) => o.isSome()) -// // // If we can't get the 0th element, the list is empty. In such a case, it's valid. -// // .getOrElse(0, (_) => none()) -// // .fold(() => right(unit), (f) => left(f)), -// // ) -// // .fold((f) => some(f), (_) => none()); -// } -// } diff --git a/lib/domain/generic_devices/abstract_device/value_objects_core.dart b/lib/domain/generic_devices/abstract_device/value_objects_core.dart deleted file mode 100644 index c36f0013..00000000 --- a/lib/domain/generic_devices/abstract_device/value_objects_core.dart +++ /dev/null @@ -1,394 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_errors.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_validators.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:dartz/dartz.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:uuid/uuid.dart'; - -@immutable -abstract class ValueObjectCore { - const ValueObjectCore(); - - Either, T> get value; - - /// Throws [UnexpectedValueError] containing the [AuthValueFailure] - T getOrCrash() { - // id = identity - same as writing (right) => right - return value.fold((f) => throw CoreUnexpectedValueError(f), id); - } - - Either, Unit> get failureOrUnit { - return value.fold((l) => left(l), (r) => right(unit)); - } - - bool isValid() => value.isRight(); - - @override - String toString() => 'Value($value)'; - - @override - @nonVirtual - bool operator ==(Object o) { - if (identical(this, o)) return true; - return o is ValueObjectCore && o.value == value; - } - - @override - int get hashCode => value.hashCode; -} - -class CoreUniqueId extends ValueObjectCore { - factory CoreUniqueId() { - return CoreUniqueId._(right(const Uuid().v1())); - } - - factory CoreUniqueId.fromUniqueString(String uniqueId) { - return CoreUniqueId._(right(uniqueId)); - } - - const CoreUniqueId._(this.value); - - @override - final Either, String> value; -} - -/// Object that will store the unique id of the device that each vendor send -class EntityUniqueId extends ValueObjectCore { - factory EntityUniqueId(String? input) { - assert(input != null); - return EntityUniqueId._( - validateNotEmpty(input!), - ); - } - - const EntityUniqueId._(this.value); - - @override - final Either, String> value; -} - -class CbjEntityName extends ValueObjectCore { - factory CbjEntityName(String? input) { - assert(input != null); - return CbjEntityName._( - validateNotEmpty(input!) - .flatMap((a) => validateMaxNameLength(input, maxLength)), - ); - } - - const CbjEntityName._(this.value); - - @override - final Either, String?> value; - - static const maxLength = 1000; -} - -class EntityOriginalName extends ValueObjectCore { - factory EntityOriginalName(String? input) { - assert(input != null); - return EntityOriginalName._( - validateNotEmpty(input!) - .flatMap((a) => validateMaxNameLength(input, maxLength)), - ); - } - - const EntityOriginalName._(this.value); - - @override - final Either, String?> value; - - static const maxLength = 1000; -} - -class DeviceOriginalName extends ValueObjectCore { - factory DeviceOriginalName(String? input) { - assert(input != null); - return DeviceOriginalName._( - validateNotEmpty(input!) - .flatMap((a) => validateMaxNameLength(input, maxLength)), - ); - } - - const DeviceOriginalName._(this.value); - - @override - final Either, String?> value; - - static const maxLength = 1000; -} - -class EntityState extends ValueObjectCore { - factory EntityState(String? input) { - return EntityState._( - validateNotEmpty(input!).flatMap((a) => validateDeviceStateExist(input)), - ); - } - - const EntityState._(this.value); - - @override - final Either, String> value; -} - -class DeviceSenderDeviceOs extends ValueObjectCore { - factory DeviceSenderDeviceOs(String? input) { - assert(input != null); - return DeviceSenderDeviceOs._( - validateNotEmpty(input!), - ); - } - - const DeviceSenderDeviceOs._(this.value); - - @override - final Either, String> value; -} - -class DeviceStateMassage extends ValueObjectCore { - factory DeviceStateMassage(String? input) { - assert(input != null); - return DeviceStateMassage._( - validateNotEmpty(input!), - ); - } - - const DeviceStateMassage._(this.value); - - @override - final Either, String> value; -} - -class DeviceSenderDeviceModel extends ValueObjectCore { - factory DeviceSenderDeviceModel(String? input) { - assert(input != null); - return DeviceSenderDeviceModel._( - validateNotEmpty(input!), - ); - } - - const DeviceSenderDeviceModel._(this.value); - - @override - final Either, String> value; -} - -class DeviceSenderId extends ValueObjectCore { - factory DeviceSenderId() { - return DeviceSenderId._(right(const Uuid().v1())); - } - - factory DeviceSenderId.fromUniqueString(String? uniqueId) { - assert(uniqueId != null); - return DeviceSenderId._(right(uniqueId!)); - } - - const DeviceSenderId._(this.value); - - @override - final Either, String> value; -} - -class DeviceAction extends ValueObjectCore { - factory DeviceAction(String? input) { - assert(input != null); - - if (input == 'false') { - input = EntityActions.off.toString(); - } else if (input == 'true') { - input = EntityActions.on.toString(); - } - return DeviceAction._( - validateNotEmpty(input!) - .flatMap((a) => validateDeviceActionExist(input!)), - ); - } - - const DeviceAction._(this.value); - - @override - final Either, String> value; -} - -class EntityType extends ValueObjectCore { - factory EntityType(String? input) { - assert(input != null); - return EntityType._( - validateNotEmpty(input!).flatMap((a) => validateDeviceTypeExist(input)), - ); - } - - const EntityType._(this.value); - - @override - final Either, String> value; -} - -class DeviceVendor extends ValueObjectCore { - factory DeviceVendor(String? input) { - assert(input != null); - return DeviceVendor._( - validateNotEmpty(input!).flatMap((a) => validateDeviceVendorExist(input)), - ); - } - - const DeviceVendor._(this.value); - - @override - final Either, String> value; -} - -class DeviceCompUuid extends ValueObjectCore { - factory DeviceCompUuid(String? input) { - assert(input != null); - return DeviceCompUuid._( - validateNotEmpty(input!), - ); - } - - const DeviceCompUuid._(this.value); - - @override - final Either, String> value; -} - -class DeviceLastKnownIp extends ValueObjectCore { - factory DeviceLastKnownIp(String? input) { - assert(input != null); - return DeviceLastKnownIp._( - validateLastKnownIpNotEmpty(input!), - ); - } - - const DeviceLastKnownIp._(this.value); - - @override - final Either, String> value; -} - -class DevicePowerConsumption extends ValueObjectCore { - factory DevicePowerConsumption(String? input) { - assert(input != null); - return DevicePowerConsumption._( - validatePowerConsumptionNotEmpty(input!), - ); - } - - const DevicePowerConsumption._(this.value); - - @override - final Either, String> value; -} - -class DeviceMdns extends ValueObjectCore { - factory DeviceMdns(String? input) { - assert(input != null); - return DeviceMdns._( - validateMdnsNameNotEmpty(input!), - ); - } - - const DeviceMdns._(this.value); - - @override - final Either, String> value; -} - -class DevicePort extends ValueObjectCore { - factory DevicePort(String? input) { - assert(input != null); - return DevicePort._( - validatePortNotEmpty(input!), - ); - } - - const DevicePort._(this.value); - - @override - final Either, String> value; -} - -class EntityKey extends ValueObjectCore { - factory EntityKey(String? input) { - assert(input != null); - return EntityKey._( - validateKeyNotEmpty(input!), - ); - } - - const EntityKey._(this.value); - - @override - final Either, String> value; -} - -class DeviceUniqueId extends ValueObjectCore { - factory DeviceUniqueId(String? input) { - assert(input != null); - return DeviceUniqueId._( - validateNotEmpty(input!), - ); - } - - const DeviceUniqueId._(this.value); - - @override - final Either, String> value; -} - -class DeviceHostName extends ValueObjectCore { - factory DeviceHostName(String? input) { - assert(input != null); - return DeviceHostName._( - validateNotEmpty(input!), - ); - } - - const DeviceHostName._(this.value); - - @override - final Either, String> value; -} - -class RequestTimeStamp extends ValueObjectCore { - factory RequestTimeStamp(String? input) { - assert(input != null); - return RequestTimeStamp._( - validateNotEmpty(input!), - ); - } - - const RequestTimeStamp._(this.value); - - @override - final Either, String> value; -} - -class LastResponseFromDeviceTimeStamp extends ValueObjectCore { - factory LastResponseFromDeviceTimeStamp(String? input) { - assert(input != null); - return LastResponseFromDeviceTimeStamp._( - validateNotEmpty(input!), - ); - } - - const LastResponseFromDeviceTimeStamp._(this.value); - - @override - final Either, String> value; -} - -class DevicesMacAddress extends ValueObjectCore { - factory DevicesMacAddress(String? input) { - assert(input != null); - return DevicesMacAddress._( - validateNotEmpty(input!), - ); - } - - const DevicesMacAddress._(this.value); - - @override - final Either, String> value; -} diff --git a/lib/domain/generic_devices/device_type_enums.dart b/lib/domain/generic_devices/device_type_enums.dart deleted file mode 100644 index c303f4fe..00000000 --- a/lib/domain/generic_devices/device_type_enums.dart +++ /dev/null @@ -1,108 +0,0 @@ -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; - -/// List of all physical devices types -enum PhysicalDeviceType { - nanoPiDuo2, - nanoPiAir, - nanoPiNeo, - nanoPiNeo2, - raspberryPi, - notSupported, -} - -enum RaspberryPiType { - raspberryPi3ModelBRev1_2, - raspberryPi4ModelBRev1_4, -} - -class EnumHelperCbj { - static String dTToString(EntityTypes deviceType) { - return deviceType.toString().replaceAll('EntityState.', ''); - } - - static String deviceVendorToString(VendorsAndServices vendorsAndServices) { - return vendorsAndServices.toString().replaceAll('VendorsAndServices.', ''); - } - - static EntityTypes? stringToDt(String deviceTypeAsString) { - String deviceTypeAsStringTemp = deviceTypeAsString; - if (deviceTypeAsStringTemp.contains('Object')) { - deviceTypeAsStringTemp = deviceTypeAsStringTemp.substring( - 0, - deviceTypeAsStringTemp.indexOf('Object'), - ); - } - for (final EntityTypes deviceType in EntityTypes.values) { - if (dTToString(deviceType) == deviceTypeAsStringTemp) { - return deviceType; - } - } - return null; - } - - static VendorsAndServices? stringToDeviceVendor(String deviceVendorAsString) { - String deviceTypeAsStringTemp = deviceVendorAsString; - if (deviceTypeAsStringTemp.contains('Object')) { - deviceTypeAsStringTemp = deviceTypeAsStringTemp.substring( - 0, - deviceTypeAsStringTemp.indexOf('Object'), - ); - } - for (final VendorsAndServices deviceType in VendorsAndServices.values) { - if (deviceVendorToString(deviceType) == deviceTypeAsStringTemp) { - return deviceType; - } - } - return null; - } - - /// Convert deviceAction to string - static String deviceActionToString(EntityActions deviceAction) { - return deviceAction.toString().replaceAll('EntityActions.', ''); - } - - /// Convert string to deviceAction - static EntityActions? stringToDeviceAction(String deviceActionString) { - for (final EntityActions deviceAction in EntityActions.values) { - if (deviceActionToString(deviceAction) == deviceActionString) { - return deviceAction; - } - } - return null; - } - - /// Convert deviceState to string - static String deviceStateToString(EntityStateGRPC deviceState) { - return deviceState.toString().replaceAll('EntityStateGRPC.', ''); - } - - /// Convert string to deviceState - static EntityStateGRPC? stringToDeviceState(String deviceStateAsString) { - for (final EntityStateGRPC deviceState in EntityStateGRPC.values) { - if (deviceStateToString(deviceState) == deviceStateAsString) { - return deviceState; - } - } - return null; - } - - /// Convert physicalDeviceType to string - static String physicalDeviceTypeToString(PhysicalDeviceType? deviceType) { - return deviceType.toString().replaceAll('PhysicalDeviceType.', ''); - } - - /// Return the corresponding SmartDeviceBaseAbstract Object of the deviceType - static dynamic deviceTypeToSmartDeviceBaseAbstractObject( - EntityTypes deviceType, - ) { - throw Exception('$deviceType Conditioner was not implemented yet'); - } - - /// Returning the non abstract of this SmartDeviceBaseAbstract - static Type getTheNonAbstractObjectOfSmartDeviceBaseAbstract( - dynamic smartDeviceBaseAbstract, - EntityTypes deviceType, - ) { - throw Exception('$deviceType Conditioner was not implemented yet'); - } -} diff --git a/lib/domain/generic_devices/generic_blinds_device/generic_blinds_entity.dart b/lib/domain/generic_devices/generic_blinds_device/generic_blinds_entity.dart deleted file mode 100644 index 04085794..00000000 --- a/lib/domain/generic_devices/generic_blinds_device/generic_blinds_entity.dart +++ /dev/null @@ -1,199 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_blinds_device/generic_blinds_value_objects.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/generic_blinds_device/generic_blinds_device_dtos.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; - -/// Abstract smart GenericBlinds that exist inside a computer, the -/// implementations will be actual GenericBlinds like blinds blindss and more -class GenericBlindsDE extends DeviceEntityAbstract { - /// All public field of GenericBlinds entity - GenericBlindsDE({ - required super.uniqueId, - required super.entityUniqueId, - required super.deviceVendor, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.entityStateGRPC, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required this.blindsSwitchState, - }) : super( - entityTypes: EntityType(EntityTypes.blinds.toString()), - ); - - /// Empty instance of GenericBlindsEntity - factory GenericBlindsDE.empty() => GenericBlindsDE( - uniqueId: CoreUniqueId(), - entityUniqueId: EntityUniqueId(''), - cbjEntityName: CbjEntityName(''), - entityOriginalName: EntityOriginalName(''), - deviceOriginalName: DeviceOriginalName(''), - entityStateGRPC: EntityState(''), - senderDeviceOs: DeviceSenderDeviceOs(''), - senderDeviceModel: DeviceSenderDeviceModel(''), - stateMassage: DeviceStateMassage(''), - senderId: DeviceSenderId(), - deviceVendor: DeviceVendor(''), - deviceUniqueId: DeviceUniqueId(''), - devicePort: DevicePort(''), - deviceLastKnownIp: DeviceLastKnownIp(''), - deviceHostName: DeviceHostName(''), - deviceMdns: DeviceMdns(''), - compUuid: DeviceCompUuid(''), - powerConsumption: DevicePowerConsumption(''), - devicesMacAddress: DevicesMacAddress(''), - entityKey: EntityKey(''), - requestTimeStamp: RequestTimeStamp(''), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp(''), - deviceCbjUniqueId: CoreUniqueId(), - blindsSwitchState: - GenericBlindsSwitchState(EntityActions.off.toString()), - ); - - /// State of the blinds on/off - GenericBlindsSwitchState? blindsSwitchState; - - // - // /// Will return failure if any of the fields failed or return unit if fields - // /// have legit values - Option> get failureOption => - cbjEntityName.value.fold((f) => some(f), (_) => none()); - // - // return body.failureOrUnit - // .andThen(todos.failureOrUnit) - // .andThen( - // todos - // .getOrCrash() - // // Getting the failureOption from the TodoItem ENTITY - NOT a failureOrUnit from a VALUE OBJECT - // .map((todoItem) => todoItem.failureOption) - // .filter((o) => o.isSome()) - // // If we can't get the 0th element, the list is empty. In such a case, it's valid. - // .getOrElse(0, (_) => none()) - // .fold(() => right(unit), (f) => left(f)), - // ) - // .fold((f) => some(f), (_) => none()); - // } - - @override - String getDeviceId() { - return uniqueId.getOrCrash(); - } - - /// Return a list of all valid actions for this device - @override - List getAllValidActions() { - return GenericBlindsSwitchState.blindsValidActions(); - } - - @override - DeviceEntityDtoAbstract toInfrastructure() { - return GenericBlindsDeviceDtos( - deviceDtoClass: (GenericBlindsDeviceDtos).toString(), - id: uniqueId.getOrCrash(), - entityUniqueId: entityUniqueId.getOrCrash(), - cbjEntityName: cbjEntityName.getOrCrash(), - entityOriginalName: entityOriginalName.getOrCrash(), - deviceOriginalName: deviceOriginalName.getOrCrash(), - entityStateGRPC: entityStateGRPC.getOrCrash(), - stateMassage: stateMassage.getOrCrash(), - senderDeviceOs: senderDeviceOs.getOrCrash(), - senderDeviceModel: senderDeviceModel.getOrCrash(), - senderId: senderId.getOrCrash(), - entityTypes: entityTypes.getOrCrash(), - compUuid: compUuid.getOrCrash(), - blindsSwitchState: blindsSwitchState!.getOrCrash(), - deviceVendor: deviceVendor.getOrCrash(), - powerConsumption: powerConsumption.getOrCrash(), - deviceUniqueId: deviceUniqueId.getOrCrash(), - devicePort: devicePort.getOrCrash(), - deviceLastKnownIp: deviceLastKnownIp.getOrCrash(), - deviceHostName: deviceHostName.getOrCrash(), - deviceMdns: deviceMdns.getOrCrash(), - devicesMacAddress: devicesMacAddress.getOrCrash(), - entityKey: entityKey.getOrCrash(), - requestTimeStamp: requestTimeStamp.getOrCrash(), - lastResponseFromDeviceTimeStamp: - lastResponseFromDeviceTimeStamp.getOrCrash(), - deviceCbjUniqueId: deviceCbjUniqueId.getOrCrash(), - ); - } - - /// Please override the following methods - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> moveUpBlinds() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> stopBlinds() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> moveDownBlinds() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - @override - bool replaceActionIfExist(String action) { - if (GenericBlindsSwitchState.blindsValidActions().contains(action)) { - blindsSwitchState = GenericBlindsSwitchState(action); - return true; - } - return false; - } - - @override - List getListOfPropertiesToChange() { - return [ - 'blindsSwitchState', - ]; - } -} diff --git a/lib/domain/generic_devices/generic_blinds_device/generic_blinds_validators.dart b/lib/domain/generic_devices/generic_blinds_device/generic_blinds_validators.dart deleted file mode 100644 index cc879f12..00000000 --- a/lib/domain/generic_devices/generic_blinds_device/generic_blinds_validators.dart +++ /dev/null @@ -1,18 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateGenericBlindsStateNotEmpty( - String input, -) { - return right(input); -} - -/// Return all the valid actions for blinds -List blindsAllValidActions() { - return [ - EntityActions.moveUp.toString(), - EntityActions.stop.toString(), - EntityActions.moveDown.toString(), - ]; -} diff --git a/lib/domain/generic_devices/generic_blinds_device/generic_blinds_value_objects.dart b/lib/domain/generic_devices/generic_blinds_device/generic_blinds_value_objects.dart deleted file mode 100644 index d0d8c05b..00000000 --- a/lib/domain/generic_devices/generic_blinds_device/generic_blinds_value_objects.dart +++ /dev/null @@ -1,22 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_blinds_device/generic_blinds_validators.dart'; -import 'package:dartz/dartz.dart'; - -class GenericBlindsSwitchState extends ValueObjectCore { - factory GenericBlindsSwitchState(String? input) { - assert(input != null); - return GenericBlindsSwitchState._( - validateGenericBlindsStateNotEmpty(input!), - ); - } - - const GenericBlindsSwitchState._(this.value); - - @override - final Either, String> value; - - static List blindsValidActions() { - return blindsAllValidActions(); - } -} diff --git a/lib/domain/generic_devices/generic_boiler_device/generic_boiler_entity.dart b/lib/domain/generic_devices/generic_boiler_device/generic_boiler_entity.dart deleted file mode 100644 index 474dc6b4..00000000 --- a/lib/domain/generic_devices/generic_boiler_device/generic_boiler_entity.dart +++ /dev/null @@ -1,189 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_boiler_device/generic_boiler_value_objects.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/generic_boiler_device/generic_boiler_device_dtos.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; - -/// Abstract smart GenericBoiler that exist inside a computer, the -/// implementations will be actual GenericBoiler like boiler boilers and more -class GenericBoilerDE extends DeviceEntityAbstract { - /// All public field of GenericBoiler entity - GenericBoilerDE({ - required super.uniqueId, - required super.entityUniqueId, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.deviceVendor, - required super.entityStateGRPC, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required this.boilerSwitchState, - }) : super( - entityTypes: EntityType(EntityTypes.boiler.toString()), - ); - - /// Empty instance of GenericBoilerEntity - factory GenericBoilerDE.empty() => GenericBoilerDE( - uniqueId: CoreUniqueId(), - entityUniqueId: EntityUniqueId(''), - cbjEntityName: CbjEntityName(''), - entityOriginalName: EntityOriginalName(''), - deviceOriginalName: DeviceOriginalName(''), - entityStateGRPC: EntityState(''), - senderDeviceOs: DeviceSenderDeviceOs(''), - senderDeviceModel: DeviceSenderDeviceModel(''), - stateMassage: DeviceStateMassage(''), - senderId: DeviceSenderId(), - deviceVendor: DeviceVendor(''), - deviceUniqueId: DeviceUniqueId(''), - devicePort: DevicePort(''), - deviceLastKnownIp: DeviceLastKnownIp(''), - deviceHostName: DeviceHostName(''), - deviceMdns: DeviceMdns(''), - compUuid: DeviceCompUuid(''), - powerConsumption: DevicePowerConsumption(''), - devicesMacAddress: DevicesMacAddress(''), - entityKey: EntityKey(''), - requestTimeStamp: RequestTimeStamp(''), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp(''), - deviceCbjUniqueId: CoreUniqueId(), - boilerSwitchState: - GenericBoilerSwitchState(EntityActions.off.toString()), - ); - - /// State of the boiler on/off - GenericBoilerSwitchState? boilerSwitchState; - - // - // /// Will return failure if any of the fields failed or return unit if fields - // /// have legit values - Option> get failureOption => - cbjEntityName.value.fold((f) => some(f), (_) => none()); - // - // return body.failureOrUnit - // .andThen(todos.failureOrUnit) - // .andThen( - // todos - // .getOrCrash() - // // Getting the failureOption from the TodoItem ENTITY - NOT a failureOrUnit from a VALUE OBJECT - // .map((todoItem) => todoItem.failureOption) - // .filter((o) => o.isSome()) - // // If we can't get the 0th element, the list is empty. In such a case, it's valid. - // .getOrElse(0, (_) => none()) - // .fold(() => right(unit), (f) => left(f)), - // ) - // .fold((f) => some(f), (_) => none()); - // } - - @override - String getDeviceId() { - return uniqueId.getOrCrash(); - } - - /// Return a list of all valid actions for this device - @override - List getAllValidActions() { - return GenericBoilerSwitchState.boilerValidActions(); - } - - @override - DeviceEntityDtoAbstract toInfrastructure() { - return GenericBoilerDeviceDtos( - deviceDtoClass: (GenericBoilerDeviceDtos).toString(), - id: uniqueId.getOrCrash(), - entityUniqueId: entityUniqueId.getOrCrash(), - cbjEntityName: cbjEntityName.getOrCrash(), - entityOriginalName: entityOriginalName.getOrCrash(), - deviceOriginalName: deviceOriginalName.getOrCrash(), - entityStateGRPC: entityStateGRPC.getOrCrash(), - stateMassage: stateMassage.getOrCrash(), - senderDeviceOs: senderDeviceOs.getOrCrash(), - senderDeviceModel: senderDeviceModel.getOrCrash(), - senderId: senderId.getOrCrash(), - entityTypes: entityTypes.getOrCrash(), - compUuid: compUuid.getOrCrash(), - deviceVendor: deviceVendor.getOrCrash(), - powerConsumption: powerConsumption.getOrCrash(), - deviceUniqueId: deviceUniqueId.getOrCrash(), - devicePort: devicePort.getOrCrash(), - deviceLastKnownIp: deviceLastKnownIp.getOrCrash(), - deviceHostName: deviceHostName.getOrCrash(), - deviceMdns: deviceMdns.getOrCrash(), - devicesMacAddress: devicesMacAddress.getOrCrash(), - entityKey: entityKey.getOrCrash(), - requestTimeStamp: requestTimeStamp.getOrCrash(), - lastResponseFromDeviceTimeStamp: - lastResponseFromDeviceTimeStamp.getOrCrash(), - deviceCbjUniqueId: deviceCbjUniqueId.getOrCrash(), - boilerSwitchState: boilerSwitchState!.getOrCrash(), - ); - } - - /// Please override the following methods - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> turnOnBoiler() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> turnOffBoiler() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - @override - bool replaceActionIfExist(String action) { - if (GenericBoilerSwitchState.boilerValidActions().contains(action)) { - boilerSwitchState = GenericBoilerSwitchState(action); - return true; - } - return false; - } - - @override - List getListOfPropertiesToChange() { - return [ - 'boilerSwitchState', - ]; - } -} diff --git a/lib/domain/generic_devices/generic_boiler_device/generic_boiler_validators.dart b/lib/domain/generic_devices/generic_boiler_device/generic_boiler_validators.dart deleted file mode 100644 index b5e22920..00000000 --- a/lib/domain/generic_devices/generic_boiler_device/generic_boiler_validators.dart +++ /dev/null @@ -1,17 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateGenericBoilerStateNotEmpty( - String input, -) { - return right(input); -} - -/// Return all the valid actions for blinds -List boilerAllValidActions() { - return [ - EntityActions.off.toString(), - EntityActions.on.toString(), - ]; -} diff --git a/lib/domain/generic_devices/generic_boiler_device/generic_boiler_value_objects.dart b/lib/domain/generic_devices/generic_boiler_device/generic_boiler_value_objects.dart deleted file mode 100644 index b9f6e488..00000000 --- a/lib/domain/generic_devices/generic_boiler_device/generic_boiler_value_objects.dart +++ /dev/null @@ -1,22 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_boiler_device/generic_boiler_validators.dart'; -import 'package:dartz/dartz.dart'; - -class GenericBoilerSwitchState extends ValueObjectCore { - factory GenericBoilerSwitchState(String? input) { - assert(input != null); - return GenericBoilerSwitchState._( - validateGenericBoilerStateNotEmpty(input!), - ); - } - - const GenericBoilerSwitchState._(this.value); - - @override - final Either, String> value; - - static List boilerValidActions() { - return boilerAllValidActions(); - } -} diff --git a/lib/domain/generic_devices/generic_dimmable_light_device/generic_dimmable_light_entity.dart b/lib/domain/generic_devices/generic_dimmable_light_device/generic_dimmable_light_entity.dart deleted file mode 100644 index 6939e1d8..00000000 --- a/lib/domain/generic_devices/generic_dimmable_light_device/generic_dimmable_light_entity.dart +++ /dev/null @@ -1,207 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_dimmable_light_device/generic_dimmable_light_value_objects.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/generic_dimmable_light_device/generic_dimmable_light_device_dtos.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; - -/// Abstract smart GenericLightWithBrightness that exist inside a computer, the -/// implementations will be actual GenericLightWithBrightness like blinds lights and more -class GenericDimmableLightDE extends DeviceEntityAbstract { - /// All public field of GenericLightWithBrightness entity - GenericDimmableLightDE({ - required super.uniqueId, - required super.entityUniqueId, - required super.deviceVendor, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required this.lightSwitchState, - required this.lightBrightness, - }) : super( - entityTypes: EntityType(EntityTypes.dimmableLight.toString()), - ); - - /// Empty instance of GenericLightWithBrightnessEntity - factory GenericDimmableLightDE.empty() => GenericDimmableLightDE( - uniqueId: CoreUniqueId(), - entityUniqueId: EntityUniqueId(''), - cbjEntityName: CbjEntityName(''), - entityOriginalName: EntityOriginalName(''), - deviceOriginalName: DeviceOriginalName(''), - entityStateGRPC: EntityState(''), - senderDeviceOs: DeviceSenderDeviceOs(''), - senderDeviceModel: DeviceSenderDeviceModel(''), - stateMassage: DeviceStateMassage(''), - senderId: DeviceSenderId(), - deviceVendor: DeviceVendor(''), - deviceUniqueId: DeviceUniqueId(''), - devicePort: DevicePort(''), - deviceLastKnownIp: DeviceLastKnownIp(''), - deviceHostName: DeviceHostName(''), - deviceMdns: DeviceMdns(''), - compUuid: DeviceCompUuid(''), - powerConsumption: DevicePowerConsumption(''), - devicesMacAddress: DevicesMacAddress(''), - entityKey: EntityKey(''), - requestTimeStamp: RequestTimeStamp(''), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp(''), - deviceCbjUniqueId: CoreUniqueId(), - lightSwitchState: - GenericDimmableLightSwitchState(EntityActions.off.toString()), - lightBrightness: GenericDimmableLightBrightness(''), - ); - - /// State of the light on/off - GenericDimmableLightSwitchState? lightSwitchState; - - /// Brightness 0-100% - GenericDimmableLightBrightness lightBrightness; - - int sendNewBrightnessEachMiliseconds = 200; - bool doesWaitingToSendBrightnessRequest = false; - - // /// Will return failure if any of the fields failed or return unit if fields - // /// have legit values - Option> get failureOption => - cbjEntityName.value.fold((f) => some(f), (_) => none()); - // - // return body.failureOrUnit - // .andThen(todos.failureOrUnit) - // .andThen( - // todos - // .getOrCrash() - // // Getting the failureOption from the TodoItem ENTITY - NOT a failureOrUnit from a VALUE OBJECT - // .map((todoItem) => todoItem.failureOption) - // .filter((o) => o.isSome()) - // // If we can't get the 0th element, the list is empty. In such a case, it's valid. - // .getOrElse(0, (_) => none()) - // .fold(() => right(unit), (f) => left(f)), - // ) - // .fold((f) => some(f), (_) => none()); - // } - - @override - String getDeviceId() { - return uniqueId.getOrCrash(); - } - - /// Return a list of all valid actions for this device - @override - List getAllValidActions() { - return GenericDimmableLightSwitchState.lightValidActions(); - } - - @override - DeviceEntityDtoAbstract toInfrastructure() { - return GenericDimmableLightDeviceDtos( - deviceDtoClass: (GenericDimmableLightDeviceDtos).toString(), - id: uniqueId.getOrCrash(), - entityUniqueId: entityUniqueId.getOrCrash(), - cbjEntityName: cbjEntityName.getOrCrash(), - entityOriginalName: entityOriginalName.getOrCrash(), - deviceOriginalName: deviceOriginalName.getOrCrash(), - entityStateGRPC: entityStateGRPC.getOrCrash(), - stateMassage: stateMassage.getOrCrash(), - senderDeviceOs: senderDeviceOs.getOrCrash(), - senderDeviceModel: senderDeviceModel.getOrCrash(), - senderId: senderId.getOrCrash(), - entityTypes: entityTypes.getOrCrash(), - compUuid: compUuid.getOrCrash(), - deviceVendor: deviceVendor.getOrCrash(), - powerConsumption: powerConsumption.getOrCrash(), - deviceUniqueId: deviceUniqueId.getOrCrash(), - devicePort: devicePort.getOrCrash(), - deviceLastKnownIp: deviceLastKnownIp.getOrCrash(), - deviceHostName: deviceHostName.getOrCrash(), - deviceMdns: deviceMdns.getOrCrash(), - devicesMacAddress: devicesMacAddress.getOrCrash(), - entityKey: entityKey.getOrCrash(), - requestTimeStamp: requestTimeStamp.getOrCrash(), - lastResponseFromDeviceTimeStamp: - lastResponseFromDeviceTimeStamp.getOrCrash(), - deviceCbjUniqueId: deviceCbjUniqueId.getOrCrash(), - lightSwitchState: lightSwitchState!.getOrCrash(), - lightBrightness: lightBrightness.getOrCrash(), - ); - } - - /// Please override the following methods - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> turnOnLight() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> turnOffLight() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> setBrightness(String brightness) async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - @override - bool replaceActionIfExist(String action) { - if (GenericDimmableLightSwitchState.lightValidActions().contains(action)) { - lightSwitchState = GenericDimmableLightSwitchState(action); - return true; - } - return false; - } - - @override - List getListOfPropertiesToChange() { - return [ - 'lightSwitchState', - ]; - } -} diff --git a/lib/domain/generic_devices/generic_dimmable_light_device/generic_dimmable_light_validators.dart b/lib/domain/generic_devices/generic_dimmable_light_device/generic_dimmable_light_validators.dart deleted file mode 100644 index 1f4f36d7..00000000 --- a/lib/domain/generic_devices/generic_dimmable_light_device/generic_dimmable_light_validators.dart +++ /dev/null @@ -1,23 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateGenericDimmableLightStateNotEmpty( - String input, -) { - return right(input); -} - -Either, String> validateGenericDimmableLightNotEmpty( - String input, -) { - return right(input); -} - -/// Return all the valid actions for blinds -List lightAllValidActions() { - return [ - EntityActions.off.toString(), - EntityActions.on.toString(), - ]; -} diff --git a/lib/domain/generic_devices/generic_dimmable_light_device/generic_dimmable_light_value_objects.dart b/lib/domain/generic_devices/generic_dimmable_light_device/generic_dimmable_light_value_objects.dart deleted file mode 100644 index 2048d722..00000000 --- a/lib/domain/generic_devices/generic_dimmable_light_device/generic_dimmable_light_value_objects.dart +++ /dev/null @@ -1,84 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_dimmable_light_device/generic_dimmable_light_validators.dart'; -import 'package:dartz/dartz.dart'; - -class GenericDimmableLightSwitchState extends ValueObjectCore { - factory GenericDimmableLightSwitchState(String? input) { - assert(input != null); - return GenericDimmableLightSwitchState._( - validateGenericDimmableLightStateNotEmpty(input!), - ); - } - - const GenericDimmableLightSwitchState._(this.value); - - @override - final Either, String> value; - - static List lightValidActions() { - return lightAllValidActions(); - } -} - -class GenericDimmableLightBrightness extends ValueObjectCore { - factory GenericDimmableLightBrightness(String? input) { - assert(input != null); - final String tempInput = input!; - - return GenericDimmableLightBrightness._( - validateGenericDimmableLightNotEmpty(tempInput), - ); - } - - factory GenericDimmableLightBrightness.fromDouble(double input) { - return GenericDimmableLightBrightness._( - validateGenericDimmableLightNotEmpty( - convertDecimalPresentagetToIntegerPercentage(input).toString(), - ), - ); - } - - const GenericDimmableLightBrightness._(this.value); - - @override - final Either, String> value; - - // Convert percentage 0.0-1.0 numbers to 0-100 with the same percentage - static int convertDecimalPresentagetToIntegerPercentage(double number) { - const double oldMax = 1.0; - const double oldMin = 0; - const double oldRange = oldMax - oldMin; - - const int newMax = 100; - const int newMin = 0; - const int newRange = newMax - newMin; - - final double newValue = - (((number - oldMin) * newRange) / oldRange) + newMin; - - return newValue.toInt(); - } - - /// From 100-0 will be converted to 1.0-0.0 - double backToDecimalPointBrightness() { - return value.fold((l) { - throw Exception('Number is not valid $l'); - }, (r) { - final int number = int.parse(r); - - const int oldMax = 100; - const int oldMin = 0; - const int oldRange = oldMax - oldMin; - - const double newMax = 1.0; - const double newMin = 0; - const double newRange = newMax - newMin; - - final double newValue = - (((number - oldMin) * newRange) / oldRange) + newMin; - - return newValue; - }); - } -} diff --git a/lib/domain/generic_devices/generic_empty_device/generic_empty_entity.dart b/lib/domain/generic_devices/generic_empty_device/generic_empty_entity.dart deleted file mode 100644 index 1ae88b81..00000000 --- a/lib/domain/generic_devices/generic_empty_device/generic_empty_entity.dart +++ /dev/null @@ -1,190 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_empty_device/generic_empty_value_objects.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/generic_empty_device/generic_empty_device_dtos.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; - -/// Abstract smart GenericEmpty that exist inside a computer, the -/// implementations will be actual GenericEmpty like blinds emptys and more -class GenericEmptyDE extends DeviceEntityAbstract { - /// All public field of GenericEmpty entity - GenericEmptyDE({ - required super.uniqueId, - required super.entityUniqueId, - required super.deviceVendor, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required this.emptySwitchState, - }) : super( - entityTypes: EntityType(EntityTypes.emptyEntity.toString()), - ); - - /// Empty instance of GenericEmptyEntity - factory GenericEmptyDE.empty() => GenericEmptyDE( - deviceVendor: DeviceVendor( - VendorsAndServices.vendorsAndServicesNotSupported.toString(), - ), - uniqueId: CoreUniqueId(), - entityUniqueId: EntityUniqueId(''), - cbjEntityName: CbjEntityName('Empty device'), - entityOriginalName: EntityOriginalName('Missing entity original name'), - deviceOriginalName: DeviceOriginalName('Missing device original name'), - entityStateGRPC: EntityState(EntityStateGRPC.ack.toString()), - senderDeviceOs: DeviceSenderDeviceOs('Hub'), - senderDeviceModel: DeviceSenderDeviceModel('Hub'), - stateMassage: DeviceStateMassage('Test'), - senderId: DeviceSenderId(), - compUuid: DeviceCompUuid('Test'), - powerConsumption: DevicePowerConsumption('Test'), - deviceUniqueId: DeviceUniqueId(''), - devicePort: DevicePort(''), - deviceLastKnownIp: DeviceLastKnownIp(''), - deviceHostName: DeviceHostName(''), - deviceMdns: DeviceMdns(''), - devicesMacAddress: DevicesMacAddress(''), - entityKey: EntityKey(''), - requestTimeStamp: RequestTimeStamp(''), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp(''), - deviceCbjUniqueId: CoreUniqueId(), - emptySwitchState: GenericEmptySwitchState(EntityActions.off.toString()), - ); - - /// State of the empty on/off - GenericEmptySwitchState? emptySwitchState; - - // - // /// Will return failure if any of the fields failed or return unit if fields - // /// have legit values - Option> get failureOption => - cbjEntityName.value.fold((f) => some(f), (_) => none()); - // - // return body.failureOrUnit - // .andThen(todos.failureOrUnit) - // .andThen( - // todos - // .getOrCrash() - // // Getting the failureOption from the TodoItem ENTITY - NOT a failureOrUnit from a VALUE OBJECT - // .map((todoItem) => todoItem.failureOption) - // .filter((o) => o.isSome()) - // // If we can't get the 0th element, the list is empty. In such a case, it's valid. - // .getOrElse(0, (_) => none()) - // .fold(() => right(unit), (f) => left(f)), - // ) - // .fold((f) => some(f), (_) => none()); - // } - - @override - String getDeviceId() { - return uniqueId.getOrCrash(); - } - - /// Return a list of all valid actions for this device - @override - List getAllValidActions() { - return GenericEmptySwitchState.emptyDeviceValidActions(); - } - - @override - DeviceEntityDtoAbstract toInfrastructure() { - return GenericEmptyDeviceDtos( - deviceDtoClass: (GenericEmptyDeviceDtos).toString(), - id: uniqueId.getOrCrash(), - entityUniqueId: entityUniqueId.getOrCrash(), - cbjEntityName: cbjEntityName.getOrCrash(), - entityOriginalName: entityOriginalName.getOrCrash(), - deviceOriginalName: deviceOriginalName.getOrCrash(), - entityStateGRPC: entityStateGRPC.getOrCrash(), - stateMassage: stateMassage.getOrCrash(), - senderDeviceOs: senderDeviceOs.getOrCrash(), - senderDeviceModel: senderDeviceModel.getOrCrash(), - senderId: senderId.getOrCrash(), - entityTypes: entityTypes.getOrCrash(), - compUuid: compUuid.getOrCrash(), - deviceVendor: deviceVendor.getOrCrash(), - powerConsumption: powerConsumption.getOrCrash(), - deviceUniqueId: deviceUniqueId.getOrCrash(), - devicePort: devicePort.getOrCrash(), - deviceLastKnownIp: deviceLastKnownIp.getOrCrash(), - deviceHostName: deviceHostName.getOrCrash(), - deviceMdns: deviceMdns.getOrCrash(), - devicesMacAddress: devicesMacAddress.getOrCrash(), - entityKey: entityKey.getOrCrash(), - requestTimeStamp: requestTimeStamp.getOrCrash(), - lastResponseFromDeviceTimeStamp: - lastResponseFromDeviceTimeStamp.getOrCrash(), - deviceCbjUniqueId: deviceCbjUniqueId.getOrCrash(), - emptySwitchState: emptySwitchState!.getOrCrash(), - ); - } - - /// Please override the following methods - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> turnOnEmpty() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> turnOffEmpty() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - @override - bool replaceActionIfExist(String action) { - if (GenericEmptySwitchState.emptyDeviceValidActions().contains(action)) { - emptySwitchState = GenericEmptySwitchState(action); - return true; - } - return false; - } - - @override - List getListOfPropertiesToChange() { - return [ - 'emptySwitchState', - ]; - } -} diff --git a/lib/domain/generic_devices/generic_empty_device/generic_empty_validators.dart b/lib/domain/generic_devices/generic_empty_device/generic_empty_validators.dart deleted file mode 100644 index 96155f7b..00000000 --- a/lib/domain/generic_devices/generic_empty_device/generic_empty_validators.dart +++ /dev/null @@ -1,16 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateGenericEmptyStateNotEmpty( - String input, -) { - return right(input); -} - -/// Return all the valid actions for blinds -List emptyDeviceAllValidActions() { - return [ - EntityActions.actionNotSupported.toString(), - ]; -} diff --git a/lib/domain/generic_devices/generic_empty_device/generic_empty_value_objects.dart b/lib/domain/generic_devices/generic_empty_device/generic_empty_value_objects.dart deleted file mode 100644 index 03b8b57b..00000000 --- a/lib/domain/generic_devices/generic_empty_device/generic_empty_value_objects.dart +++ /dev/null @@ -1,23 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_empty_device/generic_empty_validators.dart'; -import 'package:dartz/dartz.dart'; - -class GenericEmptySwitchState extends ValueObjectCore { - factory GenericEmptySwitchState(String? input) { - assert(input != null); - return GenericEmptySwitchState._( - validateGenericEmptyStateNotEmpty(input!), - ); - } - - const GenericEmptySwitchState._(this.value); - - @override - final Either, String> value; - - /// All valid actions of empty device state - static List emptyDeviceValidActions() { - return emptyDeviceAllValidActions(); - } -} diff --git a/lib/domain/generic_devices/generic_light_device/generic_light_entity.dart b/lib/domain/generic_devices/generic_light_device/generic_light_entity.dart deleted file mode 100644 index 6b24cd33..00000000 --- a/lib/domain/generic_devices/generic_light_device/generic_light_entity.dart +++ /dev/null @@ -1,188 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_light_device/generic_light_value_objects.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/generic_light_device/generic_light_device_dtos.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; - -/// Abstract smart GenericLight that exist inside a computer, the -/// implementations will be actual GenericLight like blinds lights and more -class GenericLightDE extends DeviceEntityAbstract { - /// All public field of GenericLight entity - GenericLightDE({ - required super.uniqueId, - required super.entityUniqueId, - required super.deviceVendor, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required this.lightSwitchState, - }) : super( - entityTypes: EntityType(EntityTypes.light.toString()), - ); - - /// Empty instance of GenericLightEntity - factory GenericLightDE.empty() => GenericLightDE( - uniqueId: CoreUniqueId(), - entityUniqueId: EntityUniqueId(''), - cbjEntityName: CbjEntityName(''), - entityOriginalName: EntityOriginalName(''), - deviceOriginalName: DeviceOriginalName(''), - entityStateGRPC: EntityState(''), - senderDeviceOs: DeviceSenderDeviceOs(''), - senderDeviceModel: DeviceSenderDeviceModel(''), - stateMassage: DeviceStateMassage(''), - senderId: DeviceSenderId(), - deviceVendor: DeviceVendor(''), - deviceUniqueId: DeviceUniqueId(''), - devicePort: DevicePort(''), - deviceLastKnownIp: DeviceLastKnownIp(''), - deviceHostName: DeviceHostName(''), - deviceMdns: DeviceMdns(''), - compUuid: DeviceCompUuid(''), - powerConsumption: DevicePowerConsumption(''), - devicesMacAddress: DevicesMacAddress(''), - entityKey: EntityKey(''), - requestTimeStamp: RequestTimeStamp(''), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp(''), - deviceCbjUniqueId: CoreUniqueId(), - lightSwitchState: GenericLightSwitchState(EntityActions.off.toString()), - ); - - /// State of the light on/off - GenericLightSwitchState? lightSwitchState; - - // - // /// Will return failure if any of the fields failed or return unit if fields - // /// have legit values - Option> get failureOption => - cbjEntityName.value.fold((f) => some(f), (_) => none()); - // - // return body.failureOrUnit - // .andThen(todos.failureOrUnit) - // .andThen( - // todos - // .getOrCrash() - // // Getting the failureOption from the TodoItem ENTITY - NOT a failureOrUnit from a VALUE OBJECT - // .map((todoItem) => todoItem.failureOption) - // .filter((o) => o.isSome()) - // // If we can't get the 0th element, the list is empty. In such a case, it's valid. - // .getOrElse(0, (_) => none()) - // .fold(() => right(unit), (f) => left(f)), - // ) - // .fold((f) => some(f), (_) => none()); - // } - - @override - String getDeviceId() { - return uniqueId.getOrCrash(); - } - - /// Return a list of all valid actions for this device - @override - List getAllValidActions() { - return GenericLightSwitchState.lightValidActions(); - } - - @override - DeviceEntityDtoAbstract toInfrastructure() { - return GenericLightDeviceDtos( - deviceDtoClass: (GenericLightDeviceDtos).toString(), - id: uniqueId.getOrCrash(), - entityUniqueId: entityUniqueId.getOrCrash(), - cbjEntityName: cbjEntityName.getOrCrash(), - entityOriginalName: entityOriginalName.getOrCrash(), - deviceOriginalName: deviceOriginalName.getOrCrash(), - entityStateGRPC: entityStateGRPC.getOrCrash(), - stateMassage: stateMassage.getOrCrash(), - senderDeviceOs: senderDeviceOs.getOrCrash(), - senderDeviceModel: senderDeviceModel.getOrCrash(), - senderId: senderId.getOrCrash(), - entityTypes: entityTypes.getOrCrash(), - compUuid: compUuid.getOrCrash(), - deviceVendor: deviceVendor.getOrCrash(), - powerConsumption: powerConsumption.getOrCrash(), - deviceUniqueId: deviceUniqueId.getOrCrash(), - devicePort: devicePort.getOrCrash(), - deviceLastKnownIp: deviceLastKnownIp.getOrCrash(), - deviceHostName: deviceHostName.getOrCrash(), - deviceMdns: deviceMdns.getOrCrash(), - devicesMacAddress: devicesMacAddress.getOrCrash(), - entityKey: entityKey.getOrCrash(), - requestTimeStamp: requestTimeStamp.getOrCrash(), - lastResponseFromDeviceTimeStamp: - lastResponseFromDeviceTimeStamp.getOrCrash(), - deviceCbjUniqueId: deviceCbjUniqueId.getOrCrash(), - lightSwitchState: lightSwitchState!.getOrCrash(), - ); - } - - /// Please override the following methods - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> turnOnLight() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> turnOffLight() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - @override - bool replaceActionIfExist(String action) { - if (GenericLightSwitchState.lightValidActions().contains(action)) { - lightSwitchState = GenericLightSwitchState(action); - return true; - } - return false; - } - - @override - List getListOfPropertiesToChange() { - return [ - 'lightSwitchState', - ]; - } -} diff --git a/lib/domain/generic_devices/generic_light_device/generic_light_validators.dart b/lib/domain/generic_devices/generic_light_device/generic_light_validators.dart deleted file mode 100644 index 159d571a..00000000 --- a/lib/domain/generic_devices/generic_light_device/generic_light_validators.dart +++ /dev/null @@ -1,17 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateGenericLightStateNotEmpty( - String input, -) { - return right(input); -} - -/// Return all the valid actions for blinds -List lightAllValidActions() { - return [ - EntityActions.off.toString(), - EntityActions.on.toString(), - ]; -} diff --git a/lib/domain/generic_devices/generic_light_device/generic_light_value_objects.dart b/lib/domain/generic_devices/generic_light_device/generic_light_value_objects.dart deleted file mode 100644 index a1c70976..00000000 --- a/lib/domain/generic_devices/generic_light_device/generic_light_value_objects.dart +++ /dev/null @@ -1,22 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_light_device/generic_light_validators.dart'; -import 'package:dartz/dartz.dart'; - -class GenericLightSwitchState extends ValueObjectCore { - factory GenericLightSwitchState(String? input) { - assert(input != null); - return GenericLightSwitchState._( - validateGenericLightStateNotEmpty(input!), - ); - } - - const GenericLightSwitchState._(this.value); - - @override - final Either, String> value; - - static List lightValidActions() { - return lightAllValidActions(); - } -} diff --git a/lib/domain/generic_devices/generic_ping_device/generic_ping_entity.dart b/lib/domain/generic_devices/generic_ping_device/generic_ping_entity.dart deleted file mode 100644 index c8b8a6ee..00000000 --- a/lib/domain/generic_devices/generic_ping_device/generic_ping_entity.dart +++ /dev/null @@ -1,190 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_ping_device/generic_ping_value_objects.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/generic_ping_device/generic_ping_device_dtos.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; - -/// Abstract smart GenericPing that exist inside a computer, the -/// implementations will be actual GenericPing like blinds pings and more -class GenericPingDE extends DeviceEntityAbstract { - /// All public field of GenericPing entity - GenericPingDE({ - required super.uniqueId, - required super.entityUniqueId, - required super.deviceVendor, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required this.pingSwitchState, - }) : super( - entityTypes: EntityType(EntityTypes.pingEntity.toString()), - ); - - /// Ping instance of GenericPingEntity - factory GenericPingDE.empty() => GenericPingDE( - uniqueId: CoreUniqueId(), - entityUniqueId: EntityUniqueId(''), - cbjEntityName: CbjEntityName('Ping device'), - entityOriginalName: EntityOriginalName('Missing entity original name'), - deviceOriginalName: DeviceOriginalName('Missing device original name'), - entityStateGRPC: EntityState(EntityStateGRPC.pingNow.toString()), - senderDeviceOs: DeviceSenderDeviceOs('Hub'), - senderDeviceModel: DeviceSenderDeviceModel('Hub'), - stateMassage: DeviceStateMassage('Test'), - senderId: DeviceSenderId(), - deviceVendor: DeviceVendor( - VendorsAndServices.vendorsAndServicesNotSupported.toString(), - ), - compUuid: DeviceCompUuid('Test'), - powerConsumption: DevicePowerConsumption('Test'), - deviceUniqueId: DeviceUniqueId(''), - devicePort: DevicePort(''), - deviceLastKnownIp: DeviceLastKnownIp(''), - deviceHostName: DeviceHostName(''), - deviceMdns: DeviceMdns(''), - devicesMacAddress: DevicesMacAddress(''), - entityKey: EntityKey(''), - requestTimeStamp: RequestTimeStamp(''), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp(''), - deviceCbjUniqueId: CoreUniqueId(), - pingSwitchState: GenericPingSwitchState(EntityActions.off.toString()), - ); - - /// State of the ping on/off - GenericPingSwitchState? pingSwitchState; - - // - // /// Will return failure if any of the fields failed or return unit if fields - // /// have legit values - Option> get failureOption => - cbjEntityName.value.fold((f) => some(f), (_) => none()); - // - // return body.failureOrUnit - // .andThen(todos.failureOrUnit) - // .andThen( - // todos - // .getOrCrash() - // // Getting the failureOption from the TodoItem ENTITY - NOT a failureOrUnit from a VALUE OBJECT - // .map((todoItem) => todoItem.failureOption) - // .filter((o) => o.isSome()) - // // If we can't get the 0th element, the list is ping. In such a case, it's valid. - // .getOrElse(0, (_) => none()) - // .fold(() => right(unit), (f) => left(f)), - // ) - // .fold((f) => some(f), (_) => none()); - // } - - @override - String getDeviceId() { - return uniqueId.getOrCrash(); - } - - /// Return a list of all valid actions for this device - @override - List getAllValidActions() { - return GenericPingSwitchState.pingValidActions(); - } - - @override - DeviceEntityDtoAbstract toInfrastructure() { - return GenericPingDeviceDtos( - deviceDtoClass: (GenericPingDeviceDtos).toString(), - id: uniqueId.getOrCrash(), - entityUniqueId: entityUniqueId.getOrCrash(), - cbjEntityName: cbjEntityName.getOrCrash(), - entityOriginalName: entityOriginalName.getOrCrash(), - deviceOriginalName: deviceOriginalName.getOrCrash(), - entityStateGRPC: entityStateGRPC.getOrCrash(), - stateMassage: stateMassage.getOrCrash(), - senderDeviceOs: senderDeviceOs.getOrCrash(), - senderDeviceModel: senderDeviceModel.getOrCrash(), - senderId: senderId.getOrCrash(), - entityTypes: entityTypes.getOrCrash(), - compUuid: compUuid.getOrCrash(), - deviceVendor: deviceVendor.getOrCrash(), - powerConsumption: powerConsumption.getOrCrash(), - deviceUniqueId: deviceUniqueId.getOrCrash(), - devicePort: devicePort.getOrCrash(), - deviceLastKnownIp: deviceLastKnownIp.getOrCrash(), - deviceHostName: deviceHostName.getOrCrash(), - deviceMdns: deviceMdns.getOrCrash(), - devicesMacAddress: devicesMacAddress.getOrCrash(), - entityKey: entityKey.getOrCrash(), - requestTimeStamp: requestTimeStamp.getOrCrash(), - lastResponseFromDeviceTimeStamp: - lastResponseFromDeviceTimeStamp.getOrCrash(), - deviceCbjUniqueId: deviceCbjUniqueId.getOrCrash(), - pingSwitchState: pingSwitchState!.getOrCrash(), - ); - } - - /// Please override the following methods - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> turnOnPing() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> turnOffPing() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - @override - bool replaceActionIfExist(String action) { - if (GenericPingSwitchState.pingValidActions().contains(action)) { - pingSwitchState = GenericPingSwitchState(action); - return true; - } - return false; - } - - @override - List getListOfPropertiesToChange() { - return [ - 'pingSwitchState', - ]; - } -} diff --git a/lib/domain/generic_devices/generic_ping_device/generic_ping_validators.dart b/lib/domain/generic_devices/generic_ping_device/generic_ping_validators.dart deleted file mode 100644 index f95fab10..00000000 --- a/lib/domain/generic_devices/generic_ping_device/generic_ping_validators.dart +++ /dev/null @@ -1,16 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateGenericPingStateNotEmpty( - String input, -) { - return right(input); -} - -/// Return all the valid actions for blinds -List pingAllValidActions() { - return [ - EntityActions.actionNotSupported.toString(), - ]; -} diff --git a/lib/domain/generic_devices/generic_ping_device/generic_ping_value_objects.dart b/lib/domain/generic_devices/generic_ping_device/generic_ping_value_objects.dart deleted file mode 100644 index ce7f48f9..00000000 --- a/lib/domain/generic_devices/generic_ping_device/generic_ping_value_objects.dart +++ /dev/null @@ -1,23 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_ping_device/generic_ping_validators.dart'; -import 'package:dartz/dartz.dart'; - -class GenericPingSwitchState extends ValueObjectCore { - factory GenericPingSwitchState(String? input) { - assert(input != null); - return GenericPingSwitchState._( - validateGenericPingStateNotEmpty(input!), - ); - } - - const GenericPingSwitchState._(this.value); - - @override - final Either, String> value; - - /// All valid actions of ping state - static List pingValidActions() { - return pingAllValidActions(); - } -} diff --git a/lib/domain/generic_devices/generic_printer_device/generic_printer_entity.dart b/lib/domain/generic_devices/generic_printer_device/generic_printer_entity.dart deleted file mode 100644 index 241551fe..00000000 --- a/lib/domain/generic_devices/generic_printer_device/generic_printer_entity.dart +++ /dev/null @@ -1,190 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_printer_device/generic_printer_value_objects.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/generic_printer_device/generic_printer_device_dtos.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; - -/// Abstract smart GenericPrinter that exist inside a computer, the -/// implementations will be actual GenericPrinter like blinds printers and more -class GenericPrinterDE extends DeviceEntityAbstract { - /// All public field of GenericPrinter entity - GenericPrinterDE({ - required super.uniqueId, - required super.entityUniqueId, - required super.deviceVendor, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required this.printerSwitchState, - }) : super( - entityTypes: EntityType(EntityTypes.printer.toString()), - ); - - /// Empty instance of GenericPrinterEntity - factory GenericPrinterDE.empty() => GenericPrinterDE( - uniqueId: CoreUniqueId(), - entityUniqueId: EntityUniqueId(''), - cbjEntityName: CbjEntityName(''), - entityOriginalName: EntityOriginalName(''), - deviceOriginalName: DeviceOriginalName(''), - entityStateGRPC: EntityState(''), - senderDeviceOs: DeviceSenderDeviceOs(''), - senderDeviceModel: DeviceSenderDeviceModel(''), - stateMassage: DeviceStateMassage(''), - senderId: DeviceSenderId(), - deviceVendor: DeviceVendor(''), - deviceUniqueId: DeviceUniqueId(''), - devicePort: DevicePort(''), - deviceLastKnownIp: DeviceLastKnownIp(''), - deviceHostName: DeviceHostName(''), - deviceMdns: DeviceMdns(''), - compUuid: DeviceCompUuid(''), - powerConsumption: DevicePowerConsumption(''), - devicesMacAddress: DevicesMacAddress(''), - entityKey: EntityKey(''), - requestTimeStamp: RequestTimeStamp(''), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp(''), - deviceCbjUniqueId: CoreUniqueId(), - printerSwitchState: - GenericPrinterSwitchState(EntityActions.off.toString()), - ); - - /// State of the printer on/off - GenericPrinterSwitchState? printerSwitchState; - - // - // /// Will return failure if any of the fields failed or return unit if fields - // /// have legit values - Option> get failureOption => - cbjEntityName.value.fold((f) => some(f), (_) => none()); - // - // return body.failureOrUnit - // .andThen(todos.failureOrUnit) - // .andThen( - // todos - // .getOrCrash() - // // Getting the failureOption from the TodoItem ENTITY - NOT a failureOrUnit from a VALUE OBJECT - // .map((todoItem) => todoItem.failureOption) - // .filter((o) => o.isSome()) - // // If we can't get the 0th element, the list is empty. In such a case, it's valid. - // .getOrElse(0, (_) => none()) - // .fold(() => right(unit), (f) => left(f)), - // ) - // .fold((f) => some(f), (_) => none()); - // } - - @override - String getDeviceId() { - return uniqueId.getOrCrash(); - } - - /// Return a list of all valid actions for this device - @override - List getAllValidActions() { - return GenericPrinterSwitchState.printerValidActions(); - } - - @override - DeviceEntityDtoAbstract toInfrastructure() { - return GenericPrinterDeviceDtos( - deviceDtoClass: (GenericPrinterDeviceDtos).toString(), - id: uniqueId.getOrCrash(), - entityUniqueId: entityUniqueId.getOrCrash(), - cbjEntityName: cbjEntityName.getOrCrash(), - entityOriginalName: entityOriginalName.getOrCrash(), - deviceOriginalName: deviceOriginalName.getOrCrash(), - entityStateGRPC: entityStateGRPC.getOrCrash(), - stateMassage: stateMassage.getOrCrash(), - senderDeviceOs: senderDeviceOs.getOrCrash(), - senderDeviceModel: senderDeviceModel.getOrCrash(), - senderId: senderId.getOrCrash(), - entityTypes: entityTypes.getOrCrash(), - compUuid: compUuid.getOrCrash(), - deviceVendor: deviceVendor.getOrCrash(), - powerConsumption: powerConsumption.getOrCrash(), - deviceUniqueId: deviceUniqueId.getOrCrash(), - devicePort: devicePort.getOrCrash(), - deviceLastKnownIp: deviceLastKnownIp.getOrCrash(), - deviceHostName: deviceHostName.getOrCrash(), - deviceMdns: deviceMdns.getOrCrash(), - devicesMacAddress: devicesMacAddress.getOrCrash(), - entityKey: entityKey.getOrCrash(), - requestTimeStamp: requestTimeStamp.getOrCrash(), - lastResponseFromDeviceTimeStamp: - lastResponseFromDeviceTimeStamp.getOrCrash(), - deviceCbjUniqueId: deviceCbjUniqueId.getOrCrash(), - printerSwitchState: printerSwitchState!.getOrCrash(), - lastKnownIp: deviceLastKnownIp.getOrCrash(), - ); - } - - /// Please override the following methods - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> turnOnPrinter() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> turnOffPrinter() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - @override - bool replaceActionIfExist(String action) { - if (GenericPrinterSwitchState.printerValidActions().contains(action)) { - printerSwitchState = GenericPrinterSwitchState(action); - return true; - } - return false; - } - - @override - List getListOfPropertiesToChange() { - return [ - 'printerSwitchState', - ]; - } -} diff --git a/lib/domain/generic_devices/generic_printer_device/generic_printer_validators.dart b/lib/domain/generic_devices/generic_printer_device/generic_printer_validators.dart deleted file mode 100644 index 3fb376bd..00000000 --- a/lib/domain/generic_devices/generic_printer_device/generic_printer_validators.dart +++ /dev/null @@ -1,17 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateGenericPrinterStateNotEmpty( - String input, -) { - return right(input); -} - -/// Return all the valid actions for blinds -List printerAllValidActions() { - return [ - EntityActions.off.toString(), - EntityActions.on.toString(), - ]; -} diff --git a/lib/domain/generic_devices/generic_printer_device/generic_printer_value_objects.dart b/lib/domain/generic_devices/generic_printer_device/generic_printer_value_objects.dart deleted file mode 100644 index 21379a8c..00000000 --- a/lib/domain/generic_devices/generic_printer_device/generic_printer_value_objects.dart +++ /dev/null @@ -1,22 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_printer_device/generic_printer_validators.dart'; -import 'package:dartz/dartz.dart'; - -class GenericPrinterSwitchState extends ValueObjectCore { - factory GenericPrinterSwitchState(String? input) { - assert(input != null); - return GenericPrinterSwitchState._( - validateGenericPrinterStateNotEmpty(input!), - ); - } - - const GenericPrinterSwitchState._(this.value); - - @override - final Either, String> value; - - static List printerValidActions() { - return printerAllValidActions(); - } -} diff --git a/lib/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_entity.dart b/lib/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_entity.dart deleted file mode 100644 index 03ad7f79..00000000 --- a/lib/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_entity.dart +++ /dev/null @@ -1,276 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_value_objects.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/generic_rgbw_light_device/generic_rgbw_light_device_dtos.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; - -/// Abstract smart GenericLight that exist inside a computer, the -/// implementations will be actual GenericLight like blinds lights and more -class GenericRgbwLightDE extends DeviceEntityAbstract { - /// All public field of GenericLight entity - GenericRgbwLightDE({ - required super.uniqueId, - required super.entityUniqueId, - required super.deviceVendor, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required this.lightSwitchState, - required this.lightColorTemperature, - required this.lightColorAlpha, - required this.lightColorHue, - required this.lightColorSaturation, - required this.lightColorValue, - required this.lightBrightness, - }) : super( - entityTypes: EntityType(EntityTypes.rgbwLights.toString()), - ); - - /// Empty instance of GenericLightEntity - factory GenericRgbwLightDE.empty() => GenericRgbwLightDE( - uniqueId: CoreUniqueId(), - entityUniqueId: EntityUniqueId(''), - cbjEntityName: CbjEntityName(''), - entityOriginalName: EntityOriginalName(''), - deviceOriginalName: DeviceOriginalName(''), - entityStateGRPC: EntityState(''), - senderDeviceOs: DeviceSenderDeviceOs(''), - senderDeviceModel: DeviceSenderDeviceModel(''), - stateMassage: DeviceStateMassage(''), - senderId: DeviceSenderId(), - deviceVendor: DeviceVendor(''), - deviceUniqueId: DeviceUniqueId(''), - devicePort: DevicePort(''), - deviceLastKnownIp: DeviceLastKnownIp(''), - deviceHostName: DeviceHostName(''), - deviceMdns: DeviceMdns(''), - compUuid: DeviceCompUuid(''), - powerConsumption: DevicePowerConsumption(''), - devicesMacAddress: DevicesMacAddress(''), - entityKey: EntityKey(''), - requestTimeStamp: RequestTimeStamp(''), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp(''), - deviceCbjUniqueId: CoreUniqueId(), - lightSwitchState: - GenericRgbwLightSwitchState(EntityActions.off.toString()), - lightColorTemperature: GenericRgbwLightColorTemperature(''), - lightBrightness: GenericRgbwLightBrightness(''), - lightColorAlpha: GenericRgbwLightColorAlpha(''), - lightColorHue: GenericRgbwLightColorHue(''), - lightColorSaturation: GenericRgbwLightColorSaturation(''), - lightColorValue: GenericRgbwLightColorValue(''), - ); - - /// State of the light on/off - GenericRgbwLightSwitchState? lightSwitchState; - - /// Color temperature in int - GenericRgbwLightColorTemperature lightColorTemperature; - - /// Color alpha in double - GenericRgbwLightColorAlpha lightColorAlpha; - - /// Color hue in double - GenericRgbwLightColorHue lightColorHue; - - /// Color saturation in double - GenericRgbwLightColorSaturation lightColorSaturation; - - /// Color value in double - GenericRgbwLightColorValue lightColorValue; - - /// Brightness 0-100% - GenericRgbwLightBrightness lightBrightness; - - int sendNewTemperatureColorEachMiliseconds = 200; - bool doesWaitingToSendTemperatureColorRequest = false; - - int sendNewHsvColorEachMiliseconds = 200; - bool doesWaitingToSendHsvColorRequest = false; - - int sendNewBrightnessEachMiliseconds = 200; - bool doesWaitingToSendBrightnessRequest = false; - - // /// Will return failure if any of the fields failed or return unit if fields - // /// have legit values - Option> get failureOption => - cbjEntityName.value.fold((f) => some(f), (_) => none()); - - // return body.failureOrUnit - // .andThen(todos.failureOrUnit) - // .andThen( - // todos - // .getOrCrash() - // // Getting the failureOption from the TodoItem ENTITY - NOT a failureOrUnit from a VALUE OBJECT - // .map((todoItem) => todoItem.failureOption) - // .filter((o) => o.isSome()) - // // If we can't get the 0th element, the list is empty. In such a case, it's valid. - // .getOrElse(0, (_) => none()) - // .fold(() => right(unit), (f) => left(f)), - // ) - // .fold((f) => some(f), (_) => none()); - // } - - @override - String getDeviceId() { - return uniqueId.getOrCrash(); - } - - /// Return a list of all valid actions for this device - @override - List getAllValidActions() { - return GenericRgbwLightSwitchState.rgbwLightValidActions(); - } - - @override - DeviceEntityDtoAbstract toInfrastructure() { - return GenericRgbwLightDeviceDtos( - deviceDtoClass: (GenericRgbwLightDeviceDtos).toString(), - id: uniqueId.getOrCrash(), - entityUniqueId: entityUniqueId.getOrCrash(), - cbjEntityName: cbjEntityName.getOrCrash(), - entityOriginalName: entityOriginalName.getOrCrash(), - deviceOriginalName: deviceOriginalName.getOrCrash(), - entityStateGRPC: entityStateGRPC.getOrCrash(), - stateMassage: stateMassage.getOrCrash(), - senderDeviceOs: senderDeviceOs.getOrCrash(), - senderDeviceModel: senderDeviceModel.getOrCrash(), - senderId: senderId.getOrCrash(), - entityTypes: entityTypes.getOrCrash(), - compUuid: compUuid.getOrCrash(), - deviceVendor: deviceVendor.getOrCrash(), - powerConsumption: powerConsumption.getOrCrash(), - deviceUniqueId: deviceUniqueId.getOrCrash(), - devicePort: devicePort.getOrCrash(), - deviceLastKnownIp: deviceLastKnownIp.getOrCrash(), - deviceHostName: deviceHostName.getOrCrash(), - deviceMdns: deviceMdns.getOrCrash(), - devicesMacAddress: devicesMacAddress.getOrCrash(), - entityKey: entityKey.getOrCrash(), - requestTimeStamp: requestTimeStamp.getOrCrash(), - lastResponseFromDeviceTimeStamp: - lastResponseFromDeviceTimeStamp.getOrCrash(), - deviceCbjUniqueId: deviceCbjUniqueId.getOrCrash(), - lightSwitchState: lightSwitchState!.getOrCrash(), - lightColorTemperature: lightColorTemperature.getOrCrash(), - lightBrightness: lightBrightness.getOrCrash(), - lightColorAlpha: lightColorAlpha.getOrCrash(), - lightColorHue: lightColorHue.getOrCrash(), - lightColorSaturation: lightColorSaturation.getOrCrash(), - lightColorValue: lightColorValue.getOrCrash(), - ); - } - - /// Please override the following methods - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> turnOnLight() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> turnOffLight() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> setBrightness(String brightness) async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> changeColorTemperature({ - required String lightColorTemperatureNewValue, - }) async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> changeColorHsv({ - required String lightColorAlphaNewValue, - required String lightColorHueNewValue, - required String lightColorSaturationNewValue, - required String lightColorValueNewValue, - }) async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - @override - bool replaceActionIfExist(String action) { - if (GenericRgbwLightSwitchState.rgbwLightValidActions().contains(action)) { - lightSwitchState = GenericRgbwLightSwitchState(action); - return true; - } - return false; - } - - @override - List getListOfPropertiesToChange() { - return [ - 'lightSwitchState', - 'lightColorTemperature', - 'lightColorAlpha', - 'lightColorHue', - 'lightColorSaturation', - 'lightColorValue', - 'lightBrightness', - ]; - } -} diff --git a/lib/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_validators.dart b/lib/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_validators.dart deleted file mode 100644 index c6cbe52c..00000000 --- a/lib/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_validators.dart +++ /dev/null @@ -1,50 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateGenericRgbwLightStateNotEmpty( - String input, -) { - return right(input); -} - -Either, String> validateGenericRgbwLightStringNotEmpty( - String input, -) { - return right(input); -} - -Either, String> - validateGenericRgbwLightColorTemperatureNotEmpty(String input) { - return right(input); -} - -Either, String> validateGenericRgbwLightBrightnessNotEmpty( - String input, -) { - return right(input); -} - -Either, String> validateGenericRgbwLightAlphaNotEmpty( - String input, -) { - return right(input); -} - -Either, String> validateGenericRgbwLightStringIsDouble( - String input, -) { - if (double.tryParse(input) != null) { - return right(input); - } else { - return left(CoreFailure.empty(failedValue: input)); - } -} - -/// Return all the valid actions for rgbw light -List rgbwLightAllValidActions() { - return [ - EntityActions.off.toString(), - EntityActions.on.toString(), - ]; -} diff --git a/lib/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_value_objects.dart b/lib/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_value_objects.dart deleted file mode 100644 index b990bba5..00000000 --- a/lib/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_value_objects.dart +++ /dev/null @@ -1,131 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_validators.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:dartz/dartz.dart'; - -class GenericRgbwLightSwitchState extends ValueObjectCore { - factory GenericRgbwLightSwitchState(String? input) { - assert(input != null); - if (input!.toLowerCase() == true.toString()) { - input = EntityActions.on.toString(); - } else if (input.toLowerCase() == false.toString()) { - input = EntityActions.off.toString(); - } - return GenericRgbwLightSwitchState._( - validateGenericRgbwLightStateNotEmpty(input), - ); - } - - const GenericRgbwLightSwitchState._(this.value); - - @override - final Either, String> value; - - /// All valid actions of rgb light state - static List rgbwLightValidActions() { - return rgbwLightAllValidActions(); - } -} - -class GenericRgbwLightColorTemperature extends ValueObjectCore { - factory GenericRgbwLightColorTemperature(String? input) { - assert(input != null); - return GenericRgbwLightColorTemperature._( - validateGenericRgbwLightStateNotEmpty(input!), - ); - } - - const GenericRgbwLightColorTemperature._(this.value); - - @override - final Either, String> value; -} - -/// Alpha, from 0.0 to 1.0. The describes the transparency of the color. -/// A value of 0.0 is fully transparent, and 1.0 is fully opaque. -class GenericRgbwLightColorAlpha extends ValueObjectCore { - factory GenericRgbwLightColorAlpha(String? input) { - assert(input != null); - return GenericRgbwLightColorAlpha._( - validateGenericRgbwLightAlphaNotEmpty(input!) - .flatMap((a) => validateGenericRgbwLightStringIsDouble(a)), - ); - } - - const GenericRgbwLightColorAlpha._(this.value); - - @override - final Either, String> value; -} - -/// Hue, from 0.0 to 360.0. Describes which color of the spectrum is -/// represented. A value of 0.0 represents red, as does 360.0. Values in -/// between go through all the hues representable in RGB. You can think of -/// this as selecting which pigment will be added to a color. -class GenericRgbwLightColorHue extends ValueObjectCore { - factory GenericRgbwLightColorHue(String? input) { - assert(input != null); - return GenericRgbwLightColorHue._( - validateGenericRgbwLightStringNotEmpty(input!) - .flatMap((a) => validateGenericRgbwLightStringIsDouble(a)), - ); - } - - const GenericRgbwLightColorHue._(this.value); - - @override - final Either, String> value; -} - -/// Saturation, from 0.0 to 1.0. This describes how colorful the color is. -/// 0.0 implies a shade of grey (i.e. no pigment), and 1.0 implies a color as -/// vibrant as that hue gets. You can think of this as the equivalent of -/// how much of a pigment is added. -class GenericRgbwLightColorSaturation extends ValueObjectCore { - factory GenericRgbwLightColorSaturation(String? input) { - assert(input != null); - return GenericRgbwLightColorSaturation._( - validateGenericRgbwLightStringNotEmpty(input!) - .flatMap((a) => validateGenericRgbwLightStringIsDouble(a)), - ); - } - - const GenericRgbwLightColorSaturation._(this.value); - - @override - final Either, String> value; -} - -/// Value, from 0.0 to 1.0. The "value" of a color that, in this context, -/// describes how bright a color is. A value of 0.0 indicates black, and 1.0 -/// indicates full intensity color. You can think of this as the equivalent of -/// removing black from the color as value increases. -class GenericRgbwLightColorValue extends ValueObjectCore { - factory GenericRgbwLightColorValue(String? input) { - assert(input != null); - return GenericRgbwLightColorValue._( - validateGenericRgbwLightStringNotEmpty(input!) - .flatMap((a) => validateGenericRgbwLightStringIsDouble(a)), - ); - } - - const GenericRgbwLightColorValue._(this.value); - - @override - final Either, String> value; -} - -class GenericRgbwLightBrightness extends ValueObjectCore { - factory GenericRgbwLightBrightness(String? input) { - assert(input != null); - return GenericRgbwLightBrightness._( - validateGenericRgbwLightBrightnessNotEmpty(input!), - ); - } - - const GenericRgbwLightBrightness._(this.value); - - @override - final Either, String> value; -} diff --git a/lib/domain/generic_devices/generic_smart_computer_device/generic_smart_computer_entity.dart b/lib/domain/generic_devices/generic_smart_computer_device/generic_smart_computer_entity.dart deleted file mode 100644 index de25e155..00000000 --- a/lib/domain/generic_devices/generic_smart_computer_device/generic_smart_computer_entity.dart +++ /dev/null @@ -1,204 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_computer_device/generic_smart_computer_value_objects.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/generic_smart_computer_device/generic_smart_computer_device_dtos.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; - -/// Abstract smart GenericSmartComputer that exist inside a computer, the -/// implementations will be actual GenericSmartComputer like blinds smartComputers and more -class GenericSmartComputerDE extends DeviceEntityAbstract { - /// All public field of GenericSmartComputer entity - GenericSmartComputerDE({ - required super.uniqueId, - required super.entityUniqueId, - required super.deviceVendor, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required this.smartComputerSuspendState, - required this.smartComputerShutDownState, - }) : super( - entityTypes: EntityType(EntityTypes.smartComputer.toString()), - ); - - /// Empty instance of GenericSmartComputerEntity - factory GenericSmartComputerDE.empty() => GenericSmartComputerDE( - uniqueId: CoreUniqueId(), - entityUniqueId: EntityUniqueId(''), - cbjEntityName: CbjEntityName(''), - entityOriginalName: EntityOriginalName(''), - deviceOriginalName: DeviceOriginalName(''), - entityStateGRPC: EntityState(''), - senderDeviceOs: DeviceSenderDeviceOs(''), - senderDeviceModel: DeviceSenderDeviceModel(''), - stateMassage: DeviceStateMassage(''), - senderId: DeviceSenderId(), - deviceVendor: DeviceVendor(''), - deviceUniqueId: DeviceUniqueId(''), - devicePort: DevicePort(''), - deviceLastKnownIp: DeviceLastKnownIp(''), - deviceHostName: DeviceHostName(''), - deviceMdns: DeviceMdns(''), - compUuid: DeviceCompUuid(''), - powerConsumption: DevicePowerConsumption(''), - devicesMacAddress: DevicesMacAddress(''), - entityKey: EntityKey(''), - requestTimeStamp: RequestTimeStamp(''), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp(''), - deviceCbjUniqueId: CoreUniqueId(), - smartComputerSuspendState: GenericSmartComputerSuspendState( - EntityActions.itIsFalse.toString(), - ), - smartComputerShutDownState: GenericSmartComputerShutdownState( - EntityActions.itIsFalse.toString(), - ), - ); - - /// Suspend state smart computer - GenericSmartComputerSuspendState? smartComputerSuspendState; - - /// Shut down state smart computer - GenericSmartComputerShutdownState? smartComputerShutDownState; - - // - // /// Will return failure if any of the fields failed or return unit if fields - // /// have legit values - Option> get failureOption => - cbjEntityName.value.fold((f) => some(f), (_) => none()); - // - // return body.failureOrUnit - // .andThen(todos.failureOrUnit) - // .andThen( - // todos - // .getOrCrash() - // // Getting the failureOption from the TodoItem ENTITY - NOT a failureOrUnit from a VALUE OBJECT - // .map((todoItem) => todoItem.failureOption) - // .filter((o) => o.isSome()) - // // If we can't get the 0th element, the list is empty. In such a case, it's valid. - // .getOrElse(0, (_) => none()) - // .fold(() => right(unit), (f) => left(f)), - // ) - // .fold((f) => some(f), (_) => none()); - // } - - @override - String getDeviceId() { - return uniqueId.getOrCrash(); - } - - /// Return a list of all valid actions for this device - @override - List getAllValidActions() { - return GenericSmartComputerSuspendState.smartComputerValidActions(); - } - - @override - DeviceEntityDtoAbstract toInfrastructure() { - return GenericSmartComputerDeviceDtos( - deviceDtoClass: (GenericSmartComputerDeviceDtos).toString(), - id: uniqueId.getOrCrash(), - entityUniqueId: entityUniqueId.getOrCrash(), - cbjEntityName: cbjEntityName.getOrCrash(), - entityOriginalName: entityOriginalName.getOrCrash(), - deviceOriginalName: deviceOriginalName.getOrCrash(), - entityStateGRPC: entityStateGRPC.getOrCrash(), - stateMassage: stateMassage.getOrCrash(), - senderDeviceOs: senderDeviceOs.getOrCrash(), - senderDeviceModel: senderDeviceModel.getOrCrash(), - senderId: senderId.getOrCrash(), - entityTypes: entityTypes.getOrCrash(), - compUuid: compUuid.getOrCrash(), - deviceVendor: deviceVendor.getOrCrash(), - powerConsumption: powerConsumption.getOrCrash(), - deviceUniqueId: deviceUniqueId.getOrCrash(), - devicePort: devicePort.getOrCrash(), - deviceLastKnownIp: deviceLastKnownIp.getOrCrash(), - deviceHostName: deviceHostName.getOrCrash(), - deviceMdns: deviceMdns.getOrCrash(), - devicesMacAddress: devicesMacAddress.getOrCrash(), - entityKey: entityKey.getOrCrash(), - requestTimeStamp: requestTimeStamp.getOrCrash(), - lastResponseFromDeviceTimeStamp: - lastResponseFromDeviceTimeStamp.getOrCrash(), - deviceCbjUniqueId: deviceCbjUniqueId.getOrCrash(), - smartComputerSuspendState: smartComputerSuspendState!.getOrCrash(), - smartComputerShutDownState: smartComputerShutDownState!.getOrCrash(), - ); - } - - /// Please override the following methods - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> suspendSmartComputer() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> shutDownSmartComputer() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - @override - bool replaceActionIfExist(String action) { - if (GenericSmartComputerSuspendState.smartComputerValidActions() - .contains(action)) { - smartComputerSuspendState = GenericSmartComputerSuspendState(action); - return true; - } else if (GenericSmartComputerShutdownState.smartComputerValidActions() - .contains(action)) { - smartComputerShutDownState = GenericSmartComputerShutdownState(action); - return true; - } - return false; - } - - @override - List getListOfPropertiesToChange() { - return [ - 'smartComputerSuspendState', - 'smartComputerShutDownState', - ]; - } -} diff --git a/lib/domain/generic_devices/generic_smart_computer_device/generic_smart_computer_validators.dart b/lib/domain/generic_devices/generic_smart_computer_device/generic_smart_computer_validators.dart deleted file mode 100644 index 1dcd50a9..00000000 --- a/lib/domain/generic_devices/generic_smart_computer_device/generic_smart_computer_validators.dart +++ /dev/null @@ -1,18 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateGenericSmartComputerStateNotEmpty( - String input, -) { - return right(input); -} - -/// Return all the valid actions for blinds -List smartComputerAllValidActions() { - return [ - EntityActions.suspend.toString(), - EntityActions.shutdown.toString(), - EntityActions.itIsFalse.toString(), - ]; -} diff --git a/lib/domain/generic_devices/generic_smart_computer_device/generic_smart_computer_value_objects.dart b/lib/domain/generic_devices/generic_smart_computer_device/generic_smart_computer_value_objects.dart deleted file mode 100644 index d4a1e06e..00000000 --- a/lib/domain/generic_devices/generic_smart_computer_device/generic_smart_computer_value_objects.dart +++ /dev/null @@ -1,40 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_computer_device/generic_smart_computer_validators.dart'; -import 'package:dartz/dartz.dart'; - -class GenericSmartComputerSuspendState extends ValueObjectCore { - factory GenericSmartComputerSuspendState(String? input) { - assert(input != null); - return GenericSmartComputerSuspendState._( - validateGenericSmartComputerStateNotEmpty(input!), - ); - } - - const GenericSmartComputerSuspendState._(this.value); - - @override - final Either, String> value; - - static List smartComputerValidActions() { - return smartComputerAllValidActions(); - } -} - -class GenericSmartComputerShutdownState extends ValueObjectCore { - factory GenericSmartComputerShutdownState(String? input) { - assert(input != null); - return GenericSmartComputerShutdownState._( - validateGenericSmartComputerStateNotEmpty(input!), - ); - } - - const GenericSmartComputerShutdownState._(this.value); - - @override - final Either, String> value; - - static List smartComputerValidActions() { - return smartComputerAllValidActions(); - } -} diff --git a/lib/domain/generic_devices/generic_smart_plug_device/generic_smart_plug_entity.dart b/lib/domain/generic_devices/generic_smart_plug_device/generic_smart_plug_entity.dart deleted file mode 100644 index 214d1acd..00000000 --- a/lib/domain/generic_devices/generic_smart_plug_device/generic_smart_plug_entity.dart +++ /dev/null @@ -1,188 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_plug_device/generic_smart_plug_value_objects.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/generic_smart_plug_device/generic_smart_plug_device_dtos.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; - -/// Abstract smart GenericSmartPlug that exist inside a computer, the -/// implementations will be actual GenericSmartPlug like blinds smartPlugs and more -class GenericSmartPlugDE extends DeviceEntityAbstract { - /// All public field of GenericSmartPlug entity - GenericSmartPlugDE({ - required super.uniqueId, - required super.entityUniqueId, - required super.deviceVendor, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required this.smartPlugState, - }) : super( - entityTypes: EntityType(EntityTypes.smartPlug.toString()), - ); - - /// Empty instance of GenericSmartPlugEntity - factory GenericSmartPlugDE.empty() => GenericSmartPlugDE( - uniqueId: CoreUniqueId(), - entityUniqueId: EntityUniqueId(''), - cbjEntityName: CbjEntityName(''), - entityOriginalName: EntityOriginalName(''), - deviceOriginalName: DeviceOriginalName(''), - entityStateGRPC: EntityState(''), - senderDeviceOs: DeviceSenderDeviceOs(''), - senderDeviceModel: DeviceSenderDeviceModel(''), - stateMassage: DeviceStateMassage(''), - senderId: DeviceSenderId(), - deviceVendor: DeviceVendor(''), - deviceUniqueId: DeviceUniqueId(''), - devicePort: DevicePort(''), - deviceLastKnownIp: DeviceLastKnownIp(''), - deviceHostName: DeviceHostName(''), - deviceMdns: DeviceMdns(''), - compUuid: DeviceCompUuid(''), - powerConsumption: DevicePowerConsumption(''), - devicesMacAddress: DevicesMacAddress(''), - entityKey: EntityKey(''), - requestTimeStamp: RequestTimeStamp(''), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp(''), - deviceCbjUniqueId: CoreUniqueId(), - smartPlugState: GenericSmartPlugState(EntityActions.off.toString()), - ); - - /// State of the smartPlug on/off - GenericSmartPlugState? smartPlugState; - - // - // /// Will return failure if any of the fields failed or return unit if fields - // /// have legit values - Option> get failureOption => - cbjEntityName.value.fold((f) => some(f), (_) => none()); - // - // return body.failureOrUnit - // .andThen(todos.failureOrUnit) - // .andThen( - // todos - // .getOrCrash() - // // Getting the failureOption from the TodoItem ENTITY - NOT a failureOrUnit from a VALUE OBJECT - // .map((todoItem) => todoItem.failureOption) - // .filter((o) => o.isSome()) - // // If we can't get the 0th element, the list is empty. In such a case, it's valid. - // .getOrElse(0, (_) => none()) - // .fold(() => right(unit), (f) => left(f)), - // ) - // .fold((f) => some(f), (_) => none()); - // } - - @override - String getDeviceId() { - return uniqueId.getOrCrash(); - } - - /// Return a list of all valid actions for this device - @override - List getAllValidActions() { - return GenericSmartPlugState.lightValidActions(); - } - - @override - DeviceEntityDtoAbstract toInfrastructure() { - return GenericSmartPlugDeviceDtos( - deviceDtoClass: (GenericSmartPlugDeviceDtos).toString(), - id: uniqueId.getOrCrash(), - entityUniqueId: entityUniqueId.getOrCrash(), - cbjEntityName: cbjEntityName.getOrCrash(), - entityOriginalName: entityOriginalName.getOrCrash(), - deviceOriginalName: deviceOriginalName.getOrCrash(), - entityStateGRPC: entityStateGRPC.getOrCrash(), - stateMassage: stateMassage.getOrCrash(), - senderDeviceOs: senderDeviceOs.getOrCrash(), - senderDeviceModel: senderDeviceModel.getOrCrash(), - senderId: senderId.getOrCrash(), - entityTypes: entityTypes.getOrCrash(), - compUuid: compUuid.getOrCrash(), - deviceVendor: deviceVendor.getOrCrash(), - powerConsumption: powerConsumption.getOrCrash(), - deviceUniqueId: deviceUniqueId.getOrCrash(), - devicePort: devicePort.getOrCrash(), - deviceLastKnownIp: deviceLastKnownIp.getOrCrash(), - deviceHostName: deviceHostName.getOrCrash(), - deviceMdns: deviceMdns.getOrCrash(), - devicesMacAddress: devicesMacAddress.getOrCrash(), - entityKey: entityKey.getOrCrash(), - requestTimeStamp: requestTimeStamp.getOrCrash(), - lastResponseFromDeviceTimeStamp: - lastResponseFromDeviceTimeStamp.getOrCrash(), - deviceCbjUniqueId: deviceCbjUniqueId.getOrCrash(), - smartPlugState: smartPlugState!.getOrCrash(), - ); - } - - /// Please override the following methods - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> turnOnSmartPlug() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> turnOffSmartPlug() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - @override - bool replaceActionIfExist(String action) { - if (GenericSmartPlugState.lightValidActions().contains(action)) { - smartPlugState = GenericSmartPlugState(action); - return true; - } - return false; - } - - @override - List getListOfPropertiesToChange() { - return [ - 'smartPlugState', - ]; - } -} diff --git a/lib/domain/generic_devices/generic_smart_plug_device/generic_smart_plug_validators.dart b/lib/domain/generic_devices/generic_smart_plug_device/generic_smart_plug_validators.dart deleted file mode 100644 index 0d960308..00000000 --- a/lib/domain/generic_devices/generic_smart_plug_device/generic_smart_plug_validators.dart +++ /dev/null @@ -1,17 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateGenericSmartPlugStateNotEmpty( - String input, -) { - return right(input); -} - -/// Return all the valid actions for light -List lightAllValidActions() { - return [ - EntityActions.off.toString(), - EntityActions.on.toString(), - ]; -} diff --git a/lib/domain/generic_devices/generic_smart_plug_device/generic_smart_plug_value_objects.dart b/lib/domain/generic_devices/generic_smart_plug_device/generic_smart_plug_value_objects.dart deleted file mode 100644 index 5015563c..00000000 --- a/lib/domain/generic_devices/generic_smart_plug_device/generic_smart_plug_value_objects.dart +++ /dev/null @@ -1,23 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_plug_device/generic_smart_plug_validators.dart'; -import 'package:dartz/dartz.dart'; - -class GenericSmartPlugState extends ValueObjectCore { - factory GenericSmartPlugState(String? input) { - assert(input != null); - return GenericSmartPlugState._( - validateGenericSmartPlugStateNotEmpty(input!), - ); - } - - const GenericSmartPlugState._(this.value); - - @override - final Either, String> value; - - /// All valid actions of light state - static List lightValidActions() { - return lightAllValidActions(); - } -} diff --git a/lib/domain/generic_devices/generic_smart_tv/generic_smart_tv_entity.dart b/lib/domain/generic_devices/generic_smart_tv/generic_smart_tv_entity.dart deleted file mode 100644 index ac45f72e..00000000 --- a/lib/domain/generic_devices/generic_smart_tv/generic_smart_tv_entity.dart +++ /dev/null @@ -1,286 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_tv/generic_smart_tv_value_objects.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/generic_smart_tv_device/generic_smart_tv_device_dtos.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; - -/// Abstract smart GenericSmartTv that exist inside a computer, the -/// implementations will be actual GenericSmartTv like blinds smartTvs and more -class GenericSmartTvDE extends DeviceEntityAbstract { - /// All public field of GenericSmartTv entity - GenericSmartTvDE({ - required super.uniqueId, - required super.entityUniqueId, - required super.deviceVendor, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required this.smartTvSwitchState, - this.openUrl, - this.pausePlayState, - this.skip, - this.volume, - }) : super( - entityTypes: EntityType(EntityTypes.smartTV.toString()), - ); - - /// Empty instance of GenericSmartTvEntity - factory GenericSmartTvDE.empty() => GenericSmartTvDE( - uniqueId: CoreUniqueId(), - entityUniqueId: EntityUniqueId(''), - cbjEntityName: CbjEntityName(''), - entityOriginalName: EntityOriginalName(''), - deviceOriginalName: DeviceOriginalName(''), - entityStateGRPC: EntityState(''), - senderDeviceOs: DeviceSenderDeviceOs(''), - senderDeviceModel: DeviceSenderDeviceModel(''), - stateMassage: DeviceStateMassage(''), - senderId: DeviceSenderId(), - deviceVendor: DeviceVendor(''), - deviceUniqueId: DeviceUniqueId(''), - devicePort: DevicePort(''), - deviceLastKnownIp: DeviceLastKnownIp(''), - deviceHostName: DeviceHostName(''), - deviceMdns: DeviceMdns(''), - compUuid: DeviceCompUuid(''), - powerConsumption: DevicePowerConsumption(''), - devicesMacAddress: DevicesMacAddress(''), - entityKey: EntityKey(''), - requestTimeStamp: RequestTimeStamp(''), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp(''), - deviceCbjUniqueId: CoreUniqueId(), - smartTvSwitchState: - GenericSmartTvSwitchState(EntityActions.off.toString()), - ); - - /// State of the smartTv on/off - GenericSmartTvSwitchState? smartTvSwitchState; - GenericSmartTvOpenUrl? openUrl; - GenericSmartTvPausePlayState? pausePlayState; - GenericSmartTvSkipBackOrForward? skip; - GenericSmartTvVolume? volume; - - // - // /// Will return failure if any of the fields failed or return unit if fields - // /// have legit values - Option> get failureOption => - cbjEntityName.value.fold((f) => some(f), (_) => none()); - // - // return body.failureOrUnit - // .andThen(todos.failureOrUnit) - // .andThen( - // todos - // .getOrCrash() - // // Getting the failureOption from the TodoItem ENTITY - NOT a failureOrUnit from a VALUE OBJECT - // .map((todoItem) => todoItem.failureOption) - // .filter((o) => o.isSome()) - // // If we can't get the 0th element, the list is empty. In such a case, it's valid. - // .getOrElse(0, (_) => none()) - // .fold(() => right(unit), (f) => left(f)), - // ) - // .fold((f) => some(f), (_) => none()); - // } - - @override - String getDeviceId() { - return uniqueId.getOrCrash(); - } - - /// Return a list of all valid actions for this device - @override - List getAllValidActions() { - return GenericSmartTvSwitchState.smartTvValidActions(); - } - - @override - DeviceEntityDtoAbstract toInfrastructure() { - return GenericSmartTvDeviceDtos( - deviceDtoClass: (GenericSmartTvDeviceDtos).toString(), - id: uniqueId.getOrCrash(), - entityUniqueId: entityUniqueId.getOrCrash(), - cbjEntityName: cbjEntityName.getOrCrash(), - entityOriginalName: entityOriginalName.getOrCrash(), - deviceOriginalName: deviceOriginalName.getOrCrash(), - entityStateGRPC: entityStateGRPC.getOrCrash(), - stateMassage: stateMassage.getOrCrash(), - senderDeviceOs: senderDeviceOs.getOrCrash(), - senderDeviceModel: senderDeviceModel.getOrCrash(), - senderId: senderId.getOrCrash(), - entityTypes: entityTypes.getOrCrash(), - compUuid: compUuid.getOrCrash(), - powerConsumption: powerConsumption.getOrCrash(), - deviceUniqueId: deviceUniqueId.getOrCrash(), - devicePort: devicePort.getOrCrash(), - deviceLastKnownIp: deviceLastKnownIp.getOrCrash(), - deviceHostName: deviceHostName.getOrCrash(), - deviceMdns: deviceMdns.getOrCrash(), - devicesMacAddress: devicesMacAddress.getOrCrash(), - entityKey: entityKey.getOrCrash(), - requestTimeStamp: requestTimeStamp.getOrCrash(), - lastResponseFromDeviceTimeStamp: - lastResponseFromDeviceTimeStamp.getOrCrash(), - deviceCbjUniqueId: deviceCbjUniqueId.getOrCrash(), - smartTvSwitchState: smartTvSwitchState!.getOrCrash(), - deviceVendor: deviceVendor.getOrCrash(), - openUrl: openUrl?.getOrCrash(), - pausePlayState: pausePlayState?.getOrCrash(), - skip: skip?.getOrCrash(), - volume: volume?.getOrCrash(), - ); - } - - /// Please override the following methods - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> turnOnSmartTv() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> turnOffSmartTv() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> sendUrlToDevice(String newUrl) async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> togglePausePlay( - String toggleNewState, - ) async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> togglePause() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> togglePlay() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> toggleStop() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> queueNext() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> queuePrev() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> closeApp() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - @override - bool replaceActionIfExist(String action) { - if (GenericSmartTvSwitchState.smartTvValidActions().contains(action)) { - smartTvSwitchState = GenericSmartTvSwitchState(action); - return true; - } - return false; - } - - @override - List getListOfPropertiesToChange() { - return [ - 'smartTvSwitchState', - 'openUrl', - 'skip', - 'volume', - ]; - } -} diff --git a/lib/domain/generic_devices/generic_smart_tv/generic_smart_tv_validators.dart b/lib/domain/generic_devices/generic_smart_tv/generic_smart_tv_validators.dart deleted file mode 100644 index 8a169b6c..00000000 --- a/lib/domain/generic_devices/generic_smart_tv/generic_smart_tv_validators.dart +++ /dev/null @@ -1,46 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateGenericSmartTvStateNotEmpty( - String input, -) { - return right(input); -} - -Either, String> validateGenericSmartTvUrlValidation( - String input, -) { - return right(input); -} - -Either, String> - validateGenericSmartTvPausePlayStateValidation( - String input, -) { - return right(input); -} - -Either, String> - validateGenericSmartTvSkipBackOrForwardValidation( - String input, -) { - return right(input); -} - -Either, String> validateGenericSmartTvVolumeValidation( - String input, -) { - return right(input); -} - -/// Return all the valid actions for smart tv -List smartTvAllValidActions() { - return [ - EntityActions.off.toString(), - EntityActions.on.toString(), - EntityActions.pausePlay.toString(), - EntityActions.changeVolume.toString(), - EntityActions.skip.toString(), - ]; -} diff --git a/lib/domain/generic_devices/generic_smart_tv/generic_smart_tv_value_objects.dart b/lib/domain/generic_devices/generic_smart_tv/generic_smart_tv_value_objects.dart deleted file mode 100644 index 2458dc58..00000000 --- a/lib/domain/generic_devices/generic_smart_tv/generic_smart_tv_value_objects.dart +++ /dev/null @@ -1,99 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_tv/generic_smart_tv_validators.dart'; -import 'package:dartz/dartz.dart'; - -class GenericSmartTvSwitchState extends ValueObjectCore { - factory GenericSmartTvSwitchState(String? input) { - assert(input != null); - return GenericSmartTvSwitchState._( - validateGenericSmartTvStateNotEmpty(input!), - ); - } - - const GenericSmartTvSwitchState._(this.value); - - @override - final Either, String> value; - - /// All valid actions of smart tv state - static List smartTvValidActions() { - return smartTvAllValidActions(); - } -} - -class GenericSmartTvOpenUrl extends ValueObjectCore { - factory GenericSmartTvOpenUrl(String? input) { - assert(input != null); - return GenericSmartTvOpenUrl._( - validateGenericSmartTvUrlValidation(input!), - ); - } - - const GenericSmartTvOpenUrl._(this.value); - - @override - final Either, String> value; - - /// All valid actions of smart tv state - static List smartTvValidActions() { - return smartTvAllValidActions(); - } -} - -class GenericSmartTvPausePlayState extends ValueObjectCore { - factory GenericSmartTvPausePlayState(String? input) { - assert(input != null); - return GenericSmartTvPausePlayState._( - validateGenericSmartTvPausePlayStateValidation(input!), - ); - } - - const GenericSmartTvPausePlayState._(this.value); - - @override - final Either, String> value; - - /// All valid actions of smart tv state - static List smartTvValidActions() { - return smartTvAllValidActions(); - } -} - -class GenericSmartTvSkipBackOrForward extends ValueObjectCore { - factory GenericSmartTvSkipBackOrForward(String? input) { - assert(input != null); - return GenericSmartTvSkipBackOrForward._( - validateGenericSmartTvSkipBackOrForwardValidation(input!), - ); - } - - const GenericSmartTvSkipBackOrForward._(this.value); - - @override - final Either, String> value; - - /// All valid actions of smart tv state - static List smartTvValidActions() { - return smartTvAllValidActions(); - } -} - -class GenericSmartTvVolume extends ValueObjectCore { - factory GenericSmartTvVolume(String? input) { - assert(input != null); - return GenericSmartTvVolume._( - validateGenericSmartTvVolumeValidation(input!), - ); - } - - const GenericSmartTvVolume._(this.value); - - @override - final Either, String> value; - - /// All valid actions of smart tv state - static List smartTvValidActions() { - return smartTvAllValidActions(); - } -} diff --git a/lib/domain/generic_devices/generic_smart_type_not_supported_device/generic_smart_type_not_supported_entity.dart b/lib/domain/generic_devices/generic_smart_type_not_supported_device/generic_smart_type_not_supported_entity.dart deleted file mode 100644 index d94f0726..00000000 --- a/lib/domain/generic_devices/generic_smart_type_not_supported_device/generic_smart_type_not_supported_entity.dart +++ /dev/null @@ -1,176 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/generic_smart_type_type_not_supported_device/generic_smart_type_not_supported_device_dtos.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; - -/// Abstract smart GenericSmartTypeNotSupported that exist inside a computer, the -/// implementations will be actual GenericSmartTypeNotSupported like smartTypeNotSupported smartTypeNotSupporteds and more -class GenericSmartTypeNotSupportedDE extends DeviceEntityAbstract { - /// All public field of GenericSmartTypeNotSupported entity - GenericSmartTypeNotSupportedDE({ - required super.uniqueId, - required super.entityUniqueId, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.deviceVendor, - required super.entityStateGRPC, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - }) : super( - entityTypes: EntityType(EntityTypes.smartTypeNotSupported.toString()), - ); - - /// Empty instance of GenericSmartTypeNotSupportedEntity - factory GenericSmartTypeNotSupportedDE.empty() => - GenericSmartTypeNotSupportedDE( - uniqueId: CoreUniqueId(), - entityUniqueId: EntityUniqueId(''), - cbjEntityName: CbjEntityName(''), - entityOriginalName: EntityOriginalName(''), - deviceOriginalName: DeviceOriginalName(''), - entityStateGRPC: EntityState(''), - senderDeviceOs: DeviceSenderDeviceOs(''), - senderDeviceModel: DeviceSenderDeviceModel(''), - stateMassage: DeviceStateMassage(''), - senderId: DeviceSenderId(), - deviceVendor: DeviceVendor(''), - deviceUniqueId: DeviceUniqueId(''), - devicePort: DevicePort(''), - deviceLastKnownIp: DeviceLastKnownIp(''), - deviceHostName: DeviceHostName(''), - deviceMdns: DeviceMdns(''), - compUuid: DeviceCompUuid(''), - powerConsumption: DevicePowerConsumption(''), - devicesMacAddress: DevicesMacAddress(''), - entityKey: EntityKey(''), - requestTimeStamp: RequestTimeStamp(''), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp(''), - deviceCbjUniqueId: CoreUniqueId(), - ); - - // - // /// Will return failure if any of the fields failed or return unit if fields - // /// have legit values - Option> get failureOption => - cbjEntityName.value.fold((f) => some(f), (_) => none()); - // - // return body.failureOrUnit - // .andThen(todos.failureOrUnit) - // .andThen( - // todos - // .getOrCrash() - // // Getting the failureOption from the TodoItem ENTITY - NOT a failureOrUnit from a VALUE OBJECT - // .map((todoItem) => todoItem.failureOption) - // .filter((o) => o.isSome()) - // // If we can't get the 0th element, the list is empty. In such a case, it's valid. - // .getOrElse(0, (_) => none()) - // .fold(() => right(unit), (f) => left(f)), - // ) - // .fold((f) => some(f), (_) => none()); - // } - - @override - String getDeviceId() { - return uniqueId.getOrCrash(); - } - - /// Return a list of all valid actions for this device - @override - List getAllValidActions() { - return []; - } - - @override - DeviceEntityDtoAbstract toInfrastructure() { - return GenericSmartTypeNotSupportedDeviceDtos( - deviceDtoClass: (GenericSmartTypeNotSupportedDeviceDtos).toString(), - id: uniqueId.getOrCrash(), - entityUniqueId: entityUniqueId.getOrCrash(), - cbjEntityName: cbjEntityName.getOrCrash(), - entityOriginalName: entityOriginalName.getOrCrash(), - deviceOriginalName: deviceOriginalName.getOrCrash(), - entityStateGRPC: entityStateGRPC.getOrCrash(), - stateMassage: stateMassage.getOrCrash(), - senderDeviceOs: senderDeviceOs.getOrCrash(), - senderDeviceModel: senderDeviceModel.getOrCrash(), - senderId: senderId.getOrCrash(), - entityTypes: entityTypes.getOrCrash(), - compUuid: compUuid.getOrCrash(), - deviceVendor: deviceVendor.getOrCrash(), - powerConsumption: powerConsumption.getOrCrash(), - deviceUniqueId: deviceUniqueId.getOrCrash(), - devicePort: devicePort.getOrCrash(), - deviceLastKnownIp: deviceLastKnownIp.getOrCrash(), - deviceHostName: deviceHostName.getOrCrash(), - deviceMdns: deviceMdns.getOrCrash(), - devicesMacAddress: devicesMacAddress.getOrCrash(), - entityKey: entityKey.getOrCrash(), - requestTimeStamp: requestTimeStamp.getOrCrash(), - lastResponseFromDeviceTimeStamp: - lastResponseFromDeviceTimeStamp.getOrCrash(), - deviceCbjUniqueId: deviceCbjUniqueId.getOrCrash(), - ); - } - - /// Please override the following methods - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> turnOnSmartTypeNotSupported() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> turnOffSmartTypeNotSupported() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - @override - bool replaceActionIfExist(String action) { - return true; - } - - @override - List getListOfPropertiesToChange() { - return []; - } -} diff --git a/lib/domain/generic_devices/generic_smart_type_not_supported_device/generic_smart_type_not_supported_validators.dart b/lib/domain/generic_devices/generic_smart_type_not_supported_device/generic_smart_type_not_supported_validators.dart deleted file mode 100644 index b7eab090..00000000 --- a/lib/domain/generic_devices/generic_smart_type_not_supported_device/generic_smart_type_not_supported_validators.dart +++ /dev/null @@ -1,14 +0,0 @@ -// Either, String> -// validateGenericSmartTypeNotSupportedStateNotEmpty( -// String input, -// ) { -// return right(input); -// } -// -// /// Return all the valid actions for blinds -// List smartTypeNotSupportedAllValidActions() { -// return [ -// EntityActions.off.toString(), -// EntityActions.on.toString(), -// ]; -// } diff --git a/lib/domain/generic_devices/generic_smart_type_not_supported_device/generic_smart_type_not_supported_value_objects.dart b/lib/domain/generic_devices/generic_smart_type_not_supported_device/generic_smart_type_not_supported_value_objects.dart deleted file mode 100644 index 9becf101..00000000 --- a/lib/domain/generic_devices/generic_smart_type_not_supported_device/generic_smart_type_not_supported_value_objects.dart +++ /dev/null @@ -1,17 +0,0 @@ -// class GenericSmartTypeNotSupportedSwitchState extends ValueObjectCore { -// factory GenericSmartTypeNotSupportedSwitchState(String? input) { -// assert(input != null); -// return GenericSmartTypeNotSupportedSwitchState._( -// validateGenericSmartTypeNotSupportedStateNotEmpty(input!), -// ); -// } -// -// const GenericSmartTypeNotSupportedSwitchState._(this.value); -// -// @override -// final Either, String> value; -// -// static List smartTypeNotSupportedValidActions() { -// return smartTypeNotSupportedAllValidActions(); -// } -// } diff --git a/lib/domain/generic_devices/generic_switch_device/generic_switch_entity.dart b/lib/domain/generic_devices/generic_switch_device/generic_switch_entity.dart deleted file mode 100644 index 66a76daa..00000000 --- a/lib/domain/generic_devices/generic_switch_device/generic_switch_entity.dart +++ /dev/null @@ -1,188 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_value_objects.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/generic_switch_device/generic_switch_device_dtos.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; - -/// Abstract smart GenericSwitch that exist inside a computer, the -/// implementations will be actual GenericSwitch like blinds switchs and more -class GenericSwitchDE extends DeviceEntityAbstract { - /// All public field of GenericSwitch entity - GenericSwitchDE({ - required super.uniqueId, - required super.entityUniqueId, - required super.deviceVendor, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required this.switchState, - }) : super( - entityTypes: EntityType(EntityTypes.switch_.toString()), - ); - - /// Empty instance of GenericSwitchEntity - factory GenericSwitchDE.empty() => GenericSwitchDE( - uniqueId: CoreUniqueId(), - entityUniqueId: EntityUniqueId(''), - cbjEntityName: CbjEntityName(''), - entityOriginalName: EntityOriginalName(''), - deviceOriginalName: DeviceOriginalName(''), - entityStateGRPC: EntityState(''), - senderDeviceOs: DeviceSenderDeviceOs(''), - senderDeviceModel: DeviceSenderDeviceModel(''), - stateMassage: DeviceStateMassage(''), - senderId: DeviceSenderId(), - deviceVendor: DeviceVendor(''), - deviceUniqueId: DeviceUniqueId(''), - devicePort: DevicePort(''), - deviceLastKnownIp: DeviceLastKnownIp(''), - deviceHostName: DeviceHostName(''), - deviceMdns: DeviceMdns(''), - compUuid: DeviceCompUuid(''), - powerConsumption: DevicePowerConsumption(''), - devicesMacAddress: DevicesMacAddress(''), - entityKey: EntityKey(''), - requestTimeStamp: RequestTimeStamp(''), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp(''), - deviceCbjUniqueId: CoreUniqueId(), - switchState: GenericSwitchSwitchState(EntityActions.off.toString()), - ); - - /// State of the switch on/off - GenericSwitchSwitchState? switchState; - - // - // /// Will return failure if any of the fields failed or return unit if fields - // /// have legit values - Option> get failureOption => - cbjEntityName.value.fold((f) => some(f), (_) => none()); - // - // return body.failureOrUnit - // .andThen(todos.failureOrUnit) - // .andThen( - // todos - // .getOrCrash() - // // Getting the failureOption from the TodoItem ENTITY - NOT a failureOrUnit from a VALUE OBJECT - // .map((todoItem) => todoItem.failureOption) - // .filter((o) => o.isSome()) - // // If we can't get the 0th element, the list is empty. In such a case, it's valid. - // .getOrElse(0, (_) => none()) - // .fold(() => right(unit), (f) => left(f)), - // ) - // .fold((f) => some(f), (_) => none()); - // } - - @override - String getDeviceId() { - return uniqueId.getOrCrash(); - } - - /// Return a list of all valid actions for this device - @override - List getAllValidActions() { - return GenericSwitchSwitchState.smartSwitchValidActions(); - } - - @override - DeviceEntityDtoAbstract toInfrastructure() { - return GenericSwitchDeviceDtos( - deviceDtoClass: (GenericSwitchDeviceDtos).toString(), - id: uniqueId.getOrCrash(), - entityUniqueId: entityUniqueId.getOrCrash(), - cbjEntityName: cbjEntityName.getOrCrash(), - entityOriginalName: entityOriginalName.getOrCrash(), - deviceOriginalName: deviceOriginalName.getOrCrash(), - entityStateGRPC: entityStateGRPC.getOrCrash(), - stateMassage: stateMassage.getOrCrash(), - senderDeviceOs: senderDeviceOs.getOrCrash(), - senderDeviceModel: senderDeviceModel.getOrCrash(), - senderId: senderId.getOrCrash(), - entityTypes: entityTypes.getOrCrash(), - compUuid: compUuid.getOrCrash(), - deviceVendor: deviceVendor.getOrCrash(), - powerConsumption: powerConsumption.getOrCrash(), - deviceUniqueId: deviceUniqueId.getOrCrash(), - devicePort: devicePort.getOrCrash(), - deviceLastKnownIp: deviceLastKnownIp.getOrCrash(), - deviceHostName: deviceHostName.getOrCrash(), - deviceMdns: deviceMdns.getOrCrash(), - devicesMacAddress: devicesMacAddress.getOrCrash(), - entityKey: entityKey.getOrCrash(), - requestTimeStamp: requestTimeStamp.getOrCrash(), - lastResponseFromDeviceTimeStamp: - lastResponseFromDeviceTimeStamp.getOrCrash(), - deviceCbjUniqueId: deviceCbjUniqueId.getOrCrash(), - switchState: switchState!.getOrCrash(), - ); - } - - /// Please override the following methods - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> turnOnSwitch() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - Future> turnOffSwitch() async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - @override - bool replaceActionIfExist(String action) { - if (GenericSwitchSwitchState.smartSwitchValidActions().contains(action)) { - switchState = GenericSwitchSwitchState(action); - return true; - } - return false; - } - - @override - List getListOfPropertiesToChange() { - return [ - 'switchState', - ]; - } -} diff --git a/lib/domain/generic_devices/generic_switch_device/generic_switch_validators.dart b/lib/domain/generic_devices/generic_switch_device/generic_switch_validators.dart deleted file mode 100644 index be50c519..00000000 --- a/lib/domain/generic_devices/generic_switch_device/generic_switch_validators.dart +++ /dev/null @@ -1,17 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateGenericSwitchStateNotEmpty( - String input, -) { - return right(input); -} - -/// Return all the valid actions for smart switch -List smartSwitchAllValidActions() { - return [ - EntityActions.off.toString(), - EntityActions.on.toString(), - ]; -} diff --git a/lib/domain/generic_devices/generic_switch_device/generic_switch_value_objects.dart b/lib/domain/generic_devices/generic_switch_device/generic_switch_value_objects.dart deleted file mode 100644 index 228bc133..00000000 --- a/lib/domain/generic_devices/generic_switch_device/generic_switch_value_objects.dart +++ /dev/null @@ -1,23 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_validators.dart'; -import 'package:dartz/dartz.dart'; - -class GenericSwitchSwitchState extends ValueObjectCore { - factory GenericSwitchSwitchState(String? input) { - assert(input != null); - return GenericSwitchSwitchState._( - validateGenericSwitchStateNotEmpty(input!), - ); - } - - const GenericSwitchSwitchState._(this.value); - - @override - final Either, String> value; - - /// All valid actions of smart switch state - static List smartSwitchValidActions() { - return smartSwitchAllValidActions(); - } -} diff --git a/lib/domain/local_db/i_local_db_repository.dart b/lib/domain/local_db/i_local_db_repository.dart deleted file mode 100644 index fc836762..00000000 --- a/lib/domain/local_db/i_local_db_repository.dart +++ /dev/null @@ -1,161 +0,0 @@ -import 'package:cbj_hub/domain/binding/binding_cbj_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/local_db/local_db_failures.dart'; -import 'package:cbj_hub/domain/room/room_entity.dart'; -import 'package:cbj_hub/domain/routine/routine_cbj_entity.dart'; -import 'package:cbj_hub/domain/scene/scene_cbj_entity.dart'; -import 'package:cbj_hub/domain/vendors/esphome_login/generic_esphome_login_entity.dart'; -import 'package:cbj_hub/domain/vendors/ewelink_login/generic_ewelink_login_entity.dart'; -import 'package:cbj_hub/domain/vendors/lifx_login/generic_lifx_login_entity.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/login_entity_abstract.dart'; -import 'package:cbj_hub/domain/vendors/tuya_login/generic_tuya_login_entity.dart'; -import 'package:cbj_hub/domain/vendors/xiaomi_mi_login/generic_xiaomi_mi_login_entity.dart'; -import 'package:cbj_hub/infrastructure/local_db/hive_objects/esphome_vendor_credentials_hive_model.dart'; -import 'package:cbj_hub/infrastructure/local_db/hive_objects/ewelink_vendor_credentials_hive_model.dart'; -import 'package:cbj_hub/infrastructure/local_db/hive_objects/lifx_vendor_credentials_hive_model.dart'; -import 'package:cbj_hub/infrastructure/local_db/hive_objects/tuya_vendor_credentials_hive_model.dart'; -import 'package:cbj_hub/infrastructure/local_db/hive_objects/xiaomi_mi_vendor_credentials_hive_model.dart'; -import 'package:dartz/dartz.dart'; - -/// Only ISavedDevicesRepo need to call functions here -abstract class ILocalDbRepository { - /// Name of the box that stores Remote Pipes credentials - String remotePipesBoxName = 'remotePipesBox'; - - /// Name of the box that stores all the rooms - String roomsBoxName = 'roomsBox'; - - /// Name of the box that stores all the devices in form of string json - String devicesBoxName = 'devicesBox'; - - /// Name of the box that stores all the scenes in form of string json - String scenesBoxName = 'scenesBox'; - - /// Name of the box that stores all the routines in form of string json - String routinesBoxName = 'routinesBox'; - - /// Name of the box that stores all the bindings in form of string json - String bindingsBoxName = 'bindingsBox'; - - /// Name of the box that stores Tuya login credentials - String tuyaVendorCredentialsBoxName = 'tuyaVendorCredentialsBoxName'; - - /// Name of the box that stores Smart Life login credentials - String smartLifeVendorCredentialsBoxName = - 'smartLifeVendorCredentialsBoxName'; - - /// Name of the box that stores Jinvoo Smart login credentials - String jinvooSmartVendorCredentialsBoxName = - 'jinvooSmartVendorCredentialsBoxName'; - - /// Name of the box that stores Lifx login credentials - String lifxVendorCredentialsBoxName = 'lifxVendorCredentialsBoxName'; - - /// Name of the box that stores ESPHome device password - String espHomeVendorCredentialsBoxName = 'espHomeVendorCredentialsBoxName'; - - /// Name of the box that stores Xiaomi Mi account email ans password - String xiaomiMiVendorCredentialsBoxName = 'xiaomiMiVendorCredentialsBoxName'; - - /// Name of the box that stores eWeLink account email ans password - String ewelinkVendorCredentialsBoxName = 'ewelinkVendorCredentialsBoxName'; - - /// Name of the box that stores Hub general info - String hubEntityBoxName = 'hubEntityBox'; - - /// Loading once all the data from the database - Future initializeDb(); - - /// Will load all the local database content into the program - Future loadFromDb(); - - Future> getRemotePipesDnsName(); - - /// Get all saved devices from local db - Future>> - getSmartDevicesFromDb(); - - /// Get all saved scenes from local db - Future>> getScenesFromDb(); - - /// Get all saved routines from local db - Future>> getRoutinesFromDb(); - - /// Get all saved bindings from local db - Future>> getBindingsFromDb(); - - /// Will ger all rooms from db, if didn't find any will return discovered room - /// without any devices - Future>> getRoomsFromDb(); - - Future> getHubEntityNetworkBssid(); - - Future> getHubEntityNetworkName(); - - Future> getHubEntityLastKnownIp(); - - Future> saveRemotePipes({ - required String remotePipesDomainName, - }); - - Future> - getTuyaVendorLoginCredentials({ - required List - tuyaVendorCredentialsModelFromDb, - required String vendorBoxName, - }); - - Future> - getLifxVendorLoginCredentials({ - required List - lifxVendorCredentialsModelFromDb, - }); - - Future> - getEspHomeVendorLoginCredentials({ - required List - espHomeVendorCredentialsModelFromDb, - }); - - Future> - getXiaomiMiVendorLoginCredentials({ - required List - xiaomiMiVendorCredentialsModelFromDb, - }); - - Future> - getEwelinkVendorLoginCredentials({ - required List - ewelinkVendorCredentialsModelFromDb, - }); - - Future> saveRoomsToDb({ - required List roomsList, - }); - - Future> saveSmartDevices({ - required List deviceList, - }); - - Future> saveScenes({ - required List sceneList, - }); - - Future> saveRoutines({ - required List routineList, - }); - - Future> saveBindings({ - required List bindingList, - }); - - Future> saveVendorLoginCredentials({ - required LoginEntityAbstract loginEntityAbstract, - }); - - Future> saveHubEntity({ - required String hubNetworkBssid, - required String networkName, - required String lastKnownIp, - }); -} diff --git a/lib/domain/local_db/local_db_entity.dart b/lib/domain/local_db/local_db_entity.dart deleted file mode 100644 index 1a2786b3..00000000 --- a/lib/domain/local_db/local_db_entity.dart +++ /dev/null @@ -1,30 +0,0 @@ -import 'package:cbj_hub/domain/local_db/local_db_failures.dart'; -import 'package:cbj_hub/domain/local_db/local_db_value_objects.dart'; -import 'package:dartz/dartz.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'local_db_entity.freezed.dart'; - -@freezed -abstract class LocalDbEntity implements _$LocalDbEntity { - const factory LocalDbEntity({ - required LocalDbUniqueId? id, - required LocalDbEmail? email, - required LocalDbName? name, - LocalDbPass? pass, - LocalDbFirstName? firstName, - LocalDbLastName? lastName, - }) = _LocalDbEntity; - - const LocalDbEntity._(); - - factory LocalDbEntity.empty() => LocalDbEntity( - id: LocalDbUniqueId(), - email: LocalDbEmail(''), - name: LocalDbName(''), - ); - - Option> get failureOption { - return email!.value.fold((f) => some(f), (_) => none()); - } -} diff --git a/lib/domain/local_db/local_db_errors.dart b/lib/domain/local_db/local_db_errors.dart deleted file mode 100644 index dc15b6c2..00000000 --- a/lib/domain/local_db/local_db_errors.dart +++ /dev/null @@ -1,14 +0,0 @@ -import 'package:cbj_hub/domain/local_db/local_db_failures.dart'; - -class LocalDbUnexpectedValueError extends Error { - LocalDbUnexpectedValueError(this.userValueFailure); - - final LocalDbFailures userValueFailure; - - @override - String toString() { - const explanation = - 'Encountered a ValueFailure at an unrecoverable point. Terminating.'; - return Error.safeToString('$explanation Failure was: $userValueFailure'); - } -} diff --git a/lib/domain/local_db/local_db_failures.dart b/lib/domain/local_db/local_db_failures.dart deleted file mode 100644 index 5db4559a..00000000 --- a/lib/domain/local_db/local_db_failures.dart +++ /dev/null @@ -1,20 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'local_db_failures.freezed.dart'; - -@freezed -class LocalDbFailures { - const factory LocalDbFailures.empty({ - required T failedValue, - }) = _Empty; - - const factory LocalDbFailures.unexpected() = _Unexpected; - - const factory LocalDbFailures.validateEmailNotEmpty() = - _ValidateEmailNotEmpty; - - const factory LocalDbFailures.insufficientPermission() = - _InsufficientPermission; - - const factory LocalDbFailures.unableToUpdate() = _UnableToUpdate; -} diff --git a/lib/domain/local_db/local_db_validators.dart b/lib/domain/local_db/local_db_validators.dart deleted file mode 100644 index 7dce1251..00000000 --- a/lib/domain/local_db/local_db_validators.dart +++ /dev/null @@ -1,30 +0,0 @@ -import 'package:cbj_hub/domain/local_db/local_db_failures.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateLocalDbEmailNotEmpty( - String input, -) { - if (input.isNotEmpty) { - return right(input); - } else { - return left( - LocalDbFailures.empty( - failedValue: input, - ), - ); - } -} - -Either, String> validateLocalDbNameNotEmpty( - String input, -) { - if (input.isNotEmpty) { - return right(input); - } else { - return left( - LocalDbFailures.empty( - failedValue: input, - ), - ); - } -} diff --git a/lib/domain/local_db/local_db_value_objects.dart b/lib/domain/local_db/local_db_value_objects.dart deleted file mode 100644 index aec82332..00000000 --- a/lib/domain/local_db/local_db_value_objects.dart +++ /dev/null @@ -1,129 +0,0 @@ -import 'package:cbj_hub/domain/local_db/local_db_errors.dart'; -import 'package:cbj_hub/domain/local_db/local_db_failures.dart'; -import 'package:cbj_hub/domain/local_db/local_db_validators.dart'; -import 'package:dartz/dartz.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:uuid/uuid.dart'; - -@immutable -abstract class LocalDbValueObjectAbstract { - const LocalDbValueObjectAbstract(); - - Either, T> get value; - - /// Throws [UnexpectedValueError] containing the [LocalDbFailures] - T getOrCrash() { - // id = identity - same as writing (right) => right - return value.fold((f) => throw LocalDbUnexpectedValueError(f), id); - } - - Either, Unit> get failureOrUnit { - return value.fold((l) => left(l), (r) => right(unit)); - } - - bool isValid() => value.isRight(); - - @override - String toString() => 'Value($value)'; - - @override - @nonVirtual - bool operator ==(Object o) { - if (identical(this, o)) return true; - return o is LocalDbValueObjectAbstract && o.value == value; - } - - @override - int get hashCode => value.hashCode; -} - -class LocalDbUniqueId extends LocalDbValueObjectAbstract { - factory LocalDbUniqueId() { - return LocalDbUniqueId._(right(const Uuid().v1())); - } - - factory LocalDbUniqueId.fromUniqueString(String? uniqueId) { - assert(uniqueId != null); - return LocalDbUniqueId._(right(uniqueId!)); - } - - const LocalDbUniqueId._(this.value); - - @override - final Either, String> value; -} - -class LocalDbEmail extends LocalDbValueObjectAbstract { - factory LocalDbEmail(String input) { - return LocalDbEmail._( - validateLocalDbEmailNotEmpty(input), - ); - } - - const LocalDbEmail._(this.value); - - @override - final Either, String> value; - - static const maxLength = 1000; -} - -class LocalDbName extends LocalDbValueObjectAbstract { - factory LocalDbName(String input) { - return LocalDbName._( - validateLocalDbNameNotEmpty(input), - ); - } - - const LocalDbName._(this.value); - - @override - final Either, String> value; - - static const maxLength = 1000; -} - -class LocalDbPass extends LocalDbValueObjectAbstract { - factory LocalDbPass(String input) { - return LocalDbPass._( - validateLocalDbNameNotEmpty(input), - ); - } - - const LocalDbPass._(this.value); - - @override - final Either, String> value; - - static const maxLength = 1000; -} - -class LocalDbFirstName extends LocalDbValueObjectAbstract { - factory LocalDbFirstName(String input) { - return LocalDbFirstName._( - validateLocalDbNameNotEmpty(input), - ); - } - - const LocalDbFirstName._(this.value); - - @override - final Either, String> value; - - static const maxLength = 1000; -} - -class LocalDbLastName extends LocalDbValueObjectAbstract { - factory LocalDbLastName(String input) { - return LocalDbLastName._( - validateLocalDbNameNotEmpty(input), - ); - } - - const LocalDbLastName._(this.value); - - @override - final Either, String> value; - - static const maxLength = 1000; -} diff --git a/lib/domain/matirial_colors/colors.dart b/lib/domain/matirial_colors/colors.dart deleted file mode 100644 index ebc66df8..00000000 --- a/lib/domain/matirial_colors/colors.dart +++ /dev/null @@ -1,49 +0,0 @@ -// TODO: Replace reference to this file when there is a package for dart native -// TODO: that let us choose colors like in flutter `orange` -// TODO: Created a issue for that in one of the packages -// TODO: https://github.com/material-foundation/material-color-utilities/issues/63 - -enum Colors { - orange('0xFFFF9800'), - orangeAccent('0xFFFFAB40'), - deepOrange('0xFFFF5722'), - deepOrangeAccent('0xFFFF6E40'), - amber('0xFFFFC107'), - amberAccent('0xFFFFD740'), - blue('0xFF2196F3'), - blueAccent('0xFF448AFF'), - lightBlue('0xFF03A9F4'), - lightBlueAccent('0xFF40C4FF'), - blueGrey('0xFF607D8B'), - grey('0xFF9E9E9E'), - red('0xFFF44336'), - redAccent('0xFFFF5252'), - black('0xFF000000'), - brown('0xFF795548'), - cyan('0xFF00BCD4'), - cyanAccent('0xFF18FFFF'), - deepPurple('0xFF673AB7'), - deepPurpleAccent('0xFF7C4DFF'), - green('0xFF4CAF50'), - greenAccent('0xFF69F0AE'), - lightGreen('0xFF8BC34A'), - lightGreenAccent('0xFFB2FF59'), - indigo('0xFF3F51B5'), - indigoAccent('0xFF536DFE'), - pink('0xFFE91E63'), - pinkAccent('0xFFFF4081'), - purple('0xFF9C27B0'), - purpleAccent('0xFFE040FB'), - teal('0xFF009688'), - tealAccent('0xFF64FFDA'), - transparent('0xFF000000'), - yellow('0xFFFFEB3B'), - yellowAccent('0xFFFFFF00'), - white('0xFFFFFFFF'), - white12('0x1FFFFFFF'), - ; - - const Colors(this.value); - - final String value; -} diff --git a/lib/domain/mqtt_server/i_mqtt_server_repository.dart b/lib/domain/mqtt_server/i_mqtt_server_repository.dart deleted file mode 100644 index 8f0c406b..00000000 --- a/lib/domain/mqtt_server/i_mqtt_server_repository.dart +++ /dev/null @@ -1,90 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:mqtt_client/mqtt_client.dart'; -import 'package:mqtt_client/mqtt_server_client.dart'; -// ignore: implementation_imports -import 'package:mqtt_client/src/observable/src/records.dart'; - -abstract class IMqttServerRepository { - // static const String hubBaseTopic = 'CBJ_Hub_Topic'; - // - // static const String devicesTopicTypeName = 'Devices'; - - String getHubBaseTopic(); - - String getNodeRedApiBaseTopic(); - - String getDevicesTopicTypeName(); - - String getNodeRedDevicesTopicTypeName(); - - String getScenesTopicTypeName(); - - String getRoutinesTopicTypeName(); - - String getBindingsTopicTypeName(); - - /// Connecting the hub client to broker - Future connect(); - - /// Make sure that mqtt is connected state before continuing - Future asyncConstractor(); - - /// Stream all subscription changes - Stream>> streamOfAllSubscriptions(); - - /// Stream all hub subscription changes - Stream>> streamOfAllHubSubscriptions(); - - /// Stream all devices subscription changes - Stream>> - streamOfAllDevicesHubSubscriptions(); - - /// Stream all device changes for the app - Stream>> - streamOfAllDeviceAppSubscriptions(); - - /// Stream of chosen topic, example tasmota discover new devices topic - Stream>> streamOfChosenSubscription( - String topicPath, - ); - - /// Get hub subscription and for each device change it will call method to - /// notify the needed devices - Future allHubDevicesSubscriptions(); - - /// Send requests back to the app, from updated device state to new rooms - Future sendToApp(); - - /// Publish message to a specific topic - Future publishMessage(String topic, String message); - - /// Publish all device properties - Future publishDeviceEntity( - DeviceEntityAbstract deviceEntityDtoAbstract, - ); - - /// Read mqtt last massage in given topic - Future?> readingFromMqttOnce(String topic); - - /// Subscribe to changes in given topic - Future subscribeToTopic(String topic); - - /// Post object from the app to the cbj hub through the mqtt, it insures that - /// it is posted correctly, right path and right way to post each type - Future postToHubMqtt({ - required dynamic entityFromTheApp, - bool? gotFromApp, - }); - - /// Post object from the Hub to the app through the mqtt, it insures that - /// it is posted correctly, right path and right way to post each type - Future postToAppMqtt({ - required DeviceEntityAbstract entityFromTheHub, - }); - - /// Post smart device from the Hub to the app through the mqtt, it insures that - /// it is posted correctly, right path and right way to post each type - Future postSmartDeviceToAppMqtt({ - required DeviceEntityAbstract entityFromTheHub, - }); -} diff --git a/lib/domain/rooms/i_saved_rooms_repo.dart b/lib/domain/rooms/i_saved_rooms_repo.dart index dd652156..92ef21c2 100644 --- a/lib/domain/rooms/i_saved_rooms_repo.dart +++ b/lib/domain/rooms/i_saved_rooms_repo.dart @@ -1,12 +1,18 @@ import 'package:cbj_hub/domain/binding/binding_cbj_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/local_db/local_db_failures.dart'; import 'package:cbj_hub/domain/room/room_entity.dart'; import 'package:cbj_hub/domain/routine/routine_cbj_entity.dart'; import 'package:cbj_hub/domain/scene/scene_cbj_entity.dart'; +import 'package:cbj_integrations_controller/domain/local_db/local_db_failures.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_abstract.dart'; import 'package:dartz/dartz.dart'; abstract class ISavedRoomsRepo { + ISavedRoomsRepo() { + instance = this; + } + + static late ISavedRoomsRepo instance; + /// Setting up all rooms from db Future setUpAllFromDb(); diff --git a/lib/domain/routine/i_routine_cbj_repository.dart b/lib/domain/routine/i_routine_cbj_repository.dart index 7a29c68e..a043685e 100644 --- a/lib/domain/routine/i_routine_cbj_repository.dart +++ b/lib/domain/routine/i_routine_cbj_repository.dart @@ -1,4 +1,4 @@ -import 'package:cbj_hub/domain/local_db/local_db_failures.dart'; +import 'package:cbj_integrations_controller/domain/local_db/local_db_failures.dart'; import 'package:cbj_hub/domain/routine/routine_cbj_entity.dart'; import 'package:cbj_hub/domain/routine/routine_cbj_failures.dart'; import 'package:dartz/dartz.dart'; diff --git a/lib/domain/routine/routine_cbj_entity.dart b/lib/domain/routine/routine_cbj_entity.dart index 7cc5c31f..8a62b280 100644 --- a/lib/domain/routine/routine_cbj_entity.dart +++ b/lib/domain/routine/routine_cbj_entity.dart @@ -1,6 +1,6 @@ -import 'package:cbj_hub/domain/core/value_objects.dart'; import 'package:cbj_hub/domain/routine/value_objects_routine_cbj.dart'; import 'package:cbj_hub/infrastructure/routines/routine_cbj_dtos.dart'; +import 'package:cbj_integrations_controller/domain/core/value_objects.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; part 'routine_cbj_entity.freezed.dart'; diff --git a/lib/domain/routine/routine_cbj_validators.dart b/lib/domain/routine/routine_cbj_validators.dart index 82eff85c..ec917630 100644 --- a/lib/domain/routine/routine_cbj_validators.dart +++ b/lib/domain/routine/routine_cbj_validators.dart @@ -1,5 +1,5 @@ -import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; import 'package:cbj_hub/domain/routine/routine_cbj_failures.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/device_type_enums.dart'; import 'package:dartz/dartz.dart'; Either, String> validateRoutineNotEmpty( diff --git a/lib/domain/saved_devices/i_saved_devices_repo.dart b/lib/domain/saved_devices/i_saved_devices_repo.dart deleted file mode 100644 index aeae4097..00000000 --- a/lib/domain/saved_devices/i_saved_devices_repo.dart +++ /dev/null @@ -1,38 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/local_db/local_db_failures.dart'; -import 'package:cbj_hub/domain/remote_pipes/remote_pipes_entity.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/login_entity_abstract.dart'; -import 'package:dartz/dartz.dart'; - -abstract class ISavedDevicesRepo { - /// Setting up all devices from db - Future setUpAllFromDb(); - - DeviceEntityAbstract? addOrUpdateFromMqtt(dynamic updateFromMqtt); - - /// Add new device to saved devices list - DeviceEntityAbstract addOrUpdateDevice(DeviceEntityAbstract deviceEntity); - - /// Will save the remote pipes entity to the local storage and will activate - /// connection to remote pipes with that info - /// Will return true if complete success - Future> saveAndActivateRemotePipesDomainToDb({ - required RemotePipesEntity remotePipes, - }); - - Future> saveAndActivateSmartDevicesToDb(); - - /// Save login of different form factors to the local db - Future> - saveAndActivateVendorLoginCredentialsDomainToDb({ - required LoginEntityAbstract loginEntity, - }); - - /// Get all saved devices - Future> getAllDevices(); - - /// Get device by unique ID - Future> getDeviceById( - String entityUniqueId, - ); -} diff --git a/lib/domain/scene/i_scene_cbj_repository.dart b/lib/domain/scene/i_scene_cbj_repository.dart index c78bdf30..b6e7976e 100644 --- a/lib/domain/scene/i_scene_cbj_repository.dart +++ b/lib/domain/scene/i_scene_cbj_repository.dart @@ -1,8 +1,8 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/local_db/local_db_failures.dart'; import 'package:cbj_hub/domain/scene/scene_cbj_entity.dart'; import 'package:cbj_hub/domain/scene/scene_cbj_failures.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; +import 'package:cbj_integrations_controller/domain/local_db/local_db_failures.dart'; +import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_abstract.dart'; import 'package:dartz/dartz.dart'; import 'package:kt_dart/collection.dart'; import 'package:rxdart/rxdart.dart'; diff --git a/lib/domain/scene/scene_cbj_entity.dart b/lib/domain/scene/scene_cbj_entity.dart index 89dc2d51..8c19ac50 100644 --- a/lib/domain/scene/scene_cbj_entity.dart +++ b/lib/domain/scene/scene_cbj_entity.dart @@ -1,4 +1,4 @@ -import 'package:cbj_hub/domain/core/value_objects.dart'; +import 'package:cbj_integrations_controller/domain/core/value_objects.dart'; import 'package:cbj_hub/domain/scene/value_objects_scene_cbj.dart'; import 'package:cbj_hub/infrastructure/scenes/scene_cbj_dtos.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; diff --git a/lib/domain/scene/scene_cbj_validators.dart b/lib/domain/scene/scene_cbj_validators.dart index cbdbcca3..e2c6db5b 100644 --- a/lib/domain/scene/scene_cbj_validators.dart +++ b/lib/domain/scene/scene_cbj_validators.dart @@ -1,4 +1,4 @@ -import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/device_type_enums.dart'; import 'package:cbj_hub/domain/scene/scene_cbj_failures.dart'; import 'package:dartz/dartz.dart'; diff --git a/lib/domain/vendors/esphome_login/generic_esphome_login_entity.dart b/lib/domain/vendors/esphome_login/generic_esphome_login_entity.dart deleted file mode 100644 index 5b2b46b9..00000000 --- a/lib/domain/vendors/esphome_login/generic_esphome_login_entity.dart +++ /dev/null @@ -1,62 +0,0 @@ -import 'package:cbj_hub/domain/vendors/esphome_login/generic_esphome_login_value_objects.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/core_login_failures.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/login_entity_abstract.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/value_login_objects_core.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/generic_vendors_login/generic_esphome_login/generic_esphome_login_dtos.dart'; -import 'package:cbj_hub/infrastructure/generic_vendors_login/generic_login_abstract/login_entity_dto_abstract.dart'; -import 'package:dartz/dartz.dart'; - -/// Abstract smart GenericEspHome that exist inside a computer, the -/// implementations will be actual GenericEspHome like blinds esphomes and more -class GenericEspHomeLoginDE extends LoginEntityAbstract { - /// All public field of GenericEspHome entity - GenericEspHomeLoginDE({ - required super.senderUniqueId, - required this.espHomeDevicePass, - }) : super( - loginVendor: CoreLoginVendor(VendorsAndServices.espHome.name), - ); - - /// Empty instance of GenericEspHomeEntity - factory GenericEspHomeLoginDE.empty() => GenericEspHomeLoginDE( - senderUniqueId: CoreLoginSenderId.fromUniqueString(''), - espHomeDevicePass: GenericEspHomeDeviceLoginApiPass(''), - ); - - /// EspHome api key - GenericEspHomeDeviceLoginApiPass espHomeDevicePass; - - Option> get failureOption => - senderUniqueId.value.fold((f) => some(f), (_) => none()); - - // - // /// Will return failure if any of the fields failed or return unit if fields - // /// have legit values - // Option> get failureOption { - // return cbjEntityName!.value.fold((f) => some(f), (_) => none()); - // - // return body.failureOrUnit - // .andThen(todos.failureOrUnit) - // .andThen( - // todos - // .getOrCrash() - // // Getting the failureOption from the TodoItem ENTITY - NOT a failureOrUnit from a VALUE OBJECT - // .map((todoItem) => todoItem.failureOption) - // .filter((o) => o.isSome()) - // // If we can't get the 0th element, the list is empty. In such a case, it's valid. - // .getOrElse(0, (_) => none()) - // .fold(() => right(unit), (f) => left(f)), - // ) - // .fold((f) => some(f), (_) => none()); - // } - - @override - LoginEntityDtoAbstract toInfrastructure() { - return GenericEspHomeLoginDtos( - senderUniqueId: senderUniqueId.getOrCrash(), - loginVendor: loginVendor.getOrCrash(), - esphomeDevicePass: espHomeDevicePass.getOrCrash(), - ); - } -} diff --git a/lib/domain/vendors/esphome_login/generic_esphome_login_validators.dart b/lib/domain/vendors/esphome_login/generic_esphome_login_validators.dart deleted file mode 100644 index 1ab4a32f..00000000 --- a/lib/domain/vendors/esphome_login/generic_esphome_login_validators.dart +++ /dev/null @@ -1,9 +0,0 @@ -import 'package:cbj_hub/domain/vendors/login_abstract/core_login_failures.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> - validateGenericEspHomeDeviceLoginPassiNotEmty( - String input, -) { - return right(input); -} diff --git a/lib/domain/vendors/esphome_login/generic_esphome_login_value_objects.dart b/lib/domain/vendors/esphome_login/generic_esphome_login_value_objects.dart deleted file mode 100644 index 39c4e3d1..00000000 --- a/lib/domain/vendors/esphome_login/generic_esphome_login_value_objects.dart +++ /dev/null @@ -1,18 +0,0 @@ -import 'package:cbj_hub/domain/vendors/esphome_login/generic_esphome_login_validators.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/core_login_failures.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/value_login_objects_core.dart'; -import 'package:dartz/dartz.dart'; - -class GenericEspHomeDeviceLoginApiPass extends ValueObjectCoreLogin { - factory GenericEspHomeDeviceLoginApiPass(String? input) { - assert(input != null); - return GenericEspHomeDeviceLoginApiPass._( - validateGenericEspHomeDeviceLoginPassiNotEmty(input!), - ); - } - - const GenericEspHomeDeviceLoginApiPass._(this.value); - - @override - final Either, String> value; -} diff --git a/lib/domain/vendors/ewelink_login/generic_ewelink_login_entity.dart b/lib/domain/vendors/ewelink_login/generic_ewelink_login_entity.dart deleted file mode 100644 index 818a09d8..00000000 --- a/lib/domain/vendors/ewelink_login/generic_ewelink_login_entity.dart +++ /dev/null @@ -1,68 +0,0 @@ -import 'package:cbj_hub/domain/vendors/ewelink_login/generic_ewelink_login_value_objects.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/core_login_failures.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/login_entity_abstract.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/value_login_objects_core.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/generic_vendors_login/generic_ewelink_login/generic_ewelink_login_dtos.dart'; -import 'package:cbj_hub/infrastructure/generic_vendors_login/generic_login_abstract/login_entity_dto_abstract.dart'; -import 'package:dartz/dartz.dart'; - -/// Abstract smart GenericEwelink that exist inside a computer, the -/// implementations will be actual GenericEwelink like blinds ewelinks and more -class GenericEwelinkLoginDE extends LoginEntityAbstract { - /// All public field of GenericEwelink entity - GenericEwelinkLoginDE({ - required super.senderUniqueId, - required this.ewelinkAccountEmail, - required this.ewelinkAccountPass, - }) : super( - loginVendor: CoreLoginVendor(VendorsAndServices.sonoffEweLink.name), - ); - - /// Empty instance of GenericEwelinkEntity - factory GenericEwelinkLoginDE.empty() => GenericEwelinkLoginDE( - senderUniqueId: CoreLoginSenderId.fromUniqueString(''), - ewelinkAccountEmail: GenericEwelinkAccountEmail(''), - ewelinkAccountPass: GenericEwelinkAccountPass(''), - ); - - /// Ewelink account email - GenericEwelinkAccountEmail ewelinkAccountEmail; - - /// Ewelink account password - GenericEwelinkAccountPass ewelinkAccountPass; - - Option> get failureOption => - senderUniqueId.value.fold((f) => some(f), (_) => none()); - - // - // /// Will return failure if any of the fields failed or return unit if fields - // /// have legit values - // Option> get failureOption { - // return cbjEntityName!.value.fold((f) => some(f), (_) => none()); - // - // return body.failureOrUnit - // .andThen(todos.failureOrUnit) - // .andThen( - // todos - // .getOrCrash() - // // Getting the failureOption from the TodoItem ENTITY - NOT a failureOrUnit from a VALUE OBJECT - // .map((todoItem) => todoItem.failureOption) - // .filter((o) => o.isSome()) - // // If we can't get the 0th element, the list is empty. In such a case, it's valid. - // .getOrElse(0, (_) => none()) - // .fold(() => right(unit), (f) => left(f)), - // ) - // .fold((f) => some(f), (_) => none()); - // } - - @override - LoginEntityDtoAbstract toInfrastructure() { - return GenericEwelinkLoginDtos( - senderUniqueId: senderUniqueId.getOrCrash(), - loginVendor: loginVendor.getOrCrash(), - ewelinkAccountEmail: ewelinkAccountEmail.getOrCrash(), - ewelinkAccountPass: ewelinkAccountPass.getOrCrash(), - ); - } -} diff --git a/lib/domain/vendors/ewelink_login/generic_ewelink_login_validators.dart b/lib/domain/vendors/ewelink_login/generic_ewelink_login_validators.dart deleted file mode 100644 index 876b6294..00000000 --- a/lib/domain/vendors/ewelink_login/generic_ewelink_login_validators.dart +++ /dev/null @@ -1,8 +0,0 @@ -import 'package:cbj_hub/domain/vendors/login_abstract/core_login_failures.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateGenericEwelinkNotEmpty( - String input, -) { - return right(input); -} diff --git a/lib/domain/vendors/ewelink_login/generic_ewelink_login_value_objects.dart b/lib/domain/vendors/ewelink_login/generic_ewelink_login_value_objects.dart deleted file mode 100644 index ad60c909..00000000 --- a/lib/domain/vendors/ewelink_login/generic_ewelink_login_value_objects.dart +++ /dev/null @@ -1,32 +0,0 @@ -import 'package:cbj_hub/domain/vendors/ewelink_login/generic_ewelink_login_validators.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/core_login_failures.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/value_login_objects_core.dart'; -import 'package:dartz/dartz.dart'; - -class GenericEwelinkAccountEmail extends ValueObjectCoreLogin { - factory GenericEwelinkAccountEmail(String? input) { - assert(input != null); - return GenericEwelinkAccountEmail._( - validateGenericEwelinkNotEmpty(input!), - ); - } - - const GenericEwelinkAccountEmail._(this.value); - - @override - final Either, String> value; -} - -class GenericEwelinkAccountPass extends ValueObjectCoreLogin { - factory GenericEwelinkAccountPass(String? input) { - assert(input != null); - return GenericEwelinkAccountPass._( - validateGenericEwelinkNotEmpty(input!), - ); - } - - const GenericEwelinkAccountPass._(this.value); - - @override - final Either, String> value; -} diff --git a/lib/domain/vendors/lifx_login/generic_lifx_login_entity.dart b/lib/domain/vendors/lifx_login/generic_lifx_login_entity.dart deleted file mode 100644 index 913c3d24..00000000 --- a/lib/domain/vendors/lifx_login/generic_lifx_login_entity.dart +++ /dev/null @@ -1,62 +0,0 @@ -import 'package:cbj_hub/domain/vendors/lifx_login/generic_lifx_login_value_objects.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/core_login_failures.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/login_entity_abstract.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/value_login_objects_core.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/generic_vendors_login/generic_lifx_login/generic_lifx_login_dtos.dart'; -import 'package:cbj_hub/infrastructure/generic_vendors_login/generic_login_abstract/login_entity_dto_abstract.dart'; -import 'package:dartz/dartz.dart'; - -/// Abstract smart GenericLifx that exist inside a computer, the -/// implementations will be actual GenericLifx like blinds lifxs and more -class GenericLifxLoginDE extends LoginEntityAbstract { - /// All public field of GenericLifx entity - GenericLifxLoginDE({ - required super.senderUniqueId, - required this.lifxApiKey, - }) : super( - loginVendor: CoreLoginVendor(VendorsAndServices.lifx.name), - ); - - /// Empty instance of GenericLifxEntity - factory GenericLifxLoginDE.empty() => GenericLifxLoginDE( - senderUniqueId: CoreLoginSenderId.fromUniqueString(''), - lifxApiKey: GenericLifxLoginApiKey(''), - ); - - /// Lifx api key - GenericLifxLoginApiKey lifxApiKey; - - Option> get failureOption => - senderUniqueId.value.fold((f) => some(f), (_) => none()); - - // - // /// Will return failure if any of the fields failed or return unit if fields - // /// have legit values - // Option> get failureOption { - // return cbjEntityName!.value.fold((f) => some(f), (_) => none()); - // - // return body.failureOrUnit - // .andThen(todos.failureOrUnit) - // .andThen( - // todos - // .getOrCrash() - // // Getting the failureOption from the TodoItem ENTITY - NOT a failureOrUnit from a VALUE OBJECT - // .map((todoItem) => todoItem.failureOption) - // .filter((o) => o.isSome()) - // // If we can't get the 0th element, the list is empty. In such a case, it's valid. - // .getOrElse(0, (_) => none()) - // .fold(() => right(unit), (f) => left(f)), - // ) - // .fold((f) => some(f), (_) => none()); - // } - - @override - LoginEntityDtoAbstract toInfrastructure() { - return GenericLifxLoginDtos( - senderUniqueId: senderUniqueId.getOrCrash(), - loginVendor: loginVendor.getOrCrash(), - lifxApiKey: lifxApiKey.getOrCrash(), - ); - } -} diff --git a/lib/domain/vendors/lifx_login/generic_lifx_login_validators.dart b/lib/domain/vendors/lifx_login/generic_lifx_login_validators.dart deleted file mode 100644 index af00f68b..00000000 --- a/lib/domain/vendors/lifx_login/generic_lifx_login_validators.dart +++ /dev/null @@ -1,8 +0,0 @@ -import 'package:cbj_hub/domain/vendors/login_abstract/core_login_failures.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateGenericLifxLoginApiKeyNotEmty( - String input, -) { - return right(input); -} diff --git a/lib/domain/vendors/lifx_login/generic_lifx_login_value_objects.dart b/lib/domain/vendors/lifx_login/generic_lifx_login_value_objects.dart deleted file mode 100644 index cf6e8a37..00000000 --- a/lib/domain/vendors/lifx_login/generic_lifx_login_value_objects.dart +++ /dev/null @@ -1,18 +0,0 @@ -import 'package:cbj_hub/domain/vendors/lifx_login/generic_lifx_login_validators.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/core_login_failures.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/value_login_objects_core.dart'; -import 'package:dartz/dartz.dart'; - -class GenericLifxLoginApiKey extends ValueObjectCoreLogin { - factory GenericLifxLoginApiKey(String? input) { - assert(input != null); - return GenericLifxLoginApiKey._( - validateGenericLifxLoginApiKeyNotEmty(input!), - ); - } - - const GenericLifxLoginApiKey._(this.value); - - @override - final Either, String> value; -} diff --git a/lib/domain/vendors/login_abstract/core_login_errors.dart b/lib/domain/vendors/login_abstract/core_login_errors.dart deleted file mode 100644 index e408b54c..00000000 --- a/lib/domain/vendors/login_abstract/core_login_errors.dart +++ /dev/null @@ -1,14 +0,0 @@ -import 'package:cbj_hub/domain/vendors/vendor_failures.dart'; - -class CoreLoginUnexpectedValueError extends Error { - CoreLoginUnexpectedValueError(this.loginValueFailure); - - final VendorValueFailure loginValueFailure; - - @override - String toString() { - const explanation = - 'Encountered a ValueFailure at an unrecoverable point. Terminating.'; - return Error.safeToString('$explanation Failure was: $loginValueFailure'); - } -} diff --git a/lib/domain/vendors/login_abstract/core_login_failures.dart b/lib/domain/vendors/login_abstract/core_login_failures.dart deleted file mode 100644 index 608e7b6f..00000000 --- a/lib/domain/vendors/login_abstract/core_login_failures.dart +++ /dev/null @@ -1,23 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'core_login_failures.freezed.dart'; - -/// Example how to use multiple failures types in one class -@freezed -class CoreLoginValueFailure with _$CoreLoginValueFailure { - const factory CoreLoginValueFailure.auth(CoreLoginFailure f) = _Auth; -} - -@freezed -class CoreLoginFailure { - const factory CoreLoginFailure.unexpected() = _Unexpected; - - const factory CoreLoginFailure.empty({ - required String failedValue, - }) = _Empty; - - const factory CoreLoginFailure.exceedingLength({ - required String failedValueFailure, - required int max, - }) = _ExceedingLength; -} diff --git a/lib/domain/vendors/login_abstract/core_login_validators.dart b/lib/domain/vendors/login_abstract/core_login_validators.dart deleted file mode 100644 index 843f779b..00000000 --- a/lib/domain/vendors/login_abstract/core_login_validators.dart +++ /dev/null @@ -1,23 +0,0 @@ -import 'package:cbj_hub/domain/vendors/login_abstract/core_login_failures.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateLoginNotEmpty(String input) { - if (input.isNotEmpty) { - return right(input); - } else { - return left( - CoreLoginFailure.empty( - failedValue: input, - ), - ); - } -} - -// Either, String> validateLoginVendorExist( -// String input, -// ) { -// if (EnumHelper.stringToDeviceVendor(input) != null) { -// return right(input); -// } -// return left(const CoreLoginFailure.loginTypeDoesNotExist()); -// } diff --git a/lib/domain/vendors/login_abstract/login_entity_abstract.dart b/lib/domain/vendors/login_abstract/login_entity_abstract.dart deleted file mode 100644 index fe60caca..00000000 --- a/lib/domain/vendors/login_abstract/login_entity_abstract.dart +++ /dev/null @@ -1,110 +0,0 @@ -import 'package:cbj_hub/domain/vendors/login_abstract/value_login_objects_core.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/generic_vendors_login/generic_login_abstract/login_entity_dto_abstract.dart'; - -abstract class LoginEntityAbstract { - LoginEntityAbstract({ - required this.senderUniqueId, - required this.loginVendor, - }); - - /// The user id who want to login - CoreLoginSenderId senderUniqueId; - - /// The smart GenericLight type - CoreLoginVendor loginVendor; - - // /// Copy with login state to waiting or ack - // LoginEntityAbstract copyWithLoginState(LoginStateGRPC loginStateGRPC) { - // return this; - // } - // - // /// Copy with login action - // LoginEntityAbstract copyWithLoginAction(LoginActions loginActions) { - // return this; - // } - - /// Copy with stateMassage - LoginEntityAbstract copyWithStateMassage(String stateMassage) { - return this; - } - - /// Copy with senderLoginOs - LoginEntityAbstract copyWithSenderLoginOs(String senderLoginOs) { - return this; - } - - /// Copy with loginSenderLoginModel - LoginEntityAbstract copyWithLoginSenderLoginModel( - String loginSenderLoginModel, - ) { - return this; - } - - /// Copy with currentUserId - LoginEntityAbstract copyWithSenderId(String userId) { - return this; - } - - LoginEntityDtoAbstract toInfrastructure() { - return LoginEntityDtoAbstract(); - } - -// /// The default name of the login -// LoginDefaultName? cbjEntityName; -} - -class LoginEntityEmpty extends LoginEntityAbstract { - LoginEntityEmpty() - : super( - senderUniqueId: CoreLoginSenderId(), - loginVendor: CoreLoginVendor( - VendorsAndServices.vendorsAndServicesNotSupported.toString(), - ), - ); -} - -// -// part 'login_entity_abstract.freezed.dart'; -// -// /// Abstract smart login that exist inside a computer, the implementations will -// /// be actual login like blinds lights and more -// @freezed -// abstract class LoginEntityAbstract implements _$LoginEntityAbstract { -// /// All public field of login entity -// const factory LoginEntityAbstract({ -// /// The smart login id -// required LoginUniqueId? id, -// -// /// The default name of the login -// required LoginDefaultName? cbjEntityName, -// }) = _LoginEntityAbstract; -// -// const LoginEntityAbstract._(); -// -// /// Empty instance of GenericLightDE -// factory LoginEntityAbstract.empty() => LoginEntityAbstract( -// id: LoginUniqueId(), -// cbjEntityName: LoginDefaultName(''), -// ); -// -// /// Will return failure if any of the fields failed or return unit if fields -// /// have legit values -// Option> get failureOption { -// return cbjEntityName!.value.fold((f) => some(f), (_) => none()); -// // -// // return body.failureOrUnit -// // .andThen(todos.failureOrUnit) -// // .andThen( -// // todos -// // .getOrCrash() -// // // Getting the failureOption from the TodoItem ENTITY - NOT a failureOrUnit from a VALUE OBJECT -// // .map((todoItem) => todoItem.failureOption) -// // .filter((o) => o.isSome()) -// // // If we can't get the 0th element, the list is empty. In such a case, it's valid. -// // .getOrElse(0, (_) => none()) -// // .fold(() => right(unit), (f) => left(f)), -// // ) -// // .fold((f) => some(f), (_) => none()); -// } -// } diff --git a/lib/domain/vendors/login_abstract/value_login_objects_core.dart b/lib/domain/vendors/login_abstract/value_login_objects_core.dart deleted file mode 100644 index b4f2d974..00000000 --- a/lib/domain/vendors/login_abstract/value_login_objects_core.dart +++ /dev/null @@ -1,67 +0,0 @@ -import 'package:cbj_hub/domain/vendors/login_abstract/core_login_failures.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/core_login_validators.dart'; -import 'package:cbj_hub/domain/vendors/vendor_errors.dart'; -import 'package:dartz/dartz.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:uuid/uuid.dart'; - -@immutable -abstract class ValueObjectCoreLogin { - const ValueObjectCoreLogin(); - - Either, T> get value; - - /// Throws [UnexpectedValueError] containing the [CoreLoginFailure] - T getOrCrash() { - // id = identity - same as writing (right) => right - return value.fold((f) => throw VendorUnexpectedValueError(f), id); - } - - Either, Unit> get failureOrUnit { - return value.fold((l) => left(l), (r) => right(unit)); - } - - bool isValid() => value.isRight(); - - @override - String toString() => 'Value($value)'; - - @override - @nonVirtual - bool operator ==(Object o) { - if (identical(this, o)) return true; - return o is ValueObjectCoreLogin && o.value == value; - } - - @override - int get hashCode => value.hashCode; -} - -class CoreLoginSenderId extends ValueObjectCoreLogin { - factory CoreLoginSenderId() { - return CoreLoginSenderId._(right(const Uuid().v1())); - } - - factory CoreLoginSenderId.fromUniqueString(String? uniqueId) { - return CoreLoginSenderId._(right(uniqueId)); - } - - const CoreLoginSenderId._(this.value); - - @override - final Either, String?> value; -} - -class CoreLoginVendor extends ValueObjectCoreLogin { - factory CoreLoginVendor(String? input) { - assert(input != null); - return CoreLoginVendor._( - validateLoginNotEmpty(input!), - ); - } - - const CoreLoginVendor._(this.value); - - @override - final Either, String> value; -} diff --git a/lib/domain/vendors/tuya_login/generic_tuya_login_entity.dart b/lib/domain/vendors/tuya_login/generic_tuya_login_entity.dart deleted file mode 100644 index 80f13bc4..00000000 --- a/lib/domain/vendors/tuya_login/generic_tuya_login_entity.dart +++ /dev/null @@ -1,90 +0,0 @@ -import 'package:cbj_hub/domain/vendors/login_abstract/core_login_failures.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/login_entity_abstract.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/value_login_objects_core.dart'; -import 'package:cbj_hub/domain/vendors/tuya_login/generic_tuya_login_value_objects.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/generic_vendors_login/generic_login_abstract/login_entity_dto_abstract.dart'; -import 'package:cbj_hub/infrastructure/generic_vendors_login/generic_tuya_login/generic_tuya_login_dtos.dart'; -import 'package:dartz/dartz.dart'; - -/// Abstract smart GenericTuya that exist inside a computer, the -/// implementations will be actual GenericTuya like blinds tuyas and more -class GenericTuyaLoginDE extends LoginEntityAbstract { - /// All public field of GenericTuya entity - GenericTuyaLoginDE({ - required super.senderUniqueId, - required super.loginVendor, - required this.tuyaUserName, - required this.tuyaUserPassword, - required this.tuyaCountryCode, - required this.tuyaBizType, - required this.tuyaRegion, - }); - - /// Empty instance of GenericTuyaEntity - factory GenericTuyaLoginDE.empty() => GenericTuyaLoginDE( - senderUniqueId: CoreLoginSenderId.fromUniqueString(''), - loginVendor: CoreLoginVendor( - /// I think this should stay vendorsAndServicesNotSupported so that - /// the correct tuya/smartLife/jinvooSmart to be inserted later. - VendorsAndServices.vendorsAndServicesNotSupported.name, - ), - tuyaUserName: GenericTuyaLoginUserName(''), - tuyaUserPassword: GenericTuyaLoginUserPassword(''), - tuyaCountryCode: GenericTuyaLoginCountryCode(''), - tuyaBizType: GenericTuyaLoginBizType(''), - tuyaRegion: GenericTuyaLoginRegion(''), - ); - - /// User name - GenericTuyaLoginUserName tuyaUserName; - - /// User password - GenericTuyaLoginUserPassword tuyaUserPassword; - - /// User current countryCode or countryCode of registration not sure - GenericTuyaLoginCountryCode tuyaCountryCode; - - /// App business can be: tuya, smart_life, jinvoo_smart - GenericTuyaLoginBizType tuyaBizType; - - /// Region of the user, can be cn, eu, us - GenericTuyaLoginRegion tuyaRegion; - - Option> get failureOption => - senderUniqueId.value.fold((f) => some(f), (_) => none()); - - // - // /// Will return failure if any of the fields failed or return unit if fields - // /// have legit values - // Option> get failureOption { - // return cbjEntityName!.value.fold((f) => some(f), (_) => none()); - // - // return body.failureOrUnit - // .andThen(todos.failureOrUnit) - // .andThen( - // todos - // .getOrCrash() - // // Getting the failureOption from the TodoItem ENTITY - NOT a failureOrUnit from a VALUE OBJECT - // .map((todoItem) => todoItem.failureOption) - // .filter((o) => o.isSome()) - // // If we can't get the 0th element, the list is empty. In such a case, it's valid. - // .getOrElse(0, (_) => none()) - // .fold(() => right(unit), (f) => left(f)), - // ) - // .fold((f) => some(f), (_) => none()); - // } - - @override - LoginEntityDtoAbstract toInfrastructure() { - return GenericTuyaLoginDtos( - senderUniqueId: senderUniqueId.getOrCrash(), - loginVendor: loginVendor.getOrCrash(), - userName: tuyaUserName.getOrCrash(), - userPassword: tuyaUserPassword.getOrCrash(), - countryCode: tuyaCountryCode.getOrCrash(), - bizType: tuyaBizType.getOrCrash(), - region: tuyaRegion.getOrCrash(), - ); - } -} diff --git a/lib/domain/vendors/tuya_login/generic_tuya_login_validators.dart b/lib/domain/vendors/tuya_login/generic_tuya_login_validators.dart deleted file mode 100644 index 605b3032..00000000 --- a/lib/domain/vendors/tuya_login/generic_tuya_login_validators.dart +++ /dev/null @@ -1,8 +0,0 @@ -import 'package:cbj_hub/domain/vendors/login_abstract/core_login_failures.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateGenericTuyaLoginStringNotEmty( - String input, -) { - return right(input); -} diff --git a/lib/domain/vendors/tuya_login/generic_tuya_login_value_objects.dart b/lib/domain/vendors/tuya_login/generic_tuya_login_value_objects.dart deleted file mode 100644 index a0d728c3..00000000 --- a/lib/domain/vendors/tuya_login/generic_tuya_login_value_objects.dart +++ /dev/null @@ -1,74 +0,0 @@ -import 'package:cbj_hub/domain/vendors/login_abstract/core_login_failures.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/value_login_objects_core.dart'; -import 'package:cbj_hub/domain/vendors/tuya_login/generic_tuya_login_validators.dart'; -import 'package:dartz/dartz.dart'; - -class GenericTuyaLoginUserName extends ValueObjectCoreLogin { - factory GenericTuyaLoginUserName(String? input) { - assert(input != null); - return GenericTuyaLoginUserName._( - validateGenericTuyaLoginStringNotEmty(input!), - ); - } - - const GenericTuyaLoginUserName._(this.value); - - @override - final Either, String> value; -} - -class GenericTuyaLoginUserPassword extends ValueObjectCoreLogin { - factory GenericTuyaLoginUserPassword(String? input) { - assert(input != null); - return GenericTuyaLoginUserPassword._( - validateGenericTuyaLoginStringNotEmty(input!), - ); - } - - const GenericTuyaLoginUserPassword._(this.value); - - @override - final Either, String> value; -} - -class GenericTuyaLoginCountryCode extends ValueObjectCoreLogin { - factory GenericTuyaLoginCountryCode(String? input) { - assert(input != null); - return GenericTuyaLoginCountryCode._( - validateGenericTuyaLoginStringNotEmty(input!), - ); - } - - const GenericTuyaLoginCountryCode._(this.value); - - @override - final Either, String> value; -} - -class GenericTuyaLoginBizType extends ValueObjectCoreLogin { - factory GenericTuyaLoginBizType(String? input) { - assert(input != null); - return GenericTuyaLoginBizType._( - validateGenericTuyaLoginStringNotEmty(input!), - ); - } - - const GenericTuyaLoginBizType._(this.value); - - @override - final Either, String> value; -} - -class GenericTuyaLoginRegion extends ValueObjectCoreLogin { - factory GenericTuyaLoginRegion(String? input) { - assert(input != null); - return GenericTuyaLoginRegion._( - validateGenericTuyaLoginStringNotEmty(input!), - ); - } - - const GenericTuyaLoginRegion._(this.value); - - @override - final Either, String> value; -} diff --git a/lib/domain/vendors/vendor_errors.dart b/lib/domain/vendors/vendor_errors.dart deleted file mode 100644 index 4f7d5ca6..00000000 --- a/lib/domain/vendors/vendor_errors.dart +++ /dev/null @@ -1,14 +0,0 @@ -import 'package:cbj_hub/domain/vendors/login_abstract/core_login_failures.dart'; - -class VendorUnexpectedValueError extends Error { - VendorUnexpectedValueError(this.vendorValueFailure); - - final CoreLoginFailure vendorValueFailure; - - @override - String toString() { - const explanation = - 'Encountered a ValueFailure at an unrecoverable point. Terminating.'; - return Error.safeToString('$explanation Failure was: $vendorValueFailure'); - } -} diff --git a/lib/domain/vendors/vendor_failures.dart b/lib/domain/vendors/vendor_failures.dart deleted file mode 100644 index 02ea5ff7..00000000 --- a/lib/domain/vendors/vendor_failures.dart +++ /dev/null @@ -1,63 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'vendor_failures.freezed.dart'; - -/// Example how to use multiple failures types in one class -@freezed -class VendorValueFailure with _$VendorValueFailure { - const factory VendorValueFailure.auth(VendorFailure f) = _Auth; -} - -@freezed -class VendorFailure { - const factory VendorFailure.empty({ - required T failedValue, - }) = _Empty; - - const factory VendorFailure.unexpected() = _Unexpected; - - const factory VendorFailure.validateEmailNotEmpty() = - _ValidateEmailNotEmpty; - - const factory VendorFailure.insufficientPermission() = - _InsufficientPermission; - - const factory VendorFailure.wifiIsClosed() = _wifiIsClosed; - - const factory VendorFailure.unableToUpdate() = _UnableToUpdate; - - const factory VendorFailure.vendorTypeDoesNotExist() = - _VendorTypeDoesNotExist; - - const factory VendorFailure.loginTypeDoesNotExist() = - _LoginTypeDoesNotExist; -} - -// /// If multiple failures is not needed just call a specific failure class -// @freezed -// class AuthValueFailure with _$AuthValueFailure { -// const factory AuthValueFailure.invalidEmail({ -// required String failedValue, -// }) = InvalidEmail; -// -// const factory AuthValueFailure.invalidPassword({ -// required String failedValue, -// }) = InvalidPassword; -// -// const factory AuthValueFailure.shortPassword({ -// required String failedValue, -// }) = ShortPassword; -// -// const factory AuthValueFailure.containsSpace({ -// required String failedValue, -// }) = ContainsSpace; -// -// const factory AuthValueFailure.empty({ -// required String failedValue, -// }) = Empty; -// -// const factory AuthValueFailure.listTooLong({ -// required T failedValue, -// required int max, -// }) = ListTooLong; -// } diff --git a/lib/domain/vendors/vendor_validators.dart b/lib/domain/vendors/vendor_validators.dart deleted file mode 100644 index c6004e2d..00000000 --- a/lib/domain/vendors/vendor_validators.dart +++ /dev/null @@ -1,14 +0,0 @@ -import 'package:cbj_hub/domain/vendors/login_abstract/core_login_failures.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validVendorNameNotEmpty(String input) { - if (input.isNotEmpty) { - return right(input); - } else { - return left( - CoreLoginFailure.empty( - failedValue: input, - ), - ); - } -} diff --git a/lib/domain/vendors/vendor_value_objects.dart b/lib/domain/vendors/vendor_value_objects.dart deleted file mode 100644 index b17d481b..00000000 --- a/lib/domain/vendors/vendor_value_objects.dart +++ /dev/null @@ -1,50 +0,0 @@ -import 'package:cbj_hub/domain/vendors/login_abstract/core_login_failures.dart'; -import 'package:cbj_hub/domain/vendors/vendor_errors.dart'; -import 'package:cbj_hub/domain/vendors/vendor_validators.dart'; -import 'package:dartz/dartz.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -@immutable -abstract class VendorValueObjectAbstract { - const VendorValueObjectAbstract(); - - Either, T> get value; - - /// Throws [UnexpectedValueError] containing the [CoreLoginFailure] - T getOrCrash() { - // id = identity - same as writing (right) => right - return value.fold((f) => throw VendorUnexpectedValueError(f), id); - } - - Either, Unit> get failureOrUnit { - return value.fold((l) => left(l), (r) => right(unit)); - } - - bool isValid() => value.isRight(); - - @override - String toString() => 'Value($value)'; - - @override - @nonVirtual - bool operator ==(Object o) { - if (identical(this, o)) return true; - return o is VendorValueObjectAbstract && o.value == value; - } - - @override - int get hashCode => value.hashCode; -} - -class VendorName extends VendorValueObjectAbstract { - factory VendorName(String input) { - return VendorName._( - validVendorNameNotEmpty(input), - ); - } - - const VendorName._(this.value); - - @override - final Either, String> value; -} diff --git a/lib/domain/vendors/wiz_login/generic_wiz_login_entity.dart b/lib/domain/vendors/wiz_login/generic_wiz_login_entity.dart deleted file mode 100644 index 7a2c3055..00000000 --- a/lib/domain/vendors/wiz_login/generic_wiz_login_entity.dart +++ /dev/null @@ -1,62 +0,0 @@ -import 'package:cbj_hub/domain/vendors/login_abstract/core_login_failures.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/login_entity_abstract.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/value_login_objects_core.dart'; -import 'package:cbj_hub/domain/vendors/wiz_login/generic_wiz_login_value_objects.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/generic_vendors_login/generic_login_abstract/login_entity_dto_abstract.dart'; -import 'package:cbj_hub/infrastructure/generic_vendors_login/generic_wiz_login/generic_wiz_login_dtos.dart'; -import 'package:dartz/dartz.dart'; - -/// Abstract smart GenericWiz that exist inside a computer, the -/// implementations will be actual GenericWiz like blinds wizs and more -class GenericWizLoginDE extends LoginEntityAbstract { - /// All public field of GenericWiz entity - GenericWizLoginDE({ - required super.senderUniqueId, - required this.wizApiKey, - }) : super( - loginVendor: CoreLoginVendor(VendorsAndServices.tuyaSmart.name), - ); - - /// Empty instance of GenericWizEntity - factory GenericWizLoginDE.empty() => GenericWizLoginDE( - senderUniqueId: CoreLoginSenderId.fromUniqueString(''), - wizApiKey: GenericWizLoginApiKey(''), - ); - - /// Wiz api key - GenericWizLoginApiKey wizApiKey; - - Option> get failureOption => - senderUniqueId.value.fold((f) => some(f), (_) => none()); - - // - // /// Will return failure if any of the fields failed or return unit if fields - // /// have legit values - // Option> get failureOption { - // return cbjEntityName!.value.fold((f) => some(f), (_) => none()); - // - // return body.failureOrUnit - // .andThen(todos.failureOrUnit) - // .andThen( - // todos - // .getOrCrash() - // // Getting the failureOption from the TodoItem ENTITY - NOT a failureOrUnit from a VALUE OBJECT - // .map((todoItem) => todoItem.failureOption) - // .filter((o) => o.isSome()) - // // If we can't get the 0th element, the list is empty. In such a case, it's valid. - // .getOrElse(0, (_) => none()) - // .fold(() => right(unit), (f) => left(f)), - // ) - // .fold((f) => some(f), (_) => none()); - // } - - @override - LoginEntityDtoAbstract toInfrastructure() { - return GenericWizLoginDtos( - senderUniqueId: senderUniqueId.getOrCrash(), - loginVendor: loginVendor.getOrCrash(), - wizApiKey: wizApiKey.getOrCrash(), - ); - } -} diff --git a/lib/domain/vendors/wiz_login/generic_wiz_login_validators.dart b/lib/domain/vendors/wiz_login/generic_wiz_login_validators.dart deleted file mode 100644 index 60bcab5e..00000000 --- a/lib/domain/vendors/wiz_login/generic_wiz_login_validators.dart +++ /dev/null @@ -1,8 +0,0 @@ -import 'package:cbj_hub/domain/vendors/login_abstract/core_login_failures.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateGenericWizLoginApiKeyNotEmty( - String input, -) { - return right(input); -} diff --git a/lib/domain/vendors/wiz_login/generic_wiz_login_value_objects.dart b/lib/domain/vendors/wiz_login/generic_wiz_login_value_objects.dart deleted file mode 100644 index a5517459..00000000 --- a/lib/domain/vendors/wiz_login/generic_wiz_login_value_objects.dart +++ /dev/null @@ -1,18 +0,0 @@ -import 'package:cbj_hub/domain/vendors/login_abstract/core_login_failures.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/value_login_objects_core.dart'; -import 'package:cbj_hub/domain/vendors/wiz_login/generic_wiz_login_validators.dart'; -import 'package:dartz/dartz.dart'; - -class GenericWizLoginApiKey extends ValueObjectCoreLogin { - factory GenericWizLoginApiKey(String? input) { - assert(input != null); - return GenericWizLoginApiKey._( - validateGenericWizLoginApiKeyNotEmty(input!), - ); - } - - const GenericWizLoginApiKey._(this.value); - - @override - final Either, String> value; -} diff --git a/lib/domain/vendors/xiaomi_mi_login/generic_xiaomi_mi_login_entity.dart b/lib/domain/vendors/xiaomi_mi_login/generic_xiaomi_mi_login_entity.dart deleted file mode 100644 index b7155dd0..00000000 --- a/lib/domain/vendors/xiaomi_mi_login/generic_xiaomi_mi_login_entity.dart +++ /dev/null @@ -1,68 +0,0 @@ -import 'package:cbj_hub/domain/vendors/login_abstract/core_login_failures.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/login_entity_abstract.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/value_login_objects_core.dart'; -import 'package:cbj_hub/domain/vendors/xiaomi_mi_login/generic_xiaomi_mi_login_value_objects.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/generic_vendors_login/generic_login_abstract/login_entity_dto_abstract.dart'; -import 'package:cbj_hub/infrastructure/generic_vendors_login/generic_xiaomi_mi_login/generic_xiaomi_mi_login_dtos.dart'; -import 'package:dartz/dartz.dart'; - -/// Abstract smart GenericXiaomiMi that exist inside a computer, the -/// implementations will be actual GenericXiaomiMi like blinds xiaomiMis and more -class GenericXiaomiMiLoginDE extends LoginEntityAbstract { - /// All public field of GenericXiaomiMi entity - GenericXiaomiMiLoginDE({ - required super.senderUniqueId, - required this.xiaomiMiAccountEmail, - required this.xiaomiMiAccountPass, - }) : super( - loginVendor: CoreLoginVendor(VendorsAndServices.xiaomiMi.name), - ); - - /// Empty instance of GenericXiaomiMiEntity - factory GenericXiaomiMiLoginDE.empty() => GenericXiaomiMiLoginDE( - senderUniqueId: CoreLoginSenderId.fromUniqueString(''), - xiaomiMiAccountEmail: GenericXiaomiMiAccountEmail(''), - xiaomiMiAccountPass: GenericXiaomiMiAccountPass(''), - ); - - /// XiaomiMi account email - GenericXiaomiMiAccountEmail xiaomiMiAccountEmail; - - /// XiaomiMi account password - GenericXiaomiMiAccountPass xiaomiMiAccountPass; - - Option> get failureOption => - senderUniqueId.value.fold((f) => some(f), (_) => none()); - - // - // /// Will return failure if any of the fields failed or return unit if fields - // /// have legit values - // Option> get failureOption { - // return cbjEntityName!.value.fold((f) => some(f), (_) => none()); - // - // return body.failureOrUnit - // .andThen(todos.failureOrUnit) - // .andThen( - // todos - // .getOrCrash() - // // Getting the failureOption from the TodoItem ENTITY - NOT a failureOrUnit from a VALUE OBJECT - // .map((todoItem) => todoItem.failureOption) - // .filter((o) => o.isSome()) - // // If we can't get the 0th element, the list is empty. In such a case, it's valid. - // .getOrElse(0, (_) => none()) - // .fold(() => right(unit), (f) => left(f)), - // ) - // .fold((f) => some(f), (_) => none()); - // } - - @override - LoginEntityDtoAbstract toInfrastructure() { - return GenericXiaomiMiLoginDtos( - senderUniqueId: senderUniqueId.getOrCrash(), - loginVendor: loginVendor.getOrCrash(), - xiaomiMiAccountEmail: xiaomiMiAccountEmail.getOrCrash(), - xiaomiMiAccountPass: xiaomiMiAccountPass.getOrCrash(), - ); - } -} diff --git a/lib/domain/vendors/xiaomi_mi_login/generic_xiaomi_mi_login_validators.dart b/lib/domain/vendors/xiaomi_mi_login/generic_xiaomi_mi_login_validators.dart deleted file mode 100644 index 2137d23e..00000000 --- a/lib/domain/vendors/xiaomi_mi_login/generic_xiaomi_mi_login_validators.dart +++ /dev/null @@ -1,8 +0,0 @@ -import 'package:cbj_hub/domain/vendors/login_abstract/core_login_failures.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateGenericXiaomiMiNotEmpty( - String input, -) { - return right(input); -} diff --git a/lib/domain/vendors/xiaomi_mi_login/generic_xiaomi_mi_login_value_objects.dart b/lib/domain/vendors/xiaomi_mi_login/generic_xiaomi_mi_login_value_objects.dart deleted file mode 100644 index 948095c9..00000000 --- a/lib/domain/vendors/xiaomi_mi_login/generic_xiaomi_mi_login_value_objects.dart +++ /dev/null @@ -1,32 +0,0 @@ -import 'package:cbj_hub/domain/vendors/login_abstract/core_login_failures.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/value_login_objects_core.dart'; -import 'package:cbj_hub/domain/vendors/xiaomi_mi_login/generic_xiaomi_mi_login_validators.dart'; -import 'package:dartz/dartz.dart'; - -class GenericXiaomiMiAccountEmail extends ValueObjectCoreLogin { - factory GenericXiaomiMiAccountEmail(String? input) { - assert(input != null); - return GenericXiaomiMiAccountEmail._( - validateGenericXiaomiMiNotEmpty(input!), - ); - } - - const GenericXiaomiMiAccountEmail._(this.value); - - @override - final Either, String> value; -} - -class GenericXiaomiMiAccountPass extends ValueObjectCoreLogin { - factory GenericXiaomiMiAccountPass(String? input) { - assert(input != null); - return GenericXiaomiMiAccountPass._( - validateGenericXiaomiMiNotEmpty(input!), - ); - } - - const GenericXiaomiMiAccountPass._(this.value); - - @override - final Either, String> value; -} diff --git a/lib/infrastructure/app_communication/app_communication_repository.dart b/lib/infrastructure/app_communication/app_communication_repository.dart index b643a649..bba3e457 100644 --- a/lib/infrastructure/app_communication/app_communication_repository.dart +++ b/lib/infrastructure/app_communication/app_communication_repository.dart @@ -2,42 +2,39 @@ import 'dart:async'; import 'dart:convert'; import 'package:cbj_hub/domain/app_communication/i_app_communication_repository.dart'; -import 'package:cbj_hub/domain/core/value_objects.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_empty_device/generic_empty_entity.dart'; -import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart'; -import 'package:cbj_hub/domain/remote_pipes/remote_pipes_entity.dart'; import 'package:cbj_hub/domain/room/room_entity.dart'; import 'package:cbj_hub/domain/rooms/i_saved_rooms_repo.dart'; import 'package:cbj_hub/domain/routine/i_routine_cbj_repository.dart'; import 'package:cbj_hub/domain/routine/routine_cbj_entity.dart'; -import 'package:cbj_hub/domain/saved_devices/i_saved_devices_repo.dart'; import 'package:cbj_hub/domain/scene/i_scene_cbj_repository.dart'; import 'package:cbj_hub/domain/scene/scene_cbj_entity.dart'; import 'package:cbj_hub/domain/scene/value_objects_scene_cbj.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/login_entity_abstract.dart'; import 'package:cbj_hub/infrastructure/app_communication/hub_app_server.dart'; -import 'package:cbj_hub/infrastructure/devices/device_helper/device_helper.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:cbj_hub/infrastructure/generic_vendors_login/vendor_helper.dart'; import 'package:cbj_hub/infrastructure/remote_pipes/remote_pipes_client.dart'; -import 'package:cbj_hub/infrastructure/remote_pipes/remote_pipes_dtos.dart'; import 'package:cbj_hub/infrastructure/room/room_entity_dtos.dart'; import 'package:cbj_hub/infrastructure/routines/routine_cbj_dtos.dart'; import 'package:cbj_hub/infrastructure/scenes/scene_cbj_dtos.dart'; -import 'package:cbj_hub/injection.dart'; import 'package:cbj_hub/utils.dart'; +import 'package:cbj_integrations_controller/domain/core/value_objects.dart'; +import 'package:cbj_integrations_controller/domain/mqtt_server/i_mqtt_server_repository.dart'; +import 'package:cbj_integrations_controller/domain/saved_devices/i_saved_devices_repo.dart'; +import 'package:cbj_integrations_controller/domain/vendors/login_abstract/login_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/devices/device_helper/device_helper.dart'; +import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/value_objects_core.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_empty_device/generic_empty_entity.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_vendors_login/vendor_helper.dart'; +import 'package:cbj_integrations_controller/injection.dart'; import 'package:grpc/grpc.dart'; -import 'package:injectable/injectable.dart'; import 'package:internet_connection_checker/internet_connection_checker.dart'; import 'package:mqtt_client/mqtt_client.dart'; import 'package:rxdart/rxdart.dart'; -@LazySingleton(as: IAppCommunicationRepository) class AppCommunicationRepository extends IAppCommunicationRepository { AppCommunicationRepository() { + IAppCommunicationRepository.instance = this; if (currentEnv == Env.prod) { hubPort = 50055; } else { @@ -99,14 +96,14 @@ class AppCommunicationRepository extends IAppCommunicationRepository { dataToSend.listen((MqttPublishMessage event) async { logger.i('Got hub requests to app'); - (await getIt().getAllDevices()) + (await getItCbj().getAllDevices()) .forEach((String id, deviceEntityToSend) { final DeviceEntityDtoAbstract deviceDtoAbstract = DeviceHelper.convertDomainToDto(deviceEntityToSend); HubRequestsToApp.streamRequestsToApp.sink.add(deviceDtoAbstract); }); - (await getIt().getAllScenesAsMap()) + (await getItCbj().getAllScenesAsMap()) .forEach((key, value) { HubRequestsToApp.streamRequestsToApp.sink.add(value.toInfrastructure()); }); @@ -129,7 +126,7 @@ class AppCommunicationRepository extends IAppCommunicationRepository { deviceEntityFromApp.entityStateGRPC = EntityState(EntityStateGRPC.waitingInComp.toString()); - getIt().postToHubMqtt( + IMqttServerRepository.instance.postToHubMqtt( entityFromTheApp: deviceEntityFromApp, gotFromApp: true, ); @@ -138,11 +135,11 @@ class AppCommunicationRepository extends IAppCommunicationRepository { jsonDecode(event.allRemoteCommands) as Map, ).toDomain(); - getIt().saveAndActiveRoomToDb( + ISavedRoomsRepo.instance.saveAndActiveRoomToDb( roomEntity: roomEntityFromApp, ); - getIt().postToHubMqtt( + IMqttServerRepository.instance.postToHubMqtt( entityFromTheApp: roomEntityFromApp, gotFromApp: true, ); @@ -150,7 +147,7 @@ class AppCommunicationRepository extends IAppCommunicationRepository { final LoginEntityAbstract loginEntityFromApp = VendorHelper.convertJsonStringToDomain(event.allRemoteCommands); - getIt() + getItCbj() .saveAndActivateVendorLoginCredentialsDomainToDb( loginEntity: loginEntityFromApp, ); @@ -159,14 +156,13 @@ class AppCommunicationRepository extends IAppCommunicationRepository { AppCommunicationRepository.sendAllDevicesFromHubRequestsStream(); AppCommunicationRepository.sendAllScenesFromHubRequestsStream(); } else if (event.sendingType == SendingType.remotePipesInformation) { - final Map jsonDecoded = - jsonDecode(event.allRemoteCommands) as Map; - - final RemotePipesEntity remotePipes = - RemotePipesDtos.fromJson(jsonDecoded).toDomain(); - - getIt() - .saveAndActivateRemotePipesDomainToDb(remotePipes: remotePipes); + // TODO: Fix after new cbj_integrations_controller + // final Map jsonDecoded = + // jsonDecode(event.allRemoteCommands) as Map; + // final RemotePipesEntity remotePipes = + // RemotePipesDtos.fromJson(jsonDecoded).toDomain(); + // getItCbj() + // .saveAndActivateRemotePipesDomainToDb(remotePipes: remotePipes); } else if (event.sendingType == SendingType.sceneType) { final Map jsonSceneFromJsonString = jsonDecode(event.allRemoteCommands) as Map; @@ -184,9 +180,9 @@ class AppCommunicationRepository extends IAppCommunicationRepository { // ); if (sceneStateGrpcTemp == EntityStateGRPC.addingNewScene.toString()) { - getIt().addNewSceneAndSaveInDb(sceneCbj); + getItCbj().addNewSceneAndSaveInDb(sceneCbj); } else { - getIt().activateScene(sceneCbj); + getItCbj().activateScene(sceneCbj); } } else if (event.sendingType == SendingType.routineType) { final Map jsonRoutineFromJsonString = @@ -206,11 +202,11 @@ class AppCommunicationRepository extends IAppCommunicationRepository { if (routineStateGrpcTemp == EntityStateGRPC.addingNewRoutine.toString()) { - getIt() + getItCbj() .addNewRoutineAndSaveItToLocalDb(routineCbj); } else { // For a way to active it manually - // getIt().activateRoutine(routineCbj); + // getItCbj().activateRoutine(routineCbj); } } else { logger.w('Request from app does not support this sending device type'); @@ -267,7 +263,7 @@ class AppCommunicationRepository extends IAppCommunicationRepository { /// HubRequestsToApp stream static Future sendAllRoomsFromHubRequestsStream() async { final Map allRooms = - await getIt().getAllRooms(); + await ISavedRoomsRepo.instance.getAllRooms(); if (allRooms.isNotEmpty) { allRooms.map((String id, RoomEntity d) { @@ -283,10 +279,10 @@ class AppCommunicationRepository extends IAppCommunicationRepository { /// HubRequestsToApp stream static Future sendAllDevicesFromHubRequestsStream() async { final Map allDevices = - await getIt().getAllDevices(); + await getItCbj().getAllDevices(); final Map allRooms = - await getIt().getAllRooms(); + await ISavedRoomsRepo.instance.getAllRooms(); if (allRooms.isNotEmpty) { /// The delay fix this issue in gRPC for some reason @@ -312,7 +308,7 @@ class AppCommunicationRepository extends IAppCommunicationRepository { /// HubRequestsToApp stream static Future sendAllScenesFromHubRequestsStream() async { final Map allScenes = - await getIt().getAllScenesAsMap(); + await getItCbj().getAllScenesAsMap(); if (allScenes.isNotEmpty) { allScenes.map((String id, SceneCbjEntity d) { diff --git a/lib/infrastructure/app_communication/hub_app_server.dart b/lib/infrastructure/app_communication/hub_app_server.dart index f3cb6947..8d6c9f32 100644 --- a/lib/infrastructure/app_communication/hub_app_server.dart +++ b/lib/infrastructure/app_communication/hub_app_server.dart @@ -3,15 +3,14 @@ import 'dart:io'; import 'package:cbj_hub/domain/app_communication/i_app_communication_repository.dart'; import 'package:cbj_hub/infrastructure/app_communication/app_communication_repository.dart'; -import 'package:cbj_hub/infrastructure/devices/device_helper/device_helper.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/proto_gen_date.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; import 'package:cbj_hub/infrastructure/room/room_entity_dtos.dart'; import 'package:cbj_hub/infrastructure/routines/routine_cbj_dtos.dart'; import 'package:cbj_hub/infrastructure/scenes/scene_cbj_dtos.dart'; -import 'package:cbj_hub/injection.dart'; import 'package:cbj_hub/utils.dart'; +import 'package:cbj_integrations_controller/infrastructure/devices/device_helper/device_helper.dart'; +import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/proto_gen_date.dart'; +import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; import 'package:grpc/service_api.dart'; /// Server to get and send information to the app @@ -28,7 +27,7 @@ class HubAppServer extends CbjHubServiceBase { try { logger.t('Got new Client'); - getIt().getFromApp( + IAppCommunicationRepository.instance.getFromApp( request: request, requestUrl: 'Error, Hub does not suppose to have request URL', isRemotePipes: false, diff --git a/lib/infrastructure/bindings/binding_cbj_dtos.dart b/lib/infrastructure/bindings/binding_cbj_dtos.dart index 69d8a82f..5e423a37 100644 --- a/lib/infrastructure/bindings/binding_cbj_dtos.dart +++ b/lib/infrastructure/bindings/binding_cbj_dtos.dart @@ -1,6 +1,6 @@ import 'package:cbj_hub/domain/binding/binding_cbj_entity.dart'; import 'package:cbj_hub/domain/binding/value_objects_routine_cbj.dart'; -import 'package:cbj_hub/domain/core/value_objects.dart'; +import 'package:cbj_integrations_controller/domain/core/value_objects.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; part 'binding_cbj_dtos.freezed.dart'; diff --git a/lib/infrastructure/bindings/binding_repository.dart b/lib/infrastructure/bindings/binding_repository.dart index dc707e93..6a5ccc82 100644 --- a/lib/infrastructure/bindings/binding_repository.dart +++ b/lib/infrastructure/bindings/binding_repository.dart @@ -1,14 +1,11 @@ import 'package:cbj_hub/domain/binding/binding_cbj_entity.dart'; import 'package:cbj_hub/domain/binding/binding_cbj_failures.dart'; import 'package:cbj_hub/domain/binding/i_binding_cbj_repository.dart'; -import 'package:cbj_hub/domain/binding/value_objects_routine_cbj.dart'; -import 'package:cbj_hub/domain/local_db/i_local_db_repository.dart'; -import 'package:cbj_hub/domain/local_db/local_db_failures.dart'; -import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart'; import 'package:cbj_hub/domain/rooms/i_saved_rooms_repo.dart'; -import 'package:cbj_hub/domain/saved_devices/i_saved_devices_repo.dart'; -import 'package:cbj_hub/infrastructure/node_red/node_red_repository.dart'; -import 'package:cbj_hub/injection.dart'; +import 'package:cbj_integrations_controller/domain/local_db/local_db_failures.dart'; +import 'package:cbj_integrations_controller/domain/mqtt_server/i_mqtt_server_repository.dart'; +import 'package:cbj_integrations_controller/domain/saved_devices/i_saved_devices_repo.dart'; +import 'package:cbj_integrations_controller/injection.dart'; import 'package:dartz/dartz.dart'; import 'package:injectable/injectable.dart'; @@ -18,13 +15,14 @@ class BindingCbjRepository implements IBindingCbjRepository { @override Future setUpAllFromDb() async { - await getIt().getBindingsFromDb().then((value) { - value.fold((l) => null, (r) async { - for (final element in r) { - await addNewBinding(element); - } - }); - }); + // TODO: Fix after new cbj_integrations_controller + // await getItCbj().getBindingsFromDb().then((value) { + // value.fold((l) => null, (r) async { + // for (final element in r) { + // await addNewBinding(element); + // } + // }); + // }); } @override @@ -38,10 +36,12 @@ class BindingCbjRepository implements IBindingCbjRepository { } @override - Future> saveAndActivateBindingToDb() { - return getIt().saveBindings( - bindingList: List.from(_allBindings.values), - ); + Future> saveAndActivateBindingToDb() async { + // TODO: Fix after new cbj_integrations_controller + // return getItCbj().saveBindings( + // bindingList: List.from(_allBindings.values), + // ); + return left(const LocalDbFailures.unableToUpdate()); } @override @@ -61,16 +61,17 @@ class BindingCbjRepository implements IBindingCbjRepository { /// If it is new binding _allBindings[entityId] = tempBindingCbj; - await getIt().saveAndActivateSmartDevicesToDb(); - getIt() + await getItCbj().saveAndActivateSmartDevicesToDb(); + ISavedRoomsRepo.instance .addBindingToRoomDiscoveredIfNotExist(tempBindingCbj); - final String bindingNodeRedFlowId = await getIt() - .createNewNodeRedBinding(tempBindingCbj); - if (bindingNodeRedFlowId.isNotEmpty) { - tempBindingCbj = tempBindingCbj.copyWith( - nodeRedFlowId: BindingCbjNodeRedFlowId(bindingNodeRedFlowId), - ); - } + // TODO: Fix after new cbj_integrations_controller + // final String bindingNodeRedFlowId = await getItCbj() + // .createNewNodeRedBinding(tempBindingCbj); + // if (bindingNodeRedFlowId.isNotEmpty) { + // tempBindingCbj = tempBindingCbj.copyWith( + // nodeRedFlowId: BindingCbjNodeRedFlowId(bindingNodeRedFlowId), + // ); + // } await saveAndActivateBindingToDb(); } return right(unit); @@ -79,7 +80,7 @@ class BindingCbjRepository implements IBindingCbjRepository { @override Future activateBinding(BindingCbjEntity bindingCbj) async { final String fullPathOfBinding = await getFullMqttPathOfBinding(bindingCbj); - getIt() + IMqttServerRepository.instance .publishMessage(fullPathOfBinding, DateTime.now().toString()); return true; @@ -89,9 +90,9 @@ class BindingCbjRepository implements IBindingCbjRepository { @override Future getFullMqttPathOfBinding(BindingCbjEntity bindingCbj) async { final String hubBaseTopic = - getIt().getHubBaseTopic(); + IMqttServerRepository.instance.getHubBaseTopic(); final String bindingsTopicTypeName = - getIt().getBindingsTopicTypeName(); + IMqttServerRepository.instance.getBindingsTopicTypeName(); final String bindingId = bindingCbj.firstNodeId.getOrCrash()!; return '$hubBaseTopic/$bindingsTopicTypeName/$bindingId'; diff --git a/lib/infrastructure/cbj_web_server/cbj_web_server_repository.dart b/lib/infrastructure/cbj_web_server/cbj_web_server_repository.dart index c20f7e82..c13e34c3 100644 --- a/lib/infrastructure/cbj_web_server/cbj_web_server_repository.dart +++ b/lib/infrastructure/cbj_web_server/cbj_web_server_repository.dart @@ -1,19 +1,18 @@ import 'dart:io'; import 'package:cbj_hub/domain/cbj_web_server/i_cbj_web_server_repository.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/saved_devices/i_saved_devices_repo.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:cbj_hub/injection.dart'; import 'package:cbj_hub/utils.dart'; -import 'package:injectable/injectable.dart'; +import 'package:cbj_integrations_controller/domain/saved_devices/i_saved_devices_repo.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; +import 'package:cbj_integrations_controller/injection.dart'; /// A cbj web server to interact with get current state requests from mqtt as /// well as website to change devices state locally on the network without /// the need of installing any app. -@LazySingleton(as: ICbjWebServerRepository) class CbjWebServerRepository extends ICbjWebServerRepository { CbjWebServerRepository() { + ICbjWebServerRepository.instance = this; startWebServer(); } @@ -29,7 +28,7 @@ class CbjWebServerRepository extends ICbjWebServerRepository { final String deviceId = pathArgs[1]; final ISavedDevicesRepo savedDevicesRepo = - getIt(); + getItCbj(); final Map allDevices = await savedDevicesRepo.getAllDevices(); diff --git a/lib/infrastructure/devices/cbj_devices/cbj_devices_connector_conjector.dart b/lib/infrastructure/devices/cbj_devices/cbj_devices_connector_conjector.dart deleted file mode 100644 index ac7f0033..00000000 --- a/lib/infrastructure/devices/cbj_devices/cbj_devices_connector_conjector.dart +++ /dev/null @@ -1,116 +0,0 @@ -import 'dart:async'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_computer_device/generic_smart_computer_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/cbj_devices/cbj_devices_helpers.dart'; -import 'package:cbj_hub/infrastructure/devices/cbj_devices/cbj_smart_device/cbj_smart_device_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/cbj_devices/cbj_smart_device_client/cbj_smart_device_client.dart'; -import 'package:cbj_hub/infrastructure/devices/companies_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_smart_device_server/protoc_as_dart/cbj_smart_device_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/abstract_company_connector_conjector.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:injectable/injectable.dart'; -import 'package:network_tools/network_tools.dart'; - -@singleton -class CbjDevicesConnectorConjector - implements AbstractCompanyConnectorConjector { - @override - Map companyDevices = {}; - - Future addNewDeviceByHostInfo({ - required ActiveHost activeHost, - }) async { - for (final DeviceEntityAbstract savedDevice in companyDevices.values) { - if ((savedDevice is CbjSmartComputerEntity) && - await activeHost.hostName == - savedDevice.entityUniqueId.getOrCrash()) { - return; - } else if (await activeHost.hostName == - savedDevice.entityUniqueId.getOrCrash()) { - logger.w( - 'Cbj device type supported but implementation is missing here', - ); - } - } - - final List componentsInDevice = - await getAllComponentsOfDevice(activeHost); - final List devicesList = - CbjDevicesHelpers.addDiscoverdDevice( - componentsInDevice: componentsInDevice, - deviceAddress: activeHost.address, - ); - if (devicesList.isEmpty) { - return; - } - - for (final DeviceEntityAbstract entityAsDevice in devicesList) { - final DeviceEntityAbstract deviceToAdd = - CompaniesConnectorConjector.addDiscoverdDeviceToHub(entityAsDevice); - - final MapEntry deviceAsEntry = - MapEntry(deviceToAdd.uniqueId.getOrCrash(), deviceToAdd); - - companyDevices.addEntries([deviceAsEntry]); - - logger.t( - 'New Cbj Smart Device name:${entityAsDevice.cbjEntityName.getOrCrash()}', - ); - } - } - - @override - Future manageHubRequestsForDevice( - DeviceEntityAbstract cbjDevicesDE, - ) async { - final DeviceEntityAbstract? device = - companyDevices[cbjDevicesDE.entityUniqueId.getOrCrash()]; - - // if (device == null) { - // setTheSameDeviceFromAllDevices(cbjDevicesDE); - // device = - // companyDevices[cbjDevicesDE.entityUniqueId.getOrCrash(); - // } - - if (device != null && (device is CbjSmartComputerEntity)) { - device.executeDeviceAction(newEntity: cbjDevicesDE); - } else { - logger.w('CbjDevices device type ${device.runtimeType} does not exist'); - } - } - // - // // Future setTheSameDeviceFromAllDevices( - // // DeviceEntityAbstract cbjDevicesDE, - // // ) async { - // // final String deviceEntityUniqueId = cbjDevicesDE.entityUniqueId.getOrCrash(); - // // for(a) - // // } - - Future> getAllComponentsOfDevice( - ActiveHost activeHost, - ) async { - activeHost.address; - final List devicesInfo = - await CbjSmartDeviceClient.getCbjSmartDeviceHostDevicesInfo(activeHost); - return devicesInfo; - } - - @override - Future setUpDeviceFromDb(DeviceEntityAbstract deviceEntity) async { - DeviceEntityAbstract? nonGenericDevice; - - if (deviceEntity is GenericSmartComputerDE) { - nonGenericDevice = CbjSmartComputerEntity.fromGeneric(deviceEntity); - } - - if (nonGenericDevice == null) { - logger.w('Switcher device could not get loaded from the server'); - return; - } - - companyDevices.addEntries([ - MapEntry(nonGenericDevice.entityUniqueId.getOrCrash(), nonGenericDevice), - ]); - } -} diff --git a/lib/infrastructure/devices/cbj_devices/cbj_devices_device_validators.dart b/lib/infrastructure/devices/cbj_devices/cbj_devices_device_validators.dart deleted file mode 100644 index 18dcf0f7..00000000 --- a/lib/infrastructure/devices/cbj_devices/cbj_devices_device_validators.dart +++ /dev/null @@ -1,18 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateCbjDevicesIdNotEmpty(String input) { - return right(input); -} - -Either, String> validateCbjDevicesPortNotEmpty( - String input, -) { - return right(input); -} - -Either, String> validateCbjDevicesMacAddressNotEmpty( - String input, -) { - return right(input); -} diff --git a/lib/infrastructure/devices/cbj_devices/cbj_devices_device_value_objects.dart b/lib/infrastructure/devices/cbj_devices/cbj_devices_device_value_objects.dart deleted file mode 100644 index 9934307c..00000000 --- a/lib/infrastructure/devices/cbj_devices/cbj_devices_device_value_objects.dart +++ /dev/null @@ -1,34 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/infrastructure/devices/cbj_devices/cbj_devices_device_validators.dart'; -import 'package:dartz/dartz.dart'; - -/// CbjDevices communication port -class CbjDevicesPort extends ValueObjectCore { - factory CbjDevicesPort(String? input) { - assert(input != null); - return CbjDevicesPort._( - validateCbjDevicesPortNotEmpty(input!), - ); - } - - const CbjDevicesPort._(this.value); - - @override - final Either, String> value; -} - -/// CbjDevices communication port -class CbjDevicesMacAddress extends ValueObjectCore { - factory CbjDevicesMacAddress(String? input) { - assert(input != null); - return CbjDevicesMacAddress._( - validateCbjDevicesMacAddressNotEmpty(input!), - ); - } - - const CbjDevicesMacAddress._(this.value); - - @override - final Either, String> value; -} diff --git a/lib/infrastructure/devices/cbj_devices/cbj_devices_helpers.dart b/lib/infrastructure/devices/cbj_devices/cbj_devices_helpers.dart deleted file mode 100644 index 13b58a85..00000000 --- a/lib/infrastructure/devices/cbj_devices/cbj_devices_helpers.dart +++ /dev/null @@ -1,79 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_computer_device/generic_smart_computer_value_objects.dart'; -import 'package:cbj_hub/infrastructure/devices/cbj_devices/cbj_smart_device/cbj_smart_device_entity.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_smart_device_server/protoc_as_dart/cbj_smart_device_server.pbgrpc.dart'; -import 'package:cbj_hub/utils.dart'; - -class CbjDevicesHelpers { - static List addDiscoverdDevice({ - required List componentsInDevice, - required String deviceAddress, - }) { - final List componentsAsSmartDevices = []; - - for (final CbjSmartDeviceInfo? smartDeviceInfo in componentsInDevice) { - if (smartDeviceInfo == null) { - continue; - } - DeviceEntityAbstract entityAbstract; - - final CbjDeviceTypes deviceType = - smartDeviceInfo.deviceTypesActions.deviceType; - final String deviceId = smartDeviceInfo.id; - final String cbjEntityName = smartDeviceInfo.defaultName; - // final String deviceState = smartDeviceInfo.state; - final String deviceStateMassage = smartDeviceInfo.stateMassage.isEmpty - ? 'ok' - : smartDeviceInfo.stateMassage; - final CbjDeviceStateGRPC deviceStateGrpc = - smartDeviceInfo.deviceTypesActions.deviceStateGRPC; - - final String deviceOs = smartDeviceInfo.senderDeviceOs; - final String deviceModel = smartDeviceInfo.senderDeviceModel; - final String deviceSenderId = smartDeviceInfo.senderId; - final String deviceCompUuid = smartDeviceInfo.compSpecs.compUuid; - - if (deviceType == CbjDeviceTypes.smartComputer) { - entityAbstract = CbjSmartComputerEntity( - uniqueId: CoreUniqueId(), - entityUniqueId: EntityUniqueId(deviceId), - cbjEntityName: CbjEntityName(cbjEntityName), - entityStateGRPC: EntityState(deviceStateGrpc.toString()), - stateMassage: DeviceStateMassage(deviceStateMassage), - senderDeviceOs: DeviceSenderDeviceOs(deviceOs), - senderDeviceModel: DeviceSenderDeviceModel(deviceModel), - senderId: DeviceSenderId.fromUniqueString(deviceSenderId), - compUuid: DeviceCompUuid(deviceCompUuid), - smartComputerSuspendState: GenericSmartComputerSuspendState( - EntityActions.itIsFalse.toString(), - ), - smartComputerShutDownState: GenericSmartComputerShutdownState( - EntityActions.itIsFalse.toString(), - ), - entityOriginalName: EntityOriginalName(cbjEntityName), - deviceOriginalName: DeviceOriginalName(cbjEntityName), - powerConsumption: DevicePowerConsumption('0'), - deviceUniqueId: DeviceUniqueId('0'), - devicePort: DevicePort('0'), - deviceLastKnownIp: DeviceLastKnownIp(deviceAddress), - deviceHostName: DeviceHostName('0'), - deviceMdns: DeviceMdns('0'), - devicesMacAddress: DevicesMacAddress('0'), - entityKey: EntityKey('0'), - requestTimeStamp: RequestTimeStamp('0'), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp('0'), - deviceCbjUniqueId: CoreUniqueId(), - ); - } else { - logger.w('Cbj Smart Device type is not supported ${deviceType.name}'); - continue; - } - - componentsAsSmartDevices.add(entityAbstract); - } - - return componentsAsSmartDevices; - } -} diff --git a/lib/infrastructure/devices/cbj_devices/cbj_smart_device/cbj_smart_device_entity.dart b/lib/infrastructure/devices/cbj_devices/cbj_smart_device/cbj_smart_device_entity.dart deleted file mode 100644 index 4464bf02..00000000 --- a/lib/infrastructure/devices/cbj_devices/cbj_smart_device/cbj_smart_device_entity.dart +++ /dev/null @@ -1,184 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_computer_device/generic_smart_computer_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_computer_device/generic_smart_computer_value_objects.dart'; -import 'package:cbj_hub/infrastructure/devices/cbj_devices/cbj_smart_device_client/cbj_smart_device_client.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; - -class CbjSmartComputerEntity extends GenericSmartComputerDE { - CbjSmartComputerEntity({ - required super.uniqueId, - required super.entityUniqueId, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required super.smartComputerShutDownState, - required super.smartComputerSuspendState, - }) : super( - deviceVendor: DeviceVendor( - VendorsAndServices.cyBearJinniAppSmartEntity.toString(), - ), - ); - - factory CbjSmartComputerEntity.fromGeneric( - GenericSmartComputerDE genericDevice, - ) { - return CbjSmartComputerEntity( - uniqueId: genericDevice.uniqueId, - entityUniqueId: genericDevice.entityUniqueId, - cbjEntityName: genericDevice.cbjEntityName, - entityOriginalName: genericDevice.entityOriginalName, - deviceOriginalName: genericDevice.deviceOriginalName, - stateMassage: genericDevice.stateMassage, - senderDeviceOs: genericDevice.senderDeviceOs, - senderDeviceModel: genericDevice.senderDeviceModel, - senderId: genericDevice.senderId, - compUuid: genericDevice.compUuid, - entityStateGRPC: genericDevice.entityStateGRPC, - powerConsumption: genericDevice.powerConsumption, - deviceUniqueId: genericDevice.deviceUniqueId, - devicePort: genericDevice.devicePort, - deviceLastKnownIp: genericDevice.deviceLastKnownIp, - deviceHostName: genericDevice.deviceHostName, - deviceMdns: genericDevice.deviceMdns, - devicesMacAddress: genericDevice.devicesMacAddress, - entityKey: genericDevice.entityKey, - requestTimeStamp: genericDevice.requestTimeStamp, - lastResponseFromDeviceTimeStamp: - genericDevice.lastResponseFromDeviceTimeStamp, - deviceCbjUniqueId: genericDevice.deviceCbjUniqueId, - smartComputerShutDownState: genericDevice.smartComputerShutDownState, - smartComputerSuspendState: genericDevice.smartComputerSuspendState, - ); - } - - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - if (newEntity is! GenericSmartComputerDE) { - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Not the correct type', - ), - ); - } - - try { - if (newEntity.smartComputerSuspendState!.getOrCrash() != - smartComputerSuspendState!.getOrCrash()) { - final EntityActions? actionToPreform = - EnumHelperCbj.stringToDeviceAction( - newEntity.smartComputerSuspendState!.getOrCrash(), - ); - - if (actionToPreform == EntityActions.suspend) { - (await suspendSmartComputer()).fold((l) { - logger.e('Error suspending Cbj Computer'); - throw l; - }, (r) { - logger.i('Cbj Computer suspended success'); - }); - } else { - logger.e('actionToPreform is not set correctly Cbj Computer'); - } - } - - if (newEntity.smartComputerShutDownState!.getOrCrash() != - smartComputerShutDownState!.getOrCrash()) { - final EntityActions? actionToPreform = - EnumHelperCbj.stringToDeviceAction( - newEntity.smartComputerShutDownState!.getOrCrash(), - ); - if (actionToPreform == EntityActions.shutdown) { - (await shutDownSmartComputer()).fold((l) { - logger.e('Error shutdown Cbj Computer'); - throw l; - }, (r) { - logger.i('Cbj Computer shutdown success'); - }); - } else { - logger.e('actionToPreform is not set correctly Cbj Computer'); - } - } - - smartComputerSuspendState = - GenericSmartComputerSuspendState(EntityActions.itIsFalse.toString()); - smartComputerShutDownState = - GenericSmartComputerShutdownState(EntityActions.itIsFalse.toString()); - - // entityStateGRPC = EntityState(EntityStateGRPC.ack.toString()); - // - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - - return right(unit); - } catch (e) { - entityStateGRPC = EntityState(EntityStateGRPC.newStateFailed.toString()); - - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - - return left(const CoreFailure.unexpected()); - } - } - - /// Please override the following methods - @override - Future> suspendSmartComputer() async { - smartComputerSuspendState = - GenericSmartComputerSuspendState(EntityActions.itIsFalse.toString()); - - await CbjSmartDeviceClient.suspendCbjSmartDeviceHostDevice( - deviceLastKnownIp.getOrCrash(), - entityUniqueId.getOrCrash(), - ); - - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - /// Please override the following methods - @override - Future> shutDownSmartComputer() async { - smartComputerShutDownState = - GenericSmartComputerShutdownState(EntityActions.itIsFalse.toString()); - - await CbjSmartDeviceClient.shutDownCbjSmartDeviceHostDevice( - deviceLastKnownIp.getOrCrash(), - entityUniqueId.getOrCrash(), - ); - - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } -} diff --git a/lib/infrastructure/devices/cbj_devices/cbj_smart_device_api/cbj_smart_device_api_object.dart b/lib/infrastructure/devices/cbj_devices/cbj_smart_device_api/cbj_smart_device_api_object.dart deleted file mode 100644 index f40fa647..00000000 --- a/lib/infrastructure/devices/cbj_devices/cbj_smart_device_api/cbj_smart_device_api_object.dart +++ /dev/null @@ -1,679 +0,0 @@ -import 'dart:convert'; -import 'dart:io'; -import 'dart:typed_data'; - -import 'package:cbj_hub/utils.dart'; -import 'package:crclib/crclib.dart'; - -class CbjDevicesApiObject { - CbjDevicesApiObject({ - required this.deviceType, - required this.deviceId, - required this.cbjDevicesIp, - required this.cbjDevicesName, - required this.powerConsumption, - required this.macAddress, - this.deviceState = CbjDevicesDeviceState.cantGetState, - this.deviceDirection = CbjDevicesDeviceDirection.cantGetState, - this.devicePass = '00000000', - this.phoneId = '0000', - this.statusSocket, - this.log, - this.port = cbjDevicesTcpPort, - this.lastShutdownRemainingSecondsValue, - this.remainingTimeForExecution, - }); - - factory CbjDevicesApiObject.createWithBytes(Datagram datagram) { - final Uint8List data = datagram.data; - - final List messageBuffer = intListToHex(data); - - final List hexSeparatedLetters = []; - - for (final String hexValue in messageBuffer) { - for (final element in hexValue.runes) { - hexSeparatedLetters.add(String.fromCharCode(element)); - } - } - - if (!isCbjDevicesMessage(data, hexSeparatedLetters) && - !isCbjDevicesMessageNew(data, hexSeparatedLetters)) { - logger.w('Not a cbjDevices message arrived to here'); - } - - final CbjDevicesDevicesTypes sDeviceType = getDeviceType(messageBuffer); - final String deviceId = extractDeviceId(hexSeparatedLetters); - // final String cbjDevicesIp = extractIpAddr(hexSeparatedLetters); - final String cbjDevicesIp = datagram.address.address; - final String cbjDevicesMac = extractMac(hexSeparatedLetters); - final String powerConsumption = - extractPowerConsumption(hexSeparatedLetters); - - final String cbjDevicesName = extractDeviceName(data); - - final String getRemaining = - extractRemainingTimeForExecution(hexSeparatedLetters); - final String lastShutdownRemainingSecondsValue = - extractShutdownRemainingSeconds(hexSeparatedLetters); - - if (sDeviceType == CbjDevicesDevicesTypes.cbjDevicesRunner || - sDeviceType == CbjDevicesDevicesTypes.cbjDevicesRunnerMini) { - if (!isCbjDevicesMessageNew(data, hexSeparatedLetters)) { - logger.t('Not new cbjDevices device!'); - } - - final CbjDevicesDeviceDirection cbjDevicesDeviceDirection = - extractSwitchDirection(hexSeparatedLetters); - - return CbjDevicesApiObject( - deviceType: sDeviceType, - deviceId: deviceId, - cbjDevicesIp: cbjDevicesIp, - deviceDirection: cbjDevicesDeviceDirection, - cbjDevicesName: cbjDevicesName, - macAddress: cbjDevicesMac, - powerConsumption: powerConsumption, - port: cbjDevicesTcpPort2, - ); - } - - if (!isCbjDevicesMessage(data, hexSeparatedLetters)) { - logger.t('Not old cbjDevices device!'); - } - - final CbjDevicesDeviceState cbjDevicesDeviceState = - extractSwitchState(hexSeparatedLetters); - - return CbjDevicesApiObject( - deviceType: sDeviceType, - deviceId: deviceId, - cbjDevicesIp: cbjDevicesIp, - deviceState: cbjDevicesDeviceState, - cbjDevicesName: cbjDevicesName, - macAddress: cbjDevicesMac, - lastShutdownRemainingSecondsValue: lastShutdownRemainingSecondsValue, - powerConsumption: powerConsumption, - remainingTimeForExecution: getRemaining, - ); - } - - String deviceId; - String cbjDevicesIp; - CbjDevicesDevicesTypes deviceType; - CbjDevicesDeviceState deviceState; - CbjDevicesDeviceDirection deviceDirection; - int port; - String cbjDevicesName; - String phoneId; - String powerConsumption; - String devicePass; - String macAddress; - String? remainingTimeForExecution; - String? log; - String? statusSocket; - String? lastShutdownRemainingSecondsValue; - - Socket? _socket; - - String? pSession; - - static const cbjDevicesTcpPort = 9957; - static const cbjDevicesTcpPort2 = 10000; - - static const pSessionValue = '00000000'; - static const pKey = '00000000000000000000000000000000'; - - static const statusEvent = 'status'; - static const readyEvent = 'ready'; - static const errorEvent = 'error'; - static const stateChangedEvent = 'state'; - - static const cbjDevicesUdpIp = '0.0.0.0'; - static const cbjDevicesUdpPort = 20002; - - static const offValue = '0'; - static const onValue = '1'; - - static bool isCbjDevicesMessage( - Uint8List data, - List hexSeparatedLetters, - ) { - // Verify the broadcast message had originated from a cbjDevices device. - return hexSeparatedLetters.sublist(0, 4).join() == 'fef0' && - data.length == 165; - } - - static bool isCbjDevicesMessageNew( - Uint8List data, - List hexSeparatedLetters, - ) { - // Verify the broadcast message had originated from a cbjDevices device. - return hexSeparatedLetters.sublist(0, 4).join() == 'fef0' && - data.length == 159; - } - - static CbjDevicesDevicesTypes getDeviceType(List messageBuffer) { - CbjDevicesDevicesTypes sDevicesTypes = CbjDevicesDevicesTypes.notRecognized; - - final String hexModel = messageBuffer.sublist(75, 76)[0]; - - if (hexModel == '0f') { - sDevicesTypes = CbjDevicesDevicesTypes.cbjDevicesMini; - } else if (hexModel == 'a8') { - sDevicesTypes = CbjDevicesDevicesTypes.cbjDevicesPowerPlug; - } else if (hexModel == '0b') { - sDevicesTypes = CbjDevicesDevicesTypes.cbjDevicesTouch; - } else if (hexModel == 'a7') { - sDevicesTypes = CbjDevicesDevicesTypes.cbjDevicesV2Esp; - } else if (hexModel == 'a1') { - sDevicesTypes = CbjDevicesDevicesTypes.cbjDevicesV2qualcomm; - } else if (hexModel == '17') { - sDevicesTypes = CbjDevicesDevicesTypes.cbjDevicesV4; - } else if (hexModel == '01') { - sDevicesTypes = CbjDevicesDevicesTypes.cbjDevicesRunner; - } else if (hexModel == '02') { - sDevicesTypes = CbjDevicesDevicesTypes.cbjDevicesRunnerMini; - } else { - logger.w('New device type? hexModel:$hexModel'); - } - - return sDevicesTypes; - } - - Future turnOn({int duration = 0}) async { - final String offCommand = '${onValue}00${_timerValue(duration)}'; - - await _runPowerCommand(offCommand); - } - - Future turnOff() async { - const String offCommand = '${offValue}0000000000'; - await _runPowerCommand(offCommand); - } - - Future _runPowerCommand(String commandType) async { - pSession = await _login(); - if (pSession == 'B') { - logger.e('CbjDevices run power command error'); - return; - } - var data = - 'fef05d0002320102${pSession!}340001000000000000000000${_getTimeStamp()}' - '00000000000000000000f0fe${deviceId}00${phoneId}0000$devicePass' - '000000000000000000000000000000000000000000000000000000000106000' - '$commandType'; - - data = await _crcSignFullPacketComKey(data, pKey); - - _socket = await getSocket(); - _socket!.add(hexStringToDecimalList(data)); - await _socket?.close(); - _socket = null; - } - - /// Stops the blinds - Future stopBlinds() async { - if (deviceType != CbjDevicesDevicesTypes.cbjDevicesRunner && - deviceType != CbjDevicesDevicesTypes.cbjDevicesRunnerMini) { - logger.t('Stop blinds support only for blinds'); - return; - } - - pSession = await _login2(); - if (pSession == 'B') { - logger.e('CbjDevices run position command error'); - return; - } - var data = - 'fef0590003050102${pSession!}232301000000000000000000${_getTimeStamp()}' - '00000000000000000000f0fe${deviceId}00${phoneId}0000$devicePass' - '000000000000000000000000000000000000000000000000000000370202000000'; - - data = await _crcSignFullPacketComKey(data, pKey); - - _socket = await getSocket(); - _socket!.add(hexStringToDecimalList(data)); - await _socket?.close(); - _socket = null; - } - - /// Sets the position of the blinds, 0 is down 100 is up - Future setPosition({int pos = 0}) async { - if (deviceType != CbjDevicesDevicesTypes.cbjDevicesRunner && - deviceType != CbjDevicesDevicesTypes.cbjDevicesRunnerMini) { - logger.t('Set position support only blinds'); - return; - } - - final String positionCommand = _getHexPos(pos: pos); - _runPositionCommand(positionCommand); - } - - String _getHexPos({int pos = 0}) { - String posAsHex = intListToHex([pos]).join(); - if (posAsHex.length < 2) { - posAsHex = '0$posAsHex'; - } - return posAsHex; - } - - Future _runPositionCommand(String positionCommand) async { - // final int pos = int.parse(positionCommand, radix: 16); - pSession = await _login2(); - if (pSession == 'B') { - logger.e('CbjDevices run position command error'); - return; - } - var data = - 'fef0580003050102${pSession!}290401000000000000000000${_getTimeStamp()}' - '00000000000000000000f0fe${deviceId}00${phoneId}0000$devicePass' - '00000000000000000000000000000000000000000000000000000037010100' - '$positionCommand'; - - data = await _crcSignFullPacketComKey(data, pKey); - - _socket = await getSocket(); - _socket!.add(hexStringToDecimalList(data)); - await _socket?.close(); - _socket = null; - } - - /// Used for sending actions to the device - void sendState({required CbjDevicesDeviceState command, int minutes = 0}) { - _getFullState(); - } - - /// Used for sending the get state packet to the device. - /// Returns a tuple of hex timestamp, - /// session id and an instance of CbjDevicesStateResponse - Future _getFullState() async { - return _login(); - } - - /// Used for sending the login packet to the device. - Future _login() async { - try { - String data = 'fef052000232a100${pSessionValue}340001000000000000000000' - '${_getTimeStamp()}00000000000000000000f0fe1c00${phoneId}0000' - '$devicePass' - '00000000000000000000000000000000000000000000000000000000'; - - data = await _crcSignFullPacketComKey(data, pKey); - _socket = await getSocket(); - if (_socket == null) { - throw 'Error'; - } - - _socket!.add(hexStringToDecimalList(data)); - - final Uint8List firstData = await _socket!.first; - final String resultSession = - substrLikeInJavaScript(intListToHex(firstData).join(), 16, 8); - - return resultSession; - } catch (error) { - logger.e('Cbj smart device login failed due to an error\n$error'); - pSession = 'B'; - } - return pSession!; - } - - /// Used for sending the login packet to cbjDevices runner. - Future _login2() async { - // if (pSession != null) return pSession!; - - try { - String data = 'fef030000305a600${pSessionValue}ff0301000000$phoneId' - '00000000${_getTimeStamp()}00000000000000000000f0fe${deviceId}00'; - - data = await _crcSignFullPacketComKey(data, pKey); - _socket = await getSocket(); - if (_socket == null) { - throw 'Error'; - } - - _socket!.add(hexStringToDecimalList(data)); - - final Uint8List firstData = await _socket!.first; - - final String resultSession = - substrLikeInJavaScript(intListToHex(firstData).join(), 16, 8); - - return resultSession; - } catch (error) { - logger.e('login2 failed due to an error\n$error'); - pSession = 'B'; - } - return pSession!; - } - - static Future _crcSignFullPacketComKey( - String pData, - String pKey, - ) async { - String pDataTemp = pData; - final List bufferHex = hexStringToDecimalList(pDataTemp); - - String crc = intListToHex( - packBigEndian( - int.parse(Crc16XmodemWith0x1021().convert(bufferHex).toString()), - ), - ).join(); - - pDataTemp = pDataTemp + - substrLikeInJavaScript(crc, 6, 2) + - substrLikeInJavaScript(crc, 4, 2); - - crc = substrLikeInJavaScript(crc, 6, 2) + - substrLikeInJavaScript(crc, 4, 2) + - getUtf8Encoded(pKey); - - crc = intListToHex( - packBigEndian( - int.parse( - Crc16XmodemWith0x1021() - .convert(hexStringToDecimalList(crc)) - .toString(), - ), - ), - ).join(); - - return pDataTemp + - substrLikeInJavaScript(crc, 6, 2) + - substrLikeInJavaScript(crc, 4, 2); - } - - static String _getTimeStamp() { - final int timeInSeconds = DateTime.now().millisecondsSinceEpoch ~/ 1000; - - final List timeInBytes = packLittleEndian(timeInSeconds); - - return intListToHex(timeInBytes).join(); - } - - /// Same as Buffer.from(value, 'hex') in JavaScript - static List hexStringToDecimalList(String hex) { - final List decimalIntList = []; - String twoNumbers = ''; - - for (int i = 0; i < hex.length; i++) { - if (twoNumbers == '') { - twoNumbers = twoNumbers + hex[i]; - continue; - } else { - twoNumbers = twoNumbers + hex[i]; - decimalIntList.add(int.parse(twoNumbers, radix: 16)); - twoNumbers = ''; - } - } - return decimalIntList; - } - - /// Convert number to unsigned integer as little-endian sequence of bytes - /// Same as struct.pack(' packLittleEndian(int valueToConvert) { - final ByteData sendValueBytes = ByteData(8); - - try { - sendValueBytes.setUint64(0, valueToConvert, Endian.little); - } on Exception { - sendValueBytes.setUint32(0, valueToConvert, Endian.little); - } - - final Uint8List timeInBytes = sendValueBytes.buffer.asUint8List(); - return timeInBytes.sublist(0, timeInBytes.length - 4); - } - - /// Convert number to unsigned integer as big-endian sequence of bytes - /// Same as struct.pack('>I', value) in JavaScript - static List packBigEndian(int valueToConvert) { - final ByteData sendValueBytes = ByteData(8); - - try { - sendValueBytes.setUint64(0, valueToConvert); - } on Exception { - sendValueBytes.setUint32(0, valueToConvert); - } - - final Uint8List timeInBytes = sendValueBytes.buffer.asUint8List(); - return timeInBytes.sublist(4); - } - - /// Convert list of bytes/integers into their hex 16 value with padding 2 of 0 - /// Same as .toString('hex'); in JavaScript - static List intListToHex(List bytes) { - final List messageBuffer = []; - - for (final int unit8 in bytes) { - messageBuffer.add(unit8.toRadixString(16).padLeft(2, '0')); - } - return messageBuffer; - } - - /// Generate hexadecimal representation of the current timestamp. - /// Return: Hexadecimal representation of the current - /// unix time retrieved by ``time.time``. - String currentTimestampToHexadecimal() { - final String currentTimeSinceEpoch = - DateTime.now().millisecondsSinceEpoch.toString(); - final String currentTimeRounded = - currentTimeSinceEpoch.substring(0, currentTimeSinceEpoch.length - 3); - - final int currentTimeInt = int.parse(currentTimeRounded); - - return currentTimeInt.toRadixString(16).padLeft(2, '0'); - } - - /// Extract the IP address from the broadcast message. - static String extractIpAddr(List hexSeparatedLetters) { - final String ipAddrSection = - substrLikeInJavaScript(hexSeparatedLetters.join(), 152, 8); - - final int ipAddrInt = int.parse( - substrLikeInJavaScript(ipAddrSection, 0, 2) + - substrLikeInJavaScript(ipAddrSection, 2, 2) + - substrLikeInJavaScript(ipAddrSection, 4, 2) + - substrLikeInJavaScript(ipAddrSection, 6, 2), - radix: 16, - ); - return ipAddrInt.toString(); - } - - static String extractPowerConsumption(List hexSeparatedLetters) { - // final List hexPowerConsumption = - // hexSeparatedLetters.sublist(270, 278); - // TODO: fix this method does not return number, hexPowerConsumption.join() - // return the value 64000000 - // return hexPowerConsumption.join(); - return '0'; - } - - /// Extract the time remains for the current execution. - static String extractRemainingTimeForExecution( - List hexSeparatedLetters, - ) { - final List hexPowerConsumption = - hexSeparatedLetters.sublist(294, 302); - try { - final int sum = int.parse(hexPowerConsumption.sublist(6, 8).join()) + - int.parse(hexPowerConsumption.sublist(4, 6).join()) + - int.parse(hexPowerConsumption.sublist(2, 4).join()) + - int.parse(hexPowerConsumption.sublist(0, 2).join()); - return sum.toString(); - } catch (e) { - return hexPowerConsumption.join(); - } - } - - /// Substring like in JavaScript - /// If first index is bigger than second index than it will cut until the - /// first and will get the second index number of characters from there - static String substrLikeInJavaScript( - String text, - int firstIndex, - int secondIndex, - ) { - String tempText = text; - if (firstIndex > secondIndex) { - tempText = tempText.substring(firstIndex); - tempText = tempText.substring(0, secondIndex); - } else { - tempText = tempText.substring(firstIndex, secondIndex); - } - return tempText; - } - - static String extractMac(List hexSeparatedLetters) { - final String macNoColon = - hexSeparatedLetters.sublist(160, 172).join().toUpperCase(); - final String macAddress = '${macNoColon.substring(0, 2)}:' - '${macNoColon.substring(2, 4)}:${macNoColon.substring(4, 6)}:' - '${macNoColon.substring(6, 8)}:${macNoColon.substring(8, 10)}:' - '${macNoColon.substring(10, 12)}'; - - return macAddress; - } - - static String extractDeviceName(List data) { - return utf8.decode(data.sublist(42, 74)).replaceAll('\u0000', ''); - // Maybe better name handling will be - // this.data_str.substr(38, 32).replace(/[^0-9a-zA-Z_\s]/g, '').replace(/\0/g, '') - } - - /// Same as Buffer.from(value) in javascript - /// Not to be confused with Buffer.from(value, 'hex') - static String getUtf8Encoded(String list) { - final List encoded = utf8.encode(list); - - return intListToHex(encoded).join(); - } - - static String extractShutdownRemainingSeconds( - List hexSeparatedLetters, - ) { - // final String hexAutoShutdownVal = - // hexSeparatedLetters.sublist(310, 318).join(); - final String timeLeftSeconds = - substrLikeInJavaScript(hexSeparatedLetters.join(), 294, 8); - - return int.parse( - substrLikeInJavaScript(timeLeftSeconds, 6, 8) + - substrLikeInJavaScript(timeLeftSeconds, 4, 6) + - substrLikeInJavaScript(timeLeftSeconds, 2, 4) + - substrLikeInJavaScript(timeLeftSeconds, 0, 2), - radix: 16, - ).toString(); - } - - static String extractDeviceId(List hexSeparatedLetters) { - return hexSeparatedLetters.sublist(36, 42).join(); - } - - static CbjDevicesDeviceState extractSwitchState( - List hexSeparatedLetters, - ) { - CbjDevicesDeviceState cbjDevicesDeviceState = - CbjDevicesDeviceState.cantGetState; - - final String hexModel = - substrLikeInJavaScript(hexSeparatedLetters.join(), 266, 4); - - if (hexModel == '0100') { - cbjDevicesDeviceState = CbjDevicesDeviceState.on; - } else if (hexModel == '0000') { - cbjDevicesDeviceState = CbjDevicesDeviceState.off; - } else { - logger.w('CbjDevices state is not recognized: $hexModel'); - } - return cbjDevicesDeviceState; - } - - static CbjDevicesDeviceDirection extractSwitchDirection( - List hexSeparatedLetters, - ) { - CbjDevicesDeviceDirection cbjDevicesDeviceState = - CbjDevicesDeviceDirection.cantGetState; - - final String hexModel = - substrLikeInJavaScript(hexSeparatedLetters.join(), 274, 4); - - if (hexModel == '0000') { - cbjDevicesDeviceState = CbjDevicesDeviceDirection.stop; - } else if (hexModel == '0100') { - cbjDevicesDeviceState = CbjDevicesDeviceDirection.up; - } else if (hexModel == '0001') { - cbjDevicesDeviceState = CbjDevicesDeviceDirection.down; - } else { - logger.w('CbjDevices direction is not recognized: $hexModel'); - } - return cbjDevicesDeviceState; - } - - Future getSocket() async { - if (_socket != null) { - return _socket!; - } - - try { - final Socket socket = await _connect(cbjDevicesIp, port); - return socket; - } catch (e) { - _socket = null; - logger.e('Error connecting to socket for cbjDevices device: $e'); - rethrow; - } - } - - Future _connect(String ip, int port) async { - return Socket.connect(ip, port); - } - - String _timerValue(int minutes) { - if (minutes == 0) { - // when duration set to zero, CbjDevices sends regular on command - return '00000000'; - } - final seconds = minutes * 60; - return intListToHex(packLittleEndian(seconds)).join(); - } -} - -class Crc16XmodemWith0x1021 extends ParametricCrc { - Crc16XmodemWith0x1021() - : super( - 16, - 0x1021, - 0x1021, - 0x0000, - inputReflected: false, - outputReflected: false, - ); -} - -enum CbjDevicesDeviceDirection { - cantGetState, - stop, // '0000' - up, // '0100' - down, // '0001' -} - -/// Enum class representing the device's state. -enum CbjDevicesDeviceState { - cantGetState, - on, // '0100' - off, // '0000' -} - -/// Enum for relaying the type of the cbjDevices devices. -enum CbjDevicesDevicesTypes { - notRecognized, - cbjDevicesMini, // MINI = "CbjDevices Mini", "0f", DeviceCategory.WATER_HEATER - cbjDevicesPowerPlug, // POWER_PLUG = "CbjDevices Power Plug", "a8", DeviceCategory.POWER_PLUG - cbjDevicesTouch, // TOUCH = "CbjDevices Touch", "0b", DeviceCategory.WATER_HEATER - cbjDevicesV2Esp, // V2_ESP = "CbjDevices V2 (esp)", "a7", DeviceCategory.WATER_HEATER - cbjDevicesV2qualcomm, // V2_QCA = "CbjDevices V2 (qualcomm)", "a1", DeviceCategory.WATER_HEATER - cbjDevicesV4, // V4 = "CbjDevices V4", "17", DeviceCategory.WATER_HEATER - cbjDevicesRunner, // runner = "CbjDevices Runner", "01", DeviceCategory.Blinds - cbjDevicesRunnerMini, // runner_mini = "CbjDevices Runner Mini", "02", DeviceCategory.Blinds -} diff --git a/lib/infrastructure/devices/cbj_devices/cbj_smart_device_api/cbj_smart_device_discover.dart b/lib/infrastructure/devices/cbj_devices/cbj_smart_device_api/cbj_smart_device_discover.dart deleted file mode 100644 index 7971f8bb..00000000 --- a/lib/infrastructure/devices/cbj_devices/cbj_smart_device_api/cbj_smart_device_discover.dart +++ /dev/null @@ -1,50 +0,0 @@ -// import 'dart:io'; -// -// import 'package:cbj_hub/infrastructure/devices/cbjDevices/cbjDevices_api/cbjDevices_api_object.dart'; -// import 'package:cbj_hub/utils.dart'; -// -// class CbjDevicesDiscover { -// static const cbjDevicesUdpPort = 20002; -// static const cbjDevicesUdpPort2 = 20003; -// -// static Stream discover20002Devices() async* { -// try { -// final RawDatagramSocket socket20002 = await RawDatagramSocket.bind( -// InternetAddress.anyIPv4, -// cbjDevicesUdpPort , -// ); -// -// await for (final event in socket20002) { -// final Datagram? datagram = socket20002.receive(); -// if (datagram == null) continue; -// final CbjDevicesApiObject cbjDevicesApiObject = -// CbjDevicesApiObject.createWithBytes(datagram); -// -// yield cbjDevicesApiObject; -// } -// } catch (e) { -// logger.e('CbjDevices discover devices got and exception: $e'); -// } -// } -// -// /// Blinds 20003 includes blinds for example -// static Stream discover20003Devices() async* { -// try { -// final RawDatagramSocket socket20003 = await RawDatagramSocket.bind( -// InternetAddress.anyIPv4, -// cbjDevicesUdpPort2, -// ); -// -// await for (final event in socket20003) { -// final Datagram? datagram = socket20003.receive(); -// if (datagram == null) continue; -// final CbjDevicesApiObject cbjDevicesApiObject = -// CbjDevicesApiObject.createWithBytes(datagram); -// -// yield cbjDevicesApiObject; -// } -// } catch (e) { -// logger.e('CbjDevices discover devices got and exception: $e'); -// } -// } -// } diff --git a/lib/infrastructure/devices/cbj_devices/cbj_smart_device_api/cbj_smart_device_packets.dart b/lib/infrastructure/devices/cbj_devices/cbj_smart_device_api/cbj_smart_device_packets.dart deleted file mode 100644 index a79b514c..00000000 --- a/lib/infrastructure/devices/cbj_devices/cbj_smart_device_api/cbj_smart_device_packets.dart +++ /dev/null @@ -1,51 +0,0 @@ -class CbjDevicesPackets { - ///CbjDevices integration TCP socket API packet formats./// - - /// weekdays sum, start-time timestamp, end-time timestamp - static const scheduleCreateDataFormat = '01{}01{}{}'; - - static const noTimerRequested = '00000000'; - - static const nonRecurringSchedule = '00'; - - /// format values are local session id, timestamp - static const requestFormat = - '{}340001000000000000000000{}00000000000000000000f0fe'; - - static const pad74Zeros = - '000000000000000000000000000000000000000000000000000000000000000000000' - '0000'; - - /// format value just timestamp (initial session id is '00000000') - static String loginPacket = - 'fef052000232a10000000000${requestFormat.substring(2)}1c$pad74Zeros'; - - /// format values are local session id, timestamp, device id - static const getStatePacket = 'fef0300002320103$requestFormat{}00'; - - /// format values are local session id, timestamp, device id, command, timer - static const sendControlPacket = - 'fef05d0002320102$requestFormat{}${pad74Zeros}0106000{}00{}'; - - /// format values are local session id, timestamp, device id, auto-off seconds - static const setAutoOffSetPacket = - 'fef05b0002320102$requestFormat{}${pad74Zeros}040400{}'; - - /// format values are local session id, timestamp, device id, name - static const updateDeviceNamePacket = - 'fef0740002320202$requestFormat{}$pad74Zeros{}'; - - /// format values are local session id, timestamp, device id - static const getSchedulesPacket = - 'fef0570002320102$requestFormat{}${pad74Zeros}060000'; - - /// format values are local session id, timestamp, device id, schedule id - static const deleteSchedulePacket = - 'fef0580002320102$requestFormat{}${pad74Zeros}0801000{}'; - - /// format values are local session id, timestamp, device id, -// schedule data = -// (on_off + week + timstate + start_time + end_time) - static const createSchedulePacket = - 'fef0630002320102$requestFormat{}${pad74Zeros}030c00ff{}'; -} diff --git a/lib/infrastructure/devices/cbj_devices/cbj_smart_device_client/cbj_smart_device_client.dart b/lib/infrastructure/devices/cbj_devices/cbj_smart_device_client/cbj_smart_device_client.dart deleted file mode 100644 index af7f7ba7..00000000 --- a/lib/infrastructure/devices/cbj_devices/cbj_smart_device_client/cbj_smart_device_client.dart +++ /dev/null @@ -1,124 +0,0 @@ -import 'dart:async'; - -import 'package:cbj_hub/infrastructure/gen/cbj_smart_device_server/protoc_as_dart/cbj_smart_device_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/shared_variables.dart'; -import 'package:cbj_hub/injection.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:grpc/grpc.dart'; -import 'package:network_tools/network_tools.dart'; - -class CbjSmartDeviceClient { - CbjSmartDeviceClient() { - if (currentEnv == Env.prod) { - smartDevicePort = 50054; - } else { - smartDevicePort = 50054; - // hubPort = 60054; - } - } - - /// Port to connect to the cbj hub, will change according to the current - /// running environment - static int smartDevicePort = 50054; - static ClientChannel? channel; - static CbjSmartDeviceConnectionsClient? smartDeviceClient; - - static Future> getCbjSmartDeviceHostDevicesInfo( - ActiveHost activeHost, - ) async { - await channel?.terminate(); - - channel = - await _createCbjSmartDeviceClient(activeHost.address, smartDevicePort); - - smartDeviceClient = CbjSmartDeviceConnectionsClient(channel!); - - try { - final CbjCompSmartDeviceInfo response = - await smartDeviceClient!.getCompInfo(CbjCommendStatus()); - final List smartDevicesList = - response.smartDevicesInComp; - return smartDevicesList; - } catch (e) { - logger.e('Caught error while stream with cbj smart device\n$e'); - await channel?.shutdown(); - } - return []; - } - - static Future _createCbjSmartDeviceClient( - String deviceIp, - int hubPort, - ) async { - await channel?.shutdown(); - return ClientChannel( - deviceIp, - port: hubPort, - options: const ChannelOptions(credentials: ChannelCredentials.insecure()), - ); - } - - // TODO: Change in the future that the smart device will publish itself using mdns - static Future checkIfDeviceIsCbjSmartDevice( - String deviceIp, - ) async { - final String? subnet = await getIt().getIps(); - - if (subnet == null) { - return null; - } - - final ActiveHost? activeHost = await PortScanner.connectToPort( - address: subnet, - port: smartDevicePort, - // TODO: maybe value can be lower - timeout: const Duration(milliseconds: 2000), - activeHostsController: StreamController(), - ); - return activeHost; - } - - static Future suspendCbjSmartDeviceHostDevice( - String address, - String cbjDeviceId, - ) async { - await channel?.terminate(); - - channel = await _createCbjSmartDeviceClient(address, smartDevicePort); - - smartDeviceClient = CbjSmartDeviceConnectionsClient(channel!); - - try { - final CbjCommendStatus response = await smartDeviceClient! - .suspendComputer(CbjSmartDeviceInfo(id: cbjDeviceId)); - - return response; - } catch (e) { - logger.e('Caught error while suspending cbj smart device\n$e'); - await channel?.shutdown(); - } - return null; - } - - static Future shutDownCbjSmartDeviceHostDevice( - String address, - String cbjDeviceId, - ) async { - await channel?.terminate(); - - channel = await _createCbjSmartDeviceClient(address, smartDevicePort); - - smartDeviceClient = CbjSmartDeviceConnectionsClient(channel!); - - try { - final CbjCommendStatus response = await smartDeviceClient! - .shutdownComputer(CbjSmartDeviceInfo(id: cbjDeviceId)); - - return response; - } catch (e) { - logger.e('Caught error while shut down cbj smart device\n$e'); - await channel?.shutdown(); - } - return null; - } -} diff --git a/lib/infrastructure/devices/companies_connector_conjector.dart b/lib/infrastructure/devices/companies_connector_conjector.dart deleted file mode 100644 index aa6a5134..00000000 --- a/lib/infrastructure/devices/companies_connector_conjector.dart +++ /dev/null @@ -1,421 +0,0 @@ -import 'dart:io'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart'; -import 'package:cbj_hub/domain/saved_devices/i_saved_devices_repo.dart'; -import 'package:cbj_hub/domain/vendors/esphome_login/generic_esphome_login_entity.dart'; -import 'package:cbj_hub/domain/vendors/ewelink_login/generic_ewelink_login_entity.dart'; -import 'package:cbj_hub/domain/vendors/lifx_login/generic_lifx_login_entity.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/login_entity_abstract.dart'; -import 'package:cbj_hub/domain/vendors/tuya_login/generic_tuya_login_entity.dart'; -import 'package:cbj_hub/domain/vendors/xiaomi_mi_login/generic_xiaomi_mi_login_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/cbj_devices/cbj_devices_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/cbj_devices/cbj_smart_device_client/cbj_smart_device_client.dart'; -import 'package:cbj_hub/infrastructure/devices/esphome/esphome_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/ewelink/ewelink_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/google/google_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/hp/hp_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/hp/hp_printer/hp_printer_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/lg/lg_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/lifx/lifx_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/philips_hue/philips_hue_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/shelly/shelly_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/sonoff_diy/sonoff_diy_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/switcher/switcher_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/tuya_smart/tuya_smart_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/wiz/wiz_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/xiaomi_io/xiaomi_io_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/yeelight/yeelight_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/abstract_company_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/system_commands/system_commands_manager_d.dart'; -import 'package:cbj_hub/injection.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:internet_connection_checker/internet_connection_checker.dart'; -import 'package:network_tools/network_tools.dart'; -import 'package:switcher_dart/switcher_dart.dart'; - -class CompaniesConnectorConjector { - static void updateAllDevicesReposWithDeviceChanges( - Stream allDevices, - ) { - allDevices.listen((deviceEntityAbstract) { - if (deviceEntityAbstract is DeviceEntityAbstract) { - final String deviceVendor = - deviceEntityAbstract.deviceVendor.getOrCrash(); - - final AbstractCompanyConnectorConjector? companyConnectorConjector = - vendorStringToCompanyConnectorConjector(deviceVendor); - - if (companyConnectorConjector != null) { - companyConnectorConjector - .manageHubRequestsForDevice(deviceEntityAbstract); - } else { - logger.w( - 'Cannot send device changes to its repo, company not supported $deviceVendor', - ); - } - } else { - logger.w('Connector conjector got other type'); - } - }); - } - - static void addAllDevicesToItsRepos( - Map allDevices, - ) { - for (final MapEntry deviceId - in allDevices.entries) { - addDeviceToItsRepo(deviceId); - } - } - - static void addDeviceToItsRepo( - MapEntry deviceEntityAbstract, - ) { - final MapEntry devicesEntry = - MapEntry( - deviceEntityAbstract.key, - deviceEntityAbstract.value, - ); - - final String deviceVendor = - deviceEntityAbstract.value.deviceVendor.getOrCrash(); - - final AbstractCompanyConnectorConjector? companyConnectorConjector = - vendorStringToCompanyConnectorConjector(deviceVendor); - - if (companyConnectorConjector != null) { - companyConnectorConjector.setUpDeviceFromDb(devicesEntry.value); - } else { - logger.w('Cannot add device entity to its repo, type not supported'); - } - } - - static DeviceEntityAbstract addDiscoverdDeviceToHub( - DeviceEntityAbstract deviceEntity, - ) { - final DeviceEntityAbstract deviceEntityGotSaved = - getIt().addOrUpdateDevice(deviceEntity); - - getIt() - .postSmartDeviceToAppMqtt(entityFromTheHub: deviceEntityGotSaved); - - return deviceEntityGotSaved; - } - - static void setVendorLoginCredentials(LoginEntityAbstract loginEntity) { - if (loginEntity is GenericLifxLoginDE) { - getIt().accountLogin(loginEntity); - } else if (loginEntity is GenericEspHomeLoginDE) { - getIt().accountLogin(loginEntity); - } else if (loginEntity is GenericTuyaLoginDE) { - getIt().accountLogin(loginEntity); - } else if (loginEntity is GenericXiaomiMiLoginDE) { - getIt().accountLogin(loginEntity); - } else if (loginEntity is GenericEwelinkLoginDE) { - getIt().accountLogin(loginEntity); - } else { - logger.w('Vendor login type ${loginEntity.runtimeType} is not supported'); - } - } - - static Future searchAllMdnsDevicesAndSetThemUp() async { - try { - while (true) { - while (true) { - // TODO: mdns search crash if there is no local internet connection - // but crash can't be cached using try catch. - // InternetConnectionChecker().hasConnection; check if there is - // connection to the www which is not needed for mdns search. - // we need to replace this part with check that return true if - // there is local internet connection/ device is connected to - // local network. - final bool result = await InternetConnectionChecker().hasConnection; - if (result) { - break; - } - logger.w('No internet connection detected, will try again in 2m to' - ' search mdns in the network'); - await Future.delayed(const Duration(minutes: 2)); - } - for (ActiveHost activeHost in await MdnsScanner.searchMdnsDevices( - forceUseOfSavedSrvRecordList: true, - )) { - // In some cases for some reason we get empty result when trying to - // resolve mdns name to ip, the only way we found to fix that is to - // use resolve it using avahi-resolve-host-name - if (activeHost.address == '0.0.0.0') { - final String? mdnsSrvTarget = - (await activeHost.mdnsInfo)?.mdnsSrvTarget; - if (mdnsSrvTarget == null) { - continue; - } - final String? deviceIp = await getIt() - .getIpFromMdnsName(mdnsSrvTarget); - if (deviceIp == null) { - continue; - } - activeHost = activeHost - ..internetAddress = InternetAddress(deviceIp); - } - - final MdnsInfo? mdnsInfo = await activeHost.mdnsInfo; - - if (mdnsInfo != null) { - setMdnsDeviceByCompany(activeHost); - } - } - await Future.delayed(const Duration(minutes: 2)); - } - } catch (e) { - logger.e('Mdns search error\n$e'); - } - } - - /// Getting ActiveHost that contain MdnsInfo property and activate it inside - /// The correct company. - static Future setMdnsDeviceByCompany(ActiveHost activeHost) async { - final MdnsInfo? hostMdnsInfo = await activeHost.mdnsInfo; - - if (hostMdnsInfo == null) { - return; - } - - final String mdnsDeviceIp = activeHost.address; - - if (activeHost.internetAddress.type != InternetAddressType.IPv4) { - return; - } - - final String startOfMdnsName = hostMdnsInfo.getOnlyTheStartOfMdnsName(); - final String startOfMdnsNameLower = startOfMdnsName.toLowerCase(); - - final String mdnsPort = hostMdnsInfo.mdnsPort.toString(); - - if (EspHomeConnectorConjector.mdnsTypes - .contains(hostMdnsInfo.mdnsServiceType)) { - getIt().addNewDeviceByMdnsName( - mDnsName: startOfMdnsName, - ip: mdnsDeviceIp, - port: mdnsPort, - address: mdnsDeviceIp, - ); - } else if (ShellyConnectorConjector.mdnsTypes - .contains(hostMdnsInfo.mdnsServiceType) && - hostMdnsInfo - .getOnlyTheStartOfMdnsName() - .toLowerCase() - .contains('shelly')) { - getIt().addNewDeviceByMdnsName( - mDnsName: startOfMdnsName, - ip: mdnsDeviceIp, - port: mdnsPort, - ); - } else if (EwelinkConnectorConjector.mdnsTypes - .contains(hostMdnsInfo.mdnsServiceType)) { - getIt() - .discoverNewDevices(activeHost: activeHost); - } else if (GoogleConnectorConjector.mdnsTypes - .contains(hostMdnsInfo.mdnsServiceType) && - (startOfMdnsNameLower.contains('google') || - startOfMdnsNameLower.contains('android') || - startOfMdnsNameLower.contains('chrome'))) { - getIt().addNewDeviceByMdnsName( - mDnsName: startOfMdnsName, - ip: mdnsDeviceIp, - port: mdnsPort, - ); - } else if (LgConnectorConjector.mdnsTypes - .contains(hostMdnsInfo.mdnsServiceType) && - (startOfMdnsNameLower.contains('lg') || - startOfMdnsNameLower.contains('webos'))) { - getIt().addNewDeviceByMdnsName( - mDnsName: startOfMdnsName, - ip: mdnsDeviceIp, - port: mdnsPort, - ); - } else if (HpPrinterEntity.mdnsTypes - .contains(hostMdnsInfo.mdnsServiceType) && - (startOfMdnsNameLower.contains('hp'))) { - getIt().addNewDeviceByMdnsName( - mDnsName: startOfMdnsName, - ip: mdnsDeviceIp, - port: mdnsPort, - ); - } else if (YeelightConnectorConjector.mdnsTypes - .contains(hostMdnsInfo.mdnsServiceType) && - (startOfMdnsName.startsWith('YL'))) { - getIt().addNewDeviceByMdnsName( - mDnsName: startOfMdnsName, - ip: mdnsDeviceIp, - port: mdnsPort, - ); - } else if (PhilipsHueConnectorConjector.mdnsTypes - .contains(hostMdnsInfo.mdnsServiceType)) { - getIt().addNewDeviceByMdnsName( - mDnsName: startOfMdnsName, - ip: mdnsDeviceIp, - port: mdnsPort, - ); - } else { - logger.t( - 'mDNS service type ${hostMdnsInfo.mdnsServiceType} is not supported\n IP: ${activeHost.address}, Port: ${hostMdnsInfo.mdnsPort}, ServiceType: ${hostMdnsInfo.mdnsServiceType}, MdnsName: ${hostMdnsInfo.getOnlyTheStartOfMdnsName()}', - ); - } - } - - /// Get all the host names in the connected networks and try to add the device - static Future searchPingableDevicesAndSetThemUpByHostName() async { - while (true) { - final List networkInterfaceList = - await NetworkInterface.list(); - - for (final NetworkInterface networkInterface in networkInterfaceList) { - for (final InternetAddress address in networkInterface.addresses) { - final String ip = address.address; - if (!ip.contains('.')) { - continue; - } - final String subnet = ip.substring(0, ip.lastIndexOf('.')); - - await for (final ActiveHost activeHost - in HostScanner.getAllPingableDevices( - subnet, - lastHostId: 126, - )) { - try { - setHostNameDeviceByCompany( - activeHost: activeHost, - ); - } catch (e) { - continue; - } - } - - // Spits to 2 requests to fix error in snap https://github.com/CyBear-Jinni-user/CBJ_Hub_Snap/issues/2 - await for (final ActiveHost activeHost - in HostScanner.getAllPingableDevices( - subnet, - firstHostId: 127, - )) { - try { - setHostNameDeviceByCompany( - activeHost: activeHost, - ); - } catch (e) { - continue; - } - } - } - } - await Future.delayed(const Duration(minutes: 5)); - } - } - - static Future setHostNameDeviceByCompany({ - required ActiveHost activeHost, - }) async { - final String? deviceHostNameLowerCase = - (await activeHost.hostName)?.toLowerCase(); - if (deviceHostNameLowerCase == null) { - return; - } - if (deviceHostNameLowerCase.contains('tasmota')) { - getIt().addNewDeviceByHostInfo( - activeHost: activeHost, - ); - } else if (deviceHostNameLowerCase.contains('xiaomi') || - deviceHostNameLowerCase.contains('yeelink') || - deviceHostNameLowerCase.contains('xiao')) { - getIt() - .discoverNewDevices(activeHost: activeHost); - } else if (deviceHostNameLowerCase.startsWith('wiz')) { - getIt() - .addNewDeviceByHostInfo(activeHost: activeHost); - } else { - final ActiveHost? cbjSmartDeviceHost = - await CbjSmartDeviceClient.checkIfDeviceIsCbjSmartDevice( - activeHost.address, - ); - if (cbjSmartDeviceHost != null) { - getIt() - .addNewDeviceByHostInfo(activeHost: cbjSmartDeviceHost); - return; - } - // logger.i('Found pingable device $deviceHostNameLowerCase'); - } - } - - /// Searching devices by binding to sockets, used for devices with - /// udp ports which can't be discovered by regular open (tcp) port scan - static Future searchDevicesByBindingIntoSockets() async { - SwitcherDiscover.discover20002Devices().listen((switcherApiObject) { - getIt() - .addOnlyNewSwitcherDevice(switcherApiObject); - }); - SwitcherDiscover.discover20003Devices().listen((switcherApiObject) { - getIt() - .addOnlyNewSwitcherDevice(switcherApiObject); - }); - } - - /// Searching for mqtt devices - static Future searchDevicesByMqttPath() async { - // getIt().discoverNewDevices(); - } - - /// Devices that we need to insert in to the other search options but didn't - /// got to it yet. - /// We do implement here the start of the search for convince organization - /// and since putting it in the constructor of singleton will be called - /// before all of our program. - static Future notImplementedDevicesSearch() async { - // getIt().discoverNewDevices(); - } - - static AbstractCompanyConnectorConjector? - vendorStringToCompanyConnectorConjector( - String vendorName, - ) { - //TODO: convert vendorName to type and then use switch case - - if (vendorName == VendorsAndServices.espHome.toString()) { - return getIt(); - } else if (vendorName == VendorsAndServices.switcherSmartHome.toString()) { - return getIt(); - } else if (vendorName == VendorsAndServices.lifx.toString()) { - return getIt(); - } else if (vendorName == VendorsAndServices.yeelight.toString()) { - return getIt(); - } else if (vendorName == VendorsAndServices.philipsHue.toString()) { - return getIt(); - } else if (vendorName == VendorsAndServices.tuyaSmart.toString()) { - return getIt(); - } else if (vendorName == VendorsAndServices.sonoffDiy.toString()) { - return getIt(); - } else if (vendorName == VendorsAndServices.google.toString()) { - return getIt(); - } else if (vendorName == - VendorsAndServices.cbjDeviceSmartEntity.toString()) { - return getIt(); - } else if (vendorName == VendorsAndServices.shelly.toString()) { - return getIt(); - } else if (vendorName == VendorsAndServices.hp.toString()) { - return getIt(); - } else if (vendorName == VendorsAndServices.miHome.toString()) { - return getIt(); - } else if (vendorName == VendorsAndServices.tasmota.toString()) { - return getIt(); - } else if (vendorName == VendorsAndServices.sonoffEweLink.toString()) { - return getIt(); - } - - logger.w( - 'Please add vendor to support string $vendorName to connector conjector', - ); - - return null; - } -} diff --git a/lib/infrastructure/devices/device_helper/device_helper.dart b/lib/infrastructure/devices/device_helper/device_helper.dart deleted file mode 100644 index 073546ca..00000000 --- a/lib/infrastructure/devices/device_helper/device_helper.dart +++ /dev/null @@ -1,62 +0,0 @@ -import 'dart:convert'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; - -class DeviceHelper { - /// Dto to json - static Map convertDtoToJson( - DeviceEntityDtoAbstract deviceEntityDto, - ) { - return deviceEntityDto.toJson(); - } - - /// json to Dto - static DeviceEntityDtoAbstract convertJsonToDto(Map json) { - return DeviceEntityDtoAbstract.fromJson(json); - } - - /// json to json string - static String convertJsonToJsonString(Map json) { - return jsonEncode(json); - } - - /// string json to json - static Map convertJsonStringToJson(String jsonString) { - return jsonDecode(jsonString) as Map; - } - - /// Device entity to dto - static DeviceEntityDtoAbstract convertDomainToDto( - DeviceEntityAbstract deviceEntity, - ) { - return deviceEntity.toInfrastructure(); - } - - /// Dto to device entity - static DeviceEntityAbstract convertDtoToDomain( - DeviceEntityDtoAbstract deviceEntityDto, - ) { - return deviceEntityDto.toDomain(); - } - - // Extras methods - - static String convertDtoToJsonString( - DeviceEntityDtoAbstract deviceEntityDto, - ) { - return convertJsonToJsonString(convertDtoToJson(deviceEntityDto)); - } - - static DeviceEntityAbstract convertJsonStringToDomain(String jsonString) { - return convertDtoToDomain( - convertJsonToDto(convertJsonStringToJson(jsonString)), - ); - } - - static String convertDomainToJsonString(DeviceEntityAbstract deviceEntity) { - return convertJsonToJsonString( - convertDtoToJson(convertDomainToDto(deviceEntity)), - ); - } -} diff --git a/lib/infrastructure/devices/esphome/esphome_api/esphome_api_client.dart b/lib/infrastructure/devices/esphome/esphome_api/esphome_api_client.dart deleted file mode 100644 index 0434f188..00000000 --- a/lib/infrastructure/devices/esphome/esphome_api/esphome_api_client.dart +++ /dev/null @@ -1,781 +0,0 @@ -import 'dart:async'; -import 'dart:convert'; -import 'dart:io'; -import 'dart:typed_data'; - -import 'package:cbj_hub/infrastructure/devices/esphome/esphome_api/esphome_objects_as_dart_objects.dart'; -import 'package:cbj_hub/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api.pbserver.dart'; -import 'package:cbj_hub/utils.dart'; - -/// Client to interact with ESPHome device -/// TODO: All the code here need rewrite, manage to turn device on/off -/// TODO: Source: https://github.com/esphome/aioesphomeapi -class EspHomeApiClient { - EspHomeApiClient({ - this.devicePort = 6053, - this.devicePass, - }); - - Socket? _fSocket; - String? devicePass; - String? addressOfServer; - late String deviceMdns; - int devicePort; - - /// Responses stream from the device. - /// Some responses come in chunks, this will help us with that. - /// Each response will be converted to dart object and get passed away in - /// the stream for the current listening function to decide if it part of their - /// request and stop listening. - /// Some request will just keep coming like ping request and button press. - StreamController deviceResponseStream = StreamController(); - - /// aioesphomeapi: - /// fName = _connect_socket_connect - /// Step 2 in connect process: connect the socket. - Future getSocket() async { - if (_fSocket != null && _fSocket!.isBroadcast) { - return _fSocket!; - } - addressOfServer ??= await getIpFromMdns('$deviceMdns.local'); - // TODO: Test if it is possible to connect to socket using the deviceMdns - // TODO: instead of the address, suppose to be more consistent. - - return _fSocket = await Socket.connect(addressOfServer, devicePort); - } - - Future listenToResponses() async { - final Socket socket = await getSocket(); - - socket.listen( - // handle data from the server - (Uint8List data) { - final int responseType = data[2]; - - /// HelloRequest - if (responseType == 1) { - logger.t('responseType is HelloRequest'); - } - - /// HelloResponse - else if (responseType == 2) { - logger.t('responseType is HelloResponse'); - final HelloResponse? helloResponseData = bytesToHelloResponse(data); - if (helloResponseData != null) { - deviceResponseStream.add( - EspHomeHelloResponseObject( - apiVersionMajor: helloResponseData.apiVersionMajor, - apiVersionMinor: helloResponseData.apiVersionMinor, - serverInfo: helloResponseData.serverInfo, - ), - ); - } - logger.t('HelloResponse data: ${helloResponseData?.serverInfo}'); - logger.t(''); - } - - /// ConnectRequest - else if (responseType == 3) { - logger.t('responseType is ConnectRequest'); - } - - /// ConnectResponse - else if (responseType == 4) { - logger.t('responseType is ConnectResponse'); - logger.t( - 'ConnectResponse data: ${utf8.decode(data.sublist(3), allowMalformed: true)}', - ); - logger.t('Data: $data'); - if (data.length > 3) { - logger.t('Password is wrong'); - devicePass = null; - } else { - logger.t('Correct password'); - } - logger.t(''); - } - - /// DisconnectRequest - else if (responseType == 5) { - logger.t('responseType is DisconnectRequest'); - } - - /// DisconnectResponse - else if (responseType == 6) { - logger.t('responseType is DisconnectResponse'); - } - - /// PingRequest - else if (responseType == 7) { - logger.t('responseType is PingRequest'); - logger.t('PingRequest data: ${utf8.decode(data.sublist(3))}'); - logger.t(''); - } - - /// PingResponse - else if (responseType == 8) { - logger.t('responseType is PingResponse'); - logger.t('PingResponse data: ${utf8.decode(data.sublist(3))}'); - logger.t(''); - } - - /// DeviceInfoRequest - else if (responseType == 9) { - logger.t('responseType is DeviceInfoRequest'); - } - - /// DeviceInfoResponse - else if (responseType == 10) { - logger.t('responseType is DeviceInfoResponse'); - logger.t('DeviceInfoResponse data: $data'); - logger.t(''); - } - - /// ListEntitiesRequest - else if (responseType == 11) { - logger.t('responseType is ListEntitiesRequest'); - } - - /// ListEntitiesBinarySensorResponse - else if (responseType == 12) { - logger.t('responseType is ListEntitiesBinarySensorResponse'); - } - - /// ListEntitiesCoverResponse - else if (responseType == 13) { - logger.t('responseType is ListEntitiesCoverResponse'); - } - - /// ListEntitiesFanResponse - else if (responseType == 14) { - logger.t('responseType is ListEntitiesFanResponse'); - } - - /// ListEntitiesLightResponse - else if (responseType == 15) { - logger.t('responseType is ListEntitiesLightResponse'); - } - - /// ListEntitiesSensorResponse - else if (responseType == 16) { - logger.t('responseType is ListEntitiesSensorResponse'); - } - - /// ListEntitiesSwitchResponse - else if (responseType == 17) { - logger.t('responseType is ListEntitiesSwitchResponse'); - String dataPayload = ''; - - try { - dataPayload = data.length > 3 ? utf8.decode(data.sublist(3)) : ''; - - logger.t( - 'ListEntitiesSwitchResponse data payload:' - ' $dataPayload', - ); - } catch (e) { - logger.t( - 'ListEntitiesSwitchResponse data bytes:' - ' $data', - ); - } - logger.t(''); - } - - /// ListEntitiesTextSensorResponse - else if (responseType == 18) { - logger.t('responseType is ListEntitiesTextSensorResponse'); - } - - /// dsaDoneResponse - else if (responseType == 19) { - logger.t('responseType is ListEntitiesDoneResponse'); - logger.t( - 'ListEntitiesDoneResponse data: ${utf8.decode(data.sublist(3))}', - ); - logger.t(''); - } - - /// SubscribeStatesRequest - else if (responseType == 20) { - logger.t('responseType is SubscribeStatesRequest'); - } - - /// BinarySensorStateResponse - else if (responseType == 21) { - logger.t('responseType is BinarySensorStateResponse'); - } - - /// CoverStateResponse - else if (responseType == 22) { - logger.t('responseType is CoverStateResponse'); - } - - /// FanStateResponse - else if (responseType == 23) { - logger.t('responseType is FanStateResponse'); - } - - /// LightStateResponse - else if (responseType == 24) { - logger.t('responseType is LightStateResponse'); - } - - /// SensorStateResponse - else if (responseType == 25) { - logger.t('responseType is SensorStateResponse'); - } - - /// SwitchStateResponse - else if (responseType == 26) { - logger.t('responseType is SwitchStateResponse'); - logger.t('SwitchStateResponse data: $data}'); - logger.t(''); - } - - /// TextSensorStateResponse - else if (responseType == 27) { - logger.t('responseType is TextSensorStateResponse'); - } - - /// SubscribeLogsRequest - else if (responseType == 28) { - logger.t('responseType is SubscribeLogsRequest'); - } - - /// SubscribeLogsResponse - else if (responseType == 29) { - logger.t('responseType is SubscribeLogsResponse'); - } - - /// CoverCommandRequest - else if (responseType == 30) { - logger.t('responseType is CoverCommandRequest'); - } - - /// FanCommandRequest - else if (responseType == 31) { - logger.t('responseType is FanCommandRequest'); - } - - /// LightCommandRequest - else if (responseType == 32) { - logger.t('responseType is LightCommandRequest'); - } - - /// SwitchCommandRequest - else if (responseType == 33) { - logger.t('responseType is SwitchCommandRequest'); - } - - /// SubscribeHomeassistantServicesRequest - else if (responseType == 34) { - logger.t('responseType is SubscribeHomeassistantServicesRequest'); - } - - /// HomeassistantServiceResponse - else if (responseType == 35) { - logger.t('responseType is HomeassistantServiceResponse'); - } - - /// GetTimeRequest - else if (responseType == 36) { - logger.t('responseType is GetTimeRequest'); - } - - /// GetTimeResponse - else if (responseType == 37) { - logger.t('responseType is GetTimeResponse'); - } - - /// SubscribeHomeAssistantStatesRequest - else if (responseType == 38) { - logger.t('responseType is SubscribeHomeAssistantStatesRequest'); - } - - /// SubscribeHomeAssistantStateResponse - else if (responseType == 39) { - logger.t('responseType is SubscribeHomeAssistantStateResponse'); - } - - /// HomeAssistantStateResponse - else if (responseType == 40) { - logger.t('responseType is HomeAssistantStateResponse'); - } - - /// ListEntitiesServicesResponse - else if (responseType == 41) { - logger.t('responseType is ListEntitiesServicesResponse'); - } - - /// ExecuteServiceRequest - else if (responseType == 42) { - logger.t('responseType is ExecuteServiceRequest'); - } - - /// ListEntitiesCameraResponse - else if (responseType == 43) { - logger.t('responseType is ListEntitiesCameraResponse'); - } - - /// CameraImageResponse - else if (responseType == 44) { - logger.t('responseType is CameraImageResponse'); - } - - /// CameraImageRequest - else if (responseType == 45) { - logger.t('responseType is CameraImageRequest'); - } - - /// ListEntitiesClimateResponse - else if (responseType == 46) { - logger.t('responseType is ListEntitiesClimateResponse'); - } - - /// ClimateStateResponse - else if (responseType == 47) { - logger.t('responseType is ClimateStateResponse'); - } - - /// ClimateCommandRequest - else if (responseType == 48) { - logger.t('responseType is ClimateCommandRequest'); - } - - /// ListEntitiesNumberResponse - else if (responseType == 49) { - logger.t('responseType is ListEntitiesNumberResponse'); - } - - /// NumberStateResponse - else if (responseType == 50) { - logger.t('responseType is NumberStateResponse'); - } - - /// NumberCommandRequest - else if (responseType == 51) { - logger.t('responseType is NumberCommandRequest'); - } - - /// ListEntitiesSelectResponse - else if (responseType == 52) { - logger.t('responseType is ListEntitiesSelectResponse'); - } - - /// SelectStateResponse - else if (responseType == 53) { - logger.t('responseType is SelectStateResponse'); - } - - /// SelectCommandRequest - else if (responseType == 54) { - logger.t('responseType is SelectCommandRequest'); - } else { - logger.t('responseType is else'); - logger.t('Listen to data $data'); - logger.t(''); - } - }, - - // handle errors - onError: (error) { - logger.e(error); - socket.destroy(); - }, - - // handle server ending connection - onDone: () { - logger.t('Server left.'); - socket.destroy(); - }, - ); - } - - Future sendConnect() async { - final Socket socket = await getSocket(); - - await _helloRequestToEsp(); - - final ConnectRequest connectRequest = - ConnectRequest(password: '\n\n$devicePass'); - - const int numOfByteBeforeData = 3; - - final List list = utf8.encode(connectRequest.password); - - final int totalSizeToTransfer = numOfByteBeforeData + list.length; - - final Uint8List message = Uint8List(totalSizeToTransfer); - - final ByteData byteData = ByteData.view(message.buffer); - - /// First, a message in this protocol has a specific format: - - /// A zero byte. - byteData.setUint8(0, 0x00); - - /// VarInt denoting the size of the message object. - /// (type is not part of this) - byteData.setUint8(1, list.length); - - /// * VarInt denoting the type of message. - byteData.setUint8(2, 3); - -// * The message object encoded as a ProtoBuf message - - for (int i = numOfByteBeforeData; - i < list.length + numOfByteBeforeData; - i++) { - byteData.setUint8(i, list[i - numOfByteBeforeData]); - } - - socket.add(message); - } - - Future disconnect() async { - await (await getSocket()).close(); - } - - /// aioesphomeapi: - /// fName = _connect_hello - /// Step 4 in connect process: send hello and get api version. - Future _helloRequestToEsp() async { - // connect to the socket server - final Socket socket = await getSocket(); - - const String clientName = 'aioesphomeapi'; - - final HelloRequest helloRequest = - HelloRequest(clientInfo: '\n\r$clientName'); - - const int numOfByteBeforeData = 3; - - final List clientInfoAsIntList = utf8.encode(helloRequest.clientInfo); - - final int totalSizeToTransfer = - numOfByteBeforeData + clientInfoAsIntList.length; - - final Uint8List message = Uint8List(totalSizeToTransfer); - - final ByteData byteData = ByteData.view(message.buffer); - - /// First, a message in this protocol has a specific format: - - /// A zero byte. - byteData.setUint8(0, 0x00); - - /// VarInt denoting the size of the message object. - /// (type is not part of this) - byteData.setUint8(1, clientInfoAsIntList.length); - - /// * VarInt denoting the type of message. - byteData.setUint8(2, 1); - -// * The message object encoded as a ProtoBuf message - - for (int i = numOfByteBeforeData; - i < clientInfoAsIntList.length + numOfByteBeforeData; - i++) { - byteData.setUint8(i, clientInfoAsIntList[i - numOfByteBeforeData]); - } - - socket.add(message); - } - - Future connectRequestToEsp() async { - // connect to the socket server - final socket = await getSocket(); - - final ConnectRequest connectRequest = ConnectRequest(password: devicePass); - - final List passwordAsIntList = utf8.encode(connectRequest.password); - - const int numOfBytesBeforeData = 3; - - // final List list = utf8.encode(helloRequest.password); - - final int totalSizeToTransfer = - numOfBytesBeforeData + passwordAsIntList.length; - - final Uint8List message = Uint8List(totalSizeToTransfer); - - final ByteData byteData = ByteData.view(message.buffer); - - /// First, a message in this protocol has a specific format: - - /// A zero byte. - byteData.setUint8(0, 0x00); - - /// VarInt denoting the size of the message object. - /// (type is not part of this) - byteData.setUint8(1, connectRequest.password.length); - - /// * VarInt denoting the type of message. - byteData.setUint8(2, 3); - -// * The message object encoded as a ProtoBuf message -// - for (int i = numOfBytesBeforeData; - i < connectRequest.password.length + numOfBytesBeforeData; - i++) { - byteData.setUint8(i, passwordAsIntList[i - numOfBytesBeforeData]); - } - - socket.add(message); - } - - /// aioesphomeapi: - /// fName = _connect_start_ping - /// Step 5 in connect process: start the ping loop. - Future ping() async { - // connect to the socket server - final socket = await getSocket(); - logger.t( - 'Connected request to: ' - '${socket.remoteAddress.address}:${socket.remotePort}', - ); - - PingRequest(); - - const int numOfByteBeforeData = 3; - - const int totalSizeToTransfer = numOfByteBeforeData; - - final Uint8List message = Uint8List(totalSizeToTransfer); - - final ByteData byteData = ByteData.view(message.buffer); - - /// First, a message in this protocol has a specific format: - - /// A zero byte. - byteData.setUint8(0, 0x00); - - /// VarInt denoting the size of the message object. - /// (type is not part of this) - byteData.setUint8(1, 0); - - /// * VarInt denoting the type of message. - byteData.setUint8(2, 7); - -// * The message object encoded as a ProtoBuf message - - socket.add(message); - } - - Future deviceInfoRequestToEsp() async { - // connect to the socket server - final socket = await getSocket(); - logger.t( - 'Connected request to:' - ' ${socket.remoteAddress.address}:${socket.remotePort}', - ); - - DeviceInfoRequest(); - - const int numOfByteBeforeData = 3; - - // final List list = utf8.encode(helloRequest.toString()); - - const int totalSizeToTransfer = numOfByteBeforeData; - - final Uint8List message = Uint8List(totalSizeToTransfer); - - final ByteData byteData = ByteData.view(message.buffer); - - /// First, a message in this protocol has a specific format: - - /// A zero byte. - byteData.setUint8(0, 0x00); - - /// VarInt denoting the size of the message object. - /// (type is not part of this) - byteData.setUint8(1, 0); - - /// * VarInt denoting the type of message. - byteData.setUint8(2, 9); - - socket.add(message); - } - - Future subscribeStatesRequest() async { - // connect to the socket server - final socket = await getSocket(); - logger.t( - 'Connected request to:' - ' ${socket.remoteAddress.address}:${socket.remotePort}', - ); - - SubscribeStatesRequest(); - - const int numOfByteBeforeData = 3; - - // final List list = utf8.encode(helloRequest.toString()); - - const int totalSizeToTransfer = numOfByteBeforeData; - - final Uint8List message = Uint8List(totalSizeToTransfer); - - final ByteData byteData = ByteData.view(message.buffer); - - /// First, a message in this protocol has a specific format: - - /// A zero byte. - byteData.setUint8(0, 0x00); - - /// VarInt denoting the size of the message object. - /// (type is not part of this) - byteData.setUint8(1, 0); - - /// * VarInt denoting the type of message. - byteData.setUint8(2, 20); - - socket.add(message); - } - - Future switchCommandRequest(int deviceKey, bool changeTostate) async { - if (devicePass == null) { - logger.t('Please call sendConnect, password is missing'); - return; - } - // connect to the socket server - final socket = await getSocket(); - logger.t( - 'Connected request to:' - ' ${socket.remoteAddress.address}:${socket.remotePort}', - ); - - final SwitchCommandRequest switchCommandRequest = - SwitchCommandRequest(key: deviceKey, state: changeTostate); - - final String myHexKey = - switchCommandRequest.key.toRadixString(16).padLeft(4, '0'); - - List myHexKeyList = []; - - for (int i = 0; i < myHexKey.length; i += 2) { - myHexKeyList.add(int.parse('0x${myHexKey.substring(i, i + 2)}')); - } - - myHexKeyList = List.from(myHexKeyList.reversed); - myHexKeyList.insert(0, 13); - - if (changeTostate == true) { - myHexKeyList.add(16); - myHexKeyList.add(1); - } - - const int numOfByteBeforeData = 3; - - final int totalSizeToTransfer = numOfByteBeforeData + myHexKeyList.length; - - final Uint8List message = Uint8List(totalSizeToTransfer); - - final ByteData byteData = ByteData.view(message.buffer); - - logger.t(myHexKeyList); - - /// A zero byte. - byteData.setUint8(0, 0x00); - - /// VarInt denoting the size of the message object. - /// (type is not part of this) - byteData.setUint8(1, myHexKeyList.length); - - /// * VarInt denoting the type of message. - byteData.setUint8(2, 33); - - for (int a = numOfByteBeforeData; - a < myHexKeyList.length + numOfByteBeforeData; - a++) { - byteData.setUint8(a, myHexKeyList[a - numOfByteBeforeData]); - } - - logger.t('switchCommandRequest message: $message'); - -// * The message object encoded as a ProtoBuf message - socket.add(message); - await Future.delayed(const Duration(milliseconds: 1000)); - } - - Future listEntitiesRequest() async { - if (devicePass == null) { - logger.t('Please call sendConnect, password is missing'); - return; - } - // connect to the socket server - final socket = await getSocket(); - logger.t( - 'Connected request to:' - ' ${socket.remoteAddress.address}:${socket.remotePort}', - ); - - ListEntitiesRequest(); - - const int numOfByteBeforeData = 3; - - const int totalSizeToTransfer = numOfByteBeforeData; - - final Uint8List message = Uint8List(totalSizeToTransfer); - - final ByteData byteData = ByteData.view(message.buffer); - - /// A zero byte. - byteData.setUint8(0, 0x00); - - /// VarInt denoting the size of the message object. - /// (type is not part of this) - byteData.setUint8(1, 0); - - /// * VarInt denoting the type of message. - byteData.setUint8(2, 11); - - logger.t('ListEntitiesRequest message: $message'); - -// * The message object encoded as a ProtoBuf message - socket.add(message); - } - - static HelloResponse? bytesToHelloResponse(List bytes) { - // Check if request is hello response - if (bytes[2] != 2) { - return null; - } - - final HelloResponse helloResponse = HelloResponse(); - - final List responseBytes = bytes.sublist(3); - helloResponse.serverInfo = utf8.decode(responseBytes); - - return helloResponse; - } - - /// aioesphomeapi: - /// fName = _connect_init_frame_helper - /// Step 3 in connect process: initialize the frame helper and init read loop. - Future connectInitFrameHelper() async { - await getSocket(); - - await listenToResponses(); - } - - /// Gets mDNS name and return the IP of that device - /// aioesphomeapi: - /// fName = _connect_resolve_host - /// Step 1 in connect process: resolve the address. - static Future getIpFromMdns(String deviceMdnsName) async { - try { - final List deviceIpList = - await InternetAddress.lookup(deviceMdnsName); - if (deviceIpList.isNotEmpty) { - return deviceIpList[0].address; - } - } catch (e) { - logger.e( - 'Crash when searching the IP for device with mDNS\n$e', - ); - } - - return null; - } -} diff --git a/lib/infrastructure/devices/esphome/esphome_api/esphome_api_plaintext_frame_helper.dart b/lib/infrastructure/devices/esphome/esphome_api/esphome_api_plaintext_frame_helper.dart deleted file mode 100644 index 8b137891..00000000 --- a/lib/infrastructure/devices/esphome/esphome_api/esphome_api_plaintext_frame_helper.dart +++ /dev/null @@ -1 +0,0 @@ - diff --git a/lib/infrastructure/devices/esphome/esphome_api/esphome_client.dart b/lib/infrastructure/devices/esphome/esphome_api/esphome_client.dart deleted file mode 100644 index 69978112..00000000 --- a/lib/infrastructure/devices/esphome/esphome_api/esphome_client.dart +++ /dev/null @@ -1 +0,0 @@ -class EspHomeClient {} diff --git a/lib/infrastructure/devices/esphome/esphome_api/esphome_frame_helper.dart b/lib/infrastructure/devices/esphome/esphome_api/esphome_frame_helper.dart deleted file mode 100644 index 22e95cf7..00000000 --- a/lib/infrastructure/devices/esphome/esphome_api/esphome_frame_helper.dart +++ /dev/null @@ -1,58 +0,0 @@ -// data class from _frame_helper.py in aioesphomeapi - -/// aioesphomeapi: -/// cName = Packet -class Packet { - /// Enter packet data - Packet({required this.type, required this.data}); - - int type; - List data; // bytes I think -} - -/// aioesphomeapi: -/// cName = APIFrameHelper(ABC) -abstract class APIFrameHelper { - /// aioesphomeapi: - /// fName = close - Future close(); - - /// aioesphomeapi: - /// fName = write_packet - Future writePacket(Packet packet); - - /// aioesphomeapi: - /// fName = read_packet - Future readPacket(); -} - -/// Class to handle ESPHome packets -/// aioesphomeapi: -/// cName = APIPlaintextFrameHelper -class EspApiPlaintextFrameHelper extends APIFrameHelper { - dynamic reader; - dynamic writer; - dynamic write_lock; - dynamic read_lock; - dynamic closed_event; - - @override - Future close() { - // TODO: implement close - throw UnimplementedError(); - } - - /// aioesphomeapi: - /// fName = write_packet - @override - Future writePacket(Packet packet) async { - // List data = utf8.encode('\0'); - // data.addAll(EspHomeUtil.varuintToBytes(packet.data)); - } - - @override - Future readPacket() { - // TODO: implement readPacket - throw UnimplementedError(); - } -} diff --git a/lib/infrastructure/devices/esphome/esphome_api/esphome_objects_as_dart_objects.dart b/lib/infrastructure/devices/esphome/esphome_api/esphome_objects_as_dart_objects.dart deleted file mode 100644 index 6d283d78..00000000 --- a/lib/infrastructure/devices/esphome/esphome_api/esphome_objects_as_dart_objects.dart +++ /dev/null @@ -1,10 +0,0 @@ -class EspHomeHelloResponseObject { - EspHomeHelloResponseObject({ - this.apiVersionMajor, - this.apiVersionMinor, - this.serverInfo, - }); - int? apiVersionMajor; - int? apiVersionMinor; - String? serverInfo; -} diff --git a/lib/infrastructure/devices/esphome/esphome_api/esphome_util.dart b/lib/infrastructure/devices/esphome/esphome_api/esphome_util.dart deleted file mode 100644 index 29f2b814..00000000 --- a/lib/infrastructure/devices/esphome/esphome_api/esphome_util.dart +++ /dev/null @@ -1,70 +0,0 @@ -import 'dart:convert'; - -/// Class to include all the functions that exist in util.py in aioesphomeapi -class EspHomeUtil { - /// aioesphomeapi: - /// fName = varuint_to_bytes - /// TODO: Check if this is working - static List varuintToBytes(int value) { - if (value <= 0x7F) { - return [value]; - } - - final List bytes = []; - for (int byte in utf8.encode(value.toString())) { - final int temp = byte & 0x7F; - byte >>= 7; - if (!byte.isNaN) { - bytes.add(temp | 0x80); - } else { - bytes.add(temp); - } - } - return bytes; - } - - /// aioesphomeapi: - /// fName = bytes_to_varuint - /// TODO: Check if this is working - static int? bytesToVaruint(List value) { - int result = 0; - int bitPos = 0; - - for (final int val in value) { - result |= (val & 0x7F) << bitPos; - bitPos += 7; - if ((val & 0x80) == 0) { - return result; - } - } - return null; - } - - // /// aioesphomeapi: - // /// fName = fix_float_single_double_conversion - // /// Fix precision for single-precision floats and return what was probably - // /// meant as a float. - // /// - // /// In ESPHome we work with single-precision floats internally for performance. - // /// But python uses double-precision floats, and when protobuf reads the message - // /// it's auto-converted to a double (which is possible losslessly). - // /// - // /// Unfortunately the float representation of 0.1 converted to a double is not the - // /// double representation of 0.1, but 0.10000000149011612. - // /// - // /// This methods tries to round to the closest decimal value that a float of this - // /// magnitude can accurately represent. - // /// - // /// TODO: Check if this is working - // static int fixFloatSingleDoubleConversion(int value) { - // if(value == 0 || ! value.isFinite){ - // return value; - // } - // int absVal = value.abs(); - // - // # assume ~7 decimals of precision for floats to be safe - // l10 = math.ceil(math.log10(abs_val)) - // prec = 7 - l10 - // return round(value, prec) - // } -} diff --git a/lib/infrastructure/devices/esphome/esphome_connector_conjector.dart b/lib/infrastructure/devices/esphome/esphome_connector_conjector.dart deleted file mode 100644 index 6c13fde7..00000000 --- a/lib/infrastructure/devices/esphome/esphome_connector_conjector.dart +++ /dev/null @@ -1,111 +0,0 @@ -import 'dart:async'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_light_device/generic_light_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_entity.dart'; -import 'package:cbj_hub/domain/saved_devices/i_saved_devices_repo.dart'; -import 'package:cbj_hub/domain/vendors/esphome_login/generic_esphome_login_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/companies_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/esphome/esphome_helpers.dart'; -import 'package:cbj_hub/infrastructure/devices/esphome/esphome_light/esphome_light_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/esphome/esphome_switch/esphome_switch_entity.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/abstract_company_connector_conjector.dart'; -import 'package:cbj_hub/injection.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:injectable/injectable.dart'; - -@singleton -class EspHomeConnectorConjector implements AbstractCompanyConnectorConjector { - static const List mdnsTypes = ['_esphomelib._tcp']; - - @override - Map companyDevices = {}; - - static String? espHomeDevicePass; - - Map get getAllCompanyDevices => companyDevices; - - Future accountLogin( - GenericEspHomeLoginDE genericEspHomeDeviceLoginDE, - ) async { - espHomeDevicePass = - genericEspHomeDeviceLoginDE.espHomeDevicePass.getOrCrash(); - // We can start a search of devices in node red using a request to - // /esphome/discovery but for now lets just let the devices get found by - // the global mdns search - return 'Success'; - } - - /// Add new devices to [companyDevices] if not exist - Future addNewDeviceByMdnsName({ - required String mDnsName, - required String ip, - required String port, - required String address, - }) async { - if (espHomeDevicePass == null) { - logger.w('ESPHome device got found but missing a password, please add ' - 'password for it in the app'); - return; - } - - final List espDevice = - await EspHomeHelpers.addDiscoverdEntities( - mDnsName: mDnsName, - port: port, - address: address, - devicePassword: espHomeDevicePass!, - ); - - for (final DeviceEntityAbstract entityAsDevice in espDevice) { - final DeviceEntityAbstract deviceToAdd = - CompaniesConnectorConjector.addDiscoverdDeviceToHub(entityAsDevice); - - final MapEntry deviceAsEntry = - MapEntry(deviceToAdd.entityUniqueId.getOrCrash(), deviceToAdd); - - companyDevices.addEntries([deviceAsEntry]); - - logger.i( - 'New ESPHome devices name:${entityAsDevice.cbjEntityName.getOrCrash()}', - ); - } - // Save state locally so that nodeRED flows will not get created again - // after restart - getIt().saveAndActivateSmartDevicesToDb(); - } - - @override - Future manageHubRequestsForDevice( - DeviceEntityAbstract espHomeDE, - ) async { - final DeviceEntityAbstract? device = - companyDevices[espHomeDE.entityUniqueId.getOrCrash()]; - - if (device != null) { - device.executeDeviceAction(newEntity: espHomeDE); - } else { - logger.w('ESPHome device type does not exist'); - } - } - - @override - Future setUpDeviceFromDb(DeviceEntityAbstract deviceEntity) async { - DeviceEntityAbstract? nonGenericDevice; - - if (deviceEntity is GenericLightDE) { - nonGenericDevice = EspHomeLightEntity.fromGeneric(deviceEntity); - } else if (deviceEntity is GenericSwitchDE) { - nonGenericDevice = EspHomeSwitchEntity.fromGeneric(deviceEntity); - } - - if (nonGenericDevice == null) { - logger.w('EspHome device could not get loaded from the server'); - return; - } - - companyDevices.addEntries([ - MapEntry(nonGenericDevice.entityUniqueId.getOrCrash(), nonGenericDevice), - ]); - } -} diff --git a/lib/infrastructure/devices/esphome/esphome_device_validators.dart b/lib/infrastructure/devices/esphome/esphome_device_validators.dart deleted file mode 100644 index 6d781d7b..00000000 --- a/lib/infrastructure/devices/esphome/esphome_device_validators.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateESPHomeSwitchKeyNotEmpty( - String input, -) { - return right(input); -} - -Either, String> validateESPHomePortNotEmpty(String input) { - return right(input); -} diff --git a/lib/infrastructure/devices/esphome/esphome_device_value_objects.dart b/lib/infrastructure/devices/esphome/esphome_device_value_objects.dart deleted file mode 100644 index 8b137891..00000000 --- a/lib/infrastructure/devices/esphome/esphome_device_value_objects.dart +++ /dev/null @@ -1 +0,0 @@ - diff --git a/lib/infrastructure/devices/esphome/esphome_helpers.dart b/lib/infrastructure/devices/esphome/esphome_helpers.dart deleted file mode 100644 index fffff82a..00000000 --- a/lib/infrastructure/devices/esphome/esphome_helpers.dart +++ /dev/null @@ -1,215 +0,0 @@ -import 'package:cbj_hub/domain/core/value_objects.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_light_device/generic_light_value_objects.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_value_objects.dart'; -import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart'; -import 'package:cbj_hub/infrastructure/devices/esphome/esphome_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/esphome/esphome_light/esphome_light_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/esphome/esphome_switch/esphome_switch_entity.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/node_red/node_red_repository.dart'; -import 'package:cbj_hub/injection.dart'; -import 'package:nodered/nodered.dart'; - -class EspHomeHelpers { - /// Will create new espHome device node in NodeRed if does not exist. - /// If already exits it will check if this is the correct one for the given - /// device and if so will just return the existing one node id - static Future createDeviceNodeOrReturnExistingOne({ - required String mDnsName, - required String devicePassword, - String? espHomeNodeDeviceId, - }) async { - if (espHomeNodeDeviceId == null) { - /// Try to find entity that already got added that contains the same - /// mDNS (multiple entities can exist on the device) - for (final DeviceEntityAbstract deviceE - in getIt().getAllCompanyDevices.values) { - if (deviceE.deviceMdns.getOrCrash() == mDnsName) { - return deviceE.deviceCbjUniqueId.getOrCrash(); - } - } - } - final String tempEspHomeNodeDeviceId = - espHomeNodeDeviceId ?? UniqueId().getOrCrash(); - - final EspHomeNodeRedApi espHomeNodeRedApi = EspHomeNodeRedApi( - repository: getIt(), - nodeRedApiBaseTopic: - getIt().getNodeRedApiBaseTopic(), - nodeRedDevicesTopic: - getIt().getNodeRedDevicesTopicTypeName(), - nodeRedMqttBrokerNodeName: 'Cbj NodeRed plugs Api Broker', - ); - - await espHomeNodeRedApi.setNewGlobalEspHomeDeviceNode( - deviceMdnsName: mDnsName, - password: devicePassword, - espHomeDeviceId: tempEspHomeNodeDeviceId, - ); - await Future.delayed(const Duration(milliseconds: 800)); - - return tempEspHomeNodeDeviceId; - } - - static Future> retrieveOnlyNewEntities({ - required String mDnsName, - required String devicePassword, - String? espHomeDeviceNodeId, - }) async { - /// 1. Add ESPHome Device node to node red if not given one - final String espHomeDeviceNodeIdResult = espHomeDeviceNodeId ?? - await createDeviceNodeOrReturnExistingOne( - devicePassword: devicePassword, - mDnsName: mDnsName, - ); - - /// 2. Get all entities of this device - final List allEntities = - await EspHomeNodeRedServerApiCalls.getEspHomeDeviceEntities( - espHomeDeviceNodeIdResult, - ); - - /// 3. Compere device entities with already added entities to retrieve - /// only the new once - final List tempAllEntities = []; - - for (final EspHomeDeviceEntityObject entity in allEntities) { - if (!getIt() - .getAllCompanyDevices - .containsKey(entity.config['uniqueId'])) { - tempAllEntities.add(entity); - } - } - return tempAllEntities; - } - - static Future> addDiscoverdEntities({ - required String address, - required String mDnsName, - required String devicePassword, - String port = '6053', - }) async { - final String espHomeDeviceNodeId = - await createDeviceNodeOrReturnExistingOne( - devicePassword: devicePassword, - mDnsName: mDnsName, - ); - - /// Make sure we add only new entities - final List entitiesList = - await retrieveOnlyNewEntities( - mDnsName: mDnsName, - devicePassword: devicePassword, - espHomeDeviceNodeId: espHomeDeviceNodeId, - ); - - if (entitiesList.isEmpty) { - return []; - } - - final List deviceEntityList = []; - - final EspHomeNodeRedApi espHomeNodeRedApi = EspHomeNodeRedApi( - repository: getIt(), - nodeRedApiBaseTopic: - getIt().getNodeRedApiBaseTopic(), - nodeRedDevicesTopic: - getIt().getNodeRedDevicesTopicTypeName(), - nodeRedMqttBrokerNodeName: 'Cbj NodeRed plugs Api Broker', - ); - - for (final EspHomeDeviceEntityObject espHomeDeviceEntityObject - in entitiesList) { - final String flowId = UniqueId().getOrCrash(); - - final String deviceKey = espHomeDeviceEntityObject.key.toString(); - - await espHomeNodeRedApi.setNewStateNodes( - espHomeDeviceId: espHomeDeviceNodeId, - flowId: flowId, - entityId: deviceKey, - ); - - if (espHomeDeviceEntityObject.type == 'Light') { - // TODO: Add support for more light types, I think the type is stored in supportedColorModList - // final List supportedColorModList = espHomeDeviceEntityObject - // .config['supportedColorModesList'] as List; - // if (supportedColorModList.first == 1) {} - - deviceEntityList.add( - EspHomeLightEntity( - uniqueId: CoreUniqueId(), - entityUniqueId: EntityUniqueId( - espHomeDeviceEntityObject.config['uniqueId'] as String, - ), - cbjEntityName: CbjEntityName(espHomeDeviceEntityObject.name), - entityOriginalName: - EntityOriginalName(espHomeDeviceEntityObject.name), - deviceOriginalName: - DeviceOriginalName(espHomeDeviceEntityObject.name), - entityStateGRPC: EntityState(EntityStateGRPC.ack.toString()), - stateMassage: DeviceStateMassage('Test'), - senderDeviceOs: DeviceSenderDeviceOs('EspHome'), - senderDeviceModel: DeviceSenderDeviceModel('Probably esp8266'), - senderId: DeviceSenderId.fromUniqueString('Test'), - compUuid: DeviceCompUuid('test'), - powerConsumption: DevicePowerConsumption('0'), - lightSwitchState: GenericLightSwitchState('on'), - deviceMdns: DeviceMdns(mDnsName), - devicePort: DevicePort(port), - entityKey: EntityKey(deviceKey), - deviceLastKnownIp: DeviceLastKnownIp(address), - deviceUniqueId: DeviceUniqueId(espHomeDeviceNodeId), - deviceHostName: DeviceHostName('0'), - devicesMacAddress: DevicesMacAddress('0'), - requestTimeStamp: RequestTimeStamp('0'), - lastResponseFromDeviceTimeStamp: - LastResponseFromDeviceTimeStamp('0'), - deviceCbjUniqueId: - CoreUniqueId.fromUniqueString(espHomeDeviceNodeId), - ), - ); - } else if (espHomeDeviceEntityObject.type == 'Switch' || - espHomeDeviceEntityObject.type == 'Fan' || - espHomeDeviceEntityObject.type == 'Siren') { - deviceEntityList.add( - EspHomeSwitchEntity( - uniqueId: CoreUniqueId(), - entityUniqueId: EntityUniqueId( - espHomeDeviceEntityObject.config['uniqueId'] as String, - ), - cbjEntityName: CbjEntityName(espHomeDeviceEntityObject.name), - entityOriginalName: - EntityOriginalName(espHomeDeviceEntityObject.name), - deviceOriginalName: - DeviceOriginalName(espHomeDeviceEntityObject.name), - entityStateGRPC: EntityState(EntityStateGRPC.ack.toString()), - stateMassage: DeviceStateMassage('Test'), - senderDeviceOs: DeviceSenderDeviceOs('EspHome'), - senderDeviceModel: DeviceSenderDeviceModel('Probably esp8266'), - senderId: DeviceSenderId.fromUniqueString('Test'), - compUuid: DeviceCompUuid('test'), - powerConsumption: DevicePowerConsumption('0'), - deviceMdns: DeviceMdns(mDnsName), - devicePort: DevicePort(port), - entityKey: EntityKey(deviceKey), - deviceLastKnownIp: DeviceLastKnownIp(address), - switchState: GenericSwitchSwitchState('on'), - deviceUniqueId: DeviceUniqueId('0'), - deviceHostName: DeviceHostName('0'), - devicesMacAddress: DevicesMacAddress('0'), - requestTimeStamp: RequestTimeStamp('0'), - lastResponseFromDeviceTimeStamp: - LastResponseFromDeviceTimeStamp('0'), - deviceCbjUniqueId: - CoreUniqueId.fromUniqueString(espHomeDeviceNodeId), - ), - ); - } - } - - return deviceEntityList; - } -} diff --git a/lib/infrastructure/devices/esphome/esphome_light/esphome_light_entity.dart b/lib/infrastructure/devices/esphome/esphome_light/esphome_light_entity.dart deleted file mode 100644 index 6dd6c085..00000000 --- a/lib/infrastructure/devices/esphome/esphome_light/esphome_light_entity.dart +++ /dev/null @@ -1,166 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_light_device/generic_light_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_light_device/generic_light_value_objects.dart'; -import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/injection.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; -import 'package:nodered/nodered.dart'; - -class EspHomeLightEntity extends GenericLightDE { - EspHomeLightEntity({ - required super.uniqueId, - required super.entityUniqueId, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required super.lightSwitchState, - }) : super( - deviceVendor: DeviceVendor(VendorsAndServices.espHome.toString()), - ); - - factory EspHomeLightEntity.fromGeneric(GenericLightDE genericDevice) { - return EspHomeLightEntity( - uniqueId: genericDevice.uniqueId, - entityUniqueId: genericDevice.entityUniqueId, - cbjEntityName: genericDevice.cbjEntityName, - entityOriginalName: genericDevice.entityOriginalName, - deviceOriginalName: genericDevice.deviceOriginalName, - stateMassage: genericDevice.stateMassage, - senderDeviceOs: genericDevice.senderDeviceOs, - senderDeviceModel: genericDevice.senderDeviceModel, - senderId: genericDevice.senderId, - compUuid: genericDevice.compUuid, - entityStateGRPC: genericDevice.entityStateGRPC, - powerConsumption: genericDevice.powerConsumption, - deviceUniqueId: genericDevice.deviceUniqueId, - devicePort: genericDevice.devicePort, - deviceLastKnownIp: genericDevice.deviceLastKnownIp, - deviceHostName: genericDevice.deviceHostName, - deviceMdns: genericDevice.deviceMdns, - devicesMacAddress: genericDevice.devicesMacAddress, - entityKey: genericDevice.entityKey, - requestTimeStamp: genericDevice.requestTimeStamp, - lastResponseFromDeviceTimeStamp: - genericDevice.lastResponseFromDeviceTimeStamp, - lightSwitchState: genericDevice.lightSwitchState, - deviceCbjUniqueId: genericDevice.deviceCbjUniqueId, - ); - } - - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - if (newEntity is! GenericLightDE) { - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Not the correct type', - ), - ); - } - - try { - if (newEntity.lightSwitchState!.getOrCrash() != - lightSwitchState!.getOrCrash() || - entityStateGRPC.getOrCrash() != EntityStateGRPC.ack.toString()) { - final EntityActions? actionToPreform = - EnumHelperCbj.stringToDeviceAction( - newEntity.lightSwitchState!.getOrCrash(), - ); - - if (actionToPreform == EntityActions.on) { - (await turnOnLight()).fold((l) { - logger.e('Error turning ESPHome light on'); - throw l; - }, (r) { - logger.i('ESPHome light turn on success'); - }); - } else if (actionToPreform == EntityActions.off) { - (await turnOffLight()).fold((l) { - logger.e('Error turning ESPHome light off'); - throw l; - }, (r) { - logger.i('ESPHome light turn off success'); - }); - } else { - logger.e('actionToPreform is not set correctly ESPHome light'); - } - } - entityStateGRPC = EntityState(EntityStateGRPC.ack.toString()); - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - return right(unit); - } catch (e) { - entityStateGRPC = EntityState(EntityStateGRPC.newStateFailed.toString()); - // - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> turnOnLight() async { - lightSwitchState = GenericLightSwitchState(EntityActions.on.toString()); - try { - final String nodeRedApiBaseTopic = - getIt().getNodeRedApiBaseTopic(); - - final String nodeRedDevicesTopic = - getIt().getNodeRedDevicesTopicTypeName(); - final String topic = - '$nodeRedApiBaseTopic/$nodeRedDevicesTopic/${entityKey.getOrCrash()}/${EspHomeNodeRedApi.deviceStateProperty}/${EspHomeNodeRedApi.inputDeviceProperty}'; - - getIt() - .publishMessage(topic, """{"state":true}"""); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - return right(unit); - } - - @override - Future> turnOffLight() async { - lightSwitchState = GenericLightSwitchState(EntityActions.off.toString()); - try { - final String nodeRedApiBaseTopic = - getIt().getNodeRedApiBaseTopic(); - - final String nodeRedDevicesTopic = - getIt().getNodeRedDevicesTopicTypeName(); - final String topic = - '$nodeRedApiBaseTopic/$nodeRedDevicesTopic/${entityKey.getOrCrash()}/${EspHomeNodeRedApi.deviceStateProperty}/${EspHomeNodeRedApi.inputDeviceProperty}'; - - getIt() - .publishMessage(topic, """{"state":false}"""); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - return right(unit); - } -} diff --git a/lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_api.dart b/lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_api.dart deleted file mode 100644 index e0dc93c1..00000000 --- a/lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_api.dart +++ /dev/null @@ -1,173 +0,0 @@ -// import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -// import 'package:cbj_hub/infrastructure/devices/esphome/esphome_python_api/esphome_python_json_objects_type.dart'; -// import 'package:cbj_hub/utils.dart'; -// import 'package:python_shell/python_shell.dart'; -// -// class EspHomePythonApi { -// static List requeiredPythonPackages = ['aioesphomeapi']; -// -// static PythonShell? _shell; -// -// static Future getShell() async { -// try { -// if (_shell != null) { -// return _shell!; -// } -// -// _shell = PythonShell(PythonShellConfig()); -// await _shell!.initialize(); -// final instance = ShellManager.getInstance("default"); -// instance.installRequires(requeiredPythonPackages); -// return _shell!; -// } catch (e) { -// logger.e('Error getting python shell\n$e'); -// } -// return null; -// } -// -// static Future> getAllEntities( -// HelperEspHomeDeviceInfo helperEspHomeDeviceInfo, -// ) async { -// const String devicePassword = 'MyPassword'; -// final List devicesList = []; -// -// try { -// await getShell(); -// -// final instance = ShellManager.getInstance("default"); -// -// String? currentType; -// -// final ShellListener shellListener = ShellListener( -// onMessage: (String message) { -// if (currentType != null) { -// final DeviceEntityAbstract? convertedDevice = -// EsphomePythonJsonObjectsType.getDeviceAsAbstractIfExist( -// currentType: currentType!, -// deviceJson: message, -// address: helperEspHomeDeviceInfo.address, -// mDnsName: helperEspHomeDeviceInfo.mDnsName, -// port: helperEspHomeDeviceInfo.port, -// ); -// if (convertedDevice != null) { -// devicesList.add(convertedDevice); -// } -// currentType = null; -// } else { -// currentType = message; -// } -// }, -// onComplete: () { -// logger.t('EspHome get all entities scan done'); -// }, -// onError: (object, stackTrace) { -// logger.t('EspHome device scan error $object\n$stackTrace'); -// }, -// ); -// -// await instance.runFile( -// '${helperEspHomeDeviceInfo.getProjectFilesLocation}/lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_files/get_esphome_entities.py', -// listener: shellListener, -// arguments: [ -// helperEspHomeDeviceInfo.address, -// helperEspHomeDeviceInfo.port, -// devicePassword, -// ], -// echo: false, -// ); -// } catch (e) { -// logger.e('Error while getting all ESPHome entities\n$e'); -// } -// return devicesList; -// } -// -// static Future turnOnOffLightEntity( -// HelperEspHomeDeviceInfo helperEspHomeDeviceInfo, -// ) async { -// try { -// await getShell(); -// -// final instance = ShellManager.getInstance("default"); -// -// final ShellListener shellListener = ShellListener( -// onMessage: (String message) {}, -// onComplete: () { -// logger -// .v('EspHome turn lights on or off action completed successfully'); -// }, -// onError: (object, stackTrace) { -// logger.t('EspHome device scan error $object\n$stackTrace'); -// }, -// ); -// -// await instance.runFile( -// '${helperEspHomeDeviceInfo.getProjectFilesLocation}/lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_files/turn_on_off_light_entity_esphome_devices.py', -// listener: shellListener, -// arguments: [ -// helperEspHomeDeviceInfo.address, -// helperEspHomeDeviceInfo.port, -// helperEspHomeDeviceInfo.devicePassword, -// helperEspHomeDeviceInfo.deviceKey, -// helperEspHomeDeviceInfo.newState, -// ], -// echo: false, -// ); -// } catch (e) { -// logger.e('Error while turning esphome light entity $e'); -// } -// } -// -// static Future turnOnOffSwitchEntity( -// HelperEspHomeDeviceInfo helperEspHomeDeviceInfo, -// ) async { -// try { -// final instance = ShellManager.getInstance("default"); -// -// final ShellListener shellListener = ShellListener( -// onMessage: (String message) {}, -// onComplete: () { -// logger -// .v('EspHome turn switch on or off action completed successfully'); -// }, -// onError: (object, stackTrace) { -// logger.t('EspHome device scan error $object\n$stackTrace'); -// }, -// ); -// -// await instance.runFile( -// '${helperEspHomeDeviceInfo.getProjectFilesLocation}/lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_files/turn_on_off_switch_entity_esphome_devices.py', -// listener: shellListener, -// arguments: [ -// helperEspHomeDeviceInfo.address, -// helperEspHomeDeviceInfo.port, -// helperEspHomeDeviceInfo.devicePassword, -// helperEspHomeDeviceInfo.deviceKey, -// helperEspHomeDeviceInfo.newState, -// ], -// echo: false, -// ); -// } catch (e) { -// logger.e('Error while turning esphome light entity $e'); -// } -// } -// } -// -// class HelperEspHomeDeviceInfo { -// HelperEspHomeDeviceInfo({ -// required this.address, -// required this.port, -// required this.deviceKey, -// required this.newState, -// required this.mDnsName, -// required this.devicePassword, -// required this.getProjectFilesLocation, -// }); -// -// String address; -// String port; -// String deviceKey; -// String newState; -// String mDnsName; -// String devicePassword; -// String getProjectFilesLocation; -// } diff --git a/lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_api_device_types/esphome_python_api_light_info_object_type.dart b/lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_api_device_types/esphome_python_api_light_info_object_type.dart deleted file mode 100644 index ab78c3d0..00000000 --- a/lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_api_device_types/esphome_python_api_light_info_object_type.dart +++ /dev/null @@ -1,65 +0,0 @@ -// import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -// import 'package:cbj_hub/domain/generic_devices/generic_light_device/generic_light_value_objects.dart'; -// import 'package:cbj_hub/infrastructure/devices/esphome/esphome_light/esphome_light_entity.dart'; -// import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -// import 'package:freezed_annotation/freezed_annotation.dart'; -// -// part 'esphome_python_api_light_info_object_type.freezed.dart'; -// part 'esphome_python_api_light_info_object_type.g.dart'; -// -// /// ESPHome LightInfo object type -// @freezed -// abstract class EsphomePythonApiLightInfoObjectType -// implements _$EsphomePythonApiLightInfoObjectType { -// factory EsphomePythonApiLightInfoObjectType({ -// // @JsonKey(ignore: true) -// @JsonKey(name: 'object_id') String? objectId, -// int? key, -// String? name, -// @JsonKey(name: 'unique_id') String? uniqueId, -// @JsonKey(name: 'disabled_by_default') bool? disabledByDefault, -// String? icon, -// @JsonKey(name: 'entity_category') int? entityCategory, -// @JsonKey(name: 'supported_color_modes') List? supportedColorModes, -// @JsonKey(name: 'min_mireds') double? minMireds, -// @JsonKey(name: 'max_mireds') double? maxMireds, -// List? effects, -// @JsonKey(name: 'legacy_supports_brightness') bool? legacySupportsBrightness, -// @JsonKey(name: 'legacy_supports_rgb') bool? legacySupportsRgb, -// @JsonKey(name: 'legacy_supports_white_value') -// bool? legacySupportsWhiteValue, -// @JsonKey(name: 'legacy_supports_color_temperature') -// bool? legacySupportsColorTemperature, -// }) = _EsphomePythonApiLightInfoObjectType; -// -// EsphomePythonApiLightInfoObjectType._(); -// -// factory EsphomePythonApiLightInfoObjectType.fromJson( -// Map json, -// ) => -// _$EsphomePythonApiLightInfoObjectTypeFromJson(json); -// -// EspHomeLightEntity toEspHomeLightEntity({ -// required String address, -// required String mDnsName, -// required String? port, -// }) { -// return EspHomeLightEntity( -// uniqueId: CoreUniqueId(), -// entityUniqueId: EntityUniqueId.fromUniqueString(uniqueId!), -// cbjEntityName: CbjEntityName(name), -// entityStateGRPC: EntityState(EntityStateGRPC.ack.toString()), -// stateMassage: DeviceStateMassage('EspHome Created'), -// senderDeviceOs: DeviceSenderDeviceOs('ESPHome'), -// senderDeviceModel: DeviceSenderDeviceModel('ESPHome model'), -// senderId: DeviceSenderId.fromUniqueString('No sender id'), -// compUuid: DeviceCompUuid('No comp uuid'), -// powerConsumption: DevicePowerConsumption('0'), -// lightSwitchState: GenericLightSwitchState(EntityActions.off.toString()), -// deviceMdnsName: DeviceMdnsName(mDnsName), -// devicePort: DevicePort(port), -// espHomeKey: EspHomeKey(key.toString()), -// lastKnownIp: DeviceLastKnownIp(address), -// ); -// } -// } diff --git a/lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_api_device_types/esphome_python_api_switch_info_object_type.dart b/lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_api_device_types/esphome_python_api_switch_info_object_type.dart deleted file mode 100644 index e557eae2..00000000 --- a/lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_api_device_types/esphome_python_api_switch_info_object_type.dart +++ /dev/null @@ -1,57 +0,0 @@ -// import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -// import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_value_objects.dart'; -// import 'package:cbj_hub/infrastructure/devices/esphome/esphome_switch/esphome_switch_entity.dart'; -// import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -// import 'package:freezed_annotation/freezed_annotation.dart'; -// -// part 'esphome_python_api_switch_info_object_type.freezed.dart'; -// part 'esphome_python_api_switch_info_object_type.g.dart'; -// -// /// ESPHome SwitchInfo object type -// @freezed -// abstract class EsphomePythonApiSwitchInfoObjectType -// implements _$EsphomePythonApiSwitchInfoObjectType { -// factory EsphomePythonApiSwitchInfoObjectType({ -// // @JsonKey(ignore: true) -// @JsonKey(name: 'object_id') String? objectId, -// int? key, -// String? name, -// @JsonKey(name: 'unique_id') String? uniqueId, -// @JsonKey(name: 'disabled_by_default') bool? disabledByDefault, -// String? icon, -// @JsonKey(name: 'entity_category') int? entityCategory, -// @JsonKey(name: 'assumed_state') bool? assumedState, -// @JsonKey(name: 'device_class') String? deviceClass, -// }) = _EsphomePythonApiSwitchInfoObjectType; -// -// EsphomePythonApiSwitchInfoObjectType._(); -// -// factory EsphomePythonApiSwitchInfoObjectType.fromJson( -// Map json, -// ) => -// _$EsphomePythonApiSwitchInfoObjectTypeFromJson(json); -// -// EspHomeSwitchEntity toEspHomeSwitchEntity({ -// required String address, -// required String mDnsName, -// required String? port, -// }) { -// return EspHomeSwitchEntity( -// uniqueId: CoreUniqueId(), -// entityUniqueId: EntityUniqueId.fromUniqueString(uniqueId!), -// cbjEntityName: CbjEntityName(name), -// entityStateGRPC: EntityState(EntityStateGRPC.ack.toString()), -// stateMassage: DeviceStateMassage('EspHome Created'), -// senderDeviceOs: DeviceSenderDeviceOs('ESPHome'), -// senderDeviceModel: DeviceSenderDeviceModel('ESPHome model'), -// senderId: DeviceSenderId.fromUniqueString('No sender id'), -// compUuid: DeviceCompUuid('No comp uuid'), -// powerConsumption: DevicePowerConsumption('0'), -// switchState: GenericSwitchSwitchState(EntityActions.off.toString()), -// deviceMdnsName: DeviceMdnsName(mDnsName), -// devicePort: DevicePort(port), -// espHomeKey: EspHomeKey(key.toString()), -// lastKnownIp: DeviceLastKnownIp(address), -// ); -// } -// } diff --git a/lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_files/get_esphome_entities.py b/lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_files/get_esphome_entities.py deleted file mode 100644 index 2e7d6b52..00000000 --- a/lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_files/get_esphome_entities.py +++ /dev/null @@ -1,43 +0,0 @@ -import json -import sys - -import aioesphomeapi -import asyncio - - -async def main(): - """Connect to an ESPHome device and get details.""" - - if len(sys.argv) < 4: - print('Not enough arguments') - await result_in_new_massage() - print('Error 1') - exit(1) - device_address = sys.argv[1] - device_port = int(sys.argv[2]) - device_password = sys.argv[3] - - # Establish connection - api = aioesphomeapi.APIClient(device_address, device_port, device_password) - await api.connect(login=True) - device_info = await api.device_info() - - # List all entities of the device - entities = await api.list_entities_services() - - for entity_list in entities: - for entity_temp in entity_list: - type_me = type(entity_temp).__name__ - print(type_me) - await result_in_new_massage() - print(json.dumps(entity_temp.__dict__)) - await result_in_new_massage() - await result_in_new_massage() - - -async def result_in_new_massage(): - await asyncio.sleep(2) - - -loop = asyncio.get_event_loop() -loop.run_until_complete(main()) diff --git a/lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_files/turn_on_off_light_entity_esphome_devices.py b/lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_files/turn_on_off_light_entity_esphome_devices.py deleted file mode 100644 index 322c9a92..00000000 --- a/lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_files/turn_on_off_light_entity_esphome_devices.py +++ /dev/null @@ -1,34 +0,0 @@ -import sys - -import aioesphomeapi -import asyncio - - -async def main(): - - if len(sys.argv) < 6: - print('Not enough arguments') - await result_in_new_massage() - print('Error 1') - exit(1) - device_address = sys.argv[1] - device_port = int(sys.argv[2]) - device_password = sys.argv[3] - - device_key = int(sys.argv[4]) - - device_new_state = True - if "false" == sys.argv[5].lower() or "0" == sys.argv[5]: - device_new_state = False - - # Establish connection - api = aioesphomeapi.APIClient(device_address, device_port, device_password) - await api.connect(login=True) - await api.light_command(device_key, device_new_state) - - -async def result_in_new_massage(): - await asyncio.sleep(0.0001) - -loop = asyncio.get_event_loop() -loop.run_until_complete(main()) diff --git a/lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_files/turn_on_off_switch_entity_esphome_devices.py b/lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_files/turn_on_off_switch_entity_esphome_devices.py deleted file mode 100644 index 53c5a569..00000000 --- a/lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_files/turn_on_off_switch_entity_esphome_devices.py +++ /dev/null @@ -1,34 +0,0 @@ -import sys - -import aioesphomeapi -import asyncio - - -async def main(): - - if len(sys.argv) < 6: - print('Not enough arguments') - await result_in_new_massage() - print('Error 1') - exit(1) - device_address = sys.argv[1] - device_port = int(sys.argv[2]) - device_password = sys.argv[3] - - device_key = int(sys.argv[4]) - - device_new_state = True - if "false" == sys.argv[5].lower() or "0" == sys.argv[5]: - device_new_state = False - - # Establish connection - api = aioesphomeapi.APIClient(device_address, device_port, device_password) - await api.connect(login=True) - await api.switch_command(device_key, device_new_state) - - -async def result_in_new_massage(): - await asyncio.sleep(0.0001) - -loop = asyncio.get_event_loop() -loop.run_until_complete(main()) diff --git a/lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_json_objects_type.dart b/lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_json_objects_type.dart deleted file mode 100644 index 47a8fdf8..00000000 --- a/lib/infrastructure/devices/esphome/esphome_python_api/esphome_python_json_objects_type.dart +++ /dev/null @@ -1,54 +0,0 @@ -// import 'dart:convert'; -// -// import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -// import 'package:cbj_hub/infrastructure/devices/esphome/esphome_python_api/esphome_python_api_device_types/esphome_python_api_light_info_object_type.dart'; -// import 'package:cbj_hub/utils.dart'; -// -// class EsphomePythonJsonObjectsType { -// static DeviceEntityAbstract? getDeviceAsAbstractIfExist({ -// required String address, -// required String mDnsName, -// required String? port, -// required String currentType, -// required String deviceJson, -// }) { -// DeviceEntityAbstract? deviceEntityAbstract; -// try { -// final dynamic jsonDecodeOutput = json.decode(deviceJson); -// final Map deviceJsonMap = -// jsonDecodeOutput as Map; -// -// if (currentType == 'LightInfo') { -// final EsphomePythonApiLightInfoObjectType lightObject = -// EsphomePythonApiLightInfoObjectType.fromJson(deviceJsonMap); -// deviceEntityAbstract = lightObject.toEspHomeLightEntity( -// address: address, -// mDnsName: mDnsName, -// port: port, -// ); -// } -// // else if (currentType == 'SwitchInfo') { -// // final EsphomePythonApiSwitchInfoObjectType switchObject = -// // EsphomePythonApiSwitchInfoObjectType.fromJson(deviceJsonMap); -// // deviceEntityAbstract = switchObject.toEspHomeSwitchEntity( -// // address: address, -// // mDnsName: mDnsName, -// // port: port, -// // ); -// // } -// // else if (currentType == 'BinarySensorInfo') { -// // logger.t('Esphome BinarySensorInfo is currently not supported'); -// // } -// else { -// logger -// .v('Esphome entity type is currently not supported: $currentType'); -// } -// } catch (e) { -// logger.e( -// 'Error converting esphome python device to esphome dart device\n$e', -// ); -// } -// -// return deviceEntityAbstract; -// } -// } diff --git a/lib/infrastructure/devices/esphome/esphome_switch/esphome_switch_entity.dart b/lib/infrastructure/devices/esphome/esphome_switch/esphome_switch_entity.dart deleted file mode 100644 index f49a8dfb..00000000 --- a/lib/infrastructure/devices/esphome/esphome_switch/esphome_switch_entity.dart +++ /dev/null @@ -1,166 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_value_objects.dart'; -import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/injection.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; -import 'package:nodered/nodered.dart'; - -class EspHomeSwitchEntity extends GenericSwitchDE { - EspHomeSwitchEntity({ - required super.uniqueId, - required super.entityUniqueId, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required super.switchState, - }) : super( - deviceVendor: DeviceVendor(VendorsAndServices.espHome.toString()), - ); - - factory EspHomeSwitchEntity.fromGeneric(GenericSwitchDE genericDevice) { - return EspHomeSwitchEntity( - uniqueId: genericDevice.uniqueId, - entityUniqueId: genericDevice.entityUniqueId, - cbjEntityName: genericDevice.cbjEntityName, - entityOriginalName: genericDevice.entityOriginalName, - deviceOriginalName: genericDevice.deviceOriginalName, - stateMassage: genericDevice.stateMassage, - senderDeviceOs: genericDevice.senderDeviceOs, - senderDeviceModel: genericDevice.senderDeviceModel, - senderId: genericDevice.senderId, - compUuid: genericDevice.compUuid, - entityStateGRPC: genericDevice.entityStateGRPC, - powerConsumption: genericDevice.powerConsumption, - deviceUniqueId: genericDevice.deviceUniqueId, - devicePort: genericDevice.devicePort, - deviceLastKnownIp: genericDevice.deviceLastKnownIp, - deviceHostName: genericDevice.deviceHostName, - deviceMdns: genericDevice.deviceMdns, - devicesMacAddress: genericDevice.devicesMacAddress, - entityKey: genericDevice.entityKey, - requestTimeStamp: genericDevice.requestTimeStamp, - lastResponseFromDeviceTimeStamp: - genericDevice.lastResponseFromDeviceTimeStamp, - deviceCbjUniqueId: genericDevice.deviceCbjUniqueId, - switchState: genericDevice.switchState, - ); - } - - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - if (newEntity is! GenericSwitchDE) { - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Not the correct type', - ), - ); - } - - try { - if (newEntity.switchState!.getOrCrash() != switchState!.getOrCrash() || - entityStateGRPC.getOrCrash() != EntityStateGRPC.ack.toString()) { - final EntityActions? actionToPreform = - EnumHelperCbj.stringToDeviceAction( - newEntity.switchState!.getOrCrash(), - ); - - if (actionToPreform == EntityActions.on) { - (await turnOnSwitch()).fold((l) { - logger.e('Error turning ESPHome switch on'); - throw l; - }, (r) { - logger.i('ESPHome switch turn on success'); - }); - } else if (actionToPreform == EntityActions.off) { - (await turnOffSwitch()).fold((l) { - logger.e('Error turning ESPHome switch off'); - throw l; - }, (r) { - logger.i('ESPHome switch turn off success'); - }); - } else { - logger.e('actionToPreform is not set correctly ESPHome switch'); - } - } - entityStateGRPC = EntityState(EntityStateGRPC.ack.toString()); - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - return right(unit); - } catch (e) { - entityStateGRPC = EntityState(EntityStateGRPC.newStateFailed.toString()); - // - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> turnOnSwitch() async { - switchState = GenericSwitchSwitchState(EntityActions.on.toString()); - try { - final String nodeRedApiBaseTopic = - getIt().getNodeRedApiBaseTopic(); - - final String nodeRedDevicesTopic = - getIt().getNodeRedDevicesTopicTypeName(); - final String topic = - '$nodeRedApiBaseTopic/$nodeRedDevicesTopic/${entityKey.getOrCrash()}/${EspHomeNodeRedApi.deviceStateProperty}/${EspHomeNodeRedApi.inputDeviceProperty}'; - - getIt() - .publishMessage(topic, """{"state":true}"""); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - return right(unit); - } - - @override - Future> turnOffSwitch() async { - switchState = GenericSwitchSwitchState(EntityActions.off.toString()); - - try { - final String nodeRedApiBaseTopic = - getIt().getNodeRedApiBaseTopic(); - - final String nodeRedDevicesTopic = - getIt().getNodeRedDevicesTopicTypeName(); - final String topic = - '$nodeRedApiBaseTopic/$nodeRedDevicesTopic/${entityKey.getOrCrash()}/${EspHomeNodeRedApi.deviceStateProperty}/${EspHomeNodeRedApi.inputDeviceProperty}'; - - getIt() - .publishMessage(topic, """{"state":false}"""); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - return right(unit); - } -} diff --git a/lib/infrastructure/devices/ewelink/ewelink_connector_conjector.dart b/lib/infrastructure/devices/ewelink/ewelink_connector_conjector.dart deleted file mode 100644 index a54eb84e..00000000 --- a/lib/infrastructure/devices/ewelink/ewelink_connector_conjector.dart +++ /dev/null @@ -1,160 +0,0 @@ -import 'dart:async'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/saved_devices/i_saved_devices_repo.dart'; -import 'package:cbj_hub/domain/vendors/ewelink_login/generic_ewelink_login_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/companies_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/ewelink/ewelink_helpers.dart'; -import 'package:cbj_hub/infrastructure/devices/ewelink/ewelink_switch/ewelink_switch_entity.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/abstract_company_connector_conjector.dart'; -import 'package:cbj_hub/injection.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dart_ewelink_api/dart_ewelink_api.dart'; -import 'package:injectable/injectable.dart'; -import 'package:network_tools/network_tools.dart'; - -@singleton -class EwelinkConnectorConjector implements AbstractCompanyConnectorConjector { - static const List mdnsTypes = ['_ewelink._tcp']; - - Ewelink? ewelink; - - @override - Map companyDevices = {}; - - Future accountLogin( - GenericEwelinkLoginDE loginDE, - ) async { - try { - ewelink = Ewelink( - email: loginDE.ewelinkAccountEmail.getOrCrash(), - password: loginDE.ewelinkAccountPass.getOrCrash(), - ); - - await ewelink!.getCredentials(); - discoverNewDevices(activeHost: null); - } on EwelinkInvalidAccessToken { - logger.e('invalid access token'); - return false; - } on EwelinkOfflineDeviceException { - logger.e('device is offline'); - return false; - } catch (e) { - logger.e('EweLink error: $e'); - return false; - } - return true; - } - - Future? didRequestLogin; - Future discoverNewDevices({ - required ActiveHost? activeHost, - }) async { - if (didRequestLogin != null) { - return; - } - - if (ewelink == null) { - didRequestLogin = accountLogin(GenericEwelinkLoginDE.empty()); - if (!await didRequestLogin!) { - didRequestLogin = null; - logger.w( - 'eWeLink device got found but missing a email and password, please add ' - 'it in the app'); - return; - } - } - didRequestLogin = null; - - List devices; - try { - devices = await ewelink!.getDevices(); - } catch (e) { - return; - } - - for (final EwelinkDevice ewelinkDevice in devices) { - // Getting device by id adds additional info in the result - final EwelinkDevice ewelinkDeviceWithTag = - await ewelink!.getDevice(deviceId: ewelinkDevice.deviceid); - - final List entityList = - EwelinkHelpers.addDiscoverdDevice(ewelinkDeviceWithTag); - - for (final DeviceEntityAbstract deviceEntityAbstract in entityList) { - if (companyDevices[ - '${deviceEntityAbstract.deviceUniqueId.getOrCrash()}-${deviceEntityAbstract.entityUniqueId.getOrCrash()}'] != - null) { - continue; - } - - final DeviceEntityAbstract deviceToAdd = - CompaniesConnectorConjector.addDiscoverdDeviceToHub( - deviceEntityAbstract, - ); - - final MapEntry deviceAsEntry = MapEntry( - '${deviceEntityAbstract.deviceUniqueId.getOrCrash()}-${deviceEntityAbstract.entityUniqueId.getOrCrash()}', - deviceToAdd, - ); - - companyDevices.addEntries([deviceAsEntry]); - - logger.i( - 'New EweLink devices name:${deviceEntityAbstract.cbjEntityName.getOrCrash()}', - ); - } - } - getIt().saveAndActivateSmartDevicesToDb(); - } - - @override - Future manageHubRequestsForDevice( - DeviceEntityAbstract ewelinkDE, - ) async { - if (ewelink == null || companyDevices.isEmpty) { - await waitUntilConnectionEstablished(0); - } - - final DeviceEntityAbstract? device = companyDevices[ - '${ewelinkDE.deviceUniqueId.getOrCrash()}-${ewelinkDE.entityUniqueId.getOrCrash()}']; - - if (device is EwelinkSwitchEntity) { - device.executeDeviceAction(newEntity: ewelinkDE); - } else { - logger.w('Ewelink device type does not exist'); - } - } - - @override - Future setUpDeviceFromDb(DeviceEntityAbstract deviceEntity) async { - DeviceEntityAbstract? nonGenericDevice; - if (ewelink == null || companyDevices.isEmpty) { - await waitUntilConnectionEstablished(0); - } - if (deviceEntity is EwelinkSwitchEntity) { - nonGenericDevice = EwelinkSwitchEntity.fromGeneric(deviceEntity); - } - - if (nonGenericDevice == null) { - logger.w('EweLink device could not get loaded from the server'); - return; - } - - companyDevices.addEntries([ - MapEntry( - '${nonGenericDevice.deviceUniqueId.getOrCrash()}-${nonGenericDevice.entityUniqueId.getOrCrash()}', - nonGenericDevice, - ), - ]); - } - - Future waitUntilConnectionEstablished(int executed) async { - if (executed > 20 || ewelink != null) { - await Future.delayed(const Duration(seconds: 50)); - return; - } - await Future.delayed(const Duration(seconds: 20)); - return waitUntilConnectionEstablished(executed + 1); - } -} diff --git a/lib/infrastructure/devices/ewelink/ewelink_device_validators.dart b/lib/infrastructure/devices/ewelink/ewelink_device_validators.dart deleted file mode 100644 index 8c744359..00000000 --- a/lib/infrastructure/devices/ewelink/ewelink_device_validators.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateEwelinkIdNotEmpty(String input) { - return right(input); -} - -Either, String> validateEwelinkPortNotEmpty( - String input, -) { - return right(input); -} diff --git a/lib/infrastructure/devices/ewelink/ewelink_helpers.dart b/lib/infrastructure/devices/ewelink/ewelink_helpers.dart deleted file mode 100644 index 232ccfd0..00000000 --- a/lib/infrastructure/devices/ewelink/ewelink_helpers.dart +++ /dev/null @@ -1,120 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_value_objects.dart'; -import 'package:cbj_hub/infrastructure/devices/ewelink/ewelink_switch/ewelink_switch_entity.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:dart_ewelink_api/dart_ewelink_api.dart'; - -class EwelinkHelpers { - static List addDiscoverdDevice( - EwelinkDevice ewelinkDevice, - ) { - final List deviceEntityAbstractList = []; - - if (ewelinkDevice.type == 'a9') { - deviceEntityAbstractList.add( - EwelinkSwitchEntity( - uniqueId: CoreUniqueId(), - entityUniqueId: EntityUniqueId(ewelinkDevice.deviceid), - cbjEntityName: CbjEntityName(ewelinkDevice.name), - entityOriginalName: EntityOriginalName(ewelinkDevice.name), - deviceOriginalName: DeviceOriginalName(ewelinkDevice.name), - stateMassage: DeviceStateMassage('ok'), - senderDeviceOs: DeviceSenderDeviceOs('EweLink'), - senderDeviceModel: DeviceSenderDeviceModel(ewelinkDevice.type), - senderId: DeviceSenderId(), - deviceUniqueId: DeviceUniqueId(ewelinkDevice.deviceid), - devicePort: DevicePort(''), - deviceLastKnownIp: DeviceLastKnownIp(''), - deviceHostName: DeviceHostName('0'), - deviceMdns: DeviceMdns('0'), - compUuid: DeviceCompUuid('empty'), - powerConsumption: DevicePowerConsumption('0'), - devicesMacAddress: DevicesMacAddress('0'), - // TODO: Fix because we can't use the outlet number from entityUniqueId - entityKey: EntityKey('1'), - requestTimeStamp: RequestTimeStamp('0'), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp('0'), - deviceCbjUniqueId: CoreUniqueId(), - switchState: GenericSwitchSwitchState('off'), - entityStateGRPC: EntityState(EntityStateGRPC.ack.toString()), - ), - ); - } else if (ewelinkDevice.type == '10') { - if (ewelinkDevice.params.switches == null) { - return deviceEntityAbstractList; - } - - final List> mapOfSwitches = - ewelinkDevice.params.switches!; - - final Map? possibleTags = - ewelinkDevice.tags?.entityNames; - - for (int i = 0; i < mapOfSwitches.length - 1; i++) { - final Map switchParam = mapOfSwitches[i]; - final String outletNumber = (switchParam['outlet'] as int).toString(); - - String tagName = '${ewelinkDevice.name} outlet $outletNumber'; - - if (possibleTags != null) { - if (i <= possibleTags.length - 1) { - tagName = possibleTags[i.toString()] as String; - } else { - // Device can have multiple switches, the device is purpose for 4 - // switches inside of it even if this is a unit of 2. - // So we return only switch with names because unused switches on the - // device does not have name (tag) - continue; - } - } else { - // Devices without tags at all are legit and will be added only once - } - - deviceEntityAbstractList.add( - EwelinkSwitchEntity( - uniqueId: CoreUniqueId(), - // TODO: This is temp fix, if there are multiple outlet with the - // same number for example 0 then only the last one will be - // displayed without this fix as they are not unique enough and get - // override somewhere in the process. - entityUniqueId: - EntityUniqueId('${ewelinkDevice.deviceid}-$outletNumber'), - cbjEntityName: CbjEntityName( - tagName, - ), - entityOriginalName: EntityOriginalName( - tagName, - ), - deviceOriginalName: DeviceOriginalName(ewelinkDevice.name), - stateMassage: DeviceStateMassage('ok'), - senderDeviceOs: DeviceSenderDeviceOs('EweLink'), - senderDeviceModel: DeviceSenderDeviceModel(ewelinkDevice.type), - senderId: DeviceSenderId(), - deviceUniqueId: DeviceUniqueId(ewelinkDevice.deviceid), - devicePort: DevicePort(''), - deviceLastKnownIp: DeviceLastKnownIp(''), - deviceHostName: DeviceHostName('0'), - deviceMdns: DeviceMdns('0'), - compUuid: DeviceCompUuid('empty'), - powerConsumption: DevicePowerConsumption('0'), - devicesMacAddress: DevicesMacAddress('0'), - // TODO: Fix because we can't use the outlet number from entityUniqueId - entityKey: EntityKey(outletNumber), - requestTimeStamp: RequestTimeStamp('0'), - lastResponseFromDeviceTimeStamp: - LastResponseFromDeviceTimeStamp('0'), - deviceCbjUniqueId: CoreUniqueId(), - switchState: - GenericSwitchSwitchState(switchParam['switch'] as String), - entityStateGRPC: EntityState(EntityStateGRPC.ack.toString()), - ), - ); - if (possibleTags == null) { - break; - } - } - } - return deviceEntityAbstractList; - } -} diff --git a/lib/infrastructure/devices/ewelink/ewelink_switch/ewelink_switch_entity.dart b/lib/infrastructure/devices/ewelink/ewelink_switch/ewelink_switch_entity.dart deleted file mode 100644 index 0796cf72..00000000 --- a/lib/infrastructure/devices/ewelink/ewelink_switch/ewelink_switch_entity.dart +++ /dev/null @@ -1,159 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_value_objects.dart'; -import 'package:cbj_hub/infrastructure/devices/ewelink/ewelink_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/injection.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; - -class EwelinkSwitchEntity extends GenericSwitchDE { - EwelinkSwitchEntity({ - required super.uniqueId, - required super.entityUniqueId, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required super.switchState, - }) : super( - deviceVendor: - DeviceVendor(VendorsAndServices.sonoffEweLink.toString()), - ); - - factory EwelinkSwitchEntity.fromGeneric(GenericSwitchDE genericDevice) { - return EwelinkSwitchEntity( - uniqueId: genericDevice.uniqueId, - entityUniqueId: genericDevice.entityUniqueId, - cbjEntityName: genericDevice.cbjEntityName, - entityOriginalName: genericDevice.entityOriginalName, - deviceOriginalName: genericDevice.deviceOriginalName, - stateMassage: genericDevice.stateMassage, - senderDeviceOs: genericDevice.senderDeviceOs, - senderDeviceModel: genericDevice.senderDeviceModel, - senderId: genericDevice.senderId, - compUuid: genericDevice.compUuid, - entityStateGRPC: genericDevice.entityStateGRPC, - powerConsumption: genericDevice.powerConsumption, - deviceUniqueId: genericDevice.deviceUniqueId, - devicePort: genericDevice.devicePort, - deviceLastKnownIp: genericDevice.deviceLastKnownIp, - deviceHostName: genericDevice.deviceHostName, - deviceMdns: genericDevice.deviceMdns, - devicesMacAddress: genericDevice.devicesMacAddress, - entityKey: genericDevice.entityKey, - requestTimeStamp: genericDevice.requestTimeStamp, - lastResponseFromDeviceTimeStamp: - genericDevice.lastResponseFromDeviceTimeStamp, - deviceCbjUniqueId: genericDevice.deviceCbjUniqueId, - switchState: genericDevice.switchState, - ); - } - - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - if (newEntity is! GenericSwitchDE) { - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Not the correct type', - ), - ); - } - - try { - if (newEntity.switchState!.getOrCrash() != switchState!.getOrCrash() || - entityStateGRPC.getOrCrash() != EntityStateGRPC.ack.toString()) { - final EntityActions? actionToPreform = - EnumHelperCbj.stringToDeviceAction( - newEntity.switchState!.getOrCrash(), - ); - - if (actionToPreform == EntityActions.on) { - (await turnOnSwitch()).fold((l) { - logger.e('Error turning EweLink switch on'); - throw l; - }, (r) { - logger.i('EweLink switch turn on success'); - }); - } else if (actionToPreform == EntityActions.off) { - (await turnOffSwitch()).fold((l) { - logger.e('Error turning EweLink switch off'); - throw l; - }, (r) { - logger.i('EweLink switch turn off success'); - }); - } else { - logger.e('actionToPreform is not set correctly EweLink switch'); - } - } - entityStateGRPC = EntityState(EntityStateGRPC.ack.toString()); - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - return right(unit); - } catch (e) { - entityStateGRPC = EntityState(EntityStateGRPC.newStateFailed.toString()); - // - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> turnOnSwitch() async { - switchState = GenericSwitchSwitchState(EntityActions.on.toString()); - try { - await getIt().ewelink?.setDevicePowerState( - deviceId: deviceUniqueId.getOrCrash(), - state: 'on', - // TODO: Bug in api, channel 1 get changed no matter the input - // https://github.com/ianmaciel/dart_ewelink_api/issues/21 - channel: entityKey.getOrCrash(), - ); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - return right(unit); - } - - @override - Future> turnOffSwitch() async { - switchState = GenericSwitchSwitchState(EntityActions.off.toString()); - try { - await getIt().ewelink?.setDevicePowerState( - deviceId: deviceUniqueId.getOrCrash(), - state: 'off', - // TODO: Bug in api, channel 1 get changed no matter the input - // https://github.com/ianmaciel/dart_ewelink_api/issues/21 - channel: entityKey.getOrCrash(), - ); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - return right(unit); - } -} diff --git a/lib/infrastructure/devices/google/chrome_cast/chrome_cast_entity.dart b/lib/infrastructure/devices/google/chrome_cast/chrome_cast_entity.dart deleted file mode 100644 index 24cd657f..00000000 --- a/lib/infrastructure/devices/google/chrome_cast/chrome_cast_entity.dart +++ /dev/null @@ -1,378 +0,0 @@ -import 'dart:async'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_tv/generic_smart_tv_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_tv/generic_smart_tv_value_objects.dart'; -import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/node_red/node_red_repository.dart'; -import 'package:cbj_hub/injection.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; -import 'package:nodered/nodered.dart'; - -class ChromeCastEntity extends GenericSmartTvDE { - ChromeCastEntity({ - required super.uniqueId, - required super.entityUniqueId, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required super.smartTvSwitchState, - super.openUrl, - super.pausePlayState, - super.skip, - super.volume, - this.deviceMdnsName, - this.lastKnownIp, - }) : super( - deviceVendor: DeviceVendor(VendorsAndServices.google.toString()), - ) { - setUpNodeRedApi(); - } - - factory ChromeCastEntity.fromGeneric(GenericSmartTvDE genericDevice) { - return ChromeCastEntity( - uniqueId: genericDevice.uniqueId, - entityUniqueId: genericDevice.entityUniqueId, - cbjEntityName: genericDevice.cbjEntityName, - entityOriginalName: genericDevice.entityOriginalName, - deviceOriginalName: genericDevice.deviceOriginalName, - stateMassage: genericDevice.stateMassage, - senderDeviceOs: genericDevice.senderDeviceOs, - senderDeviceModel: genericDevice.senderDeviceModel, - senderId: genericDevice.senderId, - compUuid: genericDevice.compUuid, - entityStateGRPC: genericDevice.entityStateGRPC, - powerConsumption: genericDevice.powerConsumption, - deviceUniqueId: genericDevice.deviceUniqueId, - devicePort: genericDevice.devicePort, - deviceLastKnownIp: genericDevice.deviceLastKnownIp, - deviceHostName: genericDevice.deviceHostName, - deviceMdns: genericDevice.deviceMdns, - devicesMacAddress: genericDevice.devicesMacAddress, - entityKey: genericDevice.entityKey, - requestTimeStamp: genericDevice.requestTimeStamp, - lastResponseFromDeviceTimeStamp: - genericDevice.lastResponseFromDeviceTimeStamp, - deviceCbjUniqueId: genericDevice.deviceCbjUniqueId, - smartTvSwitchState: genericDevice.smartTvSwitchState, - ); - } - - DeviceLastKnownIp? lastKnownIp; - - DeviceMdns? deviceMdnsName; - - late ChromecastNodeRedApi chromecastNodeRedApi; - - Future setUpNodeRedApi() async { - // TODO: add check to add uniqueId + action as flow in node read only if missing - if (lastKnownIp == null) { - logger.w('Chromecast last known ip is null'); - return; - } - - chromecastNodeRedApi = ChromecastNodeRedApi( - repository: getIt(), - nodeRedApiBaseTopic: - getIt().getNodeRedApiBaseTopic(), - nodeRedDevicesTopic: - getIt().getNodeRedDevicesTopicTypeName(), - nodeRedMqttBrokerNodeName: 'Cbj NodeRed plugs Api Broker', - ); - - chromecastNodeRedApi.setNewYoutubeVideoNodes( - uniqueId.getOrCrash(), - lastKnownIp!.getOrCrash(), - ); - } - - /// Please override the following methods - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - if (newEntity is! GenericSmartTvDE) { - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Not the correct type', - ), - ); - } - - try { - if (newEntity.openUrl?.getOrCrash() != null && - (newEntity.openUrl?.getOrCrash() != openUrl?.getOrCrash() && - newEntity.entityStateGRPC.getOrCrash() != - EntityStateGRPC.ack.toString())) { - (await sendUrlToDevice(newEntity.openUrl!.getOrCrash())).fold((l) { - logger.e('Error opening url on ChromeCast'); - throw l; - }, (r) { - logger.i('ChromeCast opening url success'); - }); - } - - if (newEntity.pausePlayState?.getOrCrash() != null && - (newEntity.pausePlayState?.getOrCrash() != - pausePlayState?.getOrCrash() && - newEntity.entityStateGRPC.getOrCrash() != - EntityStateGRPC.ack.toString())) { - (await togglePausePlay(newEntity.pausePlayState!.getOrCrash())).fold( - (l) { - logger.e('Error toggle pause or play on ChromeCast'); - throw l; - }, (r) { - logger.i('ChromeCast toggle pause or play success'); - }); - } - - entityStateGRPC = EntityState(EntityStateGRPC.ack.toString()); - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - return right(unit); - } catch (e) { - entityStateGRPC = EntityState(EntityStateGRPC.newStateFailed.toString()); - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> turnOnSmartTv() async { - try {} catch (e) { - return left(const CoreFailure.unexpected()); - } - return left(const CoreFailure.unexpected()); - } - - @override - Future> turnOffSmartTv() async { - try {} catch (e) { - return left(const CoreFailure.unexpected()); - } - return left(const CoreFailure.unexpected()); - } - - @override - Future> sendUrlToDevice(String newUrl) async { - try { - openUrl = GenericSmartTvOpenUrl(newUrl); - final String nodeRedApiBaseTopic = - getIt().getNodeRedApiBaseTopic(); - - final String nodeRedDevicesTopic = - getIt().getNodeRedDevicesTopicTypeName(); - - final String topic = - '$nodeRedApiBaseTopic/$nodeRedDevicesTopic/${uniqueId.getOrCrash()}/${chromecastNodeRedApi.youtubeVideoTopicProperty}/${chromecastNodeRedApi.playingVideoTopicProperty}'; - - String validYoutubeVidId = openUrl!.getOrCrash(); - if (validYoutubeVidId.contains('?v=')) { - validYoutubeVidId = - validYoutubeVidId.substring(validYoutubeVidId.indexOf('?v=') + 3); - } - if (validYoutubeVidId.contains('&index=')) { - final int valueOfAndIndexEqual = validYoutubeVidId.indexOf('&index='); - validYoutubeVidId = validYoutubeVidId.substring( - 0, - valueOfAndIndexEqual, - ); - } - if (validYoutubeVidId.contains('&list=')) { - final int valueOfAndIndexEqual = validYoutubeVidId.indexOf('&list='); - validYoutubeVidId = validYoutubeVidId.substring( - 0, - valueOfAndIndexEqual, - ); - } - getIt().publishMessage(topic, validYoutubeVidId); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - return right(unit); - } - - @override - Future> togglePausePlay( - String toggleNewState, - ) async { - if (toggleNewState == EntityActions.pause.toString()) { - return togglePause(); - } else if (toggleNewState == EntityActions.play.toString()) { - return togglePlay(); - } else if (toggleNewState == EntityActions.stop.toString()) { - return toggleStop(); - } else if (toggleNewState == EntityActions.skipPreviousVid.toString()) { - return queuePrev(); - } else if (toggleNewState == EntityActions.skipNextVid.toString()) { - return queueNext(); - } else if (toggleNewState == EntityActions.close.toString()) { - return closeApp(); - } - return left(const CoreFailure.unexpected()); - } - - @override - Future> togglePause() async { - try { - pausePlayState = - GenericSmartTvPausePlayState(EntityActions.pause.toString()); - - final String nodeRedApiBaseTopic = - getIt().getNodeRedApiBaseTopic(); - - final String nodeRedDevicesTopic = - getIt().getNodeRedDevicesTopicTypeName(); - - final String topic = - '$nodeRedApiBaseTopic/$nodeRedDevicesTopic/${uniqueId.getOrCrash()}/${chromecastNodeRedApi.youtubeVideoTopicProperty}/${chromecastNodeRedApi.pauseVideoTopicProperty}'; - - getIt() - .publishMessage(topic, 'Media Command Pause'); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - return right(unit); - } - - @override - Future> togglePlay() async { - try { - pausePlayState = - GenericSmartTvPausePlayState(EntityActions.play.toString()); - - final String nodeRedApiBaseTopic = - getIt().getNodeRedApiBaseTopic(); - - final String nodeRedDevicesTopic = - getIt().getNodeRedDevicesTopicTypeName(); - - final String topic = - '$nodeRedApiBaseTopic/$nodeRedDevicesTopic/${uniqueId.getOrCrash()}/${chromecastNodeRedApi.youtubeVideoTopicProperty}/${chromecastNodeRedApi.playVideoTopicProperty}'; - - getIt() - .publishMessage(topic, 'Media Command Play'); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - return right(unit); - } - - @override - Future> toggleStop() async { - try { - pausePlayState = - GenericSmartTvPausePlayState(EntityActions.stop.toString()); - - final String nodeRedApiBaseTopic = - getIt().getNodeRedApiBaseTopic(); - - final String nodeRedDevicesTopic = - getIt().getNodeRedDevicesTopicTypeName(); - - final String topic = - '$nodeRedApiBaseTopic/$nodeRedDevicesTopic/${uniqueId.getOrCrash()}/${chromecastNodeRedApi.youtubeVideoTopicProperty}/${chromecastNodeRedApi.stopVideoTopicProperty}'; - - getIt() - .publishMessage(topic, 'Media Command Stop'); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - return right(unit); - } - - @override - Future> queuePrev() async { - try { - pausePlayState = GenericSmartTvPausePlayState( - EntityActions.skipPreviousVid.toString(), - ); - - final String nodeRedApiBaseTopic = - getIt().getNodeRedApiBaseTopic(); - - final String nodeRedDevicesTopic = - getIt().getNodeRedDevicesTopicTypeName(); - - final String topic = - '$nodeRedApiBaseTopic/$nodeRedDevicesTopic/${uniqueId.getOrCrash()}/${chromecastNodeRedApi.youtubeVideoTopicProperty}/${chromecastNodeRedApi.queuePrevVideoTopicProperty}'; - - getIt() - .publishMessage(topic, 'Media Command Prev Queue'); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - return right(unit); - } - - @override - Future> queueNext() async { - try { - pausePlayState = - GenericSmartTvPausePlayState(EntityActions.skipNextVid.toString()); - - final String nodeRedApiBaseTopic = - getIt().getNodeRedApiBaseTopic(); - - final String nodeRedDevicesTopic = - getIt().getNodeRedDevicesTopicTypeName(); - - final String topic = - '$nodeRedApiBaseTopic/$nodeRedDevicesTopic/${uniqueId.getOrCrash()}/${chromecastNodeRedApi.youtubeVideoTopicProperty}/${chromecastNodeRedApi.queueNextVideoTopicProperty}'; - - getIt() - .publishMessage(topic, 'Media Command Next Queue'); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - return right(unit); - } - - @override - Future> closeApp() async { - try { - pausePlayState = - GenericSmartTvPausePlayState(EntityActions.close.toString()); - - final String nodeRedApiBaseTopic = - getIt().getNodeRedApiBaseTopic(); - - final String nodeRedDevicesTopic = - getIt().getNodeRedDevicesTopicTypeName(); - - final String topic = - '$nodeRedApiBaseTopic/$nodeRedDevicesTopic/${uniqueId.getOrCrash()}/${chromecastNodeRedApi.youtubeVideoTopicProperty}/${chromecastNodeRedApi.closeAppTopicProperty}'; - - getIt() - .publishMessage(topic, 'Media Command Next Queue'); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - return right(unit); - } -} diff --git a/lib/infrastructure/devices/google/google_connector_conjector.dart b/lib/infrastructure/devices/google/google_connector_conjector.dart deleted file mode 100644 index 8224616c..00000000 --- a/lib/infrastructure/devices/google/google_connector_conjector.dart +++ /dev/null @@ -1,106 +0,0 @@ -import 'dart:async'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_tv/generic_smart_tv_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/companies_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/google/chrome_cast/chrome_cast_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/google/google_helpers.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/abstract_company_connector_conjector.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:injectable/injectable.dart'; - -@singleton -class GoogleConnectorConjector implements AbstractCompanyConnectorConjector { - @override - Map companyDevices = {}; - - static const List mdnsTypes = [ - '_googlecast._tcp', - '_androidtvremote2._tcp', - '_rc._tcp', - ]; - - /// Add new devices to [companyDevices] if not exist - Future addNewDeviceByMdnsName({ - required String mDnsName, - required String ip, - required String port, - }) async { - CoreUniqueId? tempCoreUniqueId; - - for (final DeviceEntityAbstract device in companyDevices.values) { - if (device is ChromeCastEntity && - (mDnsName == device.entityUniqueId.getOrCrash() || - ip == device.lastKnownIp!.getOrCrash())) { - return; - } // Same tv can have multiple mDns names so we can't compere it without ip in the object - // else if (device is GenericSmartTvDE && - // (mDnsName == device.entityUniqueId.getOrCrash() || - // ip == device.lastKnownIp!.getOrCrash())) { - // return; - // } - else if (mDnsName == device.entityUniqueId.getOrCrash()) { - logger.w( - 'Google device type supported but implementation is missing here', - ); - return; - } - } - - final List googleDevice = - GoogleHelpers.addDiscoverdDevice( - mDnsName: mDnsName, - ip: ip, - port: port, - uniqueDeviceId: tempCoreUniqueId, - ); - - if (googleDevice.isEmpty) { - return; - } - - for (final DeviceEntityAbstract entityAsDevice in googleDevice) { - final DeviceEntityAbstract deviceToAdd = - CompaniesConnectorConjector.addDiscoverdDeviceToHub(entityAsDevice); - - final MapEntry deviceAsEntry = - MapEntry(deviceToAdd.entityUniqueId.getOrCrash(), deviceToAdd); - - companyDevices.addEntries([deviceAsEntry]); - } - logger.i('New Chromecast device got added'); - } - - @override - Future manageHubRequestsForDevice(DeviceEntityAbstract googleDE) async { - final DeviceEntityAbstract? device = - companyDevices[googleDE.entityUniqueId.getOrCrash()]; - - if (device is ChromeCastEntity) { - device.executeDeviceAction(newEntity: googleDE); - } else { - logger.w( - 'Google device type does not exist ${device?.entityTypes.getOrCrash()}', - ); - } - } - - @override - Future setUpDeviceFromDb(DeviceEntityAbstract deviceEntity) async { - DeviceEntityAbstract? nonGenericDevice; - - if (deviceEntity is GenericSmartTvDE) { - nonGenericDevice = ChromeCastEntity.fromGeneric(deviceEntity); - } - - if (nonGenericDevice == null) { - logger.w('EspHome device could not get loaded from the server'); - return; - } - - companyDevices.addEntries([ - MapEntry(nonGenericDevice.entityUniqueId.getOrCrash(), nonGenericDevice), - ]); - } -} diff --git a/lib/infrastructure/devices/google/google_device_validators.dart b/lib/infrastructure/devices/google/google_device_validators.dart deleted file mode 100644 index b542fd6d..00000000 --- a/lib/infrastructure/devices/google/google_device_validators.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateGoogleIdNotEmpty(String input) { - return right(input); -} - -Either, String> validateGooglePortNotEmpty(String input) { - return right(input); -} diff --git a/lib/infrastructure/devices/google/google_helpers.dart b/lib/infrastructure/devices/google/google_helpers.dart deleted file mode 100644 index e3e6a42c..00000000 --- a/lib/infrastructure/devices/google/google_helpers.dart +++ /dev/null @@ -1,54 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_tv/generic_smart_tv_value_objects.dart'; -import 'package:cbj_hub/infrastructure/devices/google/chrome_cast/chrome_cast_entity.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; - -class GoogleHelpers { - static List addDiscoverdDevice({ - required String mDnsName, - required String ip, - required String port, - required CoreUniqueId? uniqueDeviceId, - }) { - CoreUniqueId uniqueDeviceIdTemp; - - if (uniqueDeviceId != null) { - uniqueDeviceIdTemp = uniqueDeviceId; - } else { - uniqueDeviceIdTemp = CoreUniqueId(); - } - - final ChromeCastEntity googleDE = ChromeCastEntity( - uniqueId: uniqueDeviceIdTemp, - entityUniqueId: EntityUniqueId(mDnsName), - cbjEntityName: CbjEntityName('Chromecast'), - entityOriginalName: EntityOriginalName('Chromecast'), - deviceOriginalName: DeviceOriginalName('Chromecast'), - entityStateGRPC: EntityState(EntityStateGRPC.ack.toString()), - senderDeviceOs: DeviceSenderDeviceOs('Android'), - senderDeviceModel: DeviceSenderDeviceModel('1SE'), - senderId: DeviceSenderId(), - compUuid: DeviceCompUuid('34asdfrsd23gggg'), - deviceMdnsName: DeviceMdns(mDnsName), - lastKnownIp: DeviceLastKnownIp(ip), - stateMassage: DeviceStateMassage('Hello World'), - powerConsumption: DevicePowerConsumption('0'), - smartTvSwitchState: GenericSmartTvSwitchState( - EntityActions.actionNotSupported.toString(), - ), - deviceUniqueId: DeviceUniqueId('0'), - devicePort: DevicePort(port), - deviceLastKnownIp: DeviceLastKnownIp('0'), - deviceHostName: DeviceHostName('0'), - deviceMdns: DeviceMdns('0'), - devicesMacAddress: DevicesMacAddress('0'), - entityKey: EntityKey('0'), - requestTimeStamp: RequestTimeStamp('0'), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp('0'), - deviceCbjUniqueId: CoreUniqueId(), - ); - - return [googleDE]; - } -} diff --git a/lib/infrastructure/devices/hp/hp_connector_conjector.dart b/lib/infrastructure/devices/hp/hp_connector_conjector.dart deleted file mode 100644 index bbf24ace..00000000 --- a/lib/infrastructure/devices/hp/hp_connector_conjector.dart +++ /dev/null @@ -1,95 +0,0 @@ -import 'dart:async'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_printer_device/generic_printer_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/companies_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/hp/hp_helpers.dart'; -import 'package:cbj_hub/infrastructure/devices/hp/hp_printer/hp_printer_entity.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/abstract_company_connector_conjector.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:injectable/injectable.dart'; - -@singleton -class HpConnectorConjector implements AbstractCompanyConnectorConjector { - static const List mdnsTypes = ['_hplib._tcp']; - - @override - Map companyDevices = {}; - - /// Add new devices to [companyDevices] if not exist - Future addNewDeviceByMdnsName({ - required String mDnsName, - required String ip, - required String port, - }) async { - CoreUniqueId? tempCoreUniqueId; - - for (final DeviceEntityAbstract device in companyDevices.values) { - if (device is HpPrinterEntity && - (mDnsName == device.entityUniqueId.getOrCrash() || - ip == device.deviceLastKnownIp.getOrCrash())) { - return; - } else if (mDnsName == device.entityUniqueId.getOrCrash()) { - logger.w( - 'HP device type supported but implementation is missing here', - ); - return; - } - } - - final List hpDevice = HpHelpers.addDiscoverdDevice( - mDnsName: mDnsName, - ip: ip, - port: port, - uniqueDeviceId: tempCoreUniqueId, - ); - - if (hpDevice.isEmpty) { - return; - } - - for (final DeviceEntityAbstract entityAsDevice in hpDevice) { - final DeviceEntityAbstract deviceToAdd = - CompaniesConnectorConjector.addDiscoverdDeviceToHub(entityAsDevice); - - final MapEntry deviceAsEntry = - MapEntry(deviceToAdd.entityUniqueId.getOrCrash(), deviceToAdd); - - companyDevices.addEntries([deviceAsEntry]); - } - logger.i('New HP device got added'); - } - - @override - Future manageHubRequestsForDevice( - DeviceEntityAbstract hpDE, - ) async { - final DeviceEntityAbstract? device = - companyDevices[hpDE.entityUniqueId.getOrCrash()]; - - if (device is HpPrinterEntity) { - device.executeDeviceAction(newEntity: hpDE); - } else { - logger.w('HP device type does not exist'); - } - } - - @override - Future setUpDeviceFromDb(DeviceEntityAbstract deviceEntity) async { - DeviceEntityAbstract? nonGenericDevice; - - if (deviceEntity is GenericPrinterDE) { - nonGenericDevice = HpPrinterEntity.fromGeneric(deviceEntity); - } - - if (nonGenericDevice == null) { - logger.w('Switcher device could not get loaded from the server'); - return; - } - - companyDevices.addEntries([ - MapEntry(nonGenericDevice.entityUniqueId.getOrCrash(), nonGenericDevice), - ]); - } -} diff --git a/lib/infrastructure/devices/hp/hp_device_validators.dart b/lib/infrastructure/devices/hp/hp_device_validators.dart deleted file mode 100644 index 6d781d7b..00000000 --- a/lib/infrastructure/devices/hp/hp_device_validators.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateESPHomeSwitchKeyNotEmpty( - String input, -) { - return right(input); -} - -Either, String> validateESPHomePortNotEmpty(String input) { - return right(input); -} diff --git a/lib/infrastructure/devices/hp/hp_device_value_objects.dart b/lib/infrastructure/devices/hp/hp_device_value_objects.dart deleted file mode 100644 index 8b137891..00000000 --- a/lib/infrastructure/devices/hp/hp_device_value_objects.dart +++ /dev/null @@ -1 +0,0 @@ - diff --git a/lib/infrastructure/devices/hp/hp_helpers.dart b/lib/infrastructure/devices/hp/hp_helpers.dart deleted file mode 100644 index f3f1bcf3..00000000 --- a/lib/infrastructure/devices/hp/hp_helpers.dart +++ /dev/null @@ -1,51 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_printer_device/generic_printer_value_objects.dart'; -import 'package:cbj_hub/infrastructure/devices/hp/hp_printer/hp_printer_entity.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; - -class HpHelpers { - static List addDiscoverdDevice({ - required String mDnsName, - required String ip, - required String port, - required CoreUniqueId? uniqueDeviceId, - }) { - CoreUniqueId uniqueDeviceIdTemp; - - if (uniqueDeviceId != null) { - uniqueDeviceIdTemp = uniqueDeviceId; - } else { - uniqueDeviceIdTemp = CoreUniqueId(); - } - final HpPrinterEntity lgDE = HpPrinterEntity( - uniqueId: uniqueDeviceIdTemp, - entityUniqueId: EntityUniqueId(mDnsName), - cbjEntityName: CbjEntityName(mDnsName), - entityOriginalName: EntityOriginalName(mDnsName), - deviceOriginalName: DeviceOriginalName(mDnsName), - entityStateGRPC: EntityState(EntityStateGRPC.ack.toString()), - senderDeviceOs: DeviceSenderDeviceOs('HP'), - senderDeviceModel: DeviceSenderDeviceModel('UP7550PVG'), - senderId: DeviceSenderId(), - compUuid: DeviceCompUuid('34asdfrsd23gggg'), - deviceMdns: DeviceMdns(mDnsName), - deviceLastKnownIp: DeviceLastKnownIp(ip), - stateMassage: DeviceStateMassage('Hello World'), - powerConsumption: DevicePowerConsumption('0'), - printerSwitchState: GenericPrinterSwitchState( - EntityActions.actionNotSupported.toString(), - ), - devicePort: DevicePort(port), - deviceUniqueId: DeviceUniqueId('0'), - deviceHostName: DeviceHostName('0'), - devicesMacAddress: DevicesMacAddress('0'), - entityKey: EntityKey('0'), - requestTimeStamp: RequestTimeStamp('0'), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp('0'), - deviceCbjUniqueId: CoreUniqueId(), - ); - - return [lgDE]; - } -} diff --git a/lib/infrastructure/devices/hp/hp_printer/hp_printer_entity.dart b/lib/infrastructure/devices/hp/hp_printer/hp_printer_entity.dart deleted file mode 100644 index 5051a07e..00000000 --- a/lib/infrastructure/devices/hp/hp_printer/hp_printer_entity.dart +++ /dev/null @@ -1,98 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_printer_device/generic_printer_entity.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:dartz/dartz.dart'; - -class HpPrinterEntity extends GenericPrinterDE { - HpPrinterEntity({ - required super.uniqueId, - required super.entityUniqueId, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required super.printerSwitchState, - }) : super( - deviceVendor: DeviceVendor(VendorsAndServices.hp.toString()), - ); - - factory HpPrinterEntity.fromGeneric(GenericPrinterDE genericDevice) { - return HpPrinterEntity( - uniqueId: genericDevice.uniqueId, - entityUniqueId: genericDevice.entityUniqueId, - cbjEntityName: genericDevice.cbjEntityName, - entityOriginalName: genericDevice.entityOriginalName, - deviceOriginalName: genericDevice.deviceOriginalName, - stateMassage: genericDevice.stateMassage, - senderDeviceOs: genericDevice.senderDeviceOs, - senderDeviceModel: genericDevice.senderDeviceModel, - senderId: genericDevice.senderId, - compUuid: genericDevice.compUuid, - entityStateGRPC: genericDevice.entityStateGRPC, - powerConsumption: genericDevice.powerConsumption, - deviceUniqueId: genericDevice.deviceUniqueId, - devicePort: genericDevice.devicePort, - deviceLastKnownIp: genericDevice.deviceLastKnownIp, - deviceHostName: genericDevice.deviceHostName, - deviceMdns: genericDevice.deviceMdns, - devicesMacAddress: genericDevice.devicesMacAddress, - entityKey: genericDevice.entityKey, - requestTimeStamp: genericDevice.requestTimeStamp, - lastResponseFromDeviceTimeStamp: - genericDevice.lastResponseFromDeviceTimeStamp, - deviceCbjUniqueId: genericDevice.deviceCbjUniqueId, - printerSwitchState: genericDevice.printerSwitchState, - ); - } - - static const List mdnsTypes = [ - '_ipp._tcp', - ]; - - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - // logger.i('Currently printer does not support any action'); - // entityStateGRPC = EntityState(EntityStateGRPC.ack.toString()); - // - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - - // entityStateGRPC = EntityState(EntityStateGRPC.newStateFailed.toString()); - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - - return right(unit); - } - - @override - Future> turnOnPrinter() async { - return right(unit); - } - - @override - Future> turnOffPrinter() async { - return right(unit); - } -} diff --git a/lib/infrastructure/devices/lg/lg_connector_conjector.dart b/lib/infrastructure/devices/lg/lg_connector_conjector.dart deleted file mode 100644 index 665f8982..00000000 --- a/lib/infrastructure/devices/lg/lg_connector_conjector.dart +++ /dev/null @@ -1,90 +0,0 @@ -import 'dart:async'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/infrastructure/devices/companies_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/lg/lg_helpers.dart'; -import 'package:cbj_hub/infrastructure/devices/lg/lg_webos_tv/lg_webos_tv_entity.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/abstract_company_connector_conjector.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:injectable/injectable.dart'; - -@singleton -class LgConnectorConjector implements AbstractCompanyConnectorConjector { - @override - Map companyDevices = {}; - - static const List mdnsTypes = [ - '_hap._tcp', - '_display._tcp', - '_airplay._tcp', - ]; - - /// Add new devices to [companyDevices] if not exist - Future addNewDeviceByMdnsName({ - required String mDnsName, - required String ip, - required String port, - }) async { - CoreUniqueId? tempCoreUniqueId; - - for (final DeviceEntityAbstract device in companyDevices.values) { - if (device is LgWebosTvEntity && - (mDnsName == device.entityUniqueId.getOrCrash() || - ip == device.deviceLastKnownIp.getOrCrash())) { - return; - } - // Same tv can have multiple mDns names so we can't compere it without ip in the object - // else if (device is GenericSmartTvDE && - // (mDnsName == device.entityUniqueId.getOrCrash() || - // ip == device.lastKnownIp!.getOrCrash())) { - // return; - // } - else if (mDnsName == device.entityUniqueId.getOrCrash()) { - logger.w( - 'LG device type supported but implementation is missing here', - ); - return; - } - } - - final List lgDevice = LgHelpers.addDiscoverdDevice( - mDnsName: mDnsName, - ip: ip, - port: port, - uniqueDeviceId: tempCoreUniqueId, - ); - - if (lgDevice.isEmpty) { - return; - } - - for (final DeviceEntityAbstract entityAsDevice in lgDevice) { - final DeviceEntityAbstract deviceToAdd = - CompaniesConnectorConjector.addDiscoverdDeviceToHub(entityAsDevice); - - final MapEntry deviceAsEntry = - MapEntry(deviceToAdd.entityUniqueId.getOrCrash(), deviceToAdd); - - companyDevices.addEntries([deviceAsEntry]); - logger.i( - 'New LG device got added ${entityAsDevice.cbjEntityName.getOrCrash()}', - ); - } - } - - @override - Future manageHubRequestsForDevice(DeviceEntityAbstract lgDE) async { - final DeviceEntityAbstract? device = - companyDevices[lgDE.entityUniqueId.getOrCrash()]; - - if (device is LgWebosTvEntity) { - device.executeDeviceAction(newEntity: lgDE); - } else { - logger.i('Lg device type does not exist'); - } - } - - @override - Future setUpDeviceFromDb(DeviceEntityAbstract deviceEntity) async {} -} diff --git a/lib/infrastructure/devices/lg/lg_device_validators.dart b/lib/infrastructure/devices/lg/lg_device_validators.dart deleted file mode 100644 index 65ace3bd..00000000 --- a/lib/infrastructure/devices/lg/lg_device_validators.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateLgIdNotEmpty(String input) { - return right(input); -} - -Either, String> validateLgPortNotEmpty(String input) { - return right(input); -} diff --git a/lib/infrastructure/devices/lg/lg_device_value_objects.dart b/lib/infrastructure/devices/lg/lg_device_value_objects.dart deleted file mode 100644 index 7942102f..00000000 --- a/lib/infrastructure/devices/lg/lg_device_value_objects.dart +++ /dev/null @@ -1,19 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/infrastructure/devices/lg/lg_device_validators.dart'; -import 'package:dartz/dartz.dart'; - -/// Lg communication port -class LgPort extends ValueObjectCore { - factory LgPort(String? input) { - assert(input != null); - return LgPort._( - validateLgPortNotEmpty(input!), - ); - } - - const LgPort._(this.value); - - @override - final Either, String> value; -} diff --git a/lib/infrastructure/devices/lg/lg_helpers.dart b/lib/infrastructure/devices/lg/lg_helpers.dart deleted file mode 100644 index 64e513d7..00000000 --- a/lib/infrastructure/devices/lg/lg_helpers.dart +++ /dev/null @@ -1,42 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; - -class LgHelpers { - static List addDiscoverdDevice({ - required String mDnsName, - required String ip, - required String port, - required CoreUniqueId? uniqueDeviceId, - }) { - return []; - // TODO: Add minimal LG TV api - // CoreUniqueId uniqueDeviceIdTemp; - // - // if (uniqueDeviceId != null) { - // uniqueDeviceIdTemp = uniqueDeviceId; - // } else { - // uniqueDeviceIdTemp = CoreUniqueId(); - // } - // - // final LgWebosTvEntity lgDE = LgWebosTvEntity( - // uniqueId: uniqueDeviceIdTemp, - // entityUniqueId: EntityUniqueId.fromUniqueString(mDnsName), - // cbjEntityName: CbjEntityName('LG TV'), - // entityStateGRPC: EntityState(EntityStateGRPC.ack.toString()), - // senderDeviceOs: DeviceSenderDeviceOs('WebOs'), - // senderDeviceModel: DeviceSenderDeviceModel('UP7550PVG'), - // senderId: DeviceSenderId(), - // compUuid: DeviceCompUuid('34asdfrsd23gggg'), - // deviceMdnsName: DeviceMdnsName(mDnsName), - // lastKnownIp: DeviceLastKnownIp(ip), - // stateMassage: DeviceStateMassage('Hello World'), - // powerConsumption: DevicePowerConsumption('0'), - // port: DevicePort(port), - // smartTvSwitchState: GenericSmartTvSwitchState( - // EntityActions.actionNotSupported.toString(), - // ), - // ); - // - // return [lgDE]; - } -} diff --git a/lib/infrastructure/devices/lg/lg_webos_tv/lg_webos_tv_entity.dart b/lib/infrastructure/devices/lg/lg_webos_tv/lg_webos_tv_entity.dart deleted file mode 100644 index 152b36da..00000000 --- a/lib/infrastructure/devices/lg/lg_webos_tv/lg_webos_tv_entity.dart +++ /dev/null @@ -1,116 +0,0 @@ -import 'dart:async'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_tv/generic_smart_tv_entity.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; - -class LgWebosTvEntity extends GenericSmartTvDE { - LgWebosTvEntity({ - required super.uniqueId, - required super.entityUniqueId, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required super.smartTvSwitchState, - super.openUrl, - super.pausePlayState, - super.skip, - super.volume, - }) : super( - deviceVendor: DeviceVendor(VendorsAndServices.lg.toString()), - ); - - /// Please override the following methods - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - if (newEntity is! GenericRgbwLightDE) { - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Not the correct type', - ), - ); - } - - try { - if (newEntity.lightSwitchState!.getOrCrash() != - smartTvSwitchState!.getOrCrash() || - entityStateGRPC.getOrCrash() != EntityStateGRPC.ack.toString()) { - final EntityActions? actionToPreform = - EnumHelperCbj.stringToDeviceAction( - newEntity.lightSwitchState!.getOrCrash(), - ); - - if (actionToPreform == EntityActions.on) { - (await turnOnSmartTv()).fold((l) { - logger.e('Error turning WebOs on'); - throw l; - }, (r) { - logger.i('WebOs turn on success'); - }); - } else if (actionToPreform == EntityActions.off) { - (await turnOffSmartTv()).fold((l) { - logger.e('Error turning WebOs off'); - throw l; - }, (r) { - logger.i('WebOs turn off success'); - }); - } else { - logger.e('actionToPreform is not set correctly on WebOs'); - } - } - entityStateGRPC = EntityState(EntityStateGRPC.ack.toString()); - - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - return right(unit); - } catch (e) { - entityStateGRPC = EntityState(EntityStateGRPC.newStateFailed.toString()); - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> turnOnSmartTv() async { - try {} catch (e) { - return left(const CoreFailure.unexpected()); - } - return left(const CoreFailure.unexpected()); - } - - @override - Future> turnOffSmartTv() async { - try {} catch (e) { - return left(const CoreFailure.unexpected()); - } - return left(const CoreFailure.unexpected()); - } -} diff --git a/lib/infrastructure/devices/lifx/lifx_connector_conjector.dart b/lib/infrastructure/devices/lifx/lifx_connector_conjector.dart deleted file mode 100644 index 605d7a76..00000000 --- a/lib/infrastructure/devices/lifx/lifx_connector_conjector.dart +++ /dev/null @@ -1,117 +0,0 @@ -import 'dart:async'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_dimmable_light_device/generic_dimmable_light_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_light_device/generic_light_entity.dart'; -import 'package:cbj_hub/domain/vendors/lifx_login/generic_lifx_login_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/companies_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/lifx/lifx_helpers.dart'; -import 'package:cbj_hub/infrastructure/devices/lifx/lifx_white/lifx_white_entity.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/abstract_company_connector_conjector.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:injectable/injectable.dart'; -import 'package:lifx_http_api/lifx_http_api.dart'; - -@singleton -class LifxConnectorConjector implements AbstractCompanyConnectorConjector { - Future accountLogin(GenericLifxLoginDE genericLifxLoginDE) async { - lifxClient = LIFXClient(genericLifxLoginDE.lifxApiKey.getOrCrash()); - _discoverNewDevices(); - return 'Success'; - } - - @override - Map companyDevices = {}; - - LIFXClient? lifxClient; - - Future _discoverNewDevices() async { - while (true) { - try { - final Iterable lights = - await lifxClient!.listLights(const Selector()); - - for (final LIFXBulb lifxDevice in lights) { - CoreUniqueId? tempCoreUniqueId; - bool deviceExist = false; - for (final DeviceEntityAbstract savedDevice - in companyDevices.values) { - if (savedDevice is LifxWhiteEntity && - lifxDevice.id == savedDevice.entityUniqueId.getOrCrash()) { - deviceExist = true; - break; - } else if (savedDevice is GenericLightDE && - lifxDevice.id == savedDevice.entityUniqueId.getOrCrash()) { - tempCoreUniqueId = savedDevice.uniqueId; - break; - } else if (lifxDevice.id == - savedDevice.entityUniqueId.getOrCrash()) { - logger.w( - 'Lifx device type supported but implementation is missing here', - ); - break; - } - } - if (!deviceExist) { - final DeviceEntityAbstract? addDevice = - LifxHelpers.addDiscoverdDevice( - lifxDevice: lifxDevice, - uniqueDeviceId: tempCoreUniqueId, - ); - - if (addDevice == null) { - continue; - } - - final DeviceEntityAbstract deviceToAdd = - CompaniesConnectorConjector.addDiscoverdDeviceToHub(addDevice); - - final MapEntry deviceAsEntry = - MapEntry(deviceToAdd.entityUniqueId.getOrCrash(), deviceToAdd); - - companyDevices.addEntries([deviceAsEntry]); - - logger.i('New Lifx device got added'); - } - } - await Future.delayed(const Duration(minutes: 3)); - } catch (e) { - logger.e('Error discover in Lifx\n$e'); - await Future.delayed(const Duration(minutes: 1)); - } - } - } - - @override - Future manageHubRequestsForDevice( - DeviceEntityAbstract lifxDE, - ) async { - final DeviceEntityAbstract? device = - companyDevices[lifxDE.entityUniqueId.getOrCrash()]; - - if (device is LifxWhiteEntity) { - device.executeDeviceAction(newEntity: lifxDE); - } else { - logger.w('Lifx device type does not exist'); - } - } - - @override - Future setUpDeviceFromDb(DeviceEntityAbstract deviceEntity) async { - DeviceEntityAbstract? nonGenericDevice; - - if (deviceEntity is GenericDimmableLightDE) { - nonGenericDevice = LifxWhiteEntity.fromGeneric(deviceEntity); - } - - if (nonGenericDevice == null) { - logger.w('Switcher device could not get loaded from the server'); - return; - } - - companyDevices.addEntries([ - MapEntry(nonGenericDevice.entityUniqueId.getOrCrash(), nonGenericDevice), - ]); - } -} diff --git a/lib/infrastructure/devices/lifx/lifx_device_validators.dart b/lib/infrastructure/devices/lifx/lifx_device_validators.dart deleted file mode 100644 index 3e9b5b43..00000000 --- a/lib/infrastructure/devices/lifx/lifx_device_validators.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateLifxIdNotEmpty(String input) { - return right(input); -} - -Either, String> validateLifxPortNotEmpty(String input) { - return right(input); -} diff --git a/lib/infrastructure/devices/lifx/lifx_helpers.dart b/lib/infrastructure/devices/lifx/lifx_helpers.dart deleted file mode 100644 index f264d63d..00000000 --- a/lib/infrastructure/devices/lifx/lifx_helpers.dart +++ /dev/null @@ -1,61 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_dimmable_light_device/generic_dimmable_light_value_objects.dart'; -import 'package:cbj_hub/infrastructure/devices/lifx/lifx_white/lifx_white_entity.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:lifx_http_api/lifx_http_api.dart'; - -class LifxHelpers { - static DeviceEntityAbstract? addDiscoverdDevice({ - required LIFXBulb lifxDevice, - required CoreUniqueId? uniqueDeviceId, - }) { - CoreUniqueId uniqueDeviceIdTemp; - - if (uniqueDeviceId != null) { - uniqueDeviceIdTemp = uniqueDeviceId; - } else { - uniqueDeviceIdTemp = CoreUniqueId(); - } - final String deviceName = - lifxDevice.label != '' ? lifxDevice.label : 'Lifx test 2'; - - final LifxWhiteEntity lifxDE = LifxWhiteEntity( - uniqueId: uniqueDeviceIdTemp, - entityUniqueId: EntityUniqueId(lifxDevice.id), - cbjEntityName: CbjEntityName(deviceName), - entityOriginalName: EntityOriginalName(deviceName), - deviceOriginalName: DeviceOriginalName(deviceName), - entityStateGRPC: EntityState(EntityStateGRPC.ack.toString()), - senderDeviceOs: DeviceSenderDeviceOs('Lifx'), - senderDeviceModel: DeviceSenderDeviceModel('Cloud'), - senderId: DeviceSenderId(), - compUuid: DeviceCompUuid(lifxDevice.uuid), - stateMassage: DeviceStateMassage('Hello World'), - powerConsumption: DevicePowerConsumption('0'), - lightSwitchState: GenericDimmableLightSwitchState( - (lifxDevice.power == LIFXPower.on).toString(), - ), - deviceUniqueId: DeviceUniqueId('0'), - devicePort: DevicePort('0'), - deviceLastKnownIp: DeviceLastKnownIp('0'), - deviceHostName: DeviceHostName('0'), - deviceMdns: DeviceMdns('0'), - devicesMacAddress: DevicesMacAddress('0'), - entityKey: EntityKey('0'), - requestTimeStamp: RequestTimeStamp('0'), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp('0'), - deviceCbjUniqueId: CoreUniqueId(), - lightBrightness: - GenericDimmableLightBrightness.fromDouble(lifxDevice.brightness), - ); - - return lifxDE; - - // TODO: Add if device type does not supported return null - // logger.i( - // 'Please add new philips device type Bulb ${lifxDevice.label}', - // ); - // return null; - } -} diff --git a/lib/infrastructure/devices/lifx/lifx_white/lifx_white_entity.dart b/lib/infrastructure/devices/lifx/lifx_white/lifx_white_entity.dart deleted file mode 100644 index 5e7f7655..00000000 --- a/lib/infrastructure/devices/lifx/lifx_white/lifx_white_entity.dart +++ /dev/null @@ -1,213 +0,0 @@ -import 'dart:async'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_dimmable_light_device/generic_dimmable_light_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_dimmable_light_device/generic_dimmable_light_value_objects.dart'; -import 'package:cbj_hub/infrastructure/devices/lifx/lifx_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/injection.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; -import 'package:lifx_http_api/lifx_http_api.dart'; - -class LifxWhiteEntity extends GenericDimmableLightDE { - LifxWhiteEntity({ - required super.uniqueId, - required super.entityUniqueId, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required super.lightSwitchState, - required super.lightBrightness, - }) : super( - deviceVendor: DeviceVendor(VendorsAndServices.lifx.toString()), - ); - - factory LifxWhiteEntity.fromGeneric(GenericDimmableLightDE genericDevice) { - return LifxWhiteEntity( - uniqueId: genericDevice.uniqueId, - entityUniqueId: genericDevice.entityUniqueId, - cbjEntityName: genericDevice.cbjEntityName, - entityOriginalName: genericDevice.entityOriginalName, - deviceOriginalName: genericDevice.deviceOriginalName, - stateMassage: genericDevice.stateMassage, - senderDeviceOs: genericDevice.senderDeviceOs, - senderDeviceModel: genericDevice.senderDeviceModel, - senderId: genericDevice.senderId, - compUuid: genericDevice.compUuid, - entityStateGRPC: genericDevice.entityStateGRPC, - powerConsumption: genericDevice.powerConsumption, - deviceUniqueId: genericDevice.deviceUniqueId, - devicePort: genericDevice.devicePort, - deviceLastKnownIp: genericDevice.deviceLastKnownIp, - deviceHostName: genericDevice.deviceHostName, - deviceMdns: genericDevice.deviceMdns, - devicesMacAddress: genericDevice.devicesMacAddress, - entityKey: genericDevice.entityKey, - requestTimeStamp: genericDevice.requestTimeStamp, - lastResponseFromDeviceTimeStamp: - genericDevice.lastResponseFromDeviceTimeStamp, - lightSwitchState: genericDevice.lightSwitchState, - deviceCbjUniqueId: genericDevice.deviceCbjUniqueId, - lightBrightness: genericDevice.lightBrightness, - ); - } - - /// Please override the following methods - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - if (newEntity is! GenericDimmableLightDE) { - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Not the correct type', - ), - ); - } - - try { - if (newEntity.lightSwitchState!.getOrCrash() != - lightSwitchState!.getOrCrash() || - entityStateGRPC.getOrCrash() != EntityStateGRPC.ack.toString()) { - final EntityActions? actionToPreform = - EnumHelperCbj.stringToDeviceAction( - newEntity.lightSwitchState!.getOrCrash(), - ); - - if (actionToPreform == EntityActions.on) { - (await turnOnLight()).fold((l) { - logger.e('Error turning Lifx light on'); - throw l; - }, (r) { - logger.i('Lifx light turn on success'); - }); - } else if (actionToPreform == EntityActions.off) { - (await turnOffLight()).fold((l) { - logger.e('Error turning Lifx light off'); - throw l; - }, (r) { - logger.i('Lifx light turn off success'); - }); - } else { - logger.w('actionToPreform is not set correctly on Lifx White'); - } - } - - if (newEntity.lightBrightness.getOrCrash() != - lightBrightness.getOrCrash()) { - (await setBrightness(newEntity.lightBrightness.getOrCrash())).fold( - (l) { - logger.e('Error changing Lifx brightness\n$l'); - throw l; - }, - (r) { - logger.i('Lifx changed brightness successfully'); - }, - ); - } - entityStateGRPC = EntityState(EntityStateGRPC.ack.toString()); - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - return right(unit); - } catch (e) { - entityStateGRPC = EntityState(EntityStateGRPC.newStateFailed.toString()); - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> turnOnLight() async { - lightSwitchState = - GenericDimmableLightSwitchState(EntityActions.on.toString()); - try { - final setStateBodyResponse = - await getIt().lifxClient?.setState( - Selector.id(entityUniqueId.getOrCrash()), - power: 'on', - fast: true, - ); - if (setStateBodyResponse == null) { - throw 'setStateBodyResponse is null'; - } - - return right(unit); - } catch (e) { - // As we are using the fast = true the response is always - // LifxHttpException Error - return right(unit); - // return left(const CoreFailure.unexpected()); - } - } - - @override - Future> turnOffLight() async { - lightSwitchState = - GenericDimmableLightSwitchState(EntityActions.off.toString()); - - try { - final setStateBodyResponse = - await getIt().lifxClient?.setState( - Selector.id(entityUniqueId.getOrCrash()), - power: 'off', - fast: true, - ); - if (setStateBodyResponse == null) { - throw 'setStateBodyResponse is null'; - } - return right(unit); - } catch (e) { - // As we are using the fast = true the response is always - // LifxHttpException Error - return right(unit); - // return left(const CoreFailure.unexpected()); - } - } - - @override - Future> setBrightness(String brightness) async { - lightBrightness = GenericDimmableLightBrightness(brightness); - - try { - final setStateBodyResponse = - await getIt().lifxClient?.setState( - Selector.id(entityUniqueId.getOrCrash()), - fast: true, - brightness: lightBrightness.backToDecimalPointBrightness(), - ); - if (setStateBodyResponse == null) { - throw 'setStateBodyResponse is null'; - } - return right(unit); - } catch (e) { - // As we are using the fast = true the response is always - // LifxHttpException Error - return right(unit); - // return left(const CoreFailure.unexpected()); - } - } -} diff --git a/lib/infrastructure/devices/philips_hue/philips_hue_api/philips_hue_api_light.dart b/lib/infrastructure/devices/philips_hue/philips_hue_api/philips_hue_api_light.dart deleted file mode 100644 index c7434a83..00000000 --- a/lib/infrastructure/devices/philips_hue/philips_hue_api/philips_hue_api_light.dart +++ /dev/null @@ -1,96 +0,0 @@ -import 'package:http/http.dart'; -import 'package:hue_dart/src/core/bridge.dart'; -import 'package:hue_dart/src/light/light.dart'; -import 'package:hue_dart/src/light/light_state.dart'; - -class PhilipsHueApiLight { - PhilipsHueApiLight({ - required this.ipAdress, - required this.username, - }) { - client = Client(); - bridge = Bridge(client, ipAdress, username); - } - - final String ipAdress; - final String username; - late Client client; - late Bridge bridge; - - Future turnLightOn(String entityUniqueId) async { - final List lights = await bridge.lights(); - - for (final Light light in lights) { - if (light.uniqueId != null && light.uniqueId == entityUniqueId) { - final state = lightStateForColorOnly(light).rebuild( - (s) => s..on = true, - ); - await bridge.updateLightState( - light.rebuild( - (l) => l..state = state.toBuilder(), - ), - ); - return 'OK'; - } - } - return "Can't find device"; - } - - Future turnLightOff(String deviceUniqId) async { - final List lights = await bridge.lights(); - - for (final Light light in lights) { - if (light.uniqueId != null && light.uniqueId == deviceUniqId) { - final state = lightStateForColorOnly(light).rebuild( - (s) => s..on = false, - ); - await bridge.updateLightState( - light.rebuild( - (l) => l..state = state.toBuilder(), - ), - ); - return 'OK'; - } - } - return "Can't find device"; - } - - Future setLightBrightness( - String entityUniqueId, - int brightness, - ) async { - final List lights = await bridge.lights(); - - for (final Light light in lights) { - if (light.uniqueId != null && light.uniqueId == entityUniqueId) { - final state = lightStateForColorOnly(light).rebuild( - (s) => s..brightness = brightness, - ); - await bridge.updateLightState( - light.rebuild( - (l) => l..state = state.toBuilder(), - ), - ); - return 'OK'; - } - } - return "Can't find device"; - } - - LightState lightStateForColorOnly(Light light) { - LightState state; - if (light.state!.colorMode == 'xy') { - state = LightState((b) => b..xy = light.state!.xy!.toBuilder()); - } else if (light.state!.colorMode == 'ct') { - state = LightState((b) => b..ct = light.state!.ct); - } else { - state = LightState( - (b) => b - ..hue = light.state!.hue - ..saturation = light.state!.saturation - ..brightness = light.state!.brightness, - ); - } - return state; - } -} diff --git a/lib/infrastructure/devices/philips_hue/philips_hue_connector_conjector.dart b/lib/infrastructure/devices/philips_hue/philips_hue_connector_conjector.dart deleted file mode 100644 index dd1499d7..00000000 --- a/lib/infrastructure/devices/philips_hue/philips_hue_connector_conjector.dart +++ /dev/null @@ -1,106 +0,0 @@ -import 'dart:async'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_dimmable_light_device/generic_dimmable_light_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/companies_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/philips_hue/philips_hue_e26/philips_hue_e26_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/philips_hue/philips_hue_helpers.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/abstract_company_connector_conjector.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:injectable/injectable.dart'; - -@singleton -class PhilipsHueConnectorConjector - implements AbstractCompanyConnectorConjector { - @override - Map companyDevices = {}; - - static const List mdnsTypes = [ - '_hue._tcp', - ]; - - static bool gotHueHubIp = false; - - /// Add new devices to [companyDevices] if not exist - Future addNewDeviceByMdnsName({ - required String mDnsName, - required String ip, - required String port, - }) async { - /// There can only be one Philips Hub in the same network - if (gotHueHubIp) { - return; - } - CoreUniqueId? tempCoreUniqueId; - - for (final DeviceEntityAbstract device in companyDevices.values) { - if (device is PhilipsHueE26Entity && - (mDnsName == device.entityUniqueId.getOrCrash() || - ip == device.deviceLastKnownIp.getOrCrash())) { - return; - } else if (mDnsName == device.entityUniqueId.getOrCrash()) { - logger.w( - 'HP device type supported but implementation is missing here', - ); - return; - } - } - gotHueHubIp = true; - - final List phillipsDevice = - await PhilipsHueHelpers.addDiscoverdDevice( - mDnsName: mDnsName, - ip: ip, - port: port, - uniqueDeviceId: tempCoreUniqueId, - ); - - if (phillipsDevice.isEmpty) { - return; - } - - for (final DeviceEntityAbstract entityAsDevice in phillipsDevice) { - final DeviceEntityAbstract deviceToAdd = - CompaniesConnectorConjector.addDiscoverdDeviceToHub(entityAsDevice); - - final MapEntry deviceAsEntry = - MapEntry(deviceToAdd.entityUniqueId.getOrCrash(), deviceToAdd); - - companyDevices.addEntries([deviceAsEntry]); - } - logger.i('New Philips Hue device got added'); - } - - @override - Future manageHubRequestsForDevice( - DeviceEntityAbstract philipsHueDE, - ) async { - final DeviceEntityAbstract? device = - companyDevices[philipsHueDE.entityUniqueId.getOrCrash()]; - - if (device is PhilipsHueE26Entity) { - device.executeDeviceAction(newEntity: philipsHueDE); - } else { - logger.w('PhilipsHue device type does not exist'); - } - } - - @override - Future setUpDeviceFromDb(DeviceEntityAbstract deviceEntity) async { - DeviceEntityAbstract? nonGenericDevice; - - if (deviceEntity is GenericDimmableLightDE) { - nonGenericDevice = PhilipsHueE26Entity.fromGeneric(deviceEntity); - } - - if (nonGenericDevice == null) { - logger.w('Switcher device could not get loaded from the server'); - return; - } - - companyDevices.addEntries([ - MapEntry(nonGenericDevice.entityUniqueId.getOrCrash(), nonGenericDevice), - ]); - } -} diff --git a/lib/infrastructure/devices/philips_hue/philips_hue_device_validators.dart b/lib/infrastructure/devices/philips_hue/philips_hue_device_validators.dart deleted file mode 100644 index d7b99f05..00000000 --- a/lib/infrastructure/devices/philips_hue/philips_hue_device_validators.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validatePhilipsHueIdNotEmpty(String input) { - return right(input); -} - -Either, String> validatePhilipsHuePortNotEmpty( - String input, -) { - return right(input); -} diff --git a/lib/infrastructure/devices/philips_hue/philips_hue_e26/philips_hue_e26_entity.dart b/lib/infrastructure/devices/philips_hue/philips_hue_e26/philips_hue_e26_entity.dart deleted file mode 100644 index 432853c7..00000000 --- a/lib/infrastructure/devices/philips_hue/philips_hue_e26/philips_hue_e26_entity.dart +++ /dev/null @@ -1,219 +0,0 @@ -import 'dart:async'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_dimmable_light_device/generic_dimmable_light_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_dimmable_light_device/generic_dimmable_light_value_objects.dart'; -import 'package:cbj_hub/infrastructure/devices/philips_hue/philips_hue_api/philips_hue_api_light.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; -import 'package:yeedart/yeedart.dart'; - -class PhilipsHueE26Entity extends GenericDimmableLightDE { - PhilipsHueE26Entity({ - required super.uniqueId, - required super.entityUniqueId, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required super.lightSwitchState, - required super.lightBrightness, - required this.philipsHueApiLight, - this.philipsHuePackageObject, - }) : super( - deviceVendor: DeviceVendor( - VendorsAndServices.philipsHue.toString(), - ), - ); - - factory PhilipsHueE26Entity.fromGeneric( - GenericDimmableLightDE genericDevice, - ) { - return PhilipsHueE26Entity( - uniqueId: genericDevice.uniqueId, - entityUniqueId: genericDevice.entityUniqueId, - cbjEntityName: genericDevice.cbjEntityName, - entityOriginalName: genericDevice.entityOriginalName, - deviceOriginalName: genericDevice.deviceOriginalName, - stateMassage: genericDevice.stateMassage, - senderDeviceOs: genericDevice.senderDeviceOs, - senderDeviceModel: genericDevice.senderDeviceModel, - senderId: genericDevice.senderId, - compUuid: genericDevice.compUuid, - entityStateGRPC: genericDevice.entityStateGRPC, - powerConsumption: genericDevice.powerConsumption, - deviceUniqueId: genericDevice.deviceUniqueId, - devicePort: genericDevice.devicePort, - deviceLastKnownIp: genericDevice.deviceLastKnownIp, - deviceHostName: genericDevice.deviceHostName, - deviceMdns: genericDevice.deviceMdns, - devicesMacAddress: genericDevice.devicesMacAddress, - entityKey: genericDevice.entityKey, - requestTimeStamp: genericDevice.requestTimeStamp, - lastResponseFromDeviceTimeStamp: - genericDevice.lastResponseFromDeviceTimeStamp, - lightSwitchState: genericDevice.lightSwitchState, - deviceCbjUniqueId: genericDevice.deviceCbjUniqueId, - lightBrightness: genericDevice.lightBrightness, - - /// TODO: Save and pull philips hub generated user name - /// (created in phillips_hue_helpers.dart) - philipsHueApiLight: PhilipsHueApiLight( - ipAdress: genericDevice.deviceLastKnownIp.getOrCrash(), - username: '', - ), - ); - } - - /// PhilipsHue package object require to close previews request before new one - Device? philipsHuePackageObject; - - PhilipsHueApiLight philipsHueApiLight; - - /// Please override the following methods - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - if (newEntity is! GenericDimmableLightDE) { - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Not the correct type', - ), - ); - } - - try { - if (newEntity.lightSwitchState!.getOrCrash() != - lightSwitchState!.getOrCrash() || - entityStateGRPC.getOrCrash() != EntityStateGRPC.ack.toString()) { - final EntityActions? actionToPreform = - EnumHelperCbj.stringToDeviceAction( - newEntity.lightSwitchState!.getOrCrash(), - ); - - if (actionToPreform == EntityActions.on) { - (await turnOnLight()).fold( - (l) { - logger.e('Error turning philips_hue light on'); - throw l; - }, - (r) { - logger.i('Philips Hue light turn on success'); - }, - ); - } else if (actionToPreform == EntityActions.off) { - (await turnOffLight()).fold( - (l) { - logger.e('Error turning philips_hue light off'); - throw l; - }, - (r) { - logger.i('Philips Hue light turn off success'); - }, - ); - } else { - logger.w('actionToPreform is not set correctly on PhilipsHue E26'); - } - } - - if (newEntity.lightBrightness.getOrCrash() != - lightBrightness.getOrCrash()) { - (await setBrightness(newEntity.lightBrightness.getOrCrash())).fold( - (l) { - logger.e('Error changing Phillips hue e26 brightness\n$l'); - throw l; - }, - (r) { - logger.i('Phillips hue e26 changed brightness successfully'); - }, - ); - } - entityStateGRPC = EntityState(EntityStateGRPC.ack.toString()); - - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - return right(unit); - } catch (e) { - entityStateGRPC = EntityState(EntityStateGRPC.newStateFailed.toString()); - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> turnOnLight() async { - lightSwitchState = - GenericDimmableLightSwitchState(EntityActions.on.toString()); - - try { - await philipsHueApiLight.turnLightOn(entityUniqueId.getOrCrash()); - - return right(unit); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> turnOffLight() async { - lightSwitchState = - GenericDimmableLightSwitchState(EntityActions.off.toString()); - - try { - await philipsHueApiLight.turnLightOff(entityUniqueId.getOrCrash()); - - return right(unit); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> setBrightness(String brightness) async { - final int? brightnessInt = int.tryParse(brightness); - if (brightnessInt == null) { - return left( - const CoreFailure.actionExcecuter( - failedValue: "brightnessInt can't be converted to int", - ), - ); - } - - lightBrightness = GenericDimmableLightBrightness(brightnessInt.toString()); - - await philipsHueApiLight.setLightBrightness( - entityUniqueId.getOrCrash(), - brightnessInt, - ); - - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } -} diff --git a/lib/infrastructure/devices/philips_hue/philips_hue_helpers.dart b/lib/infrastructure/devices/philips_hue/philips_hue_helpers.dart deleted file mode 100644 index 88aabae7..00000000 --- a/lib/infrastructure/devices/philips_hue/philips_hue_helpers.dart +++ /dev/null @@ -1,93 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_dimmable_light_device/generic_dimmable_light_value_objects.dart'; -import 'package:cbj_hub/infrastructure/devices/philips_hue/philips_hue_api/philips_hue_api_light.dart'; -import 'package:cbj_hub/infrastructure/devices/philips_hue/philips_hue_e26/philips_hue_e26_entity.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:http/http.dart'; -import 'package:hue_dart/src/core/bridge.dart'; -import 'package:hue_dart/src/light/light.dart'; -import 'package:hue_dart/src/light/light_state.dart'; - -class PhilipsHueHelpers { - static Future> addDiscoverdDevice({ - required String mDnsName, - required String? port, - required String ip, - required CoreUniqueId? uniqueDeviceId, - }) async { - CoreUniqueId uniqueDeviceIdTemp; - - if (uniqueDeviceId != null) { - uniqueDeviceIdTemp = uniqueDeviceId; - } else { - uniqueDeviceIdTemp = CoreUniqueId(); - } - - final client = Client(); - - //create bridge - final bridge = Bridge(client, ip); - - /// TODO: save user phillips hub generated user name for cbj - final String userNameForPhilipsHueHub = - await bridge.brideLoopToAwaitPushlinkForUserId(); - bridge.username = userNameForPhilipsHueHub; - - final List lights = await bridge.lights(); - - final List tempDeviceEntities = []; - - for (final Light light in lights) { - final LightState? lightState = light.state; - - if (light.type != null && light.type == 'Dimmable light') { - final String deviceName = (light.name != null && light.name != '') - ? light.name! - : 'PhilipsHue test 2'; - final PhilipsHueE26Entity philipsHueDE = PhilipsHueE26Entity( - uniqueId: uniqueDeviceIdTemp, - entityUniqueId: EntityUniqueId(light.uniqueId.toString()), - cbjEntityName: CbjEntityName(deviceName), - entityOriginalName: EntityOriginalName(deviceName), - deviceOriginalName: DeviceOriginalName(deviceName), - entityStateGRPC: EntityState(EntityStateGRPC.ack.toString()), - senderDeviceOs: DeviceSenderDeviceOs('philips_hue'), - senderDeviceModel: DeviceSenderDeviceModel(light.modelId), - senderId: DeviceSenderId(), - compUuid: DeviceCompUuid('55asdhd23gggg'), - deviceMdns: DeviceMdns(mDnsName), - deviceLastKnownIp: DeviceLastKnownIp(ip), - stateMassage: DeviceStateMassage('Hello World'), - powerConsumption: DevicePowerConsumption('0'), - devicePort: DevicePort(port), - lightSwitchState: GenericDimmableLightSwitchState( - lightState != null && lightState.on != null && lightState.on == true - ? EntityActions.on.toString() - : EntityActions.off.toString(), - ), - lightBrightness: GenericDimmableLightBrightness( - (lightState?.brightness ?? 0).toString(), - ), - philipsHueApiLight: PhilipsHueApiLight( - username: userNameForPhilipsHueHub, - ipAdress: ip, - ), - deviceUniqueId: DeviceUniqueId('0'), - deviceHostName: DeviceHostName('0'), - devicesMacAddress: DevicesMacAddress('0'), - entityKey: EntityKey('0'), - requestTimeStamp: RequestTimeStamp('0'), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp('0'), - deviceCbjUniqueId: CoreUniqueId(), - ); - tempDeviceEntities.add(philipsHueDE); - } else { - logger.w('Un supported Philips Hue light type'); - } - } - - return tempDeviceEntities; - } -} diff --git a/lib/infrastructure/devices/shelly/shelly_connector_conjector.dart b/lib/infrastructure/devices/shelly/shelly_connector_conjector.dart deleted file mode 100644 index aaa301da..00000000 --- a/lib/infrastructure/devices/shelly/shelly_connector_conjector.dart +++ /dev/null @@ -1,105 +0,0 @@ -import 'dart:async'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/companies_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/shelly/shelly_helpers.dart'; -import 'package:cbj_hub/infrastructure/devices/shelly/shelly_light/shelly_light_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/shelly/shelly_relay_switch/shelly_relay_switch_entity.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/abstract_company_connector_conjector.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:injectable/injectable.dart'; - -@singleton -class ShellyConnectorConjector implements AbstractCompanyConnectorConjector { - static const List mdnsTypes = ['_http._tcp']; - - @override - Map companyDevices = {}; - - /// Add new devices to [companyDevices] if not exist - Future addNewDeviceByMdnsName({ - required String mDnsName, - required String ip, - required String port, - }) async { - CoreUniqueId? tempCoreUniqueId; - - for (final DeviceEntityAbstract device in companyDevices.values) { - if ((device is ShellyColorLightEntity || - device is ShellyRelaySwitchEntity) && - mDnsName == device.entityUniqueId.getOrCrash()) { - return; - } else if ((device is GenericRgbwLightDE || device is GenericSwitchDE) && - mDnsName == device.entityUniqueId.getOrCrash()) { - /// Device exist as generic and needs to get converted to non generic type for this vendor - tempCoreUniqueId = device.uniqueId; - break; - } else if (mDnsName == device.entityUniqueId.getOrCrash()) { - logger.w( - 'Shelly device type supported but implementation is missing here', - ); - return; - } - } - - final List shellyDevice = - await ShellyHelpers.addDiscoverdDevice( - mDnsName: mDnsName, - ip: ip, - port: port, - uniqueDeviceId: tempCoreUniqueId, - ); - - if (shellyDevice.isEmpty) { - return; - } - - for (final DeviceEntityAbstract entityAsDevice in shellyDevice) { - final DeviceEntityAbstract deviceToAdd = - CompaniesConnectorConjector.addDiscoverdDeviceToHub(entityAsDevice); - - final MapEntry deviceAsEntry = - MapEntry(deviceToAdd.entityUniqueId.getOrCrash(), deviceToAdd); - - companyDevices.addEntries([deviceAsEntry]); - } - logger.t('New shelly devices name:$mDnsName'); - } - - @override - Future manageHubRequestsForDevice( - DeviceEntityAbstract shellyDE, - ) async { - final DeviceEntityAbstract? device = - companyDevices[shellyDE.entityUniqueId.getOrCrash()]; - - if (device is ShellyColorLightEntity) { - device.executeDeviceAction(newEntity: shellyDE); - } else if (device is ShellyRelaySwitchEntity) { - device.executeDeviceAction(newEntity: shellyDE); - } else { - logger.w('Shelly device type does not exist'); - } - } - - @override - Future setUpDeviceFromDb(DeviceEntityAbstract deviceEntity) async { - DeviceEntityAbstract? nonGenericDevice; - - if (deviceEntity is GenericRgbwLightDE) { - nonGenericDevice = ShellyColorLightEntity.fromGeneric(deviceEntity); - } - - if (nonGenericDevice == null) { - logger.w('Switcher device could not get loaded from the server'); - return; - } - - companyDevices.addEntries([ - MapEntry(nonGenericDevice.entityUniqueId.getOrCrash(), nonGenericDevice), - ]); - } -} diff --git a/lib/infrastructure/devices/shelly/shelly_device_validators.dart b/lib/infrastructure/devices/shelly/shelly_device_validators.dart deleted file mode 100644 index 597348b4..00000000 --- a/lib/infrastructure/devices/shelly/shelly_device_validators.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateShellySwitchKeyNotEmpty( - String input, -) { - return right(input); -} - -Either, String> validateShellyPortNotEmpty(String input) { - return right(input); -} diff --git a/lib/infrastructure/devices/shelly/shelly_device_value_objects.dart b/lib/infrastructure/devices/shelly/shelly_device_value_objects.dart deleted file mode 100644 index 8b137891..00000000 --- a/lib/infrastructure/devices/shelly/shelly_device_value_objects.dart +++ /dev/null @@ -1 +0,0 @@ - diff --git a/lib/infrastructure/devices/shelly/shelly_helpers.dart b/lib/infrastructure/devices/shelly/shelly_helpers.dart deleted file mode 100644 index 19ed5dfd..00000000 --- a/lib/infrastructure/devices/shelly/shelly_helpers.dart +++ /dev/null @@ -1,204 +0,0 @@ -import 'dart:convert'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_value_objects.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_value_objects.dart'; -import 'package:cbj_hub/infrastructure/devices/shelly/shelly_light/shelly_light_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/shelly/shelly_relay_switch/shelly_relay_switch_entity.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbenum.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:color/color.dart'; -import 'package:shelly/shelly.dart'; - -class ShellyHelpers { - static Future> addDiscoverdDevice({ - required String mDnsName, - required String? port, - required String ip, - required CoreUniqueId? uniqueDeviceId, - }) async { - CoreUniqueId uniqueDeviceIdTemp; - - if (uniqueDeviceId != null) { - uniqueDeviceIdTemp = uniqueDeviceId; - } else { - uniqueDeviceIdTemp = CoreUniqueId(); - } - final List deviceEntityList = []; - - try { - // TODO: shelly duo bulb needs type that as the time of writing is - // not supported, bulb + brightness + white temperature (not rgb). - // Lets create new type and add it. - if (mDnsName.contains('colorbulb')) { - final ShellyApiColorBulb shellyApiDeviceAbstract = ShellyApiColorBulb( - lastKnownIp: ip, - mDnsName: mDnsName, - hostName: uniqueDeviceIdTemp.getOrCrash(), - ); - - final String status = await shellyApiDeviceAbstract.getStatus(); - final dynamic responseAsJson = json.decode(status); - - final String mac = responseAsJson['mac'] as String; - - final dynamic bulbLightProp = responseAsJson['lights'][0]; - - final String bulbMod = bulbLightProp['mode'] as String; - shellyApiDeviceAbstract.bulbMode = - bulbMod == 'color' ? ShellyBulbMode.colore : ShellyBulbMode.white; - - final int brightness = bulbLightProp['brightness'] as int; - final int gain = - bulbLightProp['gain'] as int; // Brightness for color mod - final int currentBrightness = - shellyApiDeviceAbstract.bulbMode == ShellyBulbMode.colore - ? gain - : brightness; - final int temp = bulbLightProp['temp'] as int; - - final int red = bulbLightProp['red'] as int; - final int green = bulbLightProp['green'] as int; - final int blue = bulbLightProp['blue'] as int; - - final RgbColor rgbColor = RgbColor(red, green, blue); - final HsvColor hsvColor = rgbColor.toHsvColor(); - - final bool isOn = bulbLightProp['ison'] as bool; - - final ShellyColorLightEntity shellyColorLightEntity = - ShellyColorLightEntity( - uniqueId: uniqueDeviceIdTemp, - entityUniqueId: EntityUniqueId(mDnsName), - cbjEntityName: CbjEntityName(mDnsName), - entityOriginalName: EntityOriginalName(mDnsName), - deviceOriginalName: DeviceOriginalName(mDnsName), - entityStateGRPC: EntityState(EntityStateGRPC.ack.toString()), - senderDeviceOs: DeviceSenderDeviceOs('Shelly'), - senderDeviceModel: DeviceSenderDeviceModel('d1'), - senderId: DeviceSenderId(), - compUuid: DeviceCompUuid(mac), - stateMassage: DeviceStateMassage('Hello World'), - powerConsumption: DevicePowerConsumption('0'), - lightSwitchState: GenericRgbwLightSwitchState(isOn ? 'on' : 'off'), - lightColorTemperature: - GenericRgbwLightColorTemperature(temp.toString()), - lightBrightness: - GenericRgbwLightBrightness(currentBrightness.toString()), - lightColorAlpha: GenericRgbwLightColorAlpha('1.0'), - lightColorHue: GenericRgbwLightColorHue(hsvColor.h.toString()), - lightColorSaturation: - GenericRgbwLightColorSaturation(hsvColor.s.toString()), - lightColorValue: GenericRgbwLightColorValue(hsvColor.v.toString()), - devicePort: DevicePort(port), - deviceHostName: DeviceHostName(mDnsName.toLowerCase()), - deviceMdns: DeviceMdns(mDnsName), - deviceLastKnownIp: DeviceLastKnownIp(ip), - bulbMode: shellyApiDeviceAbstract, - deviceUniqueId: DeviceUniqueId('0'), - devicesMacAddress: DevicesMacAddress('0'), - entityKey: EntityKey('0'), - requestTimeStamp: RequestTimeStamp('0'), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp('0'), - deviceCbjUniqueId: CoreUniqueId(), - ); - deviceEntityList.add(shellyColorLightEntity); - } else if (mDnsName.contains('BulbDuo')) { - final ShellyApiColorBulb shellyApiDeviceAbstract = ShellyApiColorBulb( - lastKnownIp: ip, - mDnsName: mDnsName, - hostName: uniqueDeviceIdTemp.getOrCrash(), - ); - - final String status = await shellyApiDeviceAbstract.getStatus(); - final dynamic responseAsJson = json.decode(status); - - final String mac = responseAsJson['mac'] as String; - - final dynamic bulbLightProp = responseAsJson['lights'][0]; - - shellyApiDeviceAbstract.bulbMode = ShellyBulbMode.white; - - final int brightness = bulbLightProp['brightness'] as int; - - final int currentBrightness = brightness; - - final int temp = bulbLightProp['temp'] as int; - - final bool isOn = bulbLightProp['ison'] as bool; - - final ShellyColorLightEntity shellyColorLightEntity = - ShellyColorLightEntity( - uniqueId: uniqueDeviceIdTemp, - entityUniqueId: EntityUniqueId(mDnsName), - cbjEntityName: CbjEntityName(mDnsName), - entityOriginalName: EntityOriginalName(mDnsName), - deviceOriginalName: DeviceOriginalName(mDnsName), - entityStateGRPC: EntityState(EntityStateGRPC.ack.toString()), - senderDeviceOs: DeviceSenderDeviceOs('Shelly'), - senderDeviceModel: DeviceSenderDeviceModel('d1'), - senderId: DeviceSenderId(), - compUuid: DeviceCompUuid(mac), - stateMassage: DeviceStateMassage('Hello World'), - powerConsumption: DevicePowerConsumption('0'), - lightSwitchState: GenericRgbwLightSwitchState(isOn ? 'on' : 'off'), - lightColorTemperature: - GenericRgbwLightColorTemperature(temp.toString()), - lightBrightness: - GenericRgbwLightBrightness(currentBrightness.toString()), - lightColorAlpha: GenericRgbwLightColorAlpha('1.0'), - lightColorHue: GenericRgbwLightColorHue('0'), - lightColorSaturation: GenericRgbwLightColorSaturation('0'), - lightColorValue: GenericRgbwLightColorValue('0'), - devicePort: DevicePort(port), - deviceHostName: DeviceHostName(mDnsName.toLowerCase()), - deviceMdns: DeviceMdns(mDnsName), - deviceLastKnownIp: DeviceLastKnownIp(ip), - bulbMode: shellyApiDeviceAbstract, - deviceUniqueId: DeviceUniqueId('0'), - devicesMacAddress: DevicesMacAddress('0'), - entityKey: EntityKey('0'), - requestTimeStamp: RequestTimeStamp('0'), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp('0'), - deviceCbjUniqueId: CoreUniqueId(), - ); - deviceEntityList.add(shellyColorLightEntity); - } else if (mDnsName.contains('shelly1-C45BBE78005D')) { - final ShellyRelaySwitchEntity shellyRelaySwitchEntity = - ShellyRelaySwitchEntity( - uniqueId: uniqueDeviceIdTemp, - entityUniqueId: EntityUniqueId(mDnsName), - cbjEntityName: CbjEntityName(mDnsName), - entityOriginalName: EntityOriginalName(mDnsName), - deviceOriginalName: DeviceOriginalName(mDnsName), - entityStateGRPC: EntityState(EntityStateGRPC.ack.toString()), - senderDeviceOs: DeviceSenderDeviceOs('Shelly'), - senderDeviceModel: DeviceSenderDeviceModel('d1'), - senderId: DeviceSenderId(), - compUuid: DeviceCompUuid('34asdfrsd23gggg'), - stateMassage: DeviceStateMassage('Hello World'), - powerConsumption: DevicePowerConsumption('0'), - devicePort: DevicePort(port), - deviceHostName: DeviceHostName(mDnsName.toLowerCase()), - deviceMdns: DeviceMdns(mDnsName), - deviceLastKnownIp: DeviceLastKnownIp(ip), - switchState: GenericSwitchSwitchState(false.toString()), - deviceUniqueId: DeviceUniqueId('0'), - devicesMacAddress: DevicesMacAddress('0'), - entityKey: EntityKey('0'), - requestTimeStamp: RequestTimeStamp('0'), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp('0'), - deviceCbjUniqueId: CoreUniqueId(), - ); - deviceEntityList.add(shellyRelaySwitchEntity); - } else { - logger.i('Shelly device types is not supported'); - } - } catch (e) { - logger.e('Error setting shelly\n$e'); - } - - return deviceEntityList; - } -} diff --git a/lib/infrastructure/devices/shelly/shelly_light/shelly_light_entity.dart b/lib/infrastructure/devices/shelly/shelly_light/shelly_light_entity.dart deleted file mode 100644 index 9e2033fa..00000000 --- a/lib/infrastructure/devices/shelly/shelly_light/shelly_light_entity.dart +++ /dev/null @@ -1,331 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_value_objects.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:color/color.dart'; -import 'package:dartz/dartz.dart'; -import 'package:shelly/shelly.dart'; - -class ShellyColorLightEntity extends GenericRgbwLightDE { - ShellyColorLightEntity({ - required super.uniqueId, - required super.entityUniqueId, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required super.lightSwitchState, - required super.lightColorTemperature, - required super.lightColorAlpha, - required super.lightColorHue, - required super.lightColorSaturation, - required super.lightColorValue, - required super.lightBrightness, - ShellyApiColorBulb? bulbMode, - }) : super( - deviceVendor: DeviceVendor(VendorsAndServices.shelly.toString()), - ) { - shellyColorBulb = bulbMode ?? - ShellyApiColorBulb( - lastKnownIp: deviceLastKnownIp.getOrCrash(), - mDnsName: deviceMdns.getOrCrash(), - hostName: deviceHostName.getOrCrash(), - ); - } - - factory ShellyColorLightEntity.fromGeneric(GenericRgbwLightDE genericDevice) { - return ShellyColorLightEntity( - uniqueId: genericDevice.uniqueId, - entityUniqueId: genericDevice.entityUniqueId, - cbjEntityName: genericDevice.cbjEntityName, - entityOriginalName: genericDevice.entityOriginalName, - deviceOriginalName: genericDevice.deviceOriginalName, - stateMassage: genericDevice.stateMassage, - senderDeviceOs: genericDevice.senderDeviceOs, - senderDeviceModel: genericDevice.senderDeviceModel, - senderId: genericDevice.senderId, - compUuid: genericDevice.compUuid, - entityStateGRPC: genericDevice.entityStateGRPC, - powerConsumption: genericDevice.powerConsumption, - deviceUniqueId: genericDevice.deviceUniqueId, - devicePort: genericDevice.devicePort, - deviceLastKnownIp: genericDevice.deviceLastKnownIp, - deviceHostName: genericDevice.deviceHostName, - deviceMdns: genericDevice.deviceMdns, - devicesMacAddress: genericDevice.devicesMacAddress, - entityKey: genericDevice.entityKey, - requestTimeStamp: genericDevice.requestTimeStamp, - lastResponseFromDeviceTimeStamp: - genericDevice.lastResponseFromDeviceTimeStamp, - lightSwitchState: genericDevice.lightSwitchState, - deviceCbjUniqueId: genericDevice.deviceCbjUniqueId, - lightBrightness: genericDevice.lightBrightness, - lightColorTemperature: genericDevice.lightColorTemperature, - lightColorAlpha: genericDevice.lightColorAlpha, - lightColorHue: genericDevice.lightColorHue, - lightColorSaturation: genericDevice.lightColorSaturation, - lightColorValue: genericDevice.lightColorValue, - ); - } - late ShellyApiColorBulb shellyColorBulb; - - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - if (newEntity is! GenericRgbwLightDE) { - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Not the correct type', - ), - ); - } - - try { - // if (entityStateGRPC.getOrCrash() == EntityStateGRPC.ack.toString()) { - // return right(unit); - // } - - if (newEntity.lightSwitchState!.getOrCrash() != - lightSwitchState!.getOrCrash()) { - final EntityActions? actionToPreform = - EnumHelperCbj.stringToDeviceAction( - newEntity.lightSwitchState!.getOrCrash(), - ); - - if (actionToPreform == EntityActions.on) { - (await turnOnLight()).fold((l) { - logger.e('Error turning Shelly light on'); - throw l; - }, (r) { - logger.i('Shelly light turn on success'); - }); - } else if (actionToPreform == EntityActions.off) { - (await turnOffLight()).fold((l) { - logger.e('Error turning Shelly light off'); - throw l; - }, (r) { - logger.i('Shelly light turn off success'); - }); - } else { - logger.e('actionToPreform is not set correctly Shelly light'); - } - } - - if (newEntity.lightColorTemperature.getOrCrash() != - lightColorTemperature.getOrCrash()) { - (await changeColorTemperature( - lightColorTemperatureNewValue: - newEntity.lightColorTemperature.getOrCrash(), - )) - .fold( - (l) { - logger.e('Error changing Shelly temperature\n$l'); - throw l; - }, - (r) { - logger.i('Shelly changed temperature successfully'); - }, - ); - } - - if (newEntity.lightColorAlpha.getOrCrash() != - lightColorAlpha.getOrCrash() || - newEntity.lightColorHue.getOrCrash() != lightColorHue.getOrCrash() || - newEntity.lightColorSaturation.getOrCrash() != - lightColorSaturation.getOrCrash() || - newEntity.lightColorValue.getOrCrash() != - lightColorValue.getOrCrash()) { - (await changeColorHsv( - lightColorAlphaNewValue: newEntity.lightColorAlpha.getOrCrash(), - lightColorHueNewValue: newEntity.lightColorHue.getOrCrash(), - lightColorSaturationNewValue: - newEntity.lightColorSaturation.getOrCrash(), - lightColorValueNewValue: newEntity.lightColorValue.getOrCrash(), - )) - .fold( - (l) { - logger.e('Error changing Shelly light color\n$l'); - throw l; - }, - (r) { - logger.i('Shelly changed color successfully'); - }, - ); - } - - if (newEntity.lightBrightness.getOrCrash() != - lightBrightness.getOrCrash()) { - (await setBrightness(newEntity.lightBrightness.getOrCrash())).fold( - (l) { - logger.e('Error changing Shelly brightness\n$l'); - throw l; - }, - (r) { - logger.i('Shelly changed brightness successfully'); - }, - ); - } - entityStateGRPC = EntityState(EntityStateGRPC.ack.toString()); - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - return right(unit); - } catch (e) { - entityStateGRPC = EntityState(EntityStateGRPC.newStateFailed.toString()); - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> turnOnLight() async { - lightSwitchState = GenericRgbwLightSwitchState(EntityActions.on.toString()); - - try { - logger.t('Turn on Shelly device'); - shellyColorBulb.turnOn(); - return right(unit); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> turnOffLight() async { - lightSwitchState = - GenericRgbwLightSwitchState(EntityActions.off.toString()); - - try { - logger.t('Turn off Shelly device'); - await shellyColorBulb.turnOff(); - return right(unit); - } catch (exception) { - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> changeColorTemperature({ - required String lightColorTemperatureNewValue, - }) async { - try { - int temperatureInt = int.parse(lightColorTemperatureNewValue); - if (temperatureInt < 3000) { - temperatureInt = 3000; - } else if (temperatureInt > 6465) { - temperatureInt = 6465; - } - - if (lightColorTemperature.getOrCrash() == temperatureInt.toString()) { - return right(unit); - } - - lightColorTemperature = - GenericRgbwLightColorTemperature(temperatureInt.toString()); - - await shellyColorBulb.changTemperature( - temperature: lightColorTemperature.getOrCrash(), - ); - - return right(unit); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> setBrightness(String brightness) async { - lightBrightness = GenericRgbwLightBrightness(brightness); - - try { - await shellyColorBulb.changBrightness( - brightness: brightness, - ); - - return right(unit); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> changeColorHsv({ - required String lightColorAlphaNewValue, - required String lightColorHueNewValue, - required String lightColorSaturationNewValue, - required String lightColorValueNewValue, - }) async { - lightColorAlpha = GenericRgbwLightColorAlpha(lightColorAlphaNewValue); - lightColorHue = GenericRgbwLightColorHue(lightColorHueNewValue); - lightColorSaturation = - GenericRgbwLightColorSaturation(lightColorSaturationNewValue); - lightColorValue = GenericRgbwLightColorValue(lightColorValueNewValue); - - try { - final HsvColor hsvColor = HsvColor( - double.parse(lightColorHue.getOrCrash()), - convertDecimalPresentagetToIntegerPercentage( - double.parse(lightColorSaturation.getOrCrash()), - ), - convertDecimalPresentagetToIntegerPercentage( - double.parse(lightColorValue.getOrCrash()), - ), - ); - - final RgbColor rgbColor = hsvColor.toRgbColor(); - - await shellyColorBulb.changeColor( - red: rgbColor.r.toString(), - green: rgbColor.g.toString(), - blue: rgbColor.b.toString(), - ); - - return right(unit); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - } - - // Convert percentage 0-1 numbers to 0-100 with the same percentage - int convertDecimalPresentagetToIntegerPercentage(double number) { - if (number == 1.0) { - return 100; - } else if (number == 0.0) { - return 0; - } - - if (number.toString().length <= 8) { - throw 'Error converting to integer percentage'; - } - // 0.3455545372845 - final String inString = number.toStringAsFixed(6); // 0.34555 - final int numberTemp = int.parse(inString.substring(2)); // 34555 - - final int percentage = (100 * numberTemp) ~/ 1000000; - - return percentage; - } -} diff --git a/lib/infrastructure/devices/shelly/shelly_relay_switch/shelly_relay_switch_entity.dart b/lib/infrastructure/devices/shelly/shelly_relay_switch/shelly_relay_switch_entity.dart deleted file mode 100644 index 75c1f297..00000000 --- a/lib/infrastructure/devices/shelly/shelly_relay_switch/shelly_relay_switch_entity.dart +++ /dev/null @@ -1,136 +0,0 @@ -import 'dart:async'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_value_objects.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; -import 'package:shelly/shelly.dart'; - -class ShellyRelaySwitchEntity extends GenericSwitchDE { - ShellyRelaySwitchEntity({ - required super.uniqueId, - required super.entityUniqueId, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required super.switchState, - }) : super( - deviceVendor: DeviceVendor(VendorsAndServices.shelly.toString()), - ) { - shellyRelaySwitch = ShellyApiRelaySwitch( - lastKnownIp: deviceLastKnownIp.getOrCrash(), - mDnsName: deviceMdns.getOrCrash(), - hostName: deviceHostName.getOrCrash(), - ); - } - - late ShellyApiRelaySwitch shellyRelaySwitch; - - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - if (newEntity is! GenericSwitchDE) { - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Not the correct type', - ), - ); - } - - try { - if (newEntity.switchState!.getOrCrash() != switchState!.getOrCrash() || - entityStateGRPC.getOrCrash() != EntityStateGRPC.ack.toString()) { - final EntityActions? actionToPreform = - EnumHelperCbj.stringToDeviceAction( - newEntity.switchState!.getOrCrash(), - ); - - if (actionToPreform == EntityActions.on) { - (await turnOnSwitch()).fold( - (l) { - logger.e('Error turning Shelly switch on\n$l'); - throw l; - }, - (r) { - logger.i('Shelly switch turn on success'); - }, - ); - } else if (actionToPreform == EntityActions.off) { - (await turnOffSwitch()).fold( - (l) { - logger.e('Error turning Shelly off\n$l'); - throw l; - }, - (r) { - logger.i('Shelly switch turn off success'); - }, - ); - } else { - logger.w( - 'actionToPreform is not set correctly on Shelly Switch', - ); - } - } - entityStateGRPC = EntityState(EntityStateGRPC.ack.toString()); - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - return right(unit); - } catch (e) { - entityStateGRPC = EntityState(EntityStateGRPC.newStateFailed.toString()); - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> turnOnSwitch() async { - switchState = GenericSwitchSwitchState(EntityActions.on.toString()); - - try { - logger.t('Turn on Shelly device'); - shellyRelaySwitch.turnOn(); - return right(unit); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> turnOffSwitch() async { - switchState = GenericSwitchSwitchState(EntityActions.off.toString()); - - try { - logger.t('Turn off Shelly device'); - await shellyRelaySwitch.turnOff(); - return right(unit); - } catch (exception) { - return left(const CoreFailure.unexpected()); - } - } -} diff --git a/lib/infrastructure/devices/sonoff_diy/sonoff__diy_wall_switch/sonoff_diy_mod_wall_switch_entity.dart b/lib/infrastructure/devices/sonoff_diy/sonoff__diy_wall_switch/sonoff_diy_mod_wall_switch_entity.dart deleted file mode 100644 index f4a37485..00000000 --- a/lib/infrastructure/devices/sonoff_diy/sonoff__diy_wall_switch/sonoff_diy_mod_wall_switch_entity.dart +++ /dev/null @@ -1,136 +0,0 @@ -import 'dart:async'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_value_objects.dart'; -import 'package:cbj_hub/infrastructure/devices/sonoff_diy/sonoff_diy_api/sonoff_diy_api_wall_switch.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; - -class SonoffDiyRelaySwitchEntity extends GenericSwitchDE { - SonoffDiyRelaySwitchEntity({ - required super.uniqueId, - required super.entityUniqueId, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required super.switchState, - }) : super( - deviceVendor: DeviceVendor(VendorsAndServices.sonoffDiy.toString()), - ) { - sonoffDiyRelaySwitch = SonoffDiyApiWallSwitch( - ipAddress: deviceLastKnownIp.getOrCrash(), - hostName: deviceHostName.getOrCrash(), - port: int.parse(devicePort.getOrCrash()), - ); - } - - late SonoffDiyApiWallSwitch sonoffDiyRelaySwitch; - - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - if (newEntity is! GenericSwitchDE) { - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Not the correct type', - ), - ); - } - - try { - if (newEntity.switchState!.getOrCrash() != switchState!.getOrCrash() || - entityStateGRPC.getOrCrash() != EntityStateGRPC.ack.toString()) { - final EntityActions? actionToPreform = - EnumHelperCbj.stringToDeviceAction( - newEntity.switchState!.getOrCrash(), - ); - - if (actionToPreform == EntityActions.on) { - (await turnOnSwitch()).fold( - (l) { - logger.e('Error turning Sonoff diy switch on\n$l'); - throw l; - }, - (r) { - logger.i('Sonoff diy switch turn on success'); - }, - ); - } else if (actionToPreform == EntityActions.off) { - (await turnOffSwitch()).fold( - (l) { - logger.e('Error turning Sonoff diy off\n$l'); - throw l; - }, - (r) { - logger.i('Sonoff diy switch turn off success'); - }, - ); - } else { - logger.w( - 'actionToPreform is not set correctly on Sonoff diy Switch', - ); - } - } - entityStateGRPC = EntityState(EntityStateGRPC.ack.toString()); - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - return right(unit); - } catch (e) { - entityStateGRPC = EntityState(EntityStateGRPC.newStateFailed.toString()); - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> turnOnSwitch() async { - switchState = GenericSwitchSwitchState(EntityActions.on.toString()); - - try { - logger.t('Turn on Sonoff diy device'); - sonoffDiyRelaySwitch.switchOn(); - return right(unit); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> turnOffSwitch() async { - switchState = GenericSwitchSwitchState(EntityActions.off.toString()); - - try { - logger.t('Turn off Sonoff diy device'); - await sonoffDiyRelaySwitch.switchOff(); - return right(unit); - } catch (exception) { - return left(const CoreFailure.unexpected()); - } - } -} diff --git a/lib/infrastructure/devices/sonoff_diy/sonoff_device_value_objects.dart b/lib/infrastructure/devices/sonoff_diy/sonoff_device_value_objects.dart deleted file mode 100644 index 8b137891..00000000 --- a/lib/infrastructure/devices/sonoff_diy/sonoff_device_value_objects.dart +++ /dev/null @@ -1 +0,0 @@ - diff --git a/lib/infrastructure/devices/sonoff_diy/sonoff_diy_api/sonoff_diy_api_device_abstract.dart b/lib/infrastructure/devices/sonoff_diy/sonoff_diy_api/sonoff_diy_api_device_abstract.dart deleted file mode 100644 index 15088474..00000000 --- a/lib/infrastructure/devices/sonoff_diy/sonoff_diy_api/sonoff_diy_api_device_abstract.dart +++ /dev/null @@ -1,53 +0,0 @@ -import 'dart:convert'; - -import 'package:cbj_hub/utils.dart'; -import 'package:http/http.dart' as http; - -abstract class SonoffApiDeviceAbstract { - SonoffApiDeviceAbstract({ - required this.ipAddress, - required this.port, - required this.hostName, - }) { - baseUrl = 'http://$ipAddress:$port'; - } - - String ipAddress; - String hostName; - int port; - String serviceType = '_ewelink._tcp'; - String get serviceInstanceName => hostName; - String get deviceId { - final List hostNameSplit = hostName.split('_'); - if (hostNameSplit.length >= 2) { - return hostNameSplit[1]; - } - return ''; - } - - late String baseUrl; - - Future getInfo() async { - final url = Uri.parse('$baseUrl/zeroconf/info'); - final body = ''' -{ - "deviceid": "$deviceId", - "data": { - "switch": "on" - } -} - '''; - - final Map headers = { - 'Content-type': 'application/json', - 'Accept': 'application/json', - }; - - final http.Response response = - await http.post(url, body: body, headers: headers); - final String responseJson = json.decode(response.body).toString(); - logger.t(responseJson); - - return responseJson; - } -} diff --git a/lib/infrastructure/devices/sonoff_diy/sonoff_diy_api/sonoff_diy_api_wall_switch.dart b/lib/infrastructure/devices/sonoff_diy/sonoff_diy_api/sonoff_diy_api_wall_switch.dart deleted file mode 100644 index 52c7c62e..00000000 --- a/lib/infrastructure/devices/sonoff_diy/sonoff_diy_api/sonoff_diy_api_wall_switch.dart +++ /dev/null @@ -1,61 +0,0 @@ -import 'dart:convert'; - -import 'package:cbj_hub/infrastructure/devices/sonoff_diy/sonoff_diy_api/sonoff_diy_api_device_abstract.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:http/http.dart' as http; - -class SonoffDiyApiWallSwitch extends SonoffApiDeviceAbstract { - SonoffDiyApiWallSwitch({ - required super.ipAddress, - required super.port, - required super.hostName, - }); - - Future switchOn() async { - final url = Uri.parse('$baseUrl/zeroconf/switch'); - final body = ''' -{ - "deviceid": "$deviceId", - "data": { - "switch": "on" - } -} - '''; - - final Map headers = { - 'Content-type': 'application/json', - 'Accept': 'application/json', - }; - - final http.Response response = - await http.post(url, body: body, headers: headers); - final String responseJson = json.decode(response.body).toString(); - logger.t(responseJson); - - return responseJson; - } - - Future switchOff() async { - final url = Uri.parse('$baseUrl/zeroconf/switch'); - final body = ''' -{ - "deviceid": "$deviceId", - "data": { - "switch": "off" - } -} - '''; - - final Map headers = { - 'Content-type': 'application/json', - 'Accept': 'application/json', - }; - - final http.Response response = - await http.post(url, body: body, headers: headers); - final String responseJson = json.decode(response.body).toString(); - logger.t(responseJson); - - return responseJson; - } -} diff --git a/lib/infrastructure/devices/sonoff_diy/sonoff_diy_connector_conjector.dart b/lib/infrastructure/devices/sonoff_diy/sonoff_diy_connector_conjector.dart deleted file mode 100644 index d7fa406d..00000000 --- a/lib/infrastructure/devices/sonoff_diy/sonoff_diy_connector_conjector.dart +++ /dev/null @@ -1,84 +0,0 @@ -import 'dart:async'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/companies_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/sonoff_diy/sonoff__diy_wall_switch/sonoff_diy_mod_wall_switch_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/sonoff_diy/sonoff_diy_helpers.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/abstract_company_connector_conjector.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:injectable/injectable.dart'; - -@singleton -class SonoffDiyConnectorConjector implements AbstractCompanyConnectorConjector { - static const List mdnsTypes = ['_ewelink._tcp']; - @override - Map companyDevices = {}; - - /// Add new devices to [companyDevices] if not exist - Future addNewDeviceByMdnsName({ - required String mDnsName, - required String ip, - required String port, - }) async { - CoreUniqueId? tempCoreUniqueId; - - for (final DeviceEntityAbstract device in companyDevices.values) { - if (device is SonoffDiyRelaySwitchEntity && - mDnsName == device.entityUniqueId.getOrCrash()) { - return; - } else if (device is GenericSwitchDE && - mDnsName == device.entityUniqueId.getOrCrash()) { - /// Device exist as generic and needs to get converted to non generic type for this vendor - tempCoreUniqueId = device.uniqueId; - break; - } else if (mDnsName == device.entityUniqueId.getOrCrash()) { - logger.w( - 'Sonoff device type supported but implementation is missing here', - ); - return; - } - } - - final List sonoffDevices = - SonoffDiyHelpers.addDiscoverdDevice( - mDnsName: mDnsName, - ip: ip, - port: port, - uniqueDeviceId: tempCoreUniqueId, - ); - - if (sonoffDevices.isEmpty) { - return; - } - - for (final DeviceEntityAbstract entityAsDevice in sonoffDevices) { - final DeviceEntityAbstract deviceToAdd = - CompaniesConnectorConjector.addDiscoverdDeviceToHub(entityAsDevice); - - final MapEntry deviceAsEntry = - MapEntry(deviceToAdd.uniqueId.getOrCrash(), deviceToAdd); - - companyDevices.addEntries([deviceAsEntry]); - } - logger.t('New Sonoff diy devices name:$mDnsName'); - } - - @override - Future manageHubRequestsForDevice( - DeviceEntityAbstract sonoffDiyDE, - ) async { - final DeviceEntityAbstract? device = - companyDevices[sonoffDiyDE.entityUniqueId.getOrCrash()]; - - if (device is SonoffDiyRelaySwitchEntity) { - device.executeDeviceAction(newEntity: sonoffDiyDE); - } else { - logger.w('Sonoff diy device type does not exist'); - } - } - - @override - Future setUpDeviceFromDb(DeviceEntityAbstract deviceEntity) async {} -} diff --git a/lib/infrastructure/devices/sonoff_diy/sonoff_diy_device_validators.dart b/lib/infrastructure/devices/sonoff_diy/sonoff_diy_device_validators.dart deleted file mode 100644 index 34256cff..00000000 --- a/lib/infrastructure/devices/sonoff_diy/sonoff_diy_device_validators.dart +++ /dev/null @@ -1,14 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateSonoffDiySwitchKeyNotEmpty( - String input, -) { - return right(input); -} - -Either, String> validateSonoffDiyPortNotEmpty( - String input, -) { - return right(input); -} diff --git a/lib/infrastructure/devices/sonoff_diy/sonoff_diy_helpers.dart b/lib/infrastructure/devices/sonoff_diy/sonoff_diy_helpers.dart deleted file mode 100644 index 1f1652c6..00000000 --- a/lib/infrastructure/devices/sonoff_diy/sonoff_diy_helpers.dart +++ /dev/null @@ -1,63 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_value_objects.dart'; -import 'package:cbj_hub/infrastructure/devices/sonoff_diy/sonoff__diy_wall_switch/sonoff_diy_mod_wall_switch_entity.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbenum.dart'; -import 'package:cbj_hub/utils.dart'; - -class SonoffDiyHelpers { - static List addDiscoverdDevice({ - required String mDnsName, - required String? port, - required String ip, - required CoreUniqueId? uniqueDeviceId, - }) { - CoreUniqueId uniqueDeviceIdTemp; - - if (uniqueDeviceId != null) { - uniqueDeviceIdTemp = uniqueDeviceId; - } else { - uniqueDeviceIdTemp = CoreUniqueId(); - } - - final List deviceEntityList = []; - - try { - if (mDnsName.contains('sonoffDiy1-C45BBE78005D')) { - final SonoffDiyRelaySwitchEntity sonoffDiyRelaySwitchEntity = - SonoffDiyRelaySwitchEntity( - uniqueId: uniqueDeviceIdTemp, - entityUniqueId: EntityUniqueId(mDnsName), - cbjEntityName: CbjEntityName(mDnsName), - entityOriginalName: EntityOriginalName(mDnsName), - deviceOriginalName: DeviceOriginalName(mDnsName), - entityStateGRPC: EntityState(EntityStateGRPC.ack.toString()), - senderDeviceOs: DeviceSenderDeviceOs('SonoffDiy'), - senderDeviceModel: DeviceSenderDeviceModel('d1'), - senderId: DeviceSenderId(), - compUuid: DeviceCompUuid('34asdfrsd23gggg'), - stateMassage: DeviceStateMassage('Hello World'), - powerConsumption: DevicePowerConsumption('0'), - devicePort: DevicePort(port), - deviceHostName: DeviceHostName(mDnsName.toLowerCase()), - deviceMdns: DeviceMdns(mDnsName), - deviceLastKnownIp: DeviceLastKnownIp(ip), - switchState: GenericSwitchSwitchState(false.toString()), - deviceUniqueId: DeviceUniqueId('0'), - devicesMacAddress: DevicesMacAddress('0'), - entityKey: EntityKey('0'), - requestTimeStamp: RequestTimeStamp('0'), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp('0'), - deviceCbjUniqueId: CoreUniqueId(), - ); - deviceEntityList.add(sonoffDiyRelaySwitchEntity); - } else { - logger.i('SonoffDiy device types is not supported'); - } - } catch (e) { - logger.e('Error setting SonoffDiy\n$e'); - } - - return deviceEntityList; - } -} diff --git a/lib/infrastructure/devices/switcher/switcher_connector_conjector.dart b/lib/infrastructure/devices/switcher/switcher_connector_conjector.dart deleted file mode 100644 index af68b314..00000000 --- a/lib/infrastructure/devices/switcher/switcher_connector_conjector.dart +++ /dev/null @@ -1,121 +0,0 @@ -import 'dart:async'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_blinds_device/generic_blinds_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_boiler_device/generic_boiler_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_plug_device/generic_smart_plug_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/companies_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/switcher/switcher_helpers.dart'; -import 'package:cbj_hub/infrastructure/devices/switcher/switcher_runner/switcher_runner_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/switcher/switcher_smart_plug/switcher_smart_plug_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/switcher/switcher_v2/switcher_v2_entity.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/abstract_company_connector_conjector.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:injectable/injectable.dart'; -import 'package:switcher_dart/switcher_dart.dart'; - -@singleton -class SwitcherConnectorConjector implements AbstractCompanyConnectorConjector { - @override - Map companyDevices = {}; - - Future addOnlyNewSwitcherDevice( - SwitcherApiObject switcherApiObject, - ) async { - CoreUniqueId? tempCoreUniqueId; - - for (final DeviceEntityAbstract savedDevice in companyDevices.values) { - if ((savedDevice is SwitcherV2Entity || - savedDevice is SwitcherRunnerEntity || - savedDevice is SwitcherSmartPlugEntity) && - switcherApiObject.deviceId == - savedDevice.entityUniqueId.getOrCrash()) { - return; - } else if (savedDevice is GenericBoilerDE || - savedDevice is GenericBlindsDE && - switcherApiObject.deviceId == - savedDevice.entityUniqueId.getOrCrash()) { - /// Device exist as generic and needs to get converted to non generic type for this vendor - tempCoreUniqueId = savedDevice.uniqueId; - break; - } else if (switcherApiObject.deviceId == - savedDevice.entityUniqueId.getOrCrash()) { - logger.w( - 'Switcher device type supported but implementation is missing here', - ); - break; - } - } - - final DeviceEntityAbstract? addDevice = SwitcherHelpers.addDiscoverdDevice( - switcherDevice: switcherApiObject, - uniqueDeviceId: tempCoreUniqueId, - ); - if (addDevice == null) { - return; - } - - final DeviceEntityAbstract deviceToAdd = - CompaniesConnectorConjector.addDiscoverdDeviceToHub(addDevice); - - final MapEntry deviceAsEntry = - MapEntry(deviceToAdd.entityUniqueId.getOrCrash(), deviceToAdd); - - companyDevices.addEntries([deviceAsEntry]); - - // logger.t('New switcher devices name:${switcherApiObject.switcherName}'); - } - - @override - Future manageHubRequestsForDevice( - DeviceEntityAbstract switcherDE, - ) async { - final DeviceEntityAbstract? device = - companyDevices[switcherDE.entityUniqueId.getOrCrash()]; - - // if (device == null) { - // setTheSameDeviceFromAllDevices(switcherDE); - // device = - // companyDevices[switcherDE.entityUniqueId.getOrCrash(); - // } - - if (device != null && - (device is SwitcherV2Entity || - device is SwitcherRunnerEntity || - device is SwitcherSmartPlugEntity)) { - device.executeDeviceAction(newEntity: switcherDE); - } else { - logger.w('Switcher device type ${device.runtimeType} does not exist'); - } - } - - // Future setTheSameDeviceFromAllDevices( - // DeviceEntityAbstract switcherDE, - // ) async { - // final String deviceEntityUniqueId = switcherDE.entityUniqueId.getOrCrash(); - // for(a) - // } - - @override - Future setUpDeviceFromDb(DeviceEntityAbstract deviceEntity) async { - DeviceEntityAbstract? nonGenericDevice; - - if (deviceEntity is GenericBoilerDE) { - nonGenericDevice = SwitcherV2Entity.fromGeneric(deviceEntity); - } else if (deviceEntity is GenericSmartPlugDE) { - nonGenericDevice = SwitcherSmartPlugEntity.fromGeneric(deviceEntity); - } else if (deviceEntity is GenericBlindsDE) { - nonGenericDevice = SwitcherRunnerEntity.fromGeneric(deviceEntity); - } - - if (nonGenericDevice == null) { - logger.w('Switcher device could not get loaded from the server'); - return; - } - - companyDevices.addEntries([ - MapEntry(nonGenericDevice.entityUniqueId.getOrCrash(), nonGenericDevice), - ]); - } -} diff --git a/lib/infrastructure/devices/switcher/switcher_device_validators.dart b/lib/infrastructure/devices/switcher/switcher_device_validators.dart deleted file mode 100644 index 33554985..00000000 --- a/lib/infrastructure/devices/switcher/switcher_device_validators.dart +++ /dev/null @@ -1,16 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateSwitcherIdNotEmpty(String input) { - return right(input); -} - -Either, String> validateSwitcherPortNotEmpty(String input) { - return right(input); -} - -Either, String> validateSwitcherMacAddressNotEmpty( - String input, -) { - return right(input); -} diff --git a/lib/infrastructure/devices/switcher/switcher_helpers.dart b/lib/infrastructure/devices/switcher/switcher_helpers.dart deleted file mode 100644 index e2804ccc..00000000 --- a/lib/infrastructure/devices/switcher/switcher_helpers.dart +++ /dev/null @@ -1,156 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_blinds_device/generic_blinds_value_objects.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_boiler_device/generic_boiler_value_objects.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_plug_device/generic_smart_plug_value_objects.dart'; -import 'package:cbj_hub/infrastructure/devices/switcher/switcher_runner/switcher_runner_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/switcher/switcher_smart_plug/switcher_smart_plug_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/switcher/switcher_v2/switcher_v2_entity.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:switcher_dart/switcher_dart.dart'; - -class SwitcherHelpers { - static DeviceEntityAbstract? addDiscoverdDevice({ - required SwitcherApiObject switcherDevice, - required CoreUniqueId? uniqueDeviceId, - }) { - CoreUniqueId uniqueDeviceIdTemp; - - if (uniqueDeviceId != null) { - uniqueDeviceIdTemp = uniqueDeviceId; - } else { - uniqueDeviceIdTemp = CoreUniqueId(); - } - - if (switcherDevice.deviceType == SwitcherDevicesTypes.switcherRunner || - switcherDevice.deviceType == SwitcherDevicesTypes.switcherRunnerMini) { - EntityActions deviceActions = EntityActions.actionNotSupported; - - if (switcherDevice.deviceDirection == SwitcherDeviceDirection.up) { - deviceActions = EntityActions.moveUp; - } else if (switcherDevice.deviceDirection == - SwitcherDeviceDirection.stop) { - deviceActions = EntityActions.stop; - } else if (switcherDevice.deviceDirection == - SwitcherDeviceDirection.down) { - deviceActions = EntityActions.moveDown; - } - - final SwitcherRunnerEntity switcherRunnerDe = SwitcherRunnerEntity( - uniqueId: uniqueDeviceIdTemp, - entityUniqueId: EntityUniqueId(switcherDevice.deviceId), - cbjEntityName: CbjEntityName(switcherDevice.switcherName), - entityOriginalName: EntityOriginalName(switcherDevice.switcherName), - deviceOriginalName: DeviceOriginalName(switcherDevice.switcherName), - entityStateGRPC: EntityState(EntityStateGRPC.ack.toString()), - senderDeviceOs: DeviceSenderDeviceOs('switcher'), - senderDeviceModel: - DeviceSenderDeviceModel(switcherDevice.deviceType.toString()), - senderId: DeviceSenderId(), - compUuid: DeviceCompUuid('34asdfrsd23gggg'), - deviceLastKnownIp: DeviceLastKnownIp(switcherDevice.switcherIp), - stateMassage: DeviceStateMassage('Hello World'), - powerConsumption: - DevicePowerConsumption(switcherDevice.powerConsumption), - devicePort: DevicePort(switcherDevice.port.toString()), - devicesMacAddress: DevicesMacAddress(switcherDevice.macAddress), - blindsSwitchState: GenericBlindsSwitchState( - deviceActions.toString(), - ), - deviceUniqueId: DeviceUniqueId('0'), - deviceHostName: DeviceHostName('0'), - deviceMdns: DeviceMdns('0'), - entityKey: EntityKey('0'), - requestTimeStamp: RequestTimeStamp('0'), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp('0'), - deviceCbjUniqueId: CoreUniqueId(), - ); - - return switcherRunnerDe; - } else if (switcherDevice.deviceType == SwitcherDevicesTypes.switcherMini || - switcherDevice.deviceType == SwitcherDevicesTypes.switcherTouch || - switcherDevice.deviceType == SwitcherDevicesTypes.switcherV2Esp || - switcherDevice.deviceType == SwitcherDevicesTypes.switcherV2qualcomm || - switcherDevice.deviceType == SwitcherDevicesTypes.switcherV4) { - EntityActions deviceActions = EntityActions.actionNotSupported; - if (switcherDevice.deviceState == SwitcherDeviceState.on) { - deviceActions = EntityActions.on; - } else if (switcherDevice.deviceState == SwitcherDeviceState.off) { - deviceActions = EntityActions.off; - } - final SwitcherV2Entity switcherV2De = SwitcherV2Entity( - uniqueId: uniqueDeviceIdTemp, - entityUniqueId: EntityUniqueId(switcherDevice.deviceId), - cbjEntityName: CbjEntityName(switcherDevice.switcherName), - entityOriginalName: EntityOriginalName(switcherDevice.switcherName), - deviceOriginalName: DeviceOriginalName(switcherDevice.switcherName), - entityStateGRPC: EntityState(EntityStateGRPC.ack.toString()), - senderDeviceOs: DeviceSenderDeviceOs('switcher'), - senderDeviceModel: - DeviceSenderDeviceModel(switcherDevice.deviceType.toString()), - senderId: DeviceSenderId(), - compUuid: DeviceCompUuid('34asdfrsd23gggg'), - deviceLastKnownIp: DeviceLastKnownIp(switcherDevice.switcherIp), - stateMassage: DeviceStateMassage('Hello World'), - powerConsumption: - DevicePowerConsumption(switcherDevice.powerConsumption), - boilerSwitchState: GenericBoilerSwitchState(deviceActions.toString()), - devicePort: DevicePort(switcherDevice.port.toString()), - devicesMacAddress: DevicesMacAddress(switcherDevice.macAddress), - deviceUniqueId: DeviceUniqueId('0'), - deviceHostName: DeviceHostName('0'), - deviceMdns: DeviceMdns('0'), - entityKey: EntityKey('0'), - requestTimeStamp: RequestTimeStamp('0'), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp('0'), - deviceCbjUniqueId: CoreUniqueId(), - ); - - return switcherV2De; - } else if (switcherDevice.deviceType == - SwitcherDevicesTypes.switcherPowerPlug) { - EntityActions deviceActions = EntityActions.actionNotSupported; - if (switcherDevice.deviceState == SwitcherDeviceState.on) { - deviceActions = EntityActions.on; - } else if (switcherDevice.deviceState == SwitcherDeviceState.off) { - deviceActions = EntityActions.off; - } - final SwitcherSmartPlugEntity switcherSmartPlugDe = - SwitcherSmartPlugEntity( - uniqueId: uniqueDeviceIdTemp, - entityUniqueId: EntityUniqueId(switcherDevice.deviceId), - cbjEntityName: CbjEntityName(switcherDevice.switcherName), - entityOriginalName: EntityOriginalName(switcherDevice.switcherName), - deviceOriginalName: DeviceOriginalName(switcherDevice.switcherName), - entityStateGRPC: EntityState(EntityStateGRPC.ack.toString()), - senderDeviceOs: DeviceSenderDeviceOs('switcher'), - senderDeviceModel: - DeviceSenderDeviceModel(switcherDevice.deviceType.toString()), - senderId: DeviceSenderId(), - compUuid: DeviceCompUuid('34asdfrsd23gggg'), - deviceLastKnownIp: DeviceLastKnownIp(switcherDevice.switcherIp), - stateMassage: DeviceStateMassage('Hello World'), - powerConsumption: - DevicePowerConsumption(switcherDevice.powerConsumption), - smartPlugState: GenericSmartPlugState(deviceActions.toString()), - deviceUniqueId: DeviceUniqueId('0'), - devicePort: DevicePort(switcherDevice.port.toString()), - deviceHostName: DeviceHostName('0'), - deviceMdns: DeviceMdns('0'), - devicesMacAddress: DevicesMacAddress(switcherDevice.macAddress), - entityKey: EntityKey('0'), - requestTimeStamp: RequestTimeStamp('0'), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp('0'), - deviceCbjUniqueId: CoreUniqueId(), - ); - - return switcherSmartPlugDe; - } - - logger.i( - 'Please add new Switcher device type ${switcherDevice.deviceType}', - ); - return null; - } -} diff --git a/lib/infrastructure/devices/switcher/switcher_runner/switcher_runner_entity.dart b/lib/infrastructure/devices/switcher/switcher_runner/switcher_runner_entity.dart deleted file mode 100644 index f36aeb9d..00000000 --- a/lib/infrastructure/devices/switcher/switcher_runner/switcher_runner_entity.dart +++ /dev/null @@ -1,193 +0,0 @@ -import 'dart:async'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_blinds_device/generic_blinds_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_blinds_device/generic_blinds_value_objects.dart'; -import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/injection.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; -import 'package:switcher_dart/switcher_dart.dart'; - -class SwitcherRunnerEntity extends GenericBlindsDE { - SwitcherRunnerEntity({ - required super.uniqueId, - required super.entityUniqueId, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.entityStateGRPC, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.powerConsumption, - required super.deviceUniqueId, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required super.blindsSwitchState, - required super.devicePort, - }) : super( - deviceVendor: - DeviceVendor(VendorsAndServices.switcherSmartHome.toString()), - ) { - switcherObject = SwitcherApiObject( - deviceType: SwitcherDevicesTypes.switcherRunner, - deviceId: entityUniqueId.getOrCrash(), - switcherIp: deviceLastKnownIp.getOrCrash(), - switcherName: cbjEntityName.getOrCrash()!, - macAddress: devicesMacAddress.getOrCrash(), - port: int.parse(devicePort.getOrCrash()), - powerConsumption: powerConsumption.getOrCrash(), - ); - } - - factory SwitcherRunnerEntity.fromGeneric(GenericBlindsDE genericDevice) { - return SwitcherRunnerEntity( - uniqueId: genericDevice.uniqueId, - entityUniqueId: genericDevice.entityUniqueId, - cbjEntityName: genericDevice.cbjEntityName, - entityOriginalName: genericDevice.entityOriginalName, - deviceOriginalName: genericDevice.deviceOriginalName, - stateMassage: genericDevice.stateMassage, - senderDeviceOs: genericDevice.senderDeviceOs, - senderDeviceModel: genericDevice.senderDeviceModel, - senderId: genericDevice.senderId, - compUuid: genericDevice.compUuid, - entityStateGRPC: genericDevice.entityStateGRPC, - powerConsumption: genericDevice.powerConsumption, - deviceUniqueId: genericDevice.deviceUniqueId, - devicePort: genericDevice.devicePort, - deviceLastKnownIp: genericDevice.deviceLastKnownIp, - deviceHostName: genericDevice.deviceHostName, - deviceMdns: genericDevice.deviceMdns, - devicesMacAddress: genericDevice.devicesMacAddress, - entityKey: genericDevice.entityKey, - requestTimeStamp: genericDevice.requestTimeStamp, - lastResponseFromDeviceTimeStamp: - genericDevice.lastResponseFromDeviceTimeStamp, - deviceCbjUniqueId: genericDevice.deviceCbjUniqueId, - blindsSwitchState: genericDevice.blindsSwitchState, - ); - } - - /// Switcher package object require to close previews request before new one - SwitcherApiObject? switcherObject; - - String? autoShutdown; - String? electricCurrent; - String? remainingTime; - - /// Please override the following methods - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - if (newEntity is! GenericBlindsDE) { - return left( - const CoreFailure.actionExcecuter(failedValue: 'Not the correct type'), - ); - } - - try { - if (newEntity.entityStateGRPC.getOrCrash() != - EntityStateGRPC.ack.toString()) { - if (newEntity.blindsSwitchState!.getOrCrash() != - blindsSwitchState!.getOrCrash()) { - final EntityActions? actionToPreform = - EnumHelperCbj.stringToDeviceAction( - newEntity.blindsSwitchState!.getOrCrash(), - ); - - if (actionToPreform == EntityActions.moveUp) { - (await moveUpBlinds()).fold((l) { - logger.e('Error turning blinds up'); - throw l; - }, (r) { - logger.i('Blinds up success'); - }); - } else if (actionToPreform == EntityActions.stop) { - (await stopBlinds()).fold((l) { - logger.e('Error stopping blinds'); - throw l; - }, (r) { - logger.i('Blinds stop success'); - }); - } else if (actionToPreform == EntityActions.moveDown) { - (await moveDownBlinds()).fold((l) { - logger.e('Error turning blinds down'); - throw l; - }, (r) { - logger.i('Blinds down success'); - }); - } else { - logger.e('actionToPreform is not set correctly on Switcher Runner'); - } - } - entityStateGRPC = EntityState(EntityStateGRPC.ack.toString()); - - getIt().postSmartDeviceToAppMqtt( - entityFromTheHub: this, - ); - } - return right(unit); - } catch (e) { - entityStateGRPC = EntityState(EntityStateGRPC.newStateFailed.toString()); - - getIt().postSmartDeviceToAppMqtt( - entityFromTheHub: this, - ); - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> moveUpBlinds() async { - blindsSwitchState = - GenericBlindsSwitchState(EntityActions.moveUp.toString()); - - try { - await switcherObject!.setPosition(pos: 100); - - return right(unit); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> stopBlinds() async { - blindsSwitchState = GenericBlindsSwitchState(EntityActions.stop.toString()); - - try { - await switcherObject!.stopBlinds(); - return right(unit); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> moveDownBlinds() async { - blindsSwitchState = - GenericBlindsSwitchState(EntityActions.moveDown.toString()); - - try { - await switcherObject!.setPosition(); - return right(unit); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - } -} diff --git a/lib/infrastructure/devices/switcher/switcher_smart_plug/switcher_smart_plug_entity.dart b/lib/infrastructure/devices/switcher/switcher_smart_plug/switcher_smart_plug_entity.dart deleted file mode 100644 index 8e584a84..00000000 --- a/lib/infrastructure/devices/switcher/switcher_smart_plug/switcher_smart_plug_entity.dart +++ /dev/null @@ -1,187 +0,0 @@ -import 'dart:async'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_plug_device/generic_smart_plug_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_plug_device/generic_smart_plug_value_objects.dart'; -import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/injection.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; -import 'package:switcher_dart/switcher_dart.dart'; - -class SwitcherSmartPlugEntity extends GenericSmartPlugDE { - SwitcherSmartPlugEntity({ - required super.uniqueId, - required super.entityUniqueId, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required super.smartPlugState, - }) : super( - deviceVendor: - DeviceVendor(VendorsAndServices.switcherSmartHome.toString()), - ) { - switcherObject = SwitcherApiObject( - deviceType: SwitcherDevicesTypes.switcherPowerPlug, - deviceId: entityUniqueId.getOrCrash(), - switcherIp: deviceLastKnownIp.getOrCrash(), - switcherName: cbjEntityName.getOrCrash()!, - macAddress: devicesMacAddress.getOrCrash(), - powerConsumption: powerConsumption.getOrCrash(), - ); - } - - factory SwitcherSmartPlugEntity.fromGeneric( - GenericSmartPlugDE genericDevice, - ) { - return SwitcherSmartPlugEntity( - uniqueId: genericDevice.uniqueId, - entityUniqueId: genericDevice.entityUniqueId, - cbjEntityName: genericDevice.cbjEntityName, - entityOriginalName: genericDevice.entityOriginalName, - deviceOriginalName: genericDevice.deviceOriginalName, - stateMassage: genericDevice.stateMassage, - senderDeviceOs: genericDevice.senderDeviceOs, - senderDeviceModel: genericDevice.senderDeviceModel, - senderId: genericDevice.senderId, - compUuid: genericDevice.compUuid, - entityStateGRPC: genericDevice.entityStateGRPC, - powerConsumption: genericDevice.powerConsumption, - deviceUniqueId: genericDevice.deviceUniqueId, - devicePort: genericDevice.devicePort, - deviceLastKnownIp: genericDevice.deviceLastKnownIp, - deviceHostName: genericDevice.deviceHostName, - deviceMdns: genericDevice.deviceMdns, - devicesMacAddress: genericDevice.devicesMacAddress, - entityKey: genericDevice.entityKey, - requestTimeStamp: genericDevice.requestTimeStamp, - lastResponseFromDeviceTimeStamp: - genericDevice.lastResponseFromDeviceTimeStamp, - deviceCbjUniqueId: genericDevice.deviceCbjUniqueId, - smartPlugState: genericDevice.smartPlugState, - ); - } - - /// Switcher package object require to close previews request before new one - SwitcherApiObject? switcherObject; - - String? autoShutdown; - String? electricCurrent; - String? remainingTime; - - /// Please override the following methods - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - if (newEntity is! GenericSmartPlugDE) { - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Not the correct type', - ), - ); - } - - try { - if (newEntity.entityStateGRPC.getOrCrash() != - EntityStateGRPC.ack.toString()) { - if (newEntity.smartPlugState!.getOrCrash() != - smartPlugState!.getOrCrash()) { - final EntityActions? actionToPreform = - EnumHelperCbj.stringToDeviceAction( - newEntity.smartPlugState!.getOrCrash(), - ); - - if (actionToPreform == EntityActions.on) { - (await turnOnSmartPlug()).fold( - (l) { - logger.e('Error turning smart plug on'); - throw l; - }, - (r) { - logger.i('Smart plug turn on success'); - }, - ); - } else if (actionToPreform == EntityActions.off) { - (await turnOffSmartPlug()).fold( - (l) { - logger.e('Error turning smart plug off'); - throw l; - }, - (r) { - logger.i('Smart plug turn off success'); - }, - ); - } else { - logger.e( - 'actionToPreform is not set correctly on Switcher Smart Plug', - ); - } - } - entityStateGRPC = EntityState(EntityStateGRPC.ack.toString()); - - getIt().postSmartDeviceToAppMqtt( - entityFromTheHub: this, - ); - } - return right(unit); - } catch (e) { - entityStateGRPC = EntityState(EntityStateGRPC.newStateFailed.toString()); - - getIt().postSmartDeviceToAppMqtt( - entityFromTheHub: this, - ); - - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> turnOnSmartPlug() async { - smartPlugState = GenericSmartPlugState(EntityActions.on.toString()); - - try { - await switcherObject!.turnOn(); - // TODO: Add a way to get switch value to improve code and test new - // TODO: response state from the hub - // await switcherObject.getSocket(); - return right(unit); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> turnOffSmartPlug() async { - smartPlugState = GenericSmartPlugState(EntityActions.off.toString()); - - try { - await switcherObject!.turnOff(); - - return right(unit); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - } -} diff --git a/lib/infrastructure/devices/switcher/switcher_v2/switcher_v2_entity.dart b/lib/infrastructure/devices/switcher/switcher_v2/switcher_v2_entity.dart deleted file mode 100644 index f4b73d19..00000000 --- a/lib/infrastructure/devices/switcher/switcher_v2/switcher_v2_entity.dart +++ /dev/null @@ -1,185 +0,0 @@ -import 'dart:async'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_boiler_device/generic_boiler_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_boiler_device/generic_boiler_value_objects.dart'; -import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/injection.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; -import 'package:switcher_dart/switcher_dart.dart'; - -class SwitcherV2Entity extends GenericBoilerDE { - SwitcherV2Entity({ - required super.uniqueId, - required super.entityUniqueId, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.entityStateGRPC, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required super.boilerSwitchState, - }) : super( - deviceVendor: - DeviceVendor(VendorsAndServices.switcherSmartHome.toString()), - ) { - switcherObject = SwitcherApiObject( - deviceType: SwitcherDevicesTypes.switcherV2Esp, - deviceId: entityUniqueId.getOrCrash(), - switcherIp: deviceLastKnownIp.getOrCrash(), - switcherName: cbjEntityName.getOrCrash()!, - macAddress: devicesMacAddress.getOrCrash(), - powerConsumption: powerConsumption.getOrCrash(), - ); - } - - factory SwitcherV2Entity.fromGeneric(GenericBoilerDE genericDevice) { - return SwitcherV2Entity( - uniqueId: genericDevice.uniqueId, - entityUniqueId: genericDevice.entityUniqueId, - cbjEntityName: genericDevice.cbjEntityName, - entityOriginalName: genericDevice.entityOriginalName, - deviceOriginalName: genericDevice.deviceOriginalName, - stateMassage: genericDevice.stateMassage, - senderDeviceOs: genericDevice.senderDeviceOs, - senderDeviceModel: genericDevice.senderDeviceModel, - senderId: genericDevice.senderId, - compUuid: genericDevice.compUuid, - entityStateGRPC: genericDevice.entityStateGRPC, - powerConsumption: genericDevice.powerConsumption, - deviceUniqueId: genericDevice.deviceUniqueId, - devicePort: genericDevice.devicePort, - deviceLastKnownIp: genericDevice.deviceLastKnownIp, - deviceHostName: genericDevice.deviceHostName, - deviceMdns: genericDevice.deviceMdns, - devicesMacAddress: genericDevice.devicesMacAddress, - entityKey: genericDevice.entityKey, - requestTimeStamp: genericDevice.requestTimeStamp, - lastResponseFromDeviceTimeStamp: - genericDevice.lastResponseFromDeviceTimeStamp, - deviceCbjUniqueId: genericDevice.deviceCbjUniqueId, - boilerSwitchState: genericDevice.boilerSwitchState, - ); - } - - /// Switcher package object require to close previews request before new one - SwitcherApiObject? switcherObject; - - String? autoShutdown; - String? electricCurrent; - String? lastDataUpdate; - String? macAddress; - String? remainingTime; - - /// Please override the following methods - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - if (newEntity is! GenericBoilerDE) { - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Not the correct type', - ), - ); - } - - try { - if (newEntity.entityStateGRPC.getOrCrash() != - EntityStateGRPC.ack.toString()) { - if (newEntity.boilerSwitchState!.getOrCrash() != - boilerSwitchState!.getOrCrash()) { - final EntityActions? actionToPreform = - EnumHelperCbj.stringToDeviceAction( - newEntity.boilerSwitchState!.getOrCrash(), - ); - - if (actionToPreform == EntityActions.on) { - (await turnOnBoiler()).fold( - (l) { - logger.e('Error turning boiler on'); - throw l; - }, - (r) { - logger.i('Boiler turn on success'); - }, - ); - } else if (actionToPreform == EntityActions.off) { - (await turnOffBoiler()).fold( - (l) { - logger.e('Error turning boiler off'); - throw l; - }, - (r) { - logger.i('Boiler turn off success'); - }, - ); - } else { - logger.e('actionToPreform is not set correctly on Switcher V2'); - } - } - entityStateGRPC = EntityState(EntityStateGRPC.ack.toString()); - - getIt().postSmartDeviceToAppMqtt( - entityFromTheHub: this, - ); - } - return right(unit); - } catch (e) { - entityStateGRPC = EntityState(EntityStateGRPC.newStateFailed.toString()); - - getIt().postSmartDeviceToAppMqtt( - entityFromTheHub: this, - ); - - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> turnOnBoiler() async { - boilerSwitchState = GenericBoilerSwitchState(EntityActions.on.toString()); - - try { - await switcherObject!.turnOn(); - // TODO: Add a way to get switch value to improve code and test new - // TODO: response state from the hub - // await switcherObject.getSocket(); - return right(unit); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> turnOffBoiler() async { - boilerSwitchState = GenericBoilerSwitchState(EntityActions.off.toString()); - - try { - await switcherObject!.turnOff(); - - return right(unit); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - } -} diff --git a/lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_api/tasmota_ip_api_components.dart b/lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_api/tasmota_ip_api_components.dart deleted file mode 100644 index dad8f61f..00000000 --- a/lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_api/tasmota_ip_api_components.dart +++ /dev/null @@ -1,45 +0,0 @@ -// Values from here https://tasmota.github.io/docs/Components/ -// Stored in the following way. -// MapEntry(Number label: [UI Label, Comment]) - -Map> gpioOverviewTasmota = { - 0: ['None', 'Not used'], - 32: ['Button1', 'Button active low, internal pull-up resistor'], - 33: ['Button2', 'Button active low, internal pull-up resistor'], - 34: ['Button3', 'Button active low, internal pull-up resistor'], - 35: ['Button4', 'Button active low, internal pull-up resistor'], - 36: ['Button5', 'Button active low, internal pull-up resistor'], - 37: ['Button6', 'Button active low, internal pull-up resistor'], - 38: ['Button7', 'Button active low, internal pull-up resistor'], - 39: ['Button8', 'Button active low, internal pull-up resistor'], - 64: ['Button_n1', 'Button active low, no internal pull-up resistor'], - 65: ['Button_n2', 'Button active low, no internal pull-up resistor'], - 66: ['Button_n3', 'Button active low, no internal pull-up resistor'], - 67: ['Button_n4', 'Button active low, no internal pull-up resistor'], - 68: ['Button_n5', 'Button active low, no internal pull-up resistor'], - 69: ['Button_n6', 'Button active low, no internal pull-up resistor'], - 70: ['Button_n7', 'Button active low, no internal pull-up resistor'], - 71: ['Button_n8', 'Button active low, no internal pull-up resistor'], - 96: [ - 'Button_i1', - 'Button inverted, active high with internal pull-up resistor', - ], - 97: [ - 'Button_i2', - 'Button inverted, active high with internal pull-up resistor', - ], - 160: ['Switch1', 'Switch, internal pull-up resistor'], - 192: ['Switch_n1', 'Switch, no pull-up resistor'], - 224: ['Relay1', 'Relay'], - 255: ['User', 'User pin'], - 288: ['Led1', '4 x Leds'], - 320: ['Led_i1', '4 x Leds'], - 352: ['Counter1', '4 x Counter'], -}; - -/// For 32bit microcontroller running Tasmota -Map> gpioOverviewTasmota32 = { - 0: ['None', 'Not used'], - 1: ['None', 'Not used'], - 32: ['Button1', 'Button active low, internal pull-up resistor'], -}; diff --git a/lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_connector_conjector.dart b/lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_connector_conjector.dart deleted file mode 100644 index ce456bc4..00000000 --- a/lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_connector_conjector.dart +++ /dev/null @@ -1,158 +0,0 @@ -import 'dart:async'; -import 'dart:convert'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_light_device/generic_light_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/companies_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_helpers.dart'; -import 'package:cbj_hub/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_led/tasmota_ip_led_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_switch/tasmota_ip_switch_entity.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/abstract_company_connector_conjector.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:http/http.dart'; -import 'package:injectable/injectable.dart'; -import 'package:network_tools/network_tools.dart'; - -@singleton -class TasmotaIpConnectorConjector implements AbstractCompanyConnectorConjector { - @override - Map companyDevices = {}; - - // This is how you can interact tasmota using network calls. - // http://ip/cm?cmnd=SetOption19%200 - // http://ip/cm?cmnd=MqttHost%200 - - Future addNewDeviceByHostInfo({ - required ActiveHost activeHost, - }) async { - final List tempCoreUniqueId = []; - - for (final DeviceEntityAbstract savedDevice in companyDevices.values) { - if ((savedDevice is TasmotaIpSwitchEntity) && - await activeHost.hostName == - savedDevice.entityUniqueId.getOrCrash()) { - return; - } else if (savedDevice is GenericLightDE && - await activeHost.hostName == - savedDevice.entityUniqueId.getOrCrash()) { - /// Device exist as generic and needs to get converted to non generic type for this vendor - tempCoreUniqueId.add(savedDevice.uniqueId); - break; - } else if (await activeHost.hostName == - savedDevice.entityUniqueId.getOrCrash()) { - logger.w( - 'Tasmota IP device type supported but implementation is missing here', - ); - } - } - // TODO: Create list of CoreUniqueId and populate it with all the - // components saved devices that already exist - final List componentsInDevice = - await getAllComponentsOfDevice(activeHost); - - final List tasmotaIpDevices = - await TasmotaIpHelpers.addDiscoverdDevice( - activeHost: activeHost, - uniqueDeviceIdList: tempCoreUniqueId, - componentInDeviceNumberLabelList: componentsInDevice, - ); - - if (tasmotaIpDevices.isEmpty) { - return; - } - - for (final DeviceEntityAbstract entityAsDevice in tasmotaIpDevices) { - final DeviceEntityAbstract deviceToAdd = - CompaniesConnectorConjector.addDiscoverdDeviceToHub(entityAsDevice); - - final MapEntry deviceAsEntry = - MapEntry(deviceToAdd.uniqueId.getOrCrash(), deviceToAdd); - - companyDevices.addEntries([deviceAsEntry]); - - logger.t( - 'New Tasmota Ip device name:${entityAsDevice.cbjEntityName.getOrCrash()}', - ); - } - } - - @override - Future manageHubRequestsForDevice( - DeviceEntityAbstract tasmotaIpDE, - ) async { - final DeviceEntityAbstract? device = - companyDevices[tasmotaIpDE.entityUniqueId.getOrCrash()]; - - if (device is TasmotaIpSwitchEntity) { - device.executeDeviceAction(newEntity: tasmotaIpDE); - } else { - logger.w('TasmotaIp device type does not exist'); - } - } - - /// Getting all of the components/gpio configuration of the device. - /// Doc of all components: https://tasmota.github.io/docs/Components/#tasmota - Future> getAllComponentsOfDevice( - ActiveHost activeHost, - ) async { - final String deviceIp = activeHost.address; - const String getComponentsCommand = 'cm?cmnd=Gpio'; - - Map>? responseJson; - final List componentTypeAndName = []; - - try { - final Response response = - await get(Uri.parse('http://$deviceIp/$getComponentsCommand')); - final Map temp1ResponseJson = - json.decode(response.body) as Map; - - final Map> temp2ResponseJson = - temp1ResponseJson.map( - (key, value) => MapEntry(key, value as Map), - ); - - responseJson = temp2ResponseJson.map( - (key, Map value) => MapEntry( - key, - value.map( - (key, value) { - final MapEntry tempEntry = - MapEntry(key, value.toString()); - componentTypeAndName.add(key); - return tempEntry; - }, - ), - ), - ); - } catch (e) { - logger.e(e); - } - if (responseJson == null || responseJson.isEmpty) { - return []; - } - return componentTypeAndName; - } - - @override - Future setUpDeviceFromDb(DeviceEntityAbstract deviceEntity) async { - DeviceEntityAbstract? nonGenericDevice; - - if (deviceEntity is GenericLightDE) { - nonGenericDevice = TasmotaIpLedEntity.fromGeneric(deviceEntity); - } else if (deviceEntity is GenericSwitchDE) { - nonGenericDevice = TasmotaIpSwitchEntity.fromGeneric(deviceEntity); - } - - if (nonGenericDevice == null) { - logger.w('Switcher device could not get loaded from the server'); - return; - } - - companyDevices.addEntries([ - MapEntry(nonGenericDevice.entityUniqueId.getOrCrash(), nonGenericDevice), - ]); - } -} diff --git a/lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_device_validators.dart b/lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_device_validators.dart deleted file mode 100644 index b56d06c1..00000000 --- a/lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_device_validators.dart +++ /dev/null @@ -1,20 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateTasmotaIpHostNameNotEmpty( - String input, -) { - return right(input); -} - -Either, String> validateTasmotaIpLastIpNotEmpty( - String input, -) { - return right(input); -} - -Either, String> validateTasmotaIpDeviceIdNotEmpty( - String input, -) { - return right(input); -} diff --git a/lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_helpers.dart b/lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_helpers.dart deleted file mode 100644 index 2bdcf5ed..00000000 --- a/lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_helpers.dart +++ /dev/null @@ -1,136 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_value_objects.dart'; -import 'package:cbj_hub/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_api/tasmota_ip_api_components.dart'; -import 'package:cbj_hub/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_switch/tasmota_ip_switch_entity.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbenum.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:network_tools/network_tools.dart'; - -class TasmotaIpHelpers { - static Future> addDiscoverdDevice({ - required ActiveHost activeHost, - required List uniqueDeviceIdList, - required List componentInDeviceNumberLabelList, - }) async { - final List uniqueDeviceIdTempList = []; - - for (int counter = 0; - counter < componentInDeviceNumberLabelList.length; - counter++) { - if (counter < uniqueDeviceIdList.length && - uniqueDeviceIdList[counter] != null) { - uniqueDeviceIdTempList.add(uniqueDeviceIdList[counter]!); - } else { - uniqueDeviceIdTempList.add(CoreUniqueId()); - } - } - - final List devicesToAddTemp = []; - - for (int counter = 0; - counter < componentInDeviceNumberLabelList.length; - counter++) { - final String componentInDeviceNumberLabel = - componentInDeviceNumberLabelList[counter]; - final CoreUniqueId coreUniqueIdTemp = uniqueDeviceIdTempList[counter]; - final DeviceEntityAbstract? deviceEntity = await addDeviceByTasmotaType( - componentInDeviceNumberLabel: componentInDeviceNumberLabel, - coreUniqueIdTemp: coreUniqueIdTemp, - activeHost: activeHost, - ); - if (deviceEntity != null) { - devicesToAddTemp.add(deviceEntity); - } - } - - return devicesToAddTemp; - } - - static Future addDeviceByTasmotaType({ - required String componentInDeviceNumberLabel, - required ActiveHost activeHost, - required CoreUniqueId coreUniqueIdTemp, - }) async { - final String? deviceHostName = await activeHost.hostName; - if (deviceHostName == null) { - return null; - } - final int componentInDeviceNumberLabelAsInt = - int.parse(componentInDeviceNumberLabel); - - if (!gpioOverviewTasmota.keys.contains(componentInDeviceNumberLabelAsInt) || - gpioOverviewTasmota[componentInDeviceNumberLabelAsInt]!.length < 2) { - logger.w( - 'Tasmota ip does not contain this key, you can add more in [gpioOverviewTasmota]', - ); - return null; - } - final List? componentInDeviceUiLabelAndComment = - gpioOverviewTasmota[componentInDeviceNumberLabelAsInt]; - - if (componentInDeviceNumberLabelAsInt == 0) { - // UI Label: None - return null; - } else if (componentInDeviceNumberLabelAsInt >= 32 && - componentInDeviceNumberLabelAsInt <= 39) { - // UI Label: Button - } else if (componentInDeviceNumberLabelAsInt >= 64 && - componentInDeviceNumberLabelAsInt <= 71) { - // UI Label: Button_n - } else if (componentInDeviceNumberLabelAsInt >= 96 && - componentInDeviceNumberLabelAsInt <= 103) { - // UI Label: Button_i - } else if (componentInDeviceNumberLabelAsInt >= 224 && - componentInDeviceNumberLabelAsInt <= 251) { - // UI Label: Relay - return TasmotaIpSwitchEntity( - uniqueId: coreUniqueIdTemp, - entityUniqueId: EntityUniqueId( - '$deviceHostName-$componentInDeviceNumberLabel}', - ), - cbjEntityName: CbjEntityName( - '$deviceHostName-${componentInDeviceUiLabelAndComment![0]}', - ), - entityOriginalName: EntityOriginalName( - '$deviceHostName-${componentInDeviceUiLabelAndComment[0]}', - ), - deviceOriginalName: DeviceOriginalName( - '$deviceHostName-${componentInDeviceUiLabelAndComment[0]}', - ), - entityStateGRPC: EntityState(EntityStateGRPC.ack.toString()), - senderDeviceOs: DeviceSenderDeviceOs('Tasmota'), - senderDeviceModel: DeviceSenderDeviceModel('Tasmota'), - senderId: DeviceSenderId(), - compUuid: DeviceCompUuid('34asdfrsd23gggg'), - stateMassage: DeviceStateMassage('Hello World'), - powerConsumption: DevicePowerConsumption('0'), - switchState: GenericSwitchSwitchState(EntityActions.off.toString()), - deviceHostName: DeviceHostName(deviceHostName), - deviceLastKnownIp: DeviceLastKnownIp(activeHost.address), - deviceUniqueId: DeviceUniqueId('0'), - devicePort: DevicePort('0'), - deviceMdns: DeviceMdns('0'), - devicesMacAddress: DevicesMacAddress('0'), - entityKey: EntityKey('0'), - requestTimeStamp: RequestTimeStamp('0'), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp('0'), - deviceCbjUniqueId: CoreUniqueId(), - ); - } else if (componentInDeviceNumberLabelAsInt >= 256 && - componentInDeviceNumberLabelAsInt <= 283) { - // UI Label: Relay_i - } else if (componentInDeviceNumberLabelAsInt >= 288 && - componentInDeviceNumberLabelAsInt <= 291) { - // UI Label: Led - } else if (componentInDeviceNumberLabelAsInt >= 320 && - componentInDeviceNumberLabelAsInt <= 323) { - // UI Label: Led_i - } - - logger.i( - 'Please add new Tasmota device type ${componentInDeviceUiLabelAndComment![0]}', - ); - return null; - } -} diff --git a/lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_led/tasmota_ip_led_entity.dart b/lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_led/tasmota_ip_led_entity.dart deleted file mode 100644 index d92bd751..00000000 --- a/lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_led/tasmota_ip_led_entity.dart +++ /dev/null @@ -1,172 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_light_device/generic_light_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_light_device/generic_light_value_objects.dart'; -import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/injection.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; - -// TODO: Make the commends work, currently this object does not work -// Toggle device on/off, the o is the number of output to toggle o=2 is the second -// http://ip/?m=1&o=1 -// Change brightness -// http://ip/?m=1&d0=30 -// Change color -// http://ip/?m=1&h0=232 -// Change tint (I think) -// http://ip/?m=1&t0=500 -// Change color strength -// http://ip/?m=1&n0=87 - -class TasmotaIpLedEntity extends GenericLightDE { - TasmotaIpLedEntity({ - required super.uniqueId, - required super.entityUniqueId, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required super.lightSwitchState, - }) : super( - deviceVendor: DeviceVendor(VendorsAndServices.tasmota.toString()), - ); - - factory TasmotaIpLedEntity.fromGeneric(GenericLightDE genericDevice) { - return TasmotaIpLedEntity( - uniqueId: genericDevice.uniqueId, - entityUniqueId: genericDevice.entityUniqueId, - cbjEntityName: genericDevice.cbjEntityName, - entityOriginalName: genericDevice.entityOriginalName, - deviceOriginalName: genericDevice.deviceOriginalName, - stateMassage: genericDevice.stateMassage, - senderDeviceOs: genericDevice.senderDeviceOs, - senderDeviceModel: genericDevice.senderDeviceModel, - senderId: genericDevice.senderId, - compUuid: genericDevice.compUuid, - entityStateGRPC: genericDevice.entityStateGRPC, - powerConsumption: genericDevice.powerConsumption, - deviceUniqueId: genericDevice.deviceUniqueId, - devicePort: genericDevice.devicePort, - deviceLastKnownIp: genericDevice.deviceLastKnownIp, - deviceHostName: genericDevice.deviceHostName, - deviceMdns: genericDevice.deviceMdns, - devicesMacAddress: genericDevice.devicesMacAddress, - entityKey: genericDevice.entityKey, - requestTimeStamp: genericDevice.requestTimeStamp, - lastResponseFromDeviceTimeStamp: - genericDevice.lastResponseFromDeviceTimeStamp, - lightSwitchState: genericDevice.lightSwitchState, - deviceCbjUniqueId: genericDevice.deviceCbjUniqueId, - ); - } - - /// Please override the following methods - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - if (newEntity is! GenericLightDE) { - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Not the correct type', - ), - ); - } - - try { - if (newEntity.lightSwitchState!.getOrCrash() != - lightSwitchState!.getOrCrash() || - entityStateGRPC.getOrCrash() != EntityStateGRPC.ack.toString()) { - final EntityActions? actionToPreform = - EnumHelperCbj.stringToDeviceAction( - newEntity.lightSwitchState!.getOrCrash(), - ); - - if (actionToPreform == EntityActions.on) { - (await turnOnLight()).fold( - (l) { - logger.e('Error turning TasmotaIp light on'); - throw l; - }, - (r) { - logger.i('TasmotaIp light turn on success'); - }, - ); - } else if (actionToPreform == EntityActions.off) { - (await turnOffLight()).fold( - (l) { - logger.e('Error turning TasmotaIp light off'); - throw l; - }, - (r) { - logger.i('TasmotaIp light turn off success'); - }, - ); - } else { - logger.e('actionToPreform is not set correctly on TasmotaIp Led'); - } - } - entityStateGRPC = EntityState(EntityStateGRPC.ack.toString()); - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - return right(unit); - } catch (e) { - entityStateGRPC = EntityState(EntityStateGRPC.newStateFailed.toString()); - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> turnOnLight() async { - lightSwitchState = GenericLightSwitchState(EntityActions.on.toString()); - - try { - getIt().publishMessage( - 'cmnd/${deviceHostName.getOrCrash()}/Power', - 'ON', - ); - return right(unit); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> turnOffLight() async { - lightSwitchState = GenericLightSwitchState(EntityActions.off.toString()); - - try { - getIt().publishMessage( - 'cmnd/${deviceHostName.getOrCrash()}/Power', - 'OFF', - ); - return right(unit); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - } -} diff --git a/lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_switch/tasmota_ip_switch_entity.dart b/lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_switch/tasmota_ip_switch_entity.dart deleted file mode 100644 index b95c5f37..00000000 --- a/lib/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_switch/tasmota_ip_switch_entity.dart +++ /dev/null @@ -1,186 +0,0 @@ -import 'dart:convert'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_value_objects.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; -import 'package:http/http.dart'; - -// TODO: Make the commends work, currently this object does not work -// Toggle device on/off, the o is the number of output to toggle o=2 is the second -// http://ip/?m=1&o=1 -// Change brightness -// http://ip/?m=1&d0=30 -// Change color -// http://ip/?m=1&h0=232 -// Change tint (I think) -// http://ip/?m=1&t0=500 -// Change color strength -// http://ip/?m=1&n0=87 - -class TasmotaIpSwitchEntity extends GenericSwitchDE { - TasmotaIpSwitchEntity({ - required super.uniqueId, - required super.entityUniqueId, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required super.switchState, - }) : super( - deviceVendor: DeviceVendor(VendorsAndServices.tasmota.toString()), - ); - - factory TasmotaIpSwitchEntity.fromGeneric(GenericSwitchDE genericDevice) { - return TasmotaIpSwitchEntity( - uniqueId: genericDevice.uniqueId, - entityUniqueId: genericDevice.entityUniqueId, - cbjEntityName: genericDevice.cbjEntityName, - entityOriginalName: genericDevice.entityOriginalName, - deviceOriginalName: genericDevice.deviceOriginalName, - stateMassage: genericDevice.stateMassage, - senderDeviceOs: genericDevice.senderDeviceOs, - senderDeviceModel: genericDevice.senderDeviceModel, - senderId: genericDevice.senderId, - compUuid: genericDevice.compUuid, - entityStateGRPC: genericDevice.entityStateGRPC, - powerConsumption: genericDevice.powerConsumption, - deviceUniqueId: genericDevice.deviceUniqueId, - devicePort: genericDevice.devicePort, - deviceLastKnownIp: genericDevice.deviceLastKnownIp, - deviceHostName: genericDevice.deviceHostName, - deviceMdns: genericDevice.deviceMdns, - devicesMacAddress: genericDevice.devicesMacAddress, - entityKey: genericDevice.entityKey, - requestTimeStamp: genericDevice.requestTimeStamp, - lastResponseFromDeviceTimeStamp: - genericDevice.lastResponseFromDeviceTimeStamp, - deviceCbjUniqueId: genericDevice.deviceCbjUniqueId, - switchState: genericDevice.switchState, - ); - } - - /// Please override the following methods - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - if (newEntity is! GenericSwitchDE) { - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Not the correct type', - ), - ); - } - - try { - if (newEntity.switchState!.getOrCrash() != switchState!.getOrCrash() || - entityStateGRPC.getOrCrash() != EntityStateGRPC.ack.toString()) { - final EntityActions? actionToPreform = - EnumHelperCbj.stringToDeviceAction( - newEntity.switchState!.getOrCrash(), - ); - - if (actionToPreform == EntityActions.on) { - (await turnOnSwitch()).fold( - (l) { - logger.e('Error turning TasmotaIp switch on'); - throw l; - }, - (r) { - logger.i('TasmotaIp switch turn on success'); - }, - ); - } else if (actionToPreform == EntityActions.off) { - (await turnOffSwitch()).fold( - (l) { - logger.e('Error turning TasmotaIp switch off'); - throw l; - }, - (r) { - logger.i('TasmotaIp switch turn off success'); - }, - ); - } else { - logger.e('actionToPreform is not set correctly on TasmotaIp Switch'); - } - } - entityStateGRPC = EntityState(EntityStateGRPC.ack.toString()); - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - return right(unit); - } catch (e) { - entityStateGRPC = EntityState(EntityStateGRPC.newStateFailed.toString()); - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> turnOnSwitch() async { - switchState = GenericSwitchSwitchState(EntityActions.on.toString()); - - final String deviceIp = deviceLastKnownIp.getOrCrash(); - const String getComponentsCommand = 'cm?cmnd=Power%20ON'; - - // Map? responseJson; - - try { - final Response response = - await get(Uri.parse('http://$deviceIp/$getComponentsCommand')); - // responseJson = - (json.decode(response.body) as Map) - .map((key, value) => MapEntry(key, value.toString())); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - - return right(unit); - } - - @override - Future> turnOffSwitch() async { - switchState = GenericSwitchSwitchState(EntityActions.off.toString()); - - final String deviceIp = deviceLastKnownIp.getOrCrash(); - const String getComponentsCommand = 'cm?cmnd=Power%20OFF'; - - // Map? responseJson; - - try { - final Response response = - await get(Uri.parse('http://$deviceIp/$getComponentsCommand')); - // responseJson = - (json.decode(response.body) as Map) - .map((key, value) => MapEntry(key, value.toString())); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - - return right(unit); - } -} diff --git a/lib/infrastructure/devices/tasmota/tasmota_mqtt/tasmota_mqtt_connector_conjector.dart b/lib/infrastructure/devices/tasmota/tasmota_mqtt/tasmota_mqtt_connector_conjector.dart deleted file mode 100644 index b903d7d2..00000000 --- a/lib/infrastructure/devices/tasmota/tasmota_mqtt/tasmota_mqtt_connector_conjector.dart +++ /dev/null @@ -1,109 +0,0 @@ -import 'dart:async'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_light_device/generic_light_entity.dart'; -import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart'; -import 'package:cbj_hub/infrastructure/devices/companies_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/tasmota/tasmota_mqtt/tasmota_mqtt_helpers.dart'; -import 'package:cbj_hub/infrastructure/devices/tasmota/tasmota_mqtt/tasmota_mqtt_led/tasmota_mqtt_led_entity.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/abstract_company_connector_conjector.dart'; -import 'package:cbj_hub/injection.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:injectable/injectable.dart'; - -@singleton -class TasmotaMqttConnectorConjector - implements AbstractCompanyConnectorConjector { - // Future addNewDeviceByHostInfo({ - // required ActiveHost activeHost, - // }) async { - // String tempMqttTopic = (await activeHost.hostName)!.replaceAll('-', '_'); - // if (tempMqttTopic.lastIndexOf('_') != -1) { - // tempMqttTopic = - // tempMqttTopic.substring(0, tempMqttTopic.lastIndexOf('_')); - // } - // final String tasmotaMqttTopic = tempMqttTopic; - // - // /// Make all tasmotaMqtt devices repost themselves under topic discovery - // /// in the MQTT broker - // getIt() - // .publishMessage('cmnd/$tasmotaMqttTopic/SetOption19', '0'); - // } - - @override - Map companyDevices = {}; - - Future discoverNewDevices() async { - getIt() - .streamOfChosenSubscription('tasmota/discovery/+/config') - .listen((mqttPublishMessage) async { - final String messageTopic = mqttPublishMessage[0].topic; - - final List topicsSplitted = messageTopic.split('/'); - - final String deviceId = topicsSplitted[2]; - - bool deviceExist = false; - CoreUniqueId? tempCoreUniqueId; - - for (final DeviceEntityAbstract savedDevice in companyDevices.values) { - if (savedDevice is TasmotaMqttLedEntity && - deviceId == savedDevice.entityUniqueId.getOrCrash()) { - deviceExist = true; - break; - } else if (savedDevice is GenericLightDE && - deviceId == savedDevice.entityUniqueId.getOrCrash()) { - /// Device exist as generic and needs to get converted to non generic type for this vendor - tempCoreUniqueId = savedDevice.uniqueId; - break; - } else if (deviceId == savedDevice.entityUniqueId.getOrCrash()) { - logger.e( - 'Tasmota Mqtt device type supported but implementation is missing here', - ); - return; - } - } - if (deviceExist) { - return; - } - - final DeviceEntityAbstract? addDevice = - TasmotaMqttHelpers.addDiscoverdDevice( - deviceChangeFromMqtt: - MapEntry(messageTopic, mqttPublishMessage[0].payload), - uniqueDeviceId: tempCoreUniqueId, - ); - - if (addDevice == null) { - return; - } - - final DeviceEntityAbstract deviceToAdd = - CompaniesConnectorConjector.addDiscoverdDeviceToHub(addDevice); - - final MapEntry deviceAsEntry = - MapEntry(deviceToAdd.uniqueId.getOrCrash(), deviceToAdd); - - companyDevices.addEntries([deviceAsEntry]); - logger.t('Adding Tasmota mqtt device'); - }); - } - - @override - Future manageHubRequestsForDevice( - DeviceEntityAbstract tasmotaMqttDE, - ) async { - final DeviceEntityAbstract? device = - companyDevices[tasmotaMqttDE.entityUniqueId.getOrCrash()]; - - if (device is TasmotaMqttLedEntity) { - device.executeDeviceAction(newEntity: tasmotaMqttDE); - } else { - logger.w('TasmotaMqtt device type does not exist'); - } - } - - @override - Future setUpDeviceFromDb(DeviceEntityAbstract deviceEntity) async {} -} diff --git a/lib/infrastructure/devices/tasmota/tasmota_mqtt/tasmota_mqtt_device_validators.dart b/lib/infrastructure/devices/tasmota/tasmota_mqtt/tasmota_mqtt_device_validators.dart deleted file mode 100644 index 26ff8e03..00000000 --- a/lib/infrastructure/devices/tasmota/tasmota_mqtt/tasmota_mqtt_device_validators.dart +++ /dev/null @@ -1,14 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateTasmotaMqttDeviceTopicNameNotEmpty( - String input, -) { - return right(input); -} - -Either, String> validateTasmotaMqttDeviceIdNotEmpty( - String input, -) { - return right(input); -} diff --git a/lib/infrastructure/devices/tasmota/tasmota_mqtt/tasmota_mqtt_device_value_objects.dart b/lib/infrastructure/devices/tasmota/tasmota_mqtt/tasmota_mqtt_device_value_objects.dart deleted file mode 100644 index 5cae6f70..00000000 --- a/lib/infrastructure/devices/tasmota/tasmota_mqtt/tasmota_mqtt_device_value_objects.dart +++ /dev/null @@ -1,19 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/infrastructure/devices/tasmota/tasmota_mqtt/tasmota_mqtt_device_validators.dart'; -import 'package:dartz/dartz.dart'; - -/// TasmotaMqtt device unique address that came withe the device -class TasmotaMqttDeviceTopicName extends ValueObjectCore { - factory TasmotaMqttDeviceTopicName(String? input) { - assert(input != null); - return TasmotaMqttDeviceTopicName._( - validateTasmotaMqttDeviceTopicNameNotEmpty(input!), - ); - } - - const TasmotaMqttDeviceTopicName._(this.value); - - @override - final Either, String> value; -} diff --git a/lib/infrastructure/devices/tasmota/tasmota_mqtt/tasmota_mqtt_helpers.dart b/lib/infrastructure/devices/tasmota/tasmota_mqtt/tasmota_mqtt_helpers.dart deleted file mode 100644 index a6ffcc90..00000000 --- a/lib/infrastructure/devices/tasmota/tasmota_mqtt/tasmota_mqtt_helpers.dart +++ /dev/null @@ -1,103 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_light_device/generic_light_value_objects.dart'; -import 'package:cbj_hub/infrastructure/devices/tasmota/tasmota_mqtt/tasmota_mqtt_device_value_objects.dart'; -import 'package:cbj_hub/infrastructure/devices/tasmota/tasmota_mqtt/tasmota_mqtt_led/tasmota_mqtt_led_entity.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:mqtt_client/mqtt_client.dart'; - -class TasmotaMqttHelpers { - static DeviceEntityAbstract? addDiscoverdDevice({ - required MapEntry deviceChangeFromMqtt, - required CoreUniqueId? uniqueDeviceId, - }) { - CoreUniqueId uniqueDeviceIdTemp; - - if (uniqueDeviceId != null) { - uniqueDeviceIdTemp = uniqueDeviceId; - } else { - uniqueDeviceIdTemp = CoreUniqueId(); - } - - final List topicsSplitted = deviceChangeFromMqtt.key.split('/'); - if (topicsSplitted.length < 3 || topicsSplitted[3] != 'config') { - return null; - } - - final String pt = MqttPublishPayload.bytesToStringAsString( - (deviceChangeFromMqtt.value as MqttPublishMessage).payload.message, - ).replaceAll('\n', ''); - - /// mac = Mac address of the device - final String? mac = getValueFromMqttResult(pt, 'mac'); - - /// Check if this is result full of info and not just response for action - if (mac == null) { - return null; - } - - /// t = mqtt topic of device - final String deviceTopic = getValueFromMqttResult(pt, '"t"')!; - - /// state = List of all the device supported states - final String supportedStatesOfDevice = getValueFromMqttResult(pt, 'state')!; - - /// dn = Device Name (Tasmotac) - final String name = getValueFromMqttResult(pt, 'dn')!; - - const EntityActions deviceActions = EntityActions.actionNotSupported; - - if (supportedStatesOfDevice.contains('ON') && - supportedStatesOfDevice.contains('OFF')) { - return TasmotaMqttLedEntity( - uniqueId: uniqueDeviceIdTemp, - entityUniqueId: EntityUniqueId(mac), - cbjEntityName: CbjEntityName(name), - entityOriginalName: EntityOriginalName(name), - deviceOriginalName: DeviceOriginalName(name), - entityStateGRPC: EntityState(EntityStateGRPC.ack.toString()), - senderDeviceOs: DeviceSenderDeviceOs('TasmotaMqtt'), - senderDeviceModel: DeviceSenderDeviceModel('LED'), - senderId: DeviceSenderId(), - compUuid: DeviceCompUuid(mac), - stateMassage: DeviceStateMassage('Hello World'), - powerConsumption: DevicePowerConsumption('0'), - lightSwitchState: GenericLightSwitchState(deviceActions.toString()), - tasmotaMqttDeviceTopicName: TasmotaMqttDeviceTopicName(deviceTopic), - deviceUniqueId: DeviceUniqueId('0'), - devicePort: DevicePort('0'), - deviceLastKnownIp: DeviceLastKnownIp('0'), - deviceHostName: DeviceHostName('0'), - deviceMdns: DeviceMdns('0'), - devicesMacAddress: DevicesMacAddress('0'), - entityKey: EntityKey('0'), - requestTimeStamp: RequestTimeStamp('0'), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp('0'), - deviceCbjUniqueId: CoreUniqueId(), - ); - } - - logger.i( - 'Please add new Tasmota Mqtt device type $topicsSplitted', - ); - return null; - } - - static String? getValueFromMqttResult(String result, String valueName) { - String value; - try { - value = result.substring(result.indexOf(valueName)); - value = value.substring(value.indexOf(':') + 2); - value = value.substring(0, value.indexOf(':') - 1); - if (value.contains(']')) { - value = value.substring(0, value.indexOf(']')); - } else { - value = value.substring(0, value.indexOf(',') - 1); - } - } catch (e) { - return null; - } - return value; - } -} diff --git a/lib/infrastructure/devices/tasmota/tasmota_mqtt/tasmota_mqtt_led/tasmota_mqtt_led_entity.dart b/lib/infrastructure/devices/tasmota/tasmota_mqtt/tasmota_mqtt_led/tasmota_mqtt_led_entity.dart deleted file mode 100644 index 46c3190c..00000000 --- a/lib/infrastructure/devices/tasmota/tasmota_mqtt/tasmota_mqtt_led/tasmota_mqtt_led_entity.dart +++ /dev/null @@ -1,135 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_light_device/generic_light_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_light_device/generic_light_value_objects.dart'; -import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart'; -import 'package:cbj_hub/infrastructure/devices/tasmota/tasmota_mqtt/tasmota_mqtt_device_value_objects.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/injection.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; - -class TasmotaMqttLedEntity extends GenericLightDE { - TasmotaMqttLedEntity({ - required super.uniqueId, - required super.entityUniqueId, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required super.lightSwitchState, - required this.tasmotaMqttDeviceTopicName, - }) : super( - deviceVendor: DeviceVendor(VendorsAndServices.tasmota.toString()), - ); - - TasmotaMqttDeviceTopicName tasmotaMqttDeviceTopicName; - - /// Please override the following methods - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - if (newEntity is! GenericLightDE) { - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Not the correct type', - ), - ); - } - - try { - if (newEntity.lightSwitchState!.getOrCrash() != - lightSwitchState!.getOrCrash() || - entityStateGRPC.getOrCrash() != EntityStateGRPC.ack.toString()) { - final EntityActions? actionToPreform = - EnumHelperCbj.stringToDeviceAction( - newEntity.lightSwitchState!.getOrCrash(), - ); - - if (actionToPreform == EntityActions.on) { - (await turnOnLight()).fold( - (l) { - logger.e('Error turning TasmotaMqtt light on'); - throw l; - }, - (r) { - logger.i('TasmotaMqtt light turn on success'); - }, - ); - } else if (actionToPreform == EntityActions.off) { - (await turnOffLight()).fold( - (l) { - logger.e('Error turning TasmotaMqtt light off'); - throw l; - }, - (r) { - logger.i('TasmotaMqtt light turn off success'); - }, - ); - } else { - logger.e('actionToPreform is not set correctly on TasmotaMqtt Led'); - } - } - entityStateGRPC = EntityState(EntityStateGRPC.ack.toString()); - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - return right(unit); - } catch (e) { - entityStateGRPC = EntityState(EntityStateGRPC.newStateFailed.toString()); - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> turnOnLight() async { - lightSwitchState = GenericLightSwitchState(EntityActions.on.toString()); - - try { - getIt().publishMessage( - 'cmnd/${tasmotaMqttDeviceTopicName.getOrCrash()}/Power', - 'ON', - ); - return right(unit); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> turnOffLight() async { - lightSwitchState = GenericLightSwitchState(EntityActions.off.toString()); - - try { - getIt().publishMessage( - 'cmnd/${tasmotaMqttDeviceTopicName.getOrCrash()}/Power', - 'OFF', - ); - return right(unit); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - } -} diff --git a/lib/infrastructure/devices/tuya_smart/tuya_smart_connector_conjector.dart b/lib/infrastructure/devices/tuya_smart/tuya_smart_connector_conjector.dart deleted file mode 100644 index d0146fba..00000000 --- a/lib/infrastructure/devices/tuya_smart/tuya_smart_connector_conjector.dart +++ /dev/null @@ -1,160 +0,0 @@ -import 'dart:async'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_plug_device/generic_smart_plug_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_entity.dart'; -import 'package:cbj_hub/domain/vendors/tuya_login/generic_tuya_login_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/companies_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/tuya_smart/tuya_smart_helpers.dart'; -import 'package:cbj_hub/infrastructure/devices/tuya_smart/tuya_smart_jbt_a70_rgbcw_wf/tuya_smart_jbt_a70_rgbcw_wf_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/tuya_smart/tuya_smart_plug/tuya_smart_switch_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/tuya_smart/tuya_smart_remote_api/cloudtuya.dart'; -import 'package:cbj_hub/infrastructure/devices/tuya_smart/tuya_smart_remote_api/tuya_device_abstract.dart'; -import 'package:cbj_hub/infrastructure/devices/tuya_smart/tuya_smart_switch/tuya_smart_switch_entity.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/abstract_company_connector_conjector.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:injectable/injectable.dart'; - -@singleton -class TuyaSmartConnectorConjector implements AbstractCompanyConnectorConjector { - @override - Map companyDevices = {}; - - static late CloudTuya cloudTuya; - static late CloudTuya cloudJinvooSmart; - static late CloudTuya cloudSmartLife; - - Future accountLogin( - GenericTuyaLoginDE loginDE, - ) async { - final CloudTuya cloudTuyaTemp = cloudTuya = CloudTuya( - userName: loginDE.tuyaUserName.getOrCrash(), - userPassword: loginDE.tuyaUserPassword.getOrCrash(), - countryCode: loginDE.tuyaCountryCode.getOrCrash(), - bizType: loginDE.tuyaBizType.getOrCrash(), - region: loginDE.tuyaRegion.getOrCrash(), - ); - if (loginDE.loginVendor.getOrCrash() == VendorsAndServices.tuyaSmart.name) { - cloudTuya = cloudTuyaTemp..bizType = 'tuya'; - final bool loginSuccess = await cloudTuya.login(); - if (!loginSuccess) { - return 'Error'; - } - _discoverNewDevices(cloudTuyaOrSmartLifeOrJinvooSmart: cloudTuya); - } else if (loginDE.loginVendor.getOrCrash() == - VendorsAndServices.smartLife.name) { - cloudSmartLife = cloudTuyaTemp..bizType = 'smart_life'; - final bool loginSuccess = await cloudSmartLife.login(); - if (!loginSuccess) { - return 'Error'; - } - _discoverNewDevices(cloudTuyaOrSmartLifeOrJinvooSmart: cloudSmartLife); - return 'Success'; - } else if (loginDE.loginVendor.getOrCrash() == - VendorsAndServices.jinvooSmart.name) { - cloudJinvooSmart = cloudTuyaTemp..bizType = 'jinvoo_smart'; - final bool loginSuccess = await cloudJinvooSmart.login(); - if (!loginSuccess) { - return 'Error'; - } - _discoverNewDevices(cloudTuyaOrSmartLifeOrJinvooSmart: cloudJinvooSmart); - return 'Success'; - } - // TODO: Add other types - return 'Success'; - } - - Future _discoverNewDevices({ - required CloudTuya cloudTuyaOrSmartLifeOrJinvooSmart, - }) async { - while (true) { - try { - final List deviceList = - await cloudTuyaOrSmartLifeOrJinvooSmart.findDevices(); - - for (final TuyaDeviceAbstract tuyaDevice in deviceList) { - bool deviceExist = false; - CoreUniqueId? tempCoreUniqueId; - - for (final DeviceEntityAbstract savedDevice - in companyDevices.values) { - if ((savedDevice is TuyaSmartJbtA70RgbcwWfEntity || - savedDevice is TuyaSmartSwitchEntity || - savedDevice is TuyaSmartPlugEntity) && - tuyaDevice.id == savedDevice.entityUniqueId.getOrCrash()) { - deviceExist = true; - break; - } else if ((savedDevice is GenericRgbwLightDE || - savedDevice is GenericSwitchDE || - savedDevice is GenericSmartPlugDE) && - tuyaDevice.id == savedDevice.entityUniqueId.getOrCrash()) { - /// Device exist as generic and needs to get converted to non generic type for this vendor - tempCoreUniqueId = savedDevice.uniqueId; - break; - } else if (tuyaDevice.id == - savedDevice.entityUniqueId.getOrCrash()) { - logger.w( - 'Tuya Mqtt device type supported but implementation is missing here', - ); - break; - } - } - if (!deviceExist) { - final DeviceEntityAbstract? addDevice = - TuyaSmartHelpers.addDiscoverdDevice( - tuyaSmartDevice: tuyaDevice, - cloudTuyaOrSmartLifeOrJinvooSmart: - cloudTuyaOrSmartLifeOrJinvooSmart, - uniqueDeviceId: tempCoreUniqueId, - ); - if (addDevice == null) { - continue; - } - final DeviceEntityAbstract deviceToAdd = - CompaniesConnectorConjector.addDiscoverdDeviceToHub(addDevice); - - final MapEntry deviceAsEntry = - MapEntry(deviceToAdd.uniqueId.getOrCrash(), deviceToAdd); - - companyDevices.addEntries([deviceAsEntry]); - - logger.i( - 'New Tuya device got added named ' - '${addDevice.cbjEntityName.getOrCrash()}', - ); - } - } - await Future.delayed(const Duration(minutes: 3)); - } catch (e) { - logger.e('Error discover in Tuya\n$e'); - await Future.delayed(const Duration(minutes: 1)); - } - } - } - - @override - Future manageHubRequestsForDevice( - DeviceEntityAbstract tuyaSmartDE, - ) async { - final DeviceEntityAbstract? device = - companyDevices[tuyaSmartDE.entityUniqueId.getOrCrash()]; - - if (device is TuyaSmartJbtA70RgbcwWfEntity) { - device.executeDeviceAction(newEntity: tuyaSmartDE); - } else if (device is TuyaSmartSwitchEntity) { - device.executeDeviceAction(newEntity: tuyaSmartDE); - } else if (device is TuyaSmartPlugEntity) { - device.executeDeviceAction(newEntity: tuyaSmartDE); - } else { - logger.w( - 'TuyaSmart device type does not exist ${device?.entityTypes.getOrCrash()}', - ); - } - } - - @override - Future setUpDeviceFromDb(DeviceEntityAbstract deviceEntity) async {} -} diff --git a/lib/infrastructure/devices/tuya_smart/tuya_smart_device_validators.dart b/lib/infrastructure/devices/tuya_smart/tuya_smart_device_validators.dart deleted file mode 100644 index f4e80636..00000000 --- a/lib/infrastructure/devices/tuya_smart/tuya_smart_device_validators.dart +++ /dev/null @@ -1,23 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateTuyaSmartIdNotEmpty(String input) { - return right(input); -} - -Either, String> validateTuyaSmartPortNotEmpty( - String input, -) { - return right(input); -} - -Either tuyaResponseToCyBearJinniSucessFailure( - String tuyaResponse, -) { - if (tuyaResponse == 'SUCCESS') { - return right(unit); - } else if (tuyaResponse == 'TargetOffline') { - return left(const CoreFailure.unableToUpdate()); - } - return left(const CoreFailure.unexpected()); -} diff --git a/lib/infrastructure/devices/tuya_smart/tuya_smart_device_value_objects.dart b/lib/infrastructure/devices/tuya_smart/tuya_smart_device_value_objects.dart deleted file mode 100644 index cc0a711e..00000000 --- a/lib/infrastructure/devices/tuya_smart/tuya_smart_device_value_objects.dart +++ /dev/null @@ -1,19 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/infrastructure/devices/tuya_smart/tuya_smart_device_validators.dart'; -import 'package:dartz/dartz.dart'; - -/// TuyaSmart communication port -class TuyaSmartPort extends ValueObjectCore { - factory TuyaSmartPort(String? input) { - assert(input != null); - return TuyaSmartPort._( - validateTuyaSmartPortNotEmpty(input!), - ); - } - - const TuyaSmartPort._(this.value); - - @override - final Either, String> value; -} diff --git a/lib/infrastructure/devices/tuya_smart/tuya_smart_helpers.dart b/lib/infrastructure/devices/tuya_smart/tuya_smart_helpers.dart deleted file mode 100644 index 980adf9d..00000000 --- a/lib/infrastructure/devices/tuya_smart/tuya_smart_helpers.dart +++ /dev/null @@ -1,152 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_value_objects.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_plug_device/generic_smart_plug_value_objects.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_value_objects.dart'; -import 'package:cbj_hub/infrastructure/devices/tuya_smart/tuya_smart_jbt_a70_rgbcw_wf/tuya_smart_jbt_a70_rgbcw_wf_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/tuya_smart/tuya_smart_plug/tuya_smart_switch_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/tuya_smart/tuya_smart_remote_api/cloudtuya.dart'; -import 'package:cbj_hub/infrastructure/devices/tuya_smart/tuya_smart_remote_api/tuya_device_abstract.dart'; -import 'package:cbj_hub/infrastructure/devices/tuya_smart/tuya_smart_remote_api/tuya_light.dart'; -import 'package:cbj_hub/infrastructure/devices/tuya_smart/tuya_smart_remote_api/tuya_switch.dart'; -import 'package:cbj_hub/infrastructure/devices/tuya_smart/tuya_smart_switch/tuya_smart_switch_entity.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/utils.dart'; - -class TuyaSmartHelpers { - static DeviceEntityAbstract? addDiscoverdDevice({ - required TuyaDeviceAbstract tuyaSmartDevice, - required CloudTuya cloudTuyaOrSmartLifeOrJinvooSmart, - required CoreUniqueId? uniqueDeviceId, - }) { - CoreUniqueId uniqueDeviceIdTemp; - - if (uniqueDeviceId != null) { - uniqueDeviceIdTemp = uniqueDeviceId; - } else { - uniqueDeviceIdTemp = CoreUniqueId(); - } - - DeviceEntityAbstract tuyaSmartDE; - - if (tuyaSmartDevice is TuyaLight) { - final String deviceName = tuyaSmartDevice.name != '' - ? tuyaSmartDevice.name - : 'TuyaSmart test 2'; - tuyaSmartDE = TuyaSmartJbtA70RgbcwWfEntity( - uniqueId: uniqueDeviceIdTemp, - entityUniqueId: EntityUniqueId(tuyaSmartDevice.id), - cbjEntityName: CbjEntityName(deviceName), - entityOriginalName: EntityOriginalName(deviceName), - deviceOriginalName: DeviceOriginalName(deviceName), - entityStateGRPC: EntityState(EntityStateGRPC.ack.toString()), - senderDeviceOs: DeviceSenderDeviceOs('tuya_smart'), - senderDeviceModel: DeviceSenderDeviceModel('1SE'), - senderId: DeviceSenderId(), - compUuid: DeviceCompUuid('34asdfrsd23gggg'), - stateMassage: DeviceStateMassage('Hello World'), - powerConsumption: DevicePowerConsumption('0'), - deviceCbjUniqueId: CoreUniqueId(), - lightSwitchState: - GenericRgbwLightSwitchState(tuyaSmartDevice.state.toString()), - lightColorTemperature: GenericRgbwLightColorTemperature( - tuyaSmartDevice.colorTemp.toString(), - ), - lightBrightness: - GenericRgbwLightBrightness(tuyaSmartDevice.brightness.toString()), - lightColorAlpha: GenericRgbwLightColorAlpha('1.0'), - lightColorHue: GenericRgbwLightColorHue('0.0'), - lightColorSaturation: GenericRgbwLightColorSaturation('1.0'), - lightColorValue: GenericRgbwLightColorValue('1.0'), - cloudTuya: cloudTuyaOrSmartLifeOrJinvooSmart, - deviceUniqueId: DeviceUniqueId('0'), - devicePort: DevicePort('0'), - deviceLastKnownIp: DeviceLastKnownIp('0'), - deviceHostName: DeviceHostName('0'), - deviceMdns: DeviceMdns('0'), - devicesMacAddress: DevicesMacAddress('0'), - entityKey: EntityKey('0'), - requestTimeStamp: RequestTimeStamp('0'), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp('0'), - ); - } else if (tuyaSmartDevice is TuyaSwitch && - (tuyaSmartDevice.icon == - 'https://images.tuyaeu.com/smart/solution/134001/66ba22c327bfbf3d_cover.png' || - tuyaSmartDevice.icon == - 'https://images.tuyaus.com/smart/solution/134001/66ba22c327bfbf3d_cover.png' || - tuyaSmartDevice.icon == - 'https://images.tuyaeu.com/smart/icon/ay15422864509092y6k8/1622259081104c41dc2b7.png' || - tuyaSmartDevice.icon == - 'https://images.tuyaus.com/smart/icon/ay15422864509092y6k8/1622259081104c41dc2b7.png')) { - final String deviceName = tuyaSmartDevice.name != '' - ? tuyaSmartDevice.name - : 'TuyaSmart test 2'; - - /// Spacial cases to differentiate smart plug from regular switch - - tuyaSmartDE = TuyaSmartPlugEntity( - uniqueId: uniqueDeviceIdTemp, - entityUniqueId: EntityUniqueId(tuyaSmartDevice.id), - cbjEntityName: CbjEntityName(deviceName), - entityOriginalName: EntityOriginalName(deviceName), - deviceOriginalName: DeviceOriginalName(deviceName), - entityStateGRPC: EntityState(EntityStateGRPC.ack.toString()), - senderDeviceOs: DeviceSenderDeviceOs('tuya_smart'), - senderDeviceModel: DeviceSenderDeviceModel('Cloud'), - senderId: DeviceSenderId(), - compUuid: DeviceCompUuid('34asdfrsd23gggg'), - stateMassage: DeviceStateMassage('Hello World'), - powerConsumption: DevicePowerConsumption('0'), - smartPlugState: GenericSmartPlugState(tuyaSmartDevice.state.toString()), - cloudTuya: cloudTuyaOrSmartLifeOrJinvooSmart, - deviceUniqueId: DeviceUniqueId('0'), - devicePort: DevicePort('0'), - deviceLastKnownIp: DeviceLastKnownIp('0'), - deviceHostName: DeviceHostName('0'), - deviceMdns: DeviceMdns('0'), - devicesMacAddress: DevicesMacAddress('0'), - entityKey: EntityKey('0'), - requestTimeStamp: RequestTimeStamp('0'), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp('0'), - deviceCbjUniqueId: CoreUniqueId(), - ); - } else if (tuyaSmartDevice is TuyaSwitch) { - final String deviceName = tuyaSmartDevice.name != '' - ? tuyaSmartDevice.name - : 'TuyaSmart test 2'; - - tuyaSmartDE = TuyaSmartSwitchEntity( - uniqueId: uniqueDeviceIdTemp, - entityUniqueId: EntityUniqueId(tuyaSmartDevice.id), - cbjEntityName: CbjEntityName(deviceName), - entityOriginalName: EntityOriginalName(deviceName), - deviceOriginalName: DeviceOriginalName(deviceName), - entityStateGRPC: EntityState(EntityStateGRPC.ack.toString()), - senderDeviceOs: DeviceSenderDeviceOs('tuya_smart'), - senderDeviceModel: DeviceSenderDeviceModel('Cloud'), - senderId: DeviceSenderId(), - compUuid: DeviceCompUuid('34asdfrsd23gggg'), - stateMassage: DeviceStateMassage('Hello World'), - powerConsumption: DevicePowerConsumption('0'), - switchState: GenericSwitchSwitchState(tuyaSmartDevice.state.toString()), - cloudTuya: cloudTuyaOrSmartLifeOrJinvooSmart, - deviceUniqueId: DeviceUniqueId('0'), - devicePort: DevicePort('0'), - deviceLastKnownIp: DeviceLastKnownIp('0'), - deviceHostName: DeviceHostName('0'), - deviceMdns: DeviceMdns('0'), - devicesMacAddress: DevicesMacAddress('0'), - entityKey: EntityKey('0'), - requestTimeStamp: RequestTimeStamp('0'), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp('0'), - deviceCbjUniqueId: CoreUniqueId(), - ); - } else { - logger.i( - 'Please add new Tuya device type ${tuyaSmartDevice.haType} ${tuyaSmartDevice.haType}', - ); - return null; - } - return tuyaSmartDE; - } -} diff --git a/lib/infrastructure/devices/tuya_smart/tuya_smart_jbt_a70_rgbcw_wf/tuya_smart_jbt_a70_rgbcw_wf_entity.dart b/lib/infrastructure/devices/tuya_smart/tuya_smart_jbt_a70_rgbcw_wf/tuya_smart_jbt_a70_rgbcw_wf_entity.dart deleted file mode 100644 index 2a13dd8c..00000000 --- a/lib/infrastructure/devices/tuya_smart/tuya_smart_jbt_a70_rgbcw_wf/tuya_smart_jbt_a70_rgbcw_wf_entity.dart +++ /dev/null @@ -1,261 +0,0 @@ -import 'dart:async'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_value_objects.dart'; -import 'package:cbj_hub/infrastructure/devices/tuya_smart/tuya_smart_device_validators.dart'; -import 'package:cbj_hub/infrastructure/devices/tuya_smart/tuya_smart_remote_api/cloudtuya.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; - -class TuyaSmartJbtA70RgbcwWfEntity extends GenericRgbwLightDE { - TuyaSmartJbtA70RgbcwWfEntity({ - required super.uniqueId, - required super.entityUniqueId, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required super.lightSwitchState, - required super.lightColorTemperature, - required super.lightColorAlpha, - required super.lightColorHue, - required super.lightColorSaturation, - required super.lightColorValue, - required super.lightBrightness, - required this.cloudTuya, - }) : super( - deviceVendor: DeviceVendor(VendorsAndServices.tuyaSmart.toString()), - ); - - /// Will be the cloud api reference, can be Tuya or Jinvoo Smart or Smart Life - CloudTuya cloudTuya; - - /// Please override the following methods - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - if (newEntity is! GenericRgbwLightDE) { - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Not the correct type', - ), - ); - } - try { - if (newEntity.lightSwitchState!.getOrCrash() != - lightSwitchState!.getOrCrash() || - entityStateGRPC.getOrCrash() != EntityStateGRPC.ack.toString()) { - final EntityActions? actionToPreform = - EnumHelperCbj.stringToDeviceAction( - newEntity.lightSwitchState!.getOrCrash(), - ); - - if (actionToPreform == EntityActions.on) { - (await turnOnLight()).fold( - (l) { - logger.e('Error turning Tuya light on\n$l'); - throw l; - }, - (r) { - logger.d('Tuya light turn on success'); - entityStateGRPC = EntityState(EntityStateGRPC.ack.toString()); - }, - ); - } else if (actionToPreform == EntityActions.off) { - (await turnOffLight()).fold( - (l) { - logger.e('Error turning Tuya light off\n$l'); - throw l; - }, - (r) { - logger.d('Tuya light turn off success'); - entityStateGRPC = EntityState(EntityStateGRPC.ack.toString()); - }, - ); - } else { - logger.w( - 'actionToPreform is not set correctly on TuyaSmart' - ' JbtA70RgbcwWfEntity', - ); - } - } - - if (newEntity.lightColorTemperature.getOrCrash() != - lightColorTemperature.getOrCrash() || - entityStateGRPC.getOrCrash() != EntityStateGRPC.ack.toString()) { - (await changeColorTemperature( - lightColorTemperatureNewValue: - newEntity.lightColorTemperature.getOrCrash(), - )) - .fold( - (l) { - logger.e('Error changing Tuya temperature\n$l'); - throw l; - }, - (r) { - logger.i('Tuya changed temperature successfully'); - }, - ); - } - - if (newEntity.lightColorAlpha.getOrCrash() != - lightColorAlpha.getOrCrash() || - newEntity.lightColorHue.getOrCrash() != lightColorHue.getOrCrash() || - newEntity.lightColorSaturation.getOrCrash() != - lightColorSaturation.getOrCrash() || - newEntity.lightColorValue.getOrCrash() != - lightColorValue.getOrCrash() || - entityStateGRPC.getOrCrash() != EntityStateGRPC.ack.toString()) { - (await changeColorHsv( - lightColorAlphaNewValue: newEntity.lightColorAlpha.getOrCrash(), - lightColorHueNewValue: newEntity.lightColorHue.getOrCrash(), - lightColorSaturationNewValue: - newEntity.lightColorSaturation.getOrCrash(), - lightColorValueNewValue: newEntity.lightColorValue.getOrCrash(), - )) - .fold( - (l) { - logger.e('Error changing Tuya light color\n$l'); - throw l; - }, - (r) { - logger.i('Light changed color successfully'); - }, - ); - } - - if (newEntity.lightBrightness.getOrCrash() != - lightBrightness.getOrCrash()) { - (await setBrightness(newEntity.lightBrightness.getOrCrash())).fold( - (l) { - logger.e('Error changing Tuya brightness\n$l'); - throw l; - }, - (r) { - logger.i('Tuya changed brightness successfully'); - }, - ); - } - entityStateGRPC = EntityState(EntityStateGRPC.ack.toString()); - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - return right(unit); - } catch (e) { - entityStateGRPC = EntityState(EntityStateGRPC.newStateFailed.toString()); - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> turnOnLight() async { - lightSwitchState = GenericRgbwLightSwitchState(EntityActions.on.toString()); - try { - final String requestResponse = await cloudTuya.turnOn( - entityUniqueId.getOrCrash(), - ); - return tuyaResponseToCyBearJinniSucessFailure(requestResponse); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> turnOffLight() async { - lightSwitchState = - GenericRgbwLightSwitchState(EntityActions.off.toString()); - - try { - final String requestResponse = await cloudTuya.turnOff( - entityUniqueId.getOrCrash(), - ); - return tuyaResponseToCyBearJinniSucessFailure(requestResponse); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> setBrightness(String brightness) async { - lightBrightness = GenericRgbwLightBrightness(brightness); - - try { - final String requestResponse = await cloudTuya.setBrightness( - entityUniqueId.getOrCrash(), - lightBrightness.getOrCrash(), - ); - return tuyaResponseToCyBearJinniSucessFailure(requestResponse); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> changeColorTemperature({ - required String lightColorTemperatureNewValue, - }) async { - lightColorTemperature = - GenericRgbwLightColorTemperature(lightColorTemperatureNewValue); - - try { - final String requestResponse = await cloudTuya.setColorTemperature( - deviceId: entityUniqueId.getOrCrash(), - newTemperature: lightColorTemperatureNewValue, - ); - return tuyaResponseToCyBearJinniSucessFailure(requestResponse); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> changeColorHsv({ - required String lightColorAlphaNewValue, - required String lightColorHueNewValue, - required String lightColorSaturationNewValue, - required String lightColorValueNewValue, - }) async { - lightColorAlpha = GenericRgbwLightColorAlpha(lightColorAlphaNewValue); - lightColorHue = GenericRgbwLightColorHue(lightColorHueNewValue); - lightColorSaturation = - GenericRgbwLightColorSaturation(lightColorSaturationNewValue); - lightColorValue = GenericRgbwLightColorValue(lightColorValueNewValue); - - try { - final String requestResponse = await cloudTuya.setColorHsv( - deviceId: entityUniqueId.getOrCrash(), - hue: lightColorHue.getOrCrash(), - saturation: lightColorSaturation.getOrCrash(), - brightness: lightBrightness.getOrCrash(), - ); - return tuyaResponseToCyBearJinniSucessFailure(requestResponse); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - } -} diff --git a/lib/infrastructure/devices/tuya_smart/tuya_smart_plug/tuya_smart_switch_entity.dart b/lib/infrastructure/devices/tuya_smart/tuya_smart_plug/tuya_smart_switch_entity.dart deleted file mode 100644 index 9d1e91f1..00000000 --- a/lib/infrastructure/devices/tuya_smart/tuya_smart_plug/tuya_smart_switch_entity.dart +++ /dev/null @@ -1,133 +0,0 @@ -import 'dart:async'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_plug_device/generic_smart_plug_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_plug_device/generic_smart_plug_value_objects.dart'; -import 'package:cbj_hub/infrastructure/devices/tuya_smart/tuya_smart_device_validators.dart'; -import 'package:cbj_hub/infrastructure/devices/tuya_smart/tuya_smart_remote_api/cloudtuya.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; - -class TuyaSmartPlugEntity extends GenericSmartPlugDE { - TuyaSmartPlugEntity({ - required super.uniqueId, - required super.entityUniqueId, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required super.smartPlugState, - required this.cloudTuya, - }) : super( - deviceVendor: DeviceVendor(VendorsAndServices.tuyaSmart.toString()), - ); - - /// Will be the cloud api reference, can be Tuya or Jinvoo Smart or Smart Life - CloudTuya cloudTuya; - - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - if (newEntity is! GenericSmartPlugDE) { - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Not the correct type', - ), - ); - } - - try { - if (newEntity.smartPlugState!.getOrCrash() != - smartPlugState!.getOrCrash() || - entityStateGRPC.getOrCrash() != EntityStateGRPC.ack.toString()) { - final EntityActions? actionToPreform = - EnumHelperCbj.stringToDeviceAction( - newEntity.smartPlugState!.getOrCrash(), - ); - - if (actionToPreform == EntityActions.on) { - (await turnOnLight()).fold( - (l) { - logger.e('Error turning Tuya plug on\n$l'); - throw l; - }, - (r) { - logger.i('Tuya plug turn on success'); - }, - ); - } else if (actionToPreform == EntityActions.off) { - (await turnOffLight()).fold( - (l) { - logger.e('Error turning Tuya off\n$l'); - throw l; - }, - (r) { - logger.i('Tuya plug turn off success'); - }, - ); - } else { - logger.w( - 'actionToPreform is not set correctly on Tuya Plug', - ); - } - } - entityStateGRPC = EntityState(EntityStateGRPC.ack.toString()); - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - return right(unit); - } catch (e) { - entityStateGRPC = EntityState(EntityStateGRPC.newStateFailed.toString()); - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - return left(const CoreFailure.unexpected()); - } - } - - Future> turnOnLight() async { - smartPlugState = GenericSmartPlugState(EntityActions.on.toString()); - try { - final String requestResponse = await cloudTuya.turnOn( - entityUniqueId.getOrCrash(), - ); - return tuyaResponseToCyBearJinniSucessFailure(requestResponse); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - } - - Future> turnOffLight() async { - smartPlugState = GenericSmartPlugState(EntityActions.off.toString()); - - try { - final String requestResponse = await cloudTuya.turnOff( - entityUniqueId.getOrCrash(), - ); - return tuyaResponseToCyBearJinniSucessFailure(requestResponse); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - } -} diff --git a/lib/infrastructure/devices/tuya_smart/tuya_smart_remote_api/cloudtuya.dart b/lib/infrastructure/devices/tuya_smart/tuya_smart_remote_api/cloudtuya.dart deleted file mode 100644 index 74973edf..00000000 --- a/lib/infrastructure/devices/tuya_smart/tuya_smart_remote_api/cloudtuya.dart +++ /dev/null @@ -1,287 +0,0 @@ -import 'dart:convert'; - -import 'package:cbj_hub/infrastructure/devices/tuya_smart/tuya_smart_remote_api/tuya_device_abstract.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:http/http.dart'; - -/// Tuya integration with cloud API -class CloudTuya { - CloudTuya({ - required this.userName, - required this.userPassword, - required this.countryCode, - required this.bizType, - required this.region, - }) { - uri = 'https://px1.tuya$region.com/homeassistant'; - } - - /// Email of the user - String userName; - - /// Password of the user - String userPassword; - - /// Country code (International dialing number) sometimes can be called - /// "Country Calling Code" without the +. - /// You can find yours from here https://www.countrycode.org - String countryCode; - - /// App business can be: tuya, smart_life, jinvoo_smart - String bizType; - - /// Region of the user, can be cn, eu, us - String region; - - /// You likely don't need to touch this - String from = 'tuna'; - - /// Ru - late String uri; - - String? tokens; - - Future login() async { - if (tokens != null) { - return true; - } - final Uri uriTemp = Uri.parse('$uri/auth.do'); - final Map headers = { - 'Content-Type': 'application/x-www-form-urlencoded', - }; - - final Map body = { - 'bizType': bizType, - 'countryCode': countryCode, - 'from': from, - 'password': userPassword, - 'userName': userName, - }; - - final Response response = - await consistentRequest(uriTemp, headers: headers, body: body); - - final int statusCode = response.statusCode; - final String responseBody = response.body; - - if (responseBody.contains('error')) { - if (responseBody.contains('you cannot auth exceed once in 60 seconds') || - statusCode == 404) { - logger.w( - 'Tuya ($bizType) login warning: $statusCode $responseBody\nWill try again in 60s', - ); - await Future.delayed(const Duration(seconds: 60)); - // Do not remove the await - return await login(); - } - logger.e('Tuya ($bizType) login error: $responseBody'); - return false; - } - final String accessToken = - responseBody.substring(responseBody.indexOf('access_token') + 15); - tokens = accessToken.substring(0, accessToken.indexOf('"')); - return true; - } - - /// Find all devices associated to the login user - Future> findDevices() async { - if (tokens == null) { - final bool loginSuccess = await login(); - if (!loginSuccess) { - return []; - } - } - final Uri uriTemp = Uri.parse('$uri/skill'); - - final Map headers = {'Content-Type': 'application/json'}; - - final String data = json.encode({ - 'header': { - 'name': 'Discovery', - 'namespace': 'discovery', - 'payloadVersion': '1', - }, - 'payload': { - 'accessToken': tokens, - }, - }); - - final Response response = - await consistentRequest(uriTemp, headers: headers, body: data); - - final String responseBody = response.body; - - final dynamic a = json.decode(responseBody); - final dynamic devicesList = a['payload']['devices']; - - final List tuyaDeviceList = []; - - if (devicesList == null) { - return tuyaDeviceList; - } - - for (final dynamic device in devicesList as Iterable) { - if (device['ha_type'] != 'scene') { - final TuyaDeviceAbstract tuyaDevice = - TuyaDeviceAbstract.fromInternalLinkedHashMap(device); - tuyaDeviceList.add(tuyaDevice); - } - } - - return tuyaDeviceList; - } - - /// Find all scenes associated to the login user - Future findScenes() async { - if (tokens == null) { - final bool loginSuccess = await login(); - if (!loginSuccess) { - return []; - } - } - final Uri uriTemp = Uri.parse('$uri/skill'); - - final Map headers = {'Content-Type': 'application/json'}; - - final String data = json.encode({ - 'header': { - 'name': 'Discovery', - 'namespace': 'discovery', - 'payloadVersion': '1', - }, - 'payload': { - 'accessToken': tokens, - }, - }); - - final Response response = - await consistentRequest(uriTemp, headers: headers, body: data); - - final String responseBody = response.body; - - final dynamic a = json.decode(responseBody); - final dynamic scenesList = a['payload']['scenes']; - logger.t('Scenes:\n$scenesList'); - - return scenesList; - } - - Future consistentRequest( - Uri url, { - required Map headers, - required dynamic body, - Encoding? encoding, - }) async { - Response response; - try { - response = await post( - url, - headers: headers, - body: body, - // encoding: encoding, - ); - } catch (e) { - response = Response('error', 404); - } - - return response; - } - - Future setState({ - required String deviceId, - required String action, - required String valueName, - required String newState, - }) async { - if (tokens == null) { - final bool loginSuccess = await login(); - if (!loginSuccess) { - return ''; - } - } - final Uri uriTemp = Uri.parse('$uri/skill'); - - final Map headers = {'Content-Type': 'application/json'}; - - final String data = json.encode({ - 'header': { - 'name': action, - 'namespace': 'control', - 'payloadVersion': '1', - }, - 'payload': { - 'accessToken': tokens, - 'devId': deviceId, - valueName: newState, - }, - }); - - final Response response = - await consistentRequest(uriTemp, headers: headers, body: data); - - final String responseBody = response.body; - - final dynamic responseDecoded = json.decode(responseBody); - - return responseDecoded['header']['code'] as String; - } - - Future turnOn(String deviceId) async { - return setState( - deviceId: deviceId, - action: 'turnOnOff', - valueName: 'value', - newState: '1', - ); - } - - Future turnOff(String deviceId) async { - return setState( - deviceId: deviceId, - action: 'turnOnOff', - valueName: 'value', - newState: '0', - ); - } - - /// Set Tuya device brightness - Future setBrightness(String deviceId, String value) async { - return setState( - deviceId: deviceId, - action: 'brightnessSet', - valueName: 'value', - newState: value, - ); - } - - /// Set device color - Future setColorHsv({ - required String deviceId, - required String hue, - required String saturation, - required String brightness, - }) async { - final String newColor = - '{ "hue": $hue, "saturation": $saturation, "brightness": $brightness }'; - - return setState( - deviceId: deviceId, - action: 'colorSet', - valueName: 'color', - newState: newColor, - ); - } - - /// Set device color temperature - Future setColorTemperature({ - required String deviceId, - required String newTemperature, - }) async { - return setState( - deviceId: deviceId, - action: 'colorTemperatureSet', - valueName: 'value', - newState: newTemperature, - ); - } -} diff --git a/lib/infrastructure/devices/tuya_smart/tuya_smart_remote_api/tuya_device_abstract.dart b/lib/infrastructure/devices/tuya_smart/tuya_smart_remote_api/tuya_device_abstract.dart deleted file mode 100644 index 2a42bf14..00000000 --- a/lib/infrastructure/devices/tuya_smart/tuya_smart_remote_api/tuya_device_abstract.dart +++ /dev/null @@ -1,32 +0,0 @@ -import 'package:cbj_hub/infrastructure/devices/tuya_smart/tuya_smart_remote_api/tuya_light.dart'; -import 'package:cbj_hub/infrastructure/devices/tuya_smart/tuya_smart_remote_api/tuya_switch.dart'; - -abstract class TuyaDeviceAbstract { - TuyaDeviceAbstract({ - required this.name, - required this.icon, - required this.id, - required this.devType, - required this.haType, - required this.online, - required this.state, - }); - - factory TuyaDeviceAbstract.fromInternalLinkedHashMap(dynamic deviceHashMap) { - final String haDeviceTypeString = deviceHashMap['ha_type'] as String; - if (haDeviceTypeString == 'light') { - return TuyaLight.fromInternalLinkedHashMap(deviceHashMap); - } else if (haDeviceTypeString == 'switch') { - return TuyaSwitch.fromInternalLinkedHashMap(deviceHashMap); - } - throw 'Device type $haDeviceTypeString does not exist'; - } - - String name; - String icon; - String id; - String devType; - String haType; - bool online; - bool state; -} diff --git a/lib/infrastructure/devices/tuya_smart/tuya_smart_remote_api/tuya_light.dart b/lib/infrastructure/devices/tuya_smart/tuya_smart_remote_api/tuya_light.dart deleted file mode 100644 index 5c92fd46..00000000 --- a/lib/infrastructure/devices/tuya_smart/tuya_smart_remote_api/tuya_light.dart +++ /dev/null @@ -1,35 +0,0 @@ -import 'package:cbj_hub/infrastructure/devices/tuya_smart/tuya_smart_remote_api/tuya_device_abstract.dart'; - -class TuyaLight extends TuyaDeviceAbstract { - TuyaLight({ - required super.name, - required super.icon, - required super.id, - required super.devType, - required super.haType, - required super.online, - required super.state, - required this.brightness, - required this.colorMode, - required this.colorTemp, - }); - - factory TuyaLight.fromInternalLinkedHashMap(dynamic deviceHashMap) { - return TuyaLight( - name: deviceHashMap['name'] as String, - icon: deviceHashMap['icon'] as String, - id: deviceHashMap['id'] as String, - devType: deviceHashMap['dev_type'] as String, - haType: deviceHashMap['ha_type'] as String, - brightness: int.parse(deviceHashMap['data']['brightness'] as String), - colorMode: deviceHashMap['data']['color_mode'] as String, - online: deviceHashMap['data']['online'] as bool, - state: deviceHashMap['data']['state'] == 'true', - colorTemp: deviceHashMap['data']['color_temp'] as int, - ); - } - - int brightness; - String colorMode; - int colorTemp; -} diff --git a/lib/infrastructure/devices/tuya_smart/tuya_smart_remote_api/tuya_switch.dart b/lib/infrastructure/devices/tuya_smart/tuya_smart_remote_api/tuya_switch.dart deleted file mode 100644 index 3b1f1421..00000000 --- a/lib/infrastructure/devices/tuya_smart/tuya_smart_remote_api/tuya_switch.dart +++ /dev/null @@ -1,25 +0,0 @@ -import 'package:cbj_hub/infrastructure/devices/tuya_smart/tuya_smart_remote_api/tuya_device_abstract.dart'; - -class TuyaSwitch extends TuyaDeviceAbstract { - TuyaSwitch({ - required super.name, - required super.icon, - required super.id, - required super.devType, - required super.haType, - required super.online, - required super.state, - }); - - factory TuyaSwitch.fromInternalLinkedHashMap(dynamic deviceHashMap) { - return TuyaSwitch( - name: deviceHashMap['name'] as String, - icon: deviceHashMap['icon'] as String, - id: deviceHashMap['id'] as String, - devType: deviceHashMap['dev_type'] as String, - haType: deviceHashMap['ha_type'] as String, - online: deviceHashMap['data']['online'] as bool, - state: deviceHashMap['data']['state'] == 'true', - ); - } -} diff --git a/lib/infrastructure/devices/tuya_smart/tuya_smart_switch/tuya_smart_switch_entity.dart b/lib/infrastructure/devices/tuya_smart/tuya_smart_switch/tuya_smart_switch_entity.dart deleted file mode 100644 index d379fc22..00000000 --- a/lib/infrastructure/devices/tuya_smart/tuya_smart_switch/tuya_smart_switch_entity.dart +++ /dev/null @@ -1,134 +0,0 @@ -import 'dart:async'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_value_objects.dart'; -import 'package:cbj_hub/infrastructure/devices/tuya_smart/tuya_smart_device_validators.dart'; -import 'package:cbj_hub/infrastructure/devices/tuya_smart/tuya_smart_remote_api/cloudtuya.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; - -class TuyaSmartSwitchEntity extends GenericSwitchDE { - TuyaSmartSwitchEntity({ - required super.uniqueId, - required super.entityUniqueId, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required super.switchState, - required this.cloudTuya, - }) : super( - deviceVendor: DeviceVendor(VendorsAndServices.tuyaSmart.toString()), - ); - - /// Will be the cloud api reference, can be Tuya or Jinvoo Smart or Smart Life - CloudTuya cloudTuya; - - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - if (newEntity is! GenericSwitchDE) { - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Not the correct type', - ), - ); - } - - try { - if (newEntity.switchState!.getOrCrash() != switchState!.getOrCrash() || - entityStateGRPC.getOrCrash() != EntityStateGRPC.ack.toString()) { - final EntityActions? actionToPreform = - EnumHelperCbj.stringToDeviceAction( - newEntity.switchState!.getOrCrash(), - ); - - if (actionToPreform == EntityActions.on) { - (await turnOnSwitch()).fold( - (l) { - logger.e('Error turning Tuya switch on\n$l'); - throw l; - }, - (r) { - logger.i('Tuya switch turn on success'); - }, - ); - } else if (actionToPreform == EntityActions.off) { - (await turnOffSwitch()).fold( - (l) { - logger.e('Error turning Tuya off\n$l'); - throw l; - }, - (r) { - logger.i('Tuya switch turn off success'); - }, - ); - } else { - logger.w( - 'actionToPreform is not set correctly on Tuya Switch', - ); - } - } - entityStateGRPC = EntityState(EntityStateGRPC.ack.toString()); - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - return right(unit); - } catch (e) { - entityStateGRPC = EntityState(EntityStateGRPC.newStateFailed.toString()); - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> turnOnSwitch() async { - switchState = GenericSwitchSwitchState(EntityActions.on.toString()); - try { - final String requestResponse = await cloudTuya.turnOn( - entityUniqueId.getOrCrash(), - ); - return tuyaResponseToCyBearJinniSucessFailure(requestResponse); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> turnOffSwitch() async { - switchState = GenericSwitchSwitchState(EntityActions.off.toString()); - - try { - final String requestResponse = await cloudTuya.turnOff( - entityUniqueId.getOrCrash(), - ); - return tuyaResponseToCyBearJinniSucessFailure(requestResponse); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - } -} diff --git a/lib/infrastructure/devices/wiz/wiz_connector_conjector.dart b/lib/infrastructure/devices/wiz/wiz_connector_conjector.dart deleted file mode 100644 index 9c66ecf3..00000000 --- a/lib/infrastructure/devices/wiz/wiz_connector_conjector.dart +++ /dev/null @@ -1,146 +0,0 @@ -import 'dart:async'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/vendors/wiz_login/generic_wiz_login_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/wiz/wiz_white/wiz_white_entity.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/abstract_company_connector_conjector.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:injectable/injectable.dart'; -import 'package:network_tools/network_tools.dart'; - -@singleton -class WizConnectorConjector implements AbstractCompanyConnectorConjector { - Future accountLogin(GenericWizLoginDE genericWizLoginDE) async { - // wizClient = WizClient(genericWizLoginDE.wizApiKey.getOrCrash()); - _discoverNewDevices(); - return 'Success'; - } - - @override - Map companyDevices = {}; - - Future addNewDeviceByHostInfo({ - required ActiveHost activeHost, - }) async { - logger.w('Wiz device got discovered but missing implementation'); - // final List tempCoreUniqueId = []; - // - // for (final DeviceEntityAbstract savedDevice in companyDevices.values) { - // if ((savedDevice is WizWhiteEntity) && - // await activeHost.hostName == - // savedDevice.entityUniqueId.getOrCrash()) { - // return; - // } else if (await activeHost.hostName == - // savedDevice.entityUniqueId.getOrCrash()) { - // logger.w( - // 'Wiz IP device type supported but implementation is missing here', - // ); - // } - // } - // // TODO: Create list of CoreUniqueId and populate it with all the - // // components saved devices that already exist - // final List componentsInDevice = - // await getAllComponentsOfDevice(activeHost); - // - // final List wizIpDevices = - // await WizIpHelpers.addDiscoverdDevice( - // activeHost: activeHost, - // uniqueDeviceIdList: tempCoreUniqueId, - // componentInDeviceNumberLabelList: componentsInDevice, - // ); - // - // if (wizIpDevices.isEmpty) { - // return; - // } - // - // for (final DeviceEntityAbstract entityAsDevice in wizIpDevices) { - // final DeviceEntityAbstract deviceToAdd = - // CompaniesConnectorConjector.addDiscoverdDeviceToHub(entityAsDevice); - // - // final MapEntry deviceAsEntry = - // MapEntry(deviceToAdd.uniqueId.getOrCrash(), deviceToAdd); - // - // companyDevices.addEntries([deviceAsEntry]); - // - // logger.t( - // 'New Wiz Ip device name:${entityAsDevice.cbjEntityName.getOrCrash()}', - // ); - // } - } - - // static WizClient? wizClient; - - Future _discoverNewDevices() async { - while (true) { - try { - // final Iterable lights = - // await wizClient!.listLights(const Selector()); - - // for (final WizBulb wizDevice in lights) { - // CoreUniqueId? tempCoreUniqueId; - // bool deviceExist = false; - // for (final DeviceEntityAbstract savedDevice - // in companyDevices.values) { - // if (savedDevice is WizWhiteEntity && - // wizDevice.id == savedDevice.entityUniqueId.getOrCrash()) { - // deviceExist = true; - // break; - // } else if (savedDevice is GenericLightDE && - // wizDevice.id == savedDevice.entityUniqueId.getOrCrash()) { - // tempCoreUniqueId = savedDevice.uniqueId; - // break; - // } else if (wizDevice.id == - // savedDevice.entityUniqueId.getOrCrash()) { - // logger.w( - // 'Wiz device type supported but implementation is missing here', - // ); - // break; - // } - // } - // if (!deviceExist) { - // final DeviceEntityAbstract? addDevice = - // WizHelpers.addDiscoverdDevice( - // wizDevice: wizDevice, - // uniqueDeviceId: tempCoreUniqueId, - // ); - // - // if (addDevice == null) { - // continue; - // } - // - // final DeviceEntityAbstract deviceToAdd = - // CompaniesConnectorConjector.addDiscoverdDeviceToHub(addDevice); - // - // final MapEntry deviceAsEntry = - // MapEntry(deviceToAdd.uniqueId.getOrCrash(), deviceToAdd); - // - // companyDevices.addEntries([deviceAsEntry]); - // - // logger.i('New Wiz device got added'); - // } - // } - await Future.delayed(const Duration(minutes: 3)); - } catch (e) { - logger.e('Error discover in Wiz\n$e'); - await Future.delayed(const Duration(minutes: 1)); - } - } - } - - @override - Future manageHubRequestsForDevice( - DeviceEntityAbstract wizDE, - ) async { - final DeviceEntityAbstract? device = - companyDevices[wizDE.entityUniqueId.getOrCrash()]; - - if (device is WizWhiteEntity) { - device.executeDeviceAction(newEntity: wizDE); - } else { - logger.w('Wiz device type does not exist'); - } - } - - @override - Future setUpDeviceFromDb(DeviceEntityAbstract deviceEntity) async {} -} diff --git a/lib/infrastructure/devices/wiz/wiz_device_validators.dart b/lib/infrastructure/devices/wiz/wiz_device_validators.dart deleted file mode 100644 index 14b5bb61..00000000 --- a/lib/infrastructure/devices/wiz/wiz_device_validators.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateWizIdNotEmpty(String input) { - return right(input); -} - -Either, String> validateWizPortNotEmpty(String input) { - return right(input); -} diff --git a/lib/infrastructure/devices/wiz/wiz_device_value_objects.dart b/lib/infrastructure/devices/wiz/wiz_device_value_objects.dart deleted file mode 100644 index 672321e0..00000000 --- a/lib/infrastructure/devices/wiz/wiz_device_value_objects.dart +++ /dev/null @@ -1,19 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/infrastructure/devices/wiz/wiz_device_validators.dart'; -import 'package:dartz/dartz.dart'; - -/// Wiz communication port -class WizPort extends ValueObjectCore { - factory WizPort(String? input) { - assert(input != null); - return WizPort._( - validateWizPortNotEmpty(input!), - ); - } - - const WizPort._(this.value); - - @override - final Either, String> value; -} diff --git a/lib/infrastructure/devices/wiz/wiz_helpers.dart b/lib/infrastructure/devices/wiz/wiz_helpers.dart deleted file mode 100644 index a8c9ebf6..00000000 --- a/lib/infrastructure/devices/wiz/wiz_helpers.dart +++ /dev/null @@ -1,43 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; - -class WizHelpers { - static DeviceEntityAbstract? addDiscoverdDevice({ - // required WizBulb wizDevice, - required CoreUniqueId? uniqueDeviceId, - }) { - // CoreUniqueId uniqueDeviceIdTemp; - // - // if (uniqueDeviceId != null) { - // uniqueDeviceIdTemp = uniqueDeviceId; - // } else { - // uniqueDeviceIdTemp = CoreUniqueId(); - // } - return null; - // final WizWhiteEntity wizDE = WizWhiteEntity( - // uniqueId: uniqueDeviceIdTemp, - // entityUniqueId: EntityUniqueId.fromUniqueString(wizDevice.id), - // cbjEntityName: CbjEntityName( - // wizDevice.label != '' ? wizDevice.label : 'Wiz test 2', - // ), - // entityStateGRPC: EntityState(EntityStateGRPC.ack.toString()), - // senderDeviceOs: DeviceSenderDeviceOs('Wiz'), - // senderDeviceModel: DeviceSenderDeviceModel('Cloud'), - // senderId: DeviceSenderId(), - // compUuid: DeviceCompUuid(wizDevice.uuid), - // stateMassage: DeviceStateMassage('Hello World'), - // powerConsumption: DevicePowerConsumption('0'), - // lightSwitchState: GenericLightSwitchState( - // (wizDevice.power == WizPower.on).toString(), - // ), - // ); - - // return wizDE; - - // TODO: Add if device type does not supported return null - // logger.i( - // 'Please add new philips device type Bulb ${wizDevice.label}', - // ); - // return null; - } -} diff --git a/lib/infrastructure/devices/wiz/wiz_white/wiz_white_entity.dart b/lib/infrastructure/devices/wiz/wiz_white/wiz_white_entity.dart deleted file mode 100644 index ffba2176..00000000 --- a/lib/infrastructure/devices/wiz/wiz_white/wiz_white_entity.dart +++ /dev/null @@ -1,144 +0,0 @@ -import 'dart:async'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_light_device/generic_light_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_light_device/generic_light_value_objects.dart'; -import 'package:cbj_hub/infrastructure/devices/wiz/wiz_device_value_objects.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; - -class WizWhiteEntity extends GenericLightDE { - WizWhiteEntity({ - required super.uniqueId, - required super.entityUniqueId, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required super.lightSwitchState, - }) : super( - deviceVendor: DeviceVendor(VendorsAndServices.wiz.toString()), - ); - - WizPort? wizPort; - - /// Please override the following methods - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - if (newEntity is! GenericLightDE) { - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Not the correct type', - ), - ); - } - - try { - if (newEntity.lightSwitchState!.getOrCrash() != - lightSwitchState!.getOrCrash() || - entityStateGRPC.getOrCrash() != EntityStateGRPC.ack.toString()) { - final EntityActions? actionToPreform = - EnumHelperCbj.stringToDeviceAction( - newEntity.lightSwitchState!.getOrCrash(), - ); - - if (actionToPreform == EntityActions.on) { - (await turnOnLight()).fold((l) { - logger.e('Error turning Wiz light on'); - throw l; - }, (r) { - logger.i('Wiz light turn on success'); - }); - } else if (actionToPreform == EntityActions.off) { - (await turnOffLight()).fold((l) { - logger.e('Error turning Wiz light off'); - throw l; - }, (r) { - logger.i('Wiz light turn off success'); - }); - } else { - logger.w('actionToPreform is not set correctly on Wiz White'); - } - } - entityStateGRPC = EntityState(EntityStateGRPC.ack.toString()); - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - return right(unit); - } catch (e) { - entityStateGRPC = EntityState(EntityStateGRPC.newStateFailed.toString()); - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> turnOnLight() async { - lightSwitchState = GenericLightSwitchState(EntityActions.on.toString()); - try { - // final setStateBodyResponse = - // await WizConnectorConjector.wizClient?.setState( - // // Selector.id(entityUniqueId.getOrCrash()), - // power: 'on', - // fast: true, - // ); - // if (setStateBodyResponse == null) { - // throw 'setStateBodyResponse is null'; - // } - // - // return right(unit); - } catch (e) { - // As we are using the fast = true the response is always - // WizHttpException Error - return left(const CoreFailure.unexpected()); - } - return left(const CoreFailure.unexpected()); - } - - @override - Future> turnOffLight() async { - lightSwitchState = GenericLightSwitchState(EntityActions.off.toString()); - - try { - // final setStateBodyResponse = - // await WizConnectorConjector.wizClient?.setState( - // Selector.id(entityUniqueId.getOrCrash()), - // power: 'off', - // fast: true, - // ); - // if (setStateBodyResponse == null) { - // throw 'setStateBodyResponse is null'; - // } - // return right(unit); - } catch (e) { - // As we are using the fast = true the response is always - // WizHttpException Error - return left(const CoreFailure.unexpected()); - } - return left(const CoreFailure.unexpected()); - } -} diff --git a/lib/infrastructure/devices/xiaomi_io/xiaomi_io_connector_conjector.dart b/lib/infrastructure/devices/xiaomi_io/xiaomi_io_connector_conjector.dart deleted file mode 100644 index cb63d3eb..00000000 --- a/lib/infrastructure/devices/xiaomi_io/xiaomi_io_connector_conjector.dart +++ /dev/null @@ -1,132 +0,0 @@ -import 'dart:async'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_entity.dart'; -import 'package:cbj_hub/domain/vendors/xiaomi_mi_login/generic_xiaomi_mi_login_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/xiaomi_io/xiaomi_io_gpx3021gl/xiaomi_io_gpx3021gl_entity.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/abstract_company_connector_conjector.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:injectable/injectable.dart'; -import 'package:mi_iot_token/mi_iot_token.dart'; -import 'package:network_tools/network_tools.dart'; - -@singleton -class XiaomiIoConnectorConjector implements AbstractCompanyConnectorConjector { - @override - Map companyDevices = {}; - - MiCloud? miCloud; - - Future accountLogin( - GenericXiaomiMiLoginDE loginDE, - ) async { - miCloud = MiCloud(); - await miCloud!.login( - loginDE.xiaomiMiAccountEmail.getOrCrash(), - loginDE.xiaomiMiAccountPass.getOrCrash(), - ); - // final List devices = await miCloud!.getDevices(); - // for (final dynamic device in devices) { - // print(device.name); - // print(device.toString()); - // } - return ''; - } - - // Discover from miio package does not work on Linux, but it is better than - // filtering devices by host names like we do now - Future discoverNewDevices({ - required ActiveHost activeHost, - }) async { - if (miCloud == null) { - logger.w('Please set Xiaomi Mi credentials in the app'); - } - - // try { - // if ((activeHost.address).endsWith('.1')) { - // // Currently we exclude discovered routers - // return; - // } - // // final InternetAddress internetAddress = InternetAddress('192.168.31.255'); - // final InternetAddress internetAddress = - // InternetAddress(activeHost.address); - // - // final Auth auth = Auth(); - // final Api api = Api('cn'); // your country code - // final dynamic user = await auth.login( - // , - // , - // ); // your id or name and password - // - // final dynamic data = await api.getDeviceList( - // user['userId'], - // user['ssecurity'], - // user['token'], - // 'cn', - // ); // your two-letter codes - // - // print(data); - // - // final MiIOPacket miIoPacket = await MiIO.instance.hello(internetAddress); - // MiIO.instance.send( - // activeHost.internetAddress, - // miIoPacket, - // token: user["token"] as List?, - // ); - // - // // await for (final tup.Tuple2 miDevice - // // in MiIO.instance.discover(internetAddress)) { - // // logger.t('miDevice devices $miDevice'); - // // // MiIO.inst ance.send(address, packet); - // // } - // - // // final InternetAddress internetAddress = InternetAddress('192.168.31.247'); - // // - // // MiIOPacket miIoPacket = await MiIO.instance.hello(internetAddress); - // // MiIOPacket ab = await MiIO.instance.send(internetAddress, miIoPacket); - // // logger.t('This is mi packets $miIoPacket'); - // } on MiIOError catch (e) { - // logger.e( - // 'Command failed with error from xiaomi device:\n' - // 'code: ${e.code}\n' - // 'message: ${e.message}', - // ); - // } on Exception catch (e) { - // logger.e('Xiaomi command failed with exception:\n$e'); - // } catch (e) { - // logger.t('All else'); - // } - } - - @override - Future manageHubRequestsForDevice( - DeviceEntityAbstract xiaomiDE, - ) async { - final DeviceEntityAbstract? device = - companyDevices[xiaomiDE.entityUniqueId.getOrCrash()]; - - if (device is XiaomiIoGpx4021GlEntity) { - device.executeDeviceAction(newEntity: xiaomiDE); - } else { - logger.w('XiaomiIo device type does not exist'); - } - } - - @override - Future setUpDeviceFromDb(DeviceEntityAbstract deviceEntity) async { - DeviceEntityAbstract? nonGenericDevice; - - if (deviceEntity is GenericRgbwLightDE) { - nonGenericDevice = XiaomiIoGpx4021GlEntity.fromGeneric(deviceEntity); - } - - if (nonGenericDevice == null) { - logger.w('Xiaomi mi device could not get loaded from the server'); - return; - } - - companyDevices.addEntries([ - MapEntry(nonGenericDevice.entityUniqueId.getOrCrash(), nonGenericDevice), - ]); - } -} diff --git a/lib/infrastructure/devices/xiaomi_io/xiaomi_io_device_validators.dart b/lib/infrastructure/devices/xiaomi_io/xiaomi_io_device_validators.dart deleted file mode 100644 index 9edc5dbc..00000000 --- a/lib/infrastructure/devices/xiaomi_io/xiaomi_io_device_validators.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateXiaomiIoIdNotEmpty(String input) { - return right(input); -} - -Either, String> validateXiaomiIoPortNotEmpty( - String input, -) { - return right(input); -} diff --git a/lib/infrastructure/devices/xiaomi_io/xiaomi_io_gpx3021gl/xiaomi_io_gpx3021gl_entity.dart b/lib/infrastructure/devices/xiaomi_io/xiaomi_io_gpx3021gl/xiaomi_io_gpx3021gl_entity.dart deleted file mode 100644 index b06b2427..00000000 --- a/lib/infrastructure/devices/xiaomi_io/xiaomi_io_gpx3021gl/xiaomi_io_gpx3021gl_entity.dart +++ /dev/null @@ -1,210 +0,0 @@ -import 'dart:async'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_value_objects.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; -import 'package:yeedart/yeedart.dart'; - -class XiaomiIoGpx4021GlEntity extends GenericRgbwLightDE { - XiaomiIoGpx4021GlEntity({ - required super.uniqueId, - required super.entityUniqueId, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required super.lightSwitchState, - required super.lightColorTemperature, - required super.lightColorAlpha, - required super.lightColorHue, - required super.lightColorSaturation, - required super.lightColorValue, - required super.lightBrightness, - }) : super( - deviceVendor: DeviceVendor( - VendorsAndServices.philipsHue.toString(), - ), - ); - - factory XiaomiIoGpx4021GlEntity.fromGeneric( - GenericRgbwLightDE genericDevice, - ) { - return XiaomiIoGpx4021GlEntity( - uniqueId: genericDevice.uniqueId, - entityUniqueId: genericDevice.entityUniqueId, - cbjEntityName: genericDevice.cbjEntityName, - entityOriginalName: genericDevice.entityOriginalName, - deviceOriginalName: genericDevice.deviceOriginalName, - stateMassage: genericDevice.stateMassage, - senderDeviceOs: genericDevice.senderDeviceOs, - senderDeviceModel: genericDevice.senderDeviceModel, - senderId: genericDevice.senderId, - compUuid: genericDevice.compUuid, - entityStateGRPC: genericDevice.entityStateGRPC, - powerConsumption: genericDevice.powerConsumption, - deviceUniqueId: genericDevice.deviceUniqueId, - devicePort: genericDevice.devicePort, - deviceLastKnownIp: genericDevice.deviceLastKnownIp, - deviceHostName: genericDevice.deviceHostName, - deviceMdns: genericDevice.deviceMdns, - devicesMacAddress: genericDevice.devicesMacAddress, - entityKey: genericDevice.entityKey, - requestTimeStamp: genericDevice.requestTimeStamp, - lastResponseFromDeviceTimeStamp: - genericDevice.lastResponseFromDeviceTimeStamp, - lightSwitchState: genericDevice.lightSwitchState, - deviceCbjUniqueId: genericDevice.deviceCbjUniqueId, - lightBrightness: genericDevice.lightBrightness, - lightColorTemperature: genericDevice.lightColorTemperature, - lightColorAlpha: genericDevice.lightColorAlpha, - lightColorHue: genericDevice.lightColorHue, - lightColorSaturation: genericDevice.lightColorSaturation, - lightColorValue: genericDevice.lightColorValue, - ); - } - - /// XiaomiIo package object require to close previews request before new one - Device? xiaomiIoPackageObject; - - /// Please override the following methods - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - if (newEntity is! GenericRgbwLightDE) { - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Not the correct type', - ), - ); - } - - try { - if (newEntity.lightSwitchState!.getOrCrash() != - lightSwitchState!.getOrCrash() || - entityStateGRPC.getOrCrash() != EntityStateGRPC.ack.toString()) { - final EntityActions? actionToPreform = - EnumHelperCbj.stringToDeviceAction( - newEntity.lightSwitchState!.getOrCrash(), - ); - - if (actionToPreform == EntityActions.on) { - (await turnOnLight()).fold( - (l) { - logger.e('Error turning XiaomiIO light on'); - throw l; - }, - (r) { - logger.i('XiaomiIO light turn on success'); - }, - ); - } else if (actionToPreform == EntityActions.off) { - (await turnOffLight()).fold( - (l) { - logger.e('Error turning XiaomiIO light off'); - throw l; - }, - (r) { - logger.i('XiaomiIO turn off success'); - }, - ); - } else { - logger.e( - 'The action to preform is not set correctly on XiaomiIo Gpx4021Gl', - ); - } - } - entityStateGRPC = EntityState(EntityStateGRPC.ack.toString()); - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - return right(unit); - } catch (e) { - entityStateGRPC = EntityState(EntityStateGRPC.newStateFailed.toString()); - // getIt().postSmartDeviceToAppMqtt( - // entityFromTheHub: this, - // ); - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> turnOnLight() async { - lightSwitchState = GenericRgbwLightSwitchState(EntityActions.on.toString()); - try { - return left(const CoreFailure.unexpected()); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> turnOffLight() async { - lightSwitchState = - GenericRgbwLightSwitchState(EntityActions.off.toString()); - try { - return left(const CoreFailure.unexpected()); - } catch (e) { - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> setBrightness(String brightness) async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - @override - Future> changeColorTemperature({ - required String lightColorTemperatureNewValue, - }) async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } - - @override - Future> changeColorHsv({ - required String lightColorAlphaNewValue, - required String lightColorHueNewValue, - required String lightColorSaturationNewValue, - required String lightColorValueNewValue, - }) async { - logger.w('Please override this method in the non generic implementation'); - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Action does not exist', - ), - ); - } -} diff --git a/lib/infrastructure/devices/xiaomi_io/xiaomi_io_helpers.dart b/lib/infrastructure/devices/xiaomi_io/xiaomi_io_helpers.dart deleted file mode 100644 index f9729250..00000000 --- a/lib/infrastructure/devices/xiaomi_io/xiaomi_io_helpers.dart +++ /dev/null @@ -1,69 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_value_objects.dart'; -import 'package:cbj_hub/infrastructure/devices/xiaomi_io/xiaomi_io_gpx3021gl/xiaomi_io_gpx3021gl_entity.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:yeedart/yeedart.dart'; - -class XiaomiIoHelpers { - static DeviceEntityAbstract? addDiscoverdDevice({ - required DiscoveryResponse xiaomiIoDevice, - required CoreUniqueId? uniqueDeviceId, - }) { - CoreUniqueId uniqueDeviceIdTemp; - - if (uniqueDeviceId != null) { - uniqueDeviceIdTemp = uniqueDeviceId; - } else { - uniqueDeviceIdTemp = CoreUniqueId(); - } - - final String deviceName = - xiaomiIoDevice.name != null && xiaomiIoDevice.name != '' - ? xiaomiIoDevice.name! - : 'XiaomiIo test 2'; - final XiaomiIoGpx4021GlEntity xiaomiIoDE = XiaomiIoGpx4021GlEntity( - uniqueId: uniqueDeviceIdTemp, - entityUniqueId: EntityUniqueId(xiaomiIoDevice.id.toString()), - cbjEntityName: CbjEntityName(deviceName), - entityOriginalName: EntityOriginalName(deviceName), - deviceOriginalName: DeviceOriginalName(deviceName), - entityStateGRPC: EntityState(EntityStateGRPC.ack.toString()), - senderDeviceOs: DeviceSenderDeviceOs('xiaomi_io'), - senderDeviceModel: DeviceSenderDeviceModel('1SE'), - senderId: DeviceSenderId(), - compUuid: DeviceCompUuid('34asdfrsd23gggg'), - deviceMdns: DeviceMdns('yeelink-light-colora_miap9C52'), - deviceLastKnownIp: DeviceLastKnownIp(xiaomiIoDevice.address.address), - stateMassage: DeviceStateMassage('Hello World'), - powerConsumption: DevicePowerConsumption('0'), - deviceUniqueId: DeviceUniqueId(xiaomiIoDevice.id.toString()), - devicePort: DevicePort(xiaomiIoDevice.port.toString()), - deviceCbjUniqueId: CoreUniqueId(), - lightSwitchState: - GenericRgbwLightSwitchState(xiaomiIoDevice.powered.toString()), - lightColorTemperature: GenericRgbwLightColorTemperature( - xiaomiIoDevice.colorTemperature.toString(), - ), - lightBrightness: - GenericRgbwLightBrightness(xiaomiIoDevice.brightness.toString()), - lightColorAlpha: GenericRgbwLightColorAlpha('1.0'), - lightColorHue: GenericRgbwLightColorHue('0.0'), - lightColorSaturation: GenericRgbwLightColorSaturation('1.0'), - lightColorValue: GenericRgbwLightColorValue('1.0'), - deviceHostName: DeviceHostName('0'), - devicesMacAddress: DevicesMacAddress('0'), - entityKey: EntityKey('0'), - requestTimeStamp: RequestTimeStamp('0'), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp('0'), - ); - - return xiaomiIoDE; - - // TODO: Add if device type does not supported return null - // logger.i( - // 'Please add new Xiaomi device type ${xiaomiIoDevice.model}', - // ); - // return null; - } -} diff --git a/lib/infrastructure/devices/xiaomi_io/xiaomi_led_smart_bulb_essential_white_and_color/xiaomi_led_smart_bulb_essential_white_and_color_entity.dart b/lib/infrastructure/devices/xiaomi_io/xiaomi_led_smart_bulb_essential_white_and_color/xiaomi_led_smart_bulb_essential_white_and_color_entity.dart deleted file mode 100644 index 3992bf49..00000000 --- a/lib/infrastructure/devices/xiaomi_io/xiaomi_led_smart_bulb_essential_white_and_color/xiaomi_led_smart_bulb_essential_white_and_color_entity.dart +++ /dev/null @@ -1,37 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_entity.dart'; - -class XiaomiLedSmartBulbEssentialWhiteAndColorEntity - extends GenericRgbwLightDE { - XiaomiLedSmartBulbEssentialWhiteAndColorEntity({ - required super.uniqueId, - required super.entityUniqueId, - required super.deviceVendor, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required super.lightSwitchState, - required super.lightColorTemperature, - required super.lightColorAlpha, - required super.lightColorHue, - required super.lightColorSaturation, - required super.lightColorValue, - required super.lightBrightness, - }); -} diff --git a/lib/infrastructure/devices/yeelight/yeelight_1se/yeelight_1se_entity.dart b/lib/infrastructure/devices/yeelight/yeelight_1se/yeelight_1se_entity.dart deleted file mode 100644 index cd2fae69..00000000 --- a/lib/infrastructure/devices/yeelight/yeelight_1se/yeelight_1se_entity.dart +++ /dev/null @@ -1,551 +0,0 @@ -import 'dart:async'; -import 'dart:io'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_value_objects.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; -import 'package:yeedart/yeedart.dart'; - -class Yeelight1SeEntity extends GenericRgbwLightDE { - Yeelight1SeEntity({ - required super.uniqueId, - required super.entityUniqueId, - required super.cbjEntityName, - required super.entityOriginalName, - required super.deviceOriginalName, - required super.stateMassage, - required super.senderDeviceOs, - required super.senderDeviceModel, - required super.senderId, - required super.compUuid, - required super.entityStateGRPC, - required super.powerConsumption, - required super.deviceUniqueId, - required super.devicePort, - required super.deviceLastKnownIp, - required super.deviceHostName, - required super.deviceMdns, - required super.devicesMacAddress, - required super.entityKey, - required super.requestTimeStamp, - required super.lastResponseFromDeviceTimeStamp, - required super.deviceCbjUniqueId, - required super.lightSwitchState, - required super.lightColorTemperature, - required super.lightColorAlpha, - required super.lightColorHue, - required super.lightColorSaturation, - required super.lightColorValue, - required super.lightBrightness, - }) : super( - deviceVendor: DeviceVendor(VendorsAndServices.yeelight.toString()), - ); - - factory Yeelight1SeEntity.fromGeneric(GenericRgbwLightDE genericDevice) { - return Yeelight1SeEntity( - uniqueId: genericDevice.uniqueId, - entityUniqueId: genericDevice.entityUniqueId, - cbjEntityName: genericDevice.cbjEntityName, - entityOriginalName: genericDevice.entityOriginalName, - deviceOriginalName: genericDevice.deviceOriginalName, - stateMassage: genericDevice.stateMassage, - senderDeviceOs: genericDevice.senderDeviceOs, - senderDeviceModel: genericDevice.senderDeviceModel, - senderId: genericDevice.senderId, - compUuid: genericDevice.compUuid, - entityStateGRPC: genericDevice.entityStateGRPC, - powerConsumption: genericDevice.powerConsumption, - deviceUniqueId: genericDevice.deviceUniqueId, - devicePort: genericDevice.devicePort, - deviceLastKnownIp: genericDevice.deviceLastKnownIp, - deviceHostName: genericDevice.deviceHostName, - deviceMdns: genericDevice.deviceMdns, - devicesMacAddress: genericDevice.devicesMacAddress, - entityKey: genericDevice.entityKey, - requestTimeStamp: genericDevice.requestTimeStamp, - lastResponseFromDeviceTimeStamp: - genericDevice.lastResponseFromDeviceTimeStamp, - lightSwitchState: genericDevice.lightSwitchState, - deviceCbjUniqueId: genericDevice.deviceCbjUniqueId, - lightBrightness: genericDevice.lightBrightness, - lightColorTemperature: genericDevice.lightColorTemperature, - lightColorAlpha: genericDevice.lightColorAlpha, - lightColorHue: genericDevice.lightColorHue, - lightColorSaturation: genericDevice.lightColorSaturation, - lightColorValue: genericDevice.lightColorValue, - ); - } - - /// Yeelight package object require to close previews request before new one - Device? yeelightPackageObject; - - /// Timer to execute methods with min of 1 seconds between each other - Timer? executeStateTimer; - - /// How much time to wait between execute of methods - // TODO: Test if we can lower this number to 1000 and requests do not - // get denied - final int sendNewRequestToDeviceEachMilliseconds = 1100; - - /// Fix to differentiate what value to change - String? lightColorTemperatureLastValue; - - /// Fix to differentiate what value to change - String? lightColorHueLastValue; - - /// Fix to differentiate what value to change - String? lightColorSaturationLastValue; - - String? lightBrightnessLastValue; - - /// Please override the following methods - @override - Future> executeDeviceAction({ - required DeviceEntityAbstract newEntity, - }) async { - if (newEntity is! GenericRgbwLightDE) { - return left( - const CoreFailure.actionExcecuter( - failedValue: 'Not the correct type', - ), - ); - } - if (executeStateTimer != null) { - executeStateTimer!.cancel(); - executeStateTimer = null; - } - - executeStateTimer ??= - Timer(Duration(milliseconds: sendNewRequestToDeviceEachMilliseconds), - () async { - try { - try { - if (newEntity.lightSwitchState!.getOrCrash() != - lightSwitchState!.getOrCrash() || - entityStateGRPC.getOrCrash() != EntityStateGRPC.ack.toString()) { - final EntityActions? actionToPreform = - EnumHelperCbj.stringToDeviceAction( - newEntity.lightSwitchState!.getOrCrash(), - ); - - if (actionToPreform == EntityActions.on) { - (await turnOnLight()).fold( - (l) { - logger.e('Error turning Yeelight light on\n$l'); - throw l; - }, - (r) { - logger.i('Yeelight light turn on success'); - }, - ); - } else if (actionToPreform == EntityActions.off) { - (await turnOffLight()).fold( - (l) { - logger.e('Error turning Yeelight light off\n$l'); - throw l; - }, - (r) { - logger.i('Yeelight light turn off success'); - }, - ); - } else { - logger.i('actionToPreform is not set correctly on Yeelight 1SE'); - } - } - - if (newEntity.lightColorTemperature.getOrCrash() != - lightColorTemperature.getOrCrash() || - entityStateGRPC.getOrCrash() != EntityStateGRPC.ack.toString()) { - (await changeColorTemperature( - lightColorTemperatureNewValue: - newEntity.lightColorTemperature.getOrCrash(), - )) - .fold( - (l) { - logger.e('Error changing Yeelight ColorTemper\n$l'); - throw l; - }, - (r) { - logger.i('Yeelight changed ColorTemper successfully'); - }, - ); - } - if (newEntity.lightColorAlpha.getOrCrash() != - lightColorAlpha.getOrCrash() || - newEntity.lightColorHue.getOrCrash() != - lightColorHue.getOrCrash() || - newEntity.lightColorSaturation.getOrCrash() != - lightColorSaturation.getOrCrash() || - newEntity.lightColorValue.getOrCrash() != - lightColorValue.getOrCrash() || - entityStateGRPC.getOrCrash() != EntityStateGRPC.ack.toString()) { - (await changeColorHsv( - lightColorAlphaNewValue: newEntity.lightColorAlpha.getOrCrash(), - lightColorHueNewValue: newEntity.lightColorHue.getOrCrash(), - lightColorSaturationNewValue: - newEntity.lightColorSaturation.getOrCrash(), - lightColorValueNewValue: newEntity.lightColorValue.getOrCrash(), - )) - .fold( - (l) { - logger.e('Error changing Yeelight light color\n$l'); - throw l; - }, - (r) { - logger.i('Yeelight changed color successfully'); - }, - ); - } - - if (newEntity.lightBrightness.getOrCrash() != - lightBrightness.getOrCrash() || - entityStateGRPC.getOrCrash() != EntityStateGRPC.ack.toString()) { - (await setBrightness(newEntity.lightBrightness.getOrCrash())).fold( - (l) { - logger.e('Error changing Yeelight brightness\n$l'); - throw l; - }, - (r) { - logger.i('Yeelight changed brightness successfully'); - }, - ); - } - entityStateGRPC = EntityState(EntityStateGRPC.ack.toString()); - } catch (e) { - logger.e('Error executing Yeelight current state\n$e'); - } finally { - yeelightPackageObject?.disconnect(); - } - } catch (e) { - logger.e('Yeelight throws exception on disconnect\n$e'); - entityStateGRPC = - EntityState(EntityStateGRPC.newStateFailed.toString()); - } - executeStateTimer = null; - }); - - return right(unit); - } - - @override - Future> turnOnLight() async { - lightSwitchState = GenericRgbwLightSwitchState(EntityActions.on.toString()); - try { - await _sendTurnOnDevice(); - - return right(unit); - } catch (e) { - logger.e('Error in Yeelight Device setting turn on\n$e'); - - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> turnOffLight() async { - lightSwitchState = - GenericRgbwLightSwitchState(EntityActions.off.toString()); - - try { - await _sendTurnOffDevice(); - - return right(unit); - } catch (e) { - return left(CoreFailure.actionExcecuter(failedValue: e)); - } - } - - @override - Future> setBrightness(String brightness) async { - lightBrightness = GenericRgbwLightBrightness(brightness); - - try { - await _sendSetBrightness(); - - return right(unit); - } catch (e) { - logger.e('Error in Yeelight Device setting brightness\n$e'); - - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> changeColorTemperature({ - required String lightColorTemperatureNewValue, - }) async { - try { - int temperatureInt = int.parse(lightColorTemperatureNewValue); - if (temperatureInt < 1700) { - temperatureInt = 1700; - } else if (temperatureInt > 6500) { - temperatureInt = 6500; - } - - lightColorTemperature = - GenericRgbwLightColorTemperature(temperatureInt.toString()); - - _sendChangeColorTemperature(); - - return right(unit); - } catch (e) { - logger.e('Error in Yeelight Device setting color temprature\n$e'); - - return left(const CoreFailure.unexpected()); - } - } - - @override - Future> changeColorHsv({ - required String lightColorAlphaNewValue, - required String lightColorHueNewValue, - required String lightColorSaturationNewValue, - required String lightColorValueNewValue, - }) async { - lightColorAlpha = GenericRgbwLightColorAlpha(lightColorAlphaNewValue); - lightColorHue = GenericRgbwLightColorHue(lightColorHueNewValue); - lightColorSaturation = - GenericRgbwLightColorSaturation(lightColorSaturationNewValue); - lightColorValue = GenericRgbwLightColorValue(lightColorValueNewValue); - - try { - await _sendChangeColorHsv(); - return right(unit); - } catch (e) { - logger.e('Error in Yeelight Device setting color hue\n$e'); - - return left(const CoreFailure.unexpected()); - } - } - - /// Yeelight connections are rate-limited to 60 per minute. - /// This method will take care that commends will be sent in 1 second - /// between each one - Future executeCurrentStatusWithConstDelay() async {} - - /// Will turn off the device, will not close the connection - Future> _sendTurnOffDevice() async { - try { - yeelightPackageObject = Device( - address: InternetAddress(deviceLastKnownIp.getOrCrash()), - port: int.parse(devicePort.getOrCrash()), - ); - - await yeelightPackageObject!.turnOff(); - return right(unit); - } catch (e) { - await Future.delayed(const Duration(milliseconds: 150)); - final List responses = await Yeelight.discover(); - - final response = responses.firstWhere( - (element) => element.id.toString() == entityUniqueId.getOrCrash(), - ); - - yeelightPackageObject = - Device(address: response.address, port: response.port!); - - deviceLastKnownIp = DeviceLastKnownIp(response.address.address); - devicePort = DevicePort(response.port!.toString()); - - await yeelightPackageObject!.turnOff(); - } - return right(unit); - } - - /// Will turn on the device, will not close the connection - Future> _sendTurnOnDevice() async { - try { - yeelightPackageObject = Device( - address: InternetAddress(deviceLastKnownIp.getOrCrash()), - port: int.parse(devicePort.getOrCrash()), - ); - - await yeelightPackageObject!.turnOn(); - return right(unit); - } catch (e) { - // TODO: Maybe can be removed, need testing - await Future.delayed(const Duration(milliseconds: 150)); - final responses = await Yeelight.discover(); - - final response = responses.firstWhere( - (element) => element.id.toString() == entityUniqueId.getOrCrash(), - ); - - yeelightPackageObject = - Device(address: response.address, port: response.port!); - - deviceLastKnownIp = DeviceLastKnownIp(response.address.address); - devicePort = DevicePort(response.port!.toString()); - - await yeelightPackageObject!.turnOn(); - } - return right(unit); - } - - Future> _sendSetBrightness() async { - try { - try { - yeelightPackageObject = Device( - address: InternetAddress(deviceLastKnownIp.getOrCrash()), - port: int.parse(devicePort.getOrCrash()), - ); - - await yeelightPackageObject?.turnOn(); - - await yeelightPackageObject?.setBrightness( - brightness: int.parse( - lightBrightness.getOrCrash(), - ), - duration: const Duration(milliseconds: 200), - ); - - yeelightPackageObject?.disconnect(); - - return right(unit); - } catch (e) { - await Future.delayed(const Duration(milliseconds: 150)); - - final responses = await Yeelight.discover(); - - final response = responses.firstWhere( - (element) => element.id.toString() == entityUniqueId.getOrCrash(), - ); - - yeelightPackageObject = - Device(address: response.address, port: response.port!); - deviceLastKnownIp = DeviceLastKnownIp(response.address.address); - devicePort = DevicePort(response.port!.toString()); - - await yeelightPackageObject!.turnOn(); - - await yeelightPackageObject!.setBrightness( - brightness: int.parse( - lightBrightness.getOrCrash(), - ), - duration: const Duration(milliseconds: 200), - ); - - return right(unit); - } - } catch (error) { - logger.e('Error in Yeelight Device setting brightness\n$error'); - return left(const CoreFailure.unexpected()); - } - } - - Future> _sendChangeColorTemperature() async { - try { - try { - yeelightPackageObject = Device( - address: InternetAddress(deviceLastKnownIp.getOrCrash()), - port: int.parse(devicePort.getOrCrash()), - ); - - await yeelightPackageObject!.setColorTemperature( - colorTemperature: int.parse(lightColorTemperature.getOrCrash()), - duration: const Duration( - milliseconds: 100, - ), - ); - - return right(unit); - } catch (e) { - await Future.delayed(const Duration(milliseconds: 150)); - - final responses = await Yeelight.discover(); - - final response = responses.firstWhere( - (element) => element.id.toString() == entityUniqueId.getOrCrash(), - ); - - yeelightPackageObject = - Device(address: response.address, port: response.port!); - deviceLastKnownIp = DeviceLastKnownIp(response.address.address); - devicePort = DevicePort(response.port!.toString()); - - await yeelightPackageObject!.setColorTemperature( - colorTemperature: int.parse(lightColorTemperature.getOrCrash()), - duration: const Duration( - milliseconds: 100, - ), - ); - return right(unit); - } - } catch (e) { - return left(CoreFailure.actionExcecuter(failedValue: e)); - } - } - - Future> _sendChangeColorHsv() async { - try { - try { - yeelightPackageObject = Device( - address: InternetAddress(deviceLastKnownIp.getOrCrash()), - port: int.parse(devicePort.getOrCrash()), - ); - int saturationValue; - if (lightColorSaturation.getOrCrash().length <= 3 && - lightColorSaturation.getOrCrash() == '0.0') { - saturationValue = 0; - } else if (lightColorSaturation.getOrCrash().length <= 3) { - saturationValue = 100; - } else { - saturationValue = - int.parse(lightColorSaturation.getOrCrash().substring(2, 4)); - } - - await yeelightPackageObject!.setHSV( - hue: double.parse(lightColorHue.getOrCrash()).toInt(), - saturation: saturationValue, - duration: const Duration( - milliseconds: 100, - ), - ); - - return right(unit); - } catch (e) { - await Future.delayed(const Duration(milliseconds: 150)); - - final responses = await Yeelight.discover(); - - final response = responses.firstWhere( - (element) => element.id.toString() == entityUniqueId.getOrCrash(), - ); - - yeelightPackageObject = - Device(address: response.address, port: response.port!); - deviceLastKnownIp = DeviceLastKnownIp(response.address.address); - devicePort = DevicePort(response.port!.toString()); - - int saturationValue; - if (lightColorSaturation.getOrCrash().length <= 3 && - lightColorSaturation.getOrCrash() == '0.0') { - saturationValue = 0; - } else if (lightColorSaturation.getOrCrash().length <= 3) { - saturationValue = 100; - } else { - saturationValue = - int.parse(lightColorSaturation.getOrCrash().substring(2, 4)); - } - - await yeelightPackageObject!.setHSV( - hue: double.parse(lightColorHue.getOrCrash()).toInt(), - saturation: saturationValue, - duration: const Duration( - milliseconds: 100, - ), - ); - - return right(unit); - } - } catch (e) { - return left(CoreFailure.actionExcecuter(failedValue: e)); - } - } -} diff --git a/lib/infrastructure/devices/yeelight/yeelight_connector_conjector.dart b/lib/infrastructure/devices/yeelight/yeelight_connector_conjector.dart deleted file mode 100644 index 561f8fae..00000000 --- a/lib/infrastructure/devices/yeelight/yeelight_connector_conjector.dart +++ /dev/null @@ -1,117 +0,0 @@ -import 'dart:async'; - -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/companies_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/yeelight/yeelight_1se/yeelight_1se_entity.dart'; -import 'package:cbj_hub/infrastructure/devices/yeelight/yeelight_helpers.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/abstract_company_connector_conjector.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:injectable/injectable.dart'; -import 'package:network_tools/network_tools.dart'; -import 'package:yeedart/yeedart.dart'; - -@singleton -class YeelightConnectorConjector implements AbstractCompanyConnectorConjector { - @override - Map companyDevices = {}; - - static const List mdnsTypes = [ - '_hap._tcp', - ]; - - /// Make sure that it will activate discoverNewDevices only once - bool searchStarted = false; - - Future addNewDeviceByMdnsName({ - required String mDnsName, - required String ip, - required String port, - }) async { - addNewDevice(ip: ip, mDnsName: mDnsName); - } - - Future addNewDeviceByHostInfo({ - required ActiveHost activeHost, - }) async { - addNewDevice(ip: activeHost.address); - } - - Future addNewDevice({ - required String ip, - String? mDnsName, - }) async { - try { - final responses = await Yeelight.discover(); - if (responses.isEmpty) { - return; - } - - for (final DiscoveryResponse yeelightDevice in responses) { - if (companyDevices.containsKey(yeelightDevice.id.toString())) { - return; - } - - DeviceEntityAbstract? addDevice; - if (yeelightDevice.address.address == ip) { - addDevice = YeelightHelpers.addDiscoverdDevice( - yeelightDevice: yeelightDevice, - mDnsName: mDnsName, - ); - } else { - addDevice = YeelightHelpers.addDiscoverdDevice( - yeelightDevice: yeelightDevice, - ); - } - - if (addDevice == null) { - continue; - } - - final DeviceEntityAbstract deviceToAdd = - CompaniesConnectorConjector.addDiscoverdDeviceToHub(addDevice); - - final MapEntry deviceAsEntry = - MapEntry(deviceToAdd.entityUniqueId.getOrCrash(), deviceToAdd); - - companyDevices.addEntries([deviceAsEntry]); - - logger.i('New Yeelight device got added'); - } - } catch (e) { - logger.e('Error discover in Yeelight\n$e'); - } - } - - @override - Future manageHubRequestsForDevice( - DeviceEntityAbstract entity, - ) async { - final DeviceEntityAbstract? device = - companyDevices[entity.entityUniqueId.getOrCrash()]; - - if (device is Yeelight1SeEntity) { - device.executeDeviceAction(newEntity: entity); - } else { - logger.w('Yeelight device type does not exist'); - } - } - - @override - Future setUpDeviceFromDb(DeviceEntityAbstract deviceEntity) async { - DeviceEntityAbstract? nonGenericDevice; - - if (deviceEntity is GenericRgbwLightDE) { - nonGenericDevice = Yeelight1SeEntity.fromGeneric(deviceEntity); - } - - if (nonGenericDevice == null) { - logger.w('Switcher device could not get loaded from the server'); - return; - } - - companyDevices.addEntries([ - MapEntry(nonGenericDevice.entityUniqueId.getOrCrash(), nonGenericDevice), - ]); - } -} diff --git a/lib/infrastructure/devices/yeelight/yeelight_device_validators.dart b/lib/infrastructure/devices/yeelight/yeelight_device_validators.dart deleted file mode 100644 index 014ff678..00000000 --- a/lib/infrastructure/devices/yeelight/yeelight_device_validators.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/core_failures.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateYeelightIdNotEmpty(String input) { - return right(input); -} - -Either, String> validateYeelightPortNotEmpty(String input) { - return right(input); -} diff --git a/lib/infrastructure/devices/yeelight/yeelight_helpers.dart b/lib/infrastructure/devices/yeelight/yeelight_helpers.dart deleted file mode 100644 index 9695995c..00000000 --- a/lib/infrastructure/devices/yeelight/yeelight_helpers.dart +++ /dev/null @@ -1,76 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_value_objects.dart'; -import 'package:cbj_hub/infrastructure/devices/yeelight/yeelight_1se/yeelight_1se_entity.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:yeedart/yeedart.dart'; - -class YeelightHelpers { - static DeviceEntityAbstract? addDiscoverdDevice({ - required DiscoveryResponse yeelightDevice, - String? mDnsName, - }) { - String deviceName; - if (yeelightDevice.name != null && yeelightDevice.name != '') { - deviceName = yeelightDevice.name!; - } else if (mDnsName != null) { - deviceName = mDnsName; - } else { - deviceName = 'Yeelight device'; - } - - if (yeelightDevice.model == null) { - return null; - } - - final DeviceEntityAbstract deviceEntity; - - if (yeelightDevice.model == 'color4') { - deviceEntity = Yeelight1SeEntity( - uniqueId: CoreUniqueId(), - entityUniqueId: EntityUniqueId(yeelightDevice.id.toString()), - cbjEntityName: CbjEntityName(deviceName), - entityOriginalName: EntityOriginalName(deviceName), - deviceOriginalName: DeviceOriginalName(deviceName), - entityStateGRPC: EntityState(EntityStateGRPC.ack.toString()), - senderDeviceOs: DeviceSenderDeviceOs('yeelight'), - senderDeviceModel: DeviceSenderDeviceModel('1SE'), - senderId: DeviceSenderId(), - compUuid: DeviceCompUuid('34asdfrsd23gggg'), - deviceMdns: DeviceMdns(mDnsName ?? ''), - deviceLastKnownIp: DeviceLastKnownIp(yeelightDevice.address.address), - stateMassage: DeviceStateMassage('Hello World'), - powerConsumption: DevicePowerConsumption('0'), - devicePort: DevicePort(yeelightDevice.port.toString()), - lightSwitchState: - GenericRgbwLightSwitchState(yeelightDevice.powered.toString()), - lightColorTemperature: GenericRgbwLightColorTemperature( - yeelightDevice.colorTemperature.toString(), - ), - lightBrightness: - GenericRgbwLightBrightness(yeelightDevice.brightness.toString()), - lightColorAlpha: GenericRgbwLightColorAlpha('1.0'), - lightColorHue: GenericRgbwLightColorHue(yeelightDevice.hue.toString()), - lightColorSaturation: GenericRgbwLightColorSaturation( - yeelightDevice.sat.toString(), - ), - lightColorValue: GenericRgbwLightColorValue('1.0'), - deviceUniqueId: DeviceUniqueId('0'), - deviceHostName: DeviceHostName('0'), - devicesMacAddress: DevicesMacAddress('0'), - entityKey: EntityKey('0'), - requestTimeStamp: RequestTimeStamp('0'), - lastResponseFromDeviceTimeStamp: LastResponseFromDeviceTimeStamp('0'), - deviceCbjUniqueId: CoreUniqueId(), - ); - } else { - logger.i( - 'Please add new Yeelight device type ${yeelightDevice.model}', - ); - return null; - } - - return deviceEntity; - } -} diff --git a/lib/infrastructure/gen/aioesphomeapi/proto_gen_date.dart b/lib/infrastructure/gen/aioesphomeapi/proto_gen_date.dart deleted file mode 100644 index f6508bfa..00000000 --- a/lib/infrastructure/gen/aioesphomeapi/proto_gen_date.dart +++ /dev/null @@ -1 +0,0 @@ -const hubAioEspHomeApiClientProtocGenDate = '25/03/23'; diff --git a/lib/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api.pb.dart b/lib/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api.pb.dart deleted file mode 100644 index 262849bc..00000000 --- a/lib/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api.pb.dart +++ /dev/null @@ -1,5232 +0,0 @@ -/// -// Generated code. Do not modify. -// source: aioesphomeapi/api.proto -// -// @dart = 2.12 -// ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name - -import 'dart:async' as $async; -import 'dart:core' as $core; - -import 'package:protobuf/protobuf.dart' as $pb; - -import 'api_options.pb.dart' as $0; - -import 'api.pbenum.dart'; - -export 'api.pbenum.dart'; - -class HelloRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'HelloRequest', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'clientInfo') - ..hasRequiredFields = false - ; - - HelloRequest._() : super(); - factory HelloRequest({ - $core.String? clientInfo, - }) { - final _result = create(); - if (clientInfo != null) { - _result.clientInfo = clientInfo; - } - return _result; - } - factory HelloRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory HelloRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - HelloRequest clone() => HelloRequest()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - HelloRequest copyWith(void Function(HelloRequest) updates) => super.copyWith((message) => updates(message as HelloRequest)) as HelloRequest; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static HelloRequest create() => HelloRequest._(); - HelloRequest createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static HelloRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static HelloRequest? _defaultInstance; - - @$pb.TagNumber(1) - $core.String get clientInfo => $_getSZ(0); - @$pb.TagNumber(1) - set clientInfo($core.String v) { $_setString(0, v); } - @$pb.TagNumber(1) - $core.bool hasClientInfo() => $_has(0); - @$pb.TagNumber(1) - void clearClientInfo() => clearField(1); -} - -class HelloResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'HelloResponse', createEmptyInstance: create) - ..a<$core.int>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'apiVersionMajor', $pb.PbFieldType.OU3) - ..a<$core.int>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'apiVersionMinor', $pb.PbFieldType.OU3) - ..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'serverInfo') - ..hasRequiredFields = false - ; - - HelloResponse._() : super(); - factory HelloResponse({ - $core.int? apiVersionMajor, - $core.int? apiVersionMinor, - $core.String? serverInfo, - }) { - final _result = create(); - if (apiVersionMajor != null) { - _result.apiVersionMajor = apiVersionMajor; - } - if (apiVersionMinor != null) { - _result.apiVersionMinor = apiVersionMinor; - } - if (serverInfo != null) { - _result.serverInfo = serverInfo; - } - return _result; - } - factory HelloResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory HelloResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - HelloResponse clone() => HelloResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - HelloResponse copyWith(void Function(HelloResponse) updates) => super.copyWith((message) => updates(message as HelloResponse)) as HelloResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static HelloResponse create() => HelloResponse._(); - HelloResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static HelloResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static HelloResponse? _defaultInstance; - - @$pb.TagNumber(1) - $core.int get apiVersionMajor => $_getIZ(0); - @$pb.TagNumber(1) - set apiVersionMajor($core.int v) { $_setUnsignedInt32(0, v); } - @$pb.TagNumber(1) - $core.bool hasApiVersionMajor() => $_has(0); - @$pb.TagNumber(1) - void clearApiVersionMajor() => clearField(1); - - @$pb.TagNumber(2) - $core.int get apiVersionMinor => $_getIZ(1); - @$pb.TagNumber(2) - set apiVersionMinor($core.int v) { $_setUnsignedInt32(1, v); } - @$pb.TagNumber(2) - $core.bool hasApiVersionMinor() => $_has(1); - @$pb.TagNumber(2) - void clearApiVersionMinor() => clearField(2); - - @$pb.TagNumber(3) - $core.String get serverInfo => $_getSZ(2); - @$pb.TagNumber(3) - set serverInfo($core.String v) { $_setString(2, v); } - @$pb.TagNumber(3) - $core.bool hasServerInfo() => $_has(2); - @$pb.TagNumber(3) - void clearServerInfo() => clearField(3); -} - -class ConnectRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ConnectRequest', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'password') - ..hasRequiredFields = false - ; - - ConnectRequest._() : super(); - factory ConnectRequest({ - $core.String? password, - }) { - final _result = create(); - if (password != null) { - _result.password = password; - } - return _result; - } - factory ConnectRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory ConnectRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - ConnectRequest clone() => ConnectRequest()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - ConnectRequest copyWith(void Function(ConnectRequest) updates) => super.copyWith((message) => updates(message as ConnectRequest)) as ConnectRequest; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static ConnectRequest create() => ConnectRequest._(); - ConnectRequest createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static ConnectRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static ConnectRequest? _defaultInstance; - - @$pb.TagNumber(1) - $core.String get password => $_getSZ(0); - @$pb.TagNumber(1) - set password($core.String v) { $_setString(0, v); } - @$pb.TagNumber(1) - $core.bool hasPassword() => $_has(0); - @$pb.TagNumber(1) - void clearPassword() => clearField(1); -} - -class ConnectResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ConnectResponse', createEmptyInstance: create) - ..aOB(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'invalidPassword') - ..hasRequiredFields = false - ; - - ConnectResponse._() : super(); - factory ConnectResponse({ - $core.bool? invalidPassword, - }) { - final _result = create(); - if (invalidPassword != null) { - _result.invalidPassword = invalidPassword; - } - return _result; - } - factory ConnectResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory ConnectResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - ConnectResponse clone() => ConnectResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - ConnectResponse copyWith(void Function(ConnectResponse) updates) => super.copyWith((message) => updates(message as ConnectResponse)) as ConnectResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static ConnectResponse create() => ConnectResponse._(); - ConnectResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static ConnectResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static ConnectResponse? _defaultInstance; - - @$pb.TagNumber(1) - $core.bool get invalidPassword => $_getBF(0); - @$pb.TagNumber(1) - set invalidPassword($core.bool v) { $_setBool(0, v); } - @$pb.TagNumber(1) - $core.bool hasInvalidPassword() => $_has(0); - @$pb.TagNumber(1) - void clearInvalidPassword() => clearField(1); -} - -class DisconnectRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'DisconnectRequest', createEmptyInstance: create) - ..hasRequiredFields = false - ; - - DisconnectRequest._() : super(); - factory DisconnectRequest() => create(); - factory DisconnectRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory DisconnectRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - DisconnectRequest clone() => DisconnectRequest()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - DisconnectRequest copyWith(void Function(DisconnectRequest) updates) => super.copyWith((message) => updates(message as DisconnectRequest)) as DisconnectRequest; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static DisconnectRequest create() => DisconnectRequest._(); - DisconnectRequest createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static DisconnectRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static DisconnectRequest? _defaultInstance; -} - -class DisconnectResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'DisconnectResponse', createEmptyInstance: create) - ..hasRequiredFields = false - ; - - DisconnectResponse._() : super(); - factory DisconnectResponse() => create(); - factory DisconnectResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory DisconnectResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - DisconnectResponse clone() => DisconnectResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - DisconnectResponse copyWith(void Function(DisconnectResponse) updates) => super.copyWith((message) => updates(message as DisconnectResponse)) as DisconnectResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static DisconnectResponse create() => DisconnectResponse._(); - DisconnectResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static DisconnectResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static DisconnectResponse? _defaultInstance; -} - -class PingRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'PingRequest', createEmptyInstance: create) - ..hasRequiredFields = false - ; - - PingRequest._() : super(); - factory PingRequest() => create(); - factory PingRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory PingRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - PingRequest clone() => PingRequest()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - PingRequest copyWith(void Function(PingRequest) updates) => super.copyWith((message) => updates(message as PingRequest)) as PingRequest; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static PingRequest create() => PingRequest._(); - PingRequest createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static PingRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static PingRequest? _defaultInstance; -} - -class PingResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'PingResponse', createEmptyInstance: create) - ..hasRequiredFields = false - ; - - PingResponse._() : super(); - factory PingResponse() => create(); - factory PingResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory PingResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - PingResponse clone() => PingResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - PingResponse copyWith(void Function(PingResponse) updates) => super.copyWith((message) => updates(message as PingResponse)) as PingResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static PingResponse create() => PingResponse._(); - PingResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static PingResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static PingResponse? _defaultInstance; -} - -class DeviceInfoRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'DeviceInfoRequest', createEmptyInstance: create) - ..hasRequiredFields = false - ; - - DeviceInfoRequest._() : super(); - factory DeviceInfoRequest() => create(); - factory DeviceInfoRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory DeviceInfoRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - DeviceInfoRequest clone() => DeviceInfoRequest()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - DeviceInfoRequest copyWith(void Function(DeviceInfoRequest) updates) => super.copyWith((message) => updates(message as DeviceInfoRequest)) as DeviceInfoRequest; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static DeviceInfoRequest create() => DeviceInfoRequest._(); - DeviceInfoRequest createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static DeviceInfoRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static DeviceInfoRequest? _defaultInstance; -} - -class DeviceInfoResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'DeviceInfoResponse', createEmptyInstance: create) - ..aOB(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'usesPassword') - ..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name') - ..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'macAddress') - ..aOS(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'esphomeVersion') - ..aOS(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'compilationTime') - ..aOS(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'model') - ..aOB(7, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'hasDeepSleep') - ..aOS(8, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'projectName') - ..aOS(9, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'projectVersion') - ..hasRequiredFields = false - ; - - DeviceInfoResponse._() : super(); - factory DeviceInfoResponse({ - $core.bool? usesPassword, - $core.String? name, - $core.String? macAddress, - $core.String? esphomeVersion, - $core.String? compilationTime, - $core.String? model, - $core.bool? hasDeepSleep, - $core.String? projectName, - $core.String? projectVersion, - }) { - final _result = create(); - if (usesPassword != null) { - _result.usesPassword = usesPassword; - } - if (name != null) { - _result.name = name; - } - if (macAddress != null) { - _result.macAddress = macAddress; - } - if (esphomeVersion != null) { - _result.esphomeVersion = esphomeVersion; - } - if (compilationTime != null) { - _result.compilationTime = compilationTime; - } - if (model != null) { - _result.model = model; - } - if (hasDeepSleep != null) { - _result.hasDeepSleep = hasDeepSleep; - } - if (projectName != null) { - _result.projectName = projectName; - } - if (projectVersion != null) { - _result.projectVersion = projectVersion; - } - return _result; - } - factory DeviceInfoResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory DeviceInfoResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - DeviceInfoResponse clone() => DeviceInfoResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - DeviceInfoResponse copyWith(void Function(DeviceInfoResponse) updates) => super.copyWith((message) => updates(message as DeviceInfoResponse)) as DeviceInfoResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static DeviceInfoResponse create() => DeviceInfoResponse._(); - DeviceInfoResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static DeviceInfoResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static DeviceInfoResponse? _defaultInstance; - - @$pb.TagNumber(1) - $core.bool get usesPassword => $_getBF(0); - @$pb.TagNumber(1) - set usesPassword($core.bool v) { $_setBool(0, v); } - @$pb.TagNumber(1) - $core.bool hasUsesPassword() => $_has(0); - @$pb.TagNumber(1) - void clearUsesPassword() => clearField(1); - - @$pb.TagNumber(2) - $core.String get name => $_getSZ(1); - @$pb.TagNumber(2) - set name($core.String v) { $_setString(1, v); } - @$pb.TagNumber(2) - $core.bool hasName() => $_has(1); - @$pb.TagNumber(2) - void clearName() => clearField(2); - - @$pb.TagNumber(3) - $core.String get macAddress => $_getSZ(2); - @$pb.TagNumber(3) - set macAddress($core.String v) { $_setString(2, v); } - @$pb.TagNumber(3) - $core.bool hasMacAddress() => $_has(2); - @$pb.TagNumber(3) - void clearMacAddress() => clearField(3); - - @$pb.TagNumber(4) - $core.String get esphomeVersion => $_getSZ(3); - @$pb.TagNumber(4) - set esphomeVersion($core.String v) { $_setString(3, v); } - @$pb.TagNumber(4) - $core.bool hasEsphomeVersion() => $_has(3); - @$pb.TagNumber(4) - void clearEsphomeVersion() => clearField(4); - - @$pb.TagNumber(5) - $core.String get compilationTime => $_getSZ(4); - @$pb.TagNumber(5) - set compilationTime($core.String v) { $_setString(4, v); } - @$pb.TagNumber(5) - $core.bool hasCompilationTime() => $_has(4); - @$pb.TagNumber(5) - void clearCompilationTime() => clearField(5); - - @$pb.TagNumber(6) - $core.String get model => $_getSZ(5); - @$pb.TagNumber(6) - set model($core.String v) { $_setString(5, v); } - @$pb.TagNumber(6) - $core.bool hasModel() => $_has(5); - @$pb.TagNumber(6) - void clearModel() => clearField(6); - - @$pb.TagNumber(7) - $core.bool get hasDeepSleep => $_getBF(6); - @$pb.TagNumber(7) - set hasDeepSleep($core.bool v) { $_setBool(6, v); } - @$pb.TagNumber(7) - $core.bool hasHasDeepSleep() => $_has(6); - @$pb.TagNumber(7) - void clearHasDeepSleep() => clearField(7); - - @$pb.TagNumber(8) - $core.String get projectName => $_getSZ(7); - @$pb.TagNumber(8) - set projectName($core.String v) { $_setString(7, v); } - @$pb.TagNumber(8) - $core.bool hasProjectName() => $_has(7); - @$pb.TagNumber(8) - void clearProjectName() => clearField(8); - - @$pb.TagNumber(9) - $core.String get projectVersion => $_getSZ(8); - @$pb.TagNumber(9) - set projectVersion($core.String v) { $_setString(8, v); } - @$pb.TagNumber(9) - $core.bool hasProjectVersion() => $_has(8); - @$pb.TagNumber(9) - void clearProjectVersion() => clearField(9); -} - -class ListEntitiesRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ListEntitiesRequest', createEmptyInstance: create) - ..hasRequiredFields = false - ; - - ListEntitiesRequest._() : super(); - factory ListEntitiesRequest() => create(); - factory ListEntitiesRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory ListEntitiesRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - ListEntitiesRequest clone() => ListEntitiesRequest()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - ListEntitiesRequest copyWith(void Function(ListEntitiesRequest) updates) => super.copyWith((message) => updates(message as ListEntitiesRequest)) as ListEntitiesRequest; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static ListEntitiesRequest create() => ListEntitiesRequest._(); - ListEntitiesRequest createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static ListEntitiesRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static ListEntitiesRequest? _defaultInstance; -} - -class ListEntitiesDoneResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ListEntitiesDoneResponse', createEmptyInstance: create) - ..hasRequiredFields = false - ; - - ListEntitiesDoneResponse._() : super(); - factory ListEntitiesDoneResponse() => create(); - factory ListEntitiesDoneResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory ListEntitiesDoneResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - ListEntitiesDoneResponse clone() => ListEntitiesDoneResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - ListEntitiesDoneResponse copyWith(void Function(ListEntitiesDoneResponse) updates) => super.copyWith((message) => updates(message as ListEntitiesDoneResponse)) as ListEntitiesDoneResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static ListEntitiesDoneResponse create() => ListEntitiesDoneResponse._(); - ListEntitiesDoneResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static ListEntitiesDoneResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static ListEntitiesDoneResponse? _defaultInstance; -} - -class SubscribeStatesRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'SubscribeStatesRequest', createEmptyInstance: create) - ..hasRequiredFields = false - ; - - SubscribeStatesRequest._() : super(); - factory SubscribeStatesRequest() => create(); - factory SubscribeStatesRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory SubscribeStatesRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - SubscribeStatesRequest clone() => SubscribeStatesRequest()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - SubscribeStatesRequest copyWith(void Function(SubscribeStatesRequest) updates) => super.copyWith((message) => updates(message as SubscribeStatesRequest)) as SubscribeStatesRequest; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static SubscribeStatesRequest create() => SubscribeStatesRequest._(); - SubscribeStatesRequest createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static SubscribeStatesRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static SubscribeStatesRequest? _defaultInstance; -} - -class ListEntitiesBinarySensorResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ListEntitiesBinarySensorResponse', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'objectId') - ..a<$core.int>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'key', $pb.PbFieldType.OF3) - ..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name') - ..aOS(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'uniqueId') - ..aOS(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'deviceClass') - ..aOB(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'isStatusBinarySensor') - ..hasRequiredFields = false - ; - - ListEntitiesBinarySensorResponse._() : super(); - factory ListEntitiesBinarySensorResponse({ - $core.String? objectId, - $core.int? key, - $core.String? name, - $core.String? uniqueId, - $core.String? deviceClass, - $core.bool? isStatusBinarySensor, - }) { - final _result = create(); - if (objectId != null) { - _result.objectId = objectId; - } - if (key != null) { - _result.key = key; - } - if (name != null) { - _result.name = name; - } - if (uniqueId != null) { - _result.uniqueId = uniqueId; - } - if (deviceClass != null) { - _result.deviceClass = deviceClass; - } - if (isStatusBinarySensor != null) { - _result.isStatusBinarySensor = isStatusBinarySensor; - } - return _result; - } - factory ListEntitiesBinarySensorResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory ListEntitiesBinarySensorResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - ListEntitiesBinarySensorResponse clone() => ListEntitiesBinarySensorResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - ListEntitiesBinarySensorResponse copyWith(void Function(ListEntitiesBinarySensorResponse) updates) => super.copyWith((message) => updates(message as ListEntitiesBinarySensorResponse)) as ListEntitiesBinarySensorResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static ListEntitiesBinarySensorResponse create() => ListEntitiesBinarySensorResponse._(); - ListEntitiesBinarySensorResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static ListEntitiesBinarySensorResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static ListEntitiesBinarySensorResponse? _defaultInstance; - - @$pb.TagNumber(1) - $core.String get objectId => $_getSZ(0); - @$pb.TagNumber(1) - set objectId($core.String v) { $_setString(0, v); } - @$pb.TagNumber(1) - $core.bool hasObjectId() => $_has(0); - @$pb.TagNumber(1) - void clearObjectId() => clearField(1); - - @$pb.TagNumber(2) - $core.int get key => $_getIZ(1); - @$pb.TagNumber(2) - set key($core.int v) { $_setUnsignedInt32(1, v); } - @$pb.TagNumber(2) - $core.bool hasKey() => $_has(1); - @$pb.TagNumber(2) - void clearKey() => clearField(2); - - @$pb.TagNumber(3) - $core.String get name => $_getSZ(2); - @$pb.TagNumber(3) - set name($core.String v) { $_setString(2, v); } - @$pb.TagNumber(3) - $core.bool hasName() => $_has(2); - @$pb.TagNumber(3) - void clearName() => clearField(3); - - @$pb.TagNumber(4) - $core.String get uniqueId => $_getSZ(3); - @$pb.TagNumber(4) - set uniqueId($core.String v) { $_setString(3, v); } - @$pb.TagNumber(4) - $core.bool hasUniqueId() => $_has(3); - @$pb.TagNumber(4) - void clearUniqueId() => clearField(4); - - @$pb.TagNumber(5) - $core.String get deviceClass => $_getSZ(4); - @$pb.TagNumber(5) - set deviceClass($core.String v) { $_setString(4, v); } - @$pb.TagNumber(5) - $core.bool hasDeviceClass() => $_has(4); - @$pb.TagNumber(5) - void clearDeviceClass() => clearField(5); - - @$pb.TagNumber(6) - $core.bool get isStatusBinarySensor => $_getBF(5); - @$pb.TagNumber(6) - set isStatusBinarySensor($core.bool v) { $_setBool(5, v); } - @$pb.TagNumber(6) - $core.bool hasIsStatusBinarySensor() => $_has(5); - @$pb.TagNumber(6) - void clearIsStatusBinarySensor() => clearField(6); -} - -class BinarySensorStateResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'BinarySensorStateResponse', createEmptyInstance: create) - ..a<$core.int>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'key', $pb.PbFieldType.OF3) - ..aOB(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'state') - ..aOB(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'missingState') - ..hasRequiredFields = false - ; - - BinarySensorStateResponse._() : super(); - factory BinarySensorStateResponse({ - $core.int? key, - $core.bool? state, - $core.bool? missingState, - }) { - final _result = create(); - if (key != null) { - _result.key = key; - } - if (state != null) { - _result.state = state; - } - if (missingState != null) { - _result.missingState = missingState; - } - return _result; - } - factory BinarySensorStateResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory BinarySensorStateResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - BinarySensorStateResponse clone() => BinarySensorStateResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - BinarySensorStateResponse copyWith(void Function(BinarySensorStateResponse) updates) => super.copyWith((message) => updates(message as BinarySensorStateResponse)) as BinarySensorStateResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static BinarySensorStateResponse create() => BinarySensorStateResponse._(); - BinarySensorStateResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static BinarySensorStateResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static BinarySensorStateResponse? _defaultInstance; - - @$pb.TagNumber(1) - $core.int get key => $_getIZ(0); - @$pb.TagNumber(1) - set key($core.int v) { $_setUnsignedInt32(0, v); } - @$pb.TagNumber(1) - $core.bool hasKey() => $_has(0); - @$pb.TagNumber(1) - void clearKey() => clearField(1); - - @$pb.TagNumber(2) - $core.bool get state => $_getBF(1); - @$pb.TagNumber(2) - set state($core.bool v) { $_setBool(1, v); } - @$pb.TagNumber(2) - $core.bool hasState() => $_has(1); - @$pb.TagNumber(2) - void clearState() => clearField(2); - - @$pb.TagNumber(3) - $core.bool get missingState => $_getBF(2); - @$pb.TagNumber(3) - set missingState($core.bool v) { $_setBool(2, v); } - @$pb.TagNumber(3) - $core.bool hasMissingState() => $_has(2); - @$pb.TagNumber(3) - void clearMissingState() => clearField(3); -} - -class ListEntitiesCoverResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ListEntitiesCoverResponse', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'objectId') - ..a<$core.int>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'key', $pb.PbFieldType.OF3) - ..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name') - ..aOS(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'uniqueId') - ..aOB(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'assumedState') - ..aOB(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'supportsPosition') - ..aOB(7, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'supportsTilt') - ..aOS(8, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'deviceClass') - ..hasRequiredFields = false - ; - - ListEntitiesCoverResponse._() : super(); - factory ListEntitiesCoverResponse({ - $core.String? objectId, - $core.int? key, - $core.String? name, - $core.String? uniqueId, - $core.bool? assumedState, - $core.bool? supportsPosition, - $core.bool? supportsTilt, - $core.String? deviceClass, - }) { - final _result = create(); - if (objectId != null) { - _result.objectId = objectId; - } - if (key != null) { - _result.key = key; - } - if (name != null) { - _result.name = name; - } - if (uniqueId != null) { - _result.uniqueId = uniqueId; - } - if (assumedState != null) { - _result.assumedState = assumedState; - } - if (supportsPosition != null) { - _result.supportsPosition = supportsPosition; - } - if (supportsTilt != null) { - _result.supportsTilt = supportsTilt; - } - if (deviceClass != null) { - _result.deviceClass = deviceClass; - } - return _result; - } - factory ListEntitiesCoverResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory ListEntitiesCoverResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - ListEntitiesCoverResponse clone() => ListEntitiesCoverResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - ListEntitiesCoverResponse copyWith(void Function(ListEntitiesCoverResponse) updates) => super.copyWith((message) => updates(message as ListEntitiesCoverResponse)) as ListEntitiesCoverResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static ListEntitiesCoverResponse create() => ListEntitiesCoverResponse._(); - ListEntitiesCoverResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static ListEntitiesCoverResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static ListEntitiesCoverResponse? _defaultInstance; - - @$pb.TagNumber(1) - $core.String get objectId => $_getSZ(0); - @$pb.TagNumber(1) - set objectId($core.String v) { $_setString(0, v); } - @$pb.TagNumber(1) - $core.bool hasObjectId() => $_has(0); - @$pb.TagNumber(1) - void clearObjectId() => clearField(1); - - @$pb.TagNumber(2) - $core.int get key => $_getIZ(1); - @$pb.TagNumber(2) - set key($core.int v) { $_setUnsignedInt32(1, v); } - @$pb.TagNumber(2) - $core.bool hasKey() => $_has(1); - @$pb.TagNumber(2) - void clearKey() => clearField(2); - - @$pb.TagNumber(3) - $core.String get name => $_getSZ(2); - @$pb.TagNumber(3) - set name($core.String v) { $_setString(2, v); } - @$pb.TagNumber(3) - $core.bool hasName() => $_has(2); - @$pb.TagNumber(3) - void clearName() => clearField(3); - - @$pb.TagNumber(4) - $core.String get uniqueId => $_getSZ(3); - @$pb.TagNumber(4) - set uniqueId($core.String v) { $_setString(3, v); } - @$pb.TagNumber(4) - $core.bool hasUniqueId() => $_has(3); - @$pb.TagNumber(4) - void clearUniqueId() => clearField(4); - - @$pb.TagNumber(5) - $core.bool get assumedState => $_getBF(4); - @$pb.TagNumber(5) - set assumedState($core.bool v) { $_setBool(4, v); } - @$pb.TagNumber(5) - $core.bool hasAssumedState() => $_has(4); - @$pb.TagNumber(5) - void clearAssumedState() => clearField(5); - - @$pb.TagNumber(6) - $core.bool get supportsPosition => $_getBF(5); - @$pb.TagNumber(6) - set supportsPosition($core.bool v) { $_setBool(5, v); } - @$pb.TagNumber(6) - $core.bool hasSupportsPosition() => $_has(5); - @$pb.TagNumber(6) - void clearSupportsPosition() => clearField(6); - - @$pb.TagNumber(7) - $core.bool get supportsTilt => $_getBF(6); - @$pb.TagNumber(7) - set supportsTilt($core.bool v) { $_setBool(6, v); } - @$pb.TagNumber(7) - $core.bool hasSupportsTilt() => $_has(6); - @$pb.TagNumber(7) - void clearSupportsTilt() => clearField(7); - - @$pb.TagNumber(8) - $core.String get deviceClass => $_getSZ(7); - @$pb.TagNumber(8) - set deviceClass($core.String v) { $_setString(7, v); } - @$pb.TagNumber(8) - $core.bool hasDeviceClass() => $_has(7); - @$pb.TagNumber(8) - void clearDeviceClass() => clearField(8); -} - -class CoverStateResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CoverStateResponse', createEmptyInstance: create) - ..a<$core.int>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'key', $pb.PbFieldType.OF3) - ..e(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'legacyState', $pb.PbFieldType.OE, defaultOrMaker: LegacyCoverState.LEGACY_COVER_STATE_OPEN, valueOf: LegacyCoverState.valueOf, enumValues: LegacyCoverState.values) - ..a<$core.double>(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'position', $pb.PbFieldType.OF) - ..a<$core.double>(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'tilt', $pb.PbFieldType.OF) - ..e(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'currentOperation', $pb.PbFieldType.OE, defaultOrMaker: CoverOperation.COVER_OPERATION_IDLE, valueOf: CoverOperation.valueOf, enumValues: CoverOperation.values) - ..hasRequiredFields = false - ; - - CoverStateResponse._() : super(); - factory CoverStateResponse({ - $core.int? key, - LegacyCoverState? legacyState, - $core.double? position, - $core.double? tilt, - CoverOperation? currentOperation, - }) { - final _result = create(); - if (key != null) { - _result.key = key; - } - if (legacyState != null) { - _result.legacyState = legacyState; - } - if (position != null) { - _result.position = position; - } - if (tilt != null) { - _result.tilt = tilt; - } - if (currentOperation != null) { - _result.currentOperation = currentOperation; - } - return _result; - } - factory CoverStateResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory CoverStateResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - CoverStateResponse clone() => CoverStateResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - CoverStateResponse copyWith(void Function(CoverStateResponse) updates) => super.copyWith((message) => updates(message as CoverStateResponse)) as CoverStateResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static CoverStateResponse create() => CoverStateResponse._(); - CoverStateResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static CoverStateResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static CoverStateResponse? _defaultInstance; - - @$pb.TagNumber(1) - $core.int get key => $_getIZ(0); - @$pb.TagNumber(1) - set key($core.int v) { $_setUnsignedInt32(0, v); } - @$pb.TagNumber(1) - $core.bool hasKey() => $_has(0); - @$pb.TagNumber(1) - void clearKey() => clearField(1); - - @$pb.TagNumber(2) - LegacyCoverState get legacyState => $_getN(1); - @$pb.TagNumber(2) - set legacyState(LegacyCoverState v) { setField(2, v); } - @$pb.TagNumber(2) - $core.bool hasLegacyState() => $_has(1); - @$pb.TagNumber(2) - void clearLegacyState() => clearField(2); - - @$pb.TagNumber(3) - $core.double get position => $_getN(2); - @$pb.TagNumber(3) - set position($core.double v) { $_setFloat(2, v); } - @$pb.TagNumber(3) - $core.bool hasPosition() => $_has(2); - @$pb.TagNumber(3) - void clearPosition() => clearField(3); - - @$pb.TagNumber(4) - $core.double get tilt => $_getN(3); - @$pb.TagNumber(4) - set tilt($core.double v) { $_setFloat(3, v); } - @$pb.TagNumber(4) - $core.bool hasTilt() => $_has(3); - @$pb.TagNumber(4) - void clearTilt() => clearField(4); - - @$pb.TagNumber(5) - CoverOperation get currentOperation => $_getN(4); - @$pb.TagNumber(5) - set currentOperation(CoverOperation v) { setField(5, v); } - @$pb.TagNumber(5) - $core.bool hasCurrentOperation() => $_has(4); - @$pb.TagNumber(5) - void clearCurrentOperation() => clearField(5); -} - -class CoverCommandRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CoverCommandRequest', createEmptyInstance: create) - ..a<$core.int>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'key', $pb.PbFieldType.OF3) - ..aOB(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'hasLegacyCommand') - ..e(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'legacyCommand', $pb.PbFieldType.OE, defaultOrMaker: LegacyCoverCommand.LEGACY_COVER_COMMAND_OPEN, valueOf: LegacyCoverCommand.valueOf, enumValues: LegacyCoverCommand.values) - ..aOB(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'hasPosition') - ..a<$core.double>(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'position', $pb.PbFieldType.OF) - ..aOB(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'hasTilt') - ..a<$core.double>(7, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'tilt', $pb.PbFieldType.OF) - ..aOB(8, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'stop') - ..hasRequiredFields = false - ; - - CoverCommandRequest._() : super(); - factory CoverCommandRequest({ - $core.int? key, - $core.bool? hasLegacyCommand, - LegacyCoverCommand? legacyCommand_3, - $core.bool? hasPosition, - $core.double? position_5, - $core.bool? hasTilt, - $core.double? tilt_7, - $core.bool? stop, - }) { - final _result = create(); - if (key != null) { - _result.key = key; - } - if (hasLegacyCommand != null) { - _result.hasLegacyCommand = hasLegacyCommand; - } - if (legacyCommand_3 != null) { - _result.legacyCommand_3 = legacyCommand_3; - } - if (hasPosition != null) { - _result.hasPosition = hasPosition; - } - if (position_5 != null) { - _result.position_5 = position_5; - } - if (hasTilt != null) { - _result.hasTilt = hasTilt; - } - if (tilt_7 != null) { - _result.tilt_7 = tilt_7; - } - if (stop != null) { - _result.stop = stop; - } - return _result; - } - factory CoverCommandRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory CoverCommandRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - CoverCommandRequest clone() => CoverCommandRequest()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - CoverCommandRequest copyWith(void Function(CoverCommandRequest) updates) => super.copyWith((message) => updates(message as CoverCommandRequest)) as CoverCommandRequest; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static CoverCommandRequest create() => CoverCommandRequest._(); - CoverCommandRequest createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static CoverCommandRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static CoverCommandRequest? _defaultInstance; - - @$pb.TagNumber(1) - $core.int get key => $_getIZ(0); - @$pb.TagNumber(1) - set key($core.int v) { $_setUnsignedInt32(0, v); } - @$pb.TagNumber(1) - $core.bool hasKey() => $_has(0); - @$pb.TagNumber(1) - void clearKey() => clearField(1); - - @$pb.TagNumber(2) - $core.bool get hasLegacyCommand => $_getBF(1); - @$pb.TagNumber(2) - set hasLegacyCommand($core.bool v) { $_setBool(1, v); } - @$pb.TagNumber(2) - $core.bool hasHasLegacyCommand() => $_has(1); - @$pb.TagNumber(2) - void clearHasLegacyCommand() => clearField(2); - - @$pb.TagNumber(3) - LegacyCoverCommand get legacyCommand_3 => $_getN(2); - @$pb.TagNumber(3) - set legacyCommand_3(LegacyCoverCommand v) { setField(3, v); } - @$pb.TagNumber(3) - $core.bool hasLegacyCommand_3() => $_has(2); - @$pb.TagNumber(3) - void clearLegacyCommand_3() => clearField(3); - - @$pb.TagNumber(4) - $core.bool get hasPosition => $_getBF(3); - @$pb.TagNumber(4) - set hasPosition($core.bool v) { $_setBool(3, v); } - @$pb.TagNumber(4) - $core.bool hasHasPosition() => $_has(3); - @$pb.TagNumber(4) - void clearHasPosition() => clearField(4); - - @$pb.TagNumber(5) - $core.double get position_5 => $_getN(4); - @$pb.TagNumber(5) - set position_5($core.double v) { $_setFloat(4, v); } - @$pb.TagNumber(5) - $core.bool hasPosition_5() => $_has(4); - @$pb.TagNumber(5) - void clearPosition_5() => clearField(5); - - @$pb.TagNumber(6) - $core.bool get hasTilt => $_getBF(5); - @$pb.TagNumber(6) - set hasTilt($core.bool v) { $_setBool(5, v); } - @$pb.TagNumber(6) - $core.bool hasHasTilt() => $_has(5); - @$pb.TagNumber(6) - void clearHasTilt() => clearField(6); - - @$pb.TagNumber(7) - $core.double get tilt_7 => $_getN(6); - @$pb.TagNumber(7) - set tilt_7($core.double v) { $_setFloat(6, v); } - @$pb.TagNumber(7) - $core.bool hasTilt_7() => $_has(6); - @$pb.TagNumber(7) - void clearTilt_7() => clearField(7); - - @$pb.TagNumber(8) - $core.bool get stop => $_getBF(7); - @$pb.TagNumber(8) - set stop($core.bool v) { $_setBool(7, v); } - @$pb.TagNumber(8) - $core.bool hasStop() => $_has(7); - @$pb.TagNumber(8) - void clearStop() => clearField(8); -} - -class ListEntitiesFanResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ListEntitiesFanResponse', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'objectId') - ..a<$core.int>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'key', $pb.PbFieldType.OF3) - ..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name') - ..aOS(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'uniqueId') - ..aOB(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'supportsOscillation') - ..aOB(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'supportsSpeed') - ..aOB(7, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'supportsDirection') - ..a<$core.int>(8, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'supportedSpeedLevels', $pb.PbFieldType.O3) - ..hasRequiredFields = false - ; - - ListEntitiesFanResponse._() : super(); - factory ListEntitiesFanResponse({ - $core.String? objectId, - $core.int? key, - $core.String? name, - $core.String? uniqueId, - $core.bool? supportsOscillation, - $core.bool? supportsSpeed, - $core.bool? supportsDirection, - $core.int? supportedSpeedLevels, - }) { - final _result = create(); - if (objectId != null) { - _result.objectId = objectId; - } - if (key != null) { - _result.key = key; - } - if (name != null) { - _result.name = name; - } - if (uniqueId != null) { - _result.uniqueId = uniqueId; - } - if (supportsOscillation != null) { - _result.supportsOscillation = supportsOscillation; - } - if (supportsSpeed != null) { - _result.supportsSpeed = supportsSpeed; - } - if (supportsDirection != null) { - _result.supportsDirection = supportsDirection; - } - if (supportedSpeedLevels != null) { - _result.supportedSpeedLevels = supportedSpeedLevels; - } - return _result; - } - factory ListEntitiesFanResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory ListEntitiesFanResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - ListEntitiesFanResponse clone() => ListEntitiesFanResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - ListEntitiesFanResponse copyWith(void Function(ListEntitiesFanResponse) updates) => super.copyWith((message) => updates(message as ListEntitiesFanResponse)) as ListEntitiesFanResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static ListEntitiesFanResponse create() => ListEntitiesFanResponse._(); - ListEntitiesFanResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static ListEntitiesFanResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static ListEntitiesFanResponse? _defaultInstance; - - @$pb.TagNumber(1) - $core.String get objectId => $_getSZ(0); - @$pb.TagNumber(1) - set objectId($core.String v) { $_setString(0, v); } - @$pb.TagNumber(1) - $core.bool hasObjectId() => $_has(0); - @$pb.TagNumber(1) - void clearObjectId() => clearField(1); - - @$pb.TagNumber(2) - $core.int get key => $_getIZ(1); - @$pb.TagNumber(2) - set key($core.int v) { $_setUnsignedInt32(1, v); } - @$pb.TagNumber(2) - $core.bool hasKey() => $_has(1); - @$pb.TagNumber(2) - void clearKey() => clearField(2); - - @$pb.TagNumber(3) - $core.String get name => $_getSZ(2); - @$pb.TagNumber(3) - set name($core.String v) { $_setString(2, v); } - @$pb.TagNumber(3) - $core.bool hasName() => $_has(2); - @$pb.TagNumber(3) - void clearName() => clearField(3); - - @$pb.TagNumber(4) - $core.String get uniqueId => $_getSZ(3); - @$pb.TagNumber(4) - set uniqueId($core.String v) { $_setString(3, v); } - @$pb.TagNumber(4) - $core.bool hasUniqueId() => $_has(3); - @$pb.TagNumber(4) - void clearUniqueId() => clearField(4); - - @$pb.TagNumber(5) - $core.bool get supportsOscillation => $_getBF(4); - @$pb.TagNumber(5) - set supportsOscillation($core.bool v) { $_setBool(4, v); } - @$pb.TagNumber(5) - $core.bool hasSupportsOscillation() => $_has(4); - @$pb.TagNumber(5) - void clearSupportsOscillation() => clearField(5); - - @$pb.TagNumber(6) - $core.bool get supportsSpeed => $_getBF(5); - @$pb.TagNumber(6) - set supportsSpeed($core.bool v) { $_setBool(5, v); } - @$pb.TagNumber(6) - $core.bool hasSupportsSpeed() => $_has(5); - @$pb.TagNumber(6) - void clearSupportsSpeed() => clearField(6); - - @$pb.TagNumber(7) - $core.bool get supportsDirection => $_getBF(6); - @$pb.TagNumber(7) - set supportsDirection($core.bool v) { $_setBool(6, v); } - @$pb.TagNumber(7) - $core.bool hasSupportsDirection() => $_has(6); - @$pb.TagNumber(7) - void clearSupportsDirection() => clearField(7); - - @$pb.TagNumber(8) - $core.int get supportedSpeedLevels => $_getIZ(7); - @$pb.TagNumber(8) - set supportedSpeedLevels($core.int v) { $_setSignedInt32(7, v); } - @$pb.TagNumber(8) - $core.bool hasSupportedSpeedLevels() => $_has(7); - @$pb.TagNumber(8) - void clearSupportedSpeedLevels() => clearField(8); -} - -class FanStateResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'FanStateResponse', createEmptyInstance: create) - ..a<$core.int>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'key', $pb.PbFieldType.OF3) - ..aOB(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'state') - ..aOB(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'oscillating') - ..e(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'speed', $pb.PbFieldType.OE, defaultOrMaker: FanSpeed.FAN_SPEED_LOW, valueOf: FanSpeed.valueOf, enumValues: FanSpeed.values) - ..e(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'direction', $pb.PbFieldType.OE, defaultOrMaker: FanDirection.FAN_DIRECTION_FORWARD, valueOf: FanDirection.valueOf, enumValues: FanDirection.values) - ..a<$core.int>(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'speedLevel', $pb.PbFieldType.O3) - ..hasRequiredFields = false - ; - - FanStateResponse._() : super(); - factory FanStateResponse({ - $core.int? key, - $core.bool? state, - $core.bool? oscillating, - @$core.Deprecated('This field is deprecated.') - FanSpeed? speed, - FanDirection? direction, - $core.int? speedLevel, - }) { - final _result = create(); - if (key != null) { - _result.key = key; - } - if (state != null) { - _result.state = state; - } - if (oscillating != null) { - _result.oscillating = oscillating; - } - if (speed != null) { - // ignore: deprecated_member_use_from_same_package - _result.speed = speed; - } - if (direction != null) { - _result.direction = direction; - } - if (speedLevel != null) { - _result.speedLevel = speedLevel; - } - return _result; - } - factory FanStateResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory FanStateResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - FanStateResponse clone() => FanStateResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - FanStateResponse copyWith(void Function(FanStateResponse) updates) => super.copyWith((message) => updates(message as FanStateResponse)) as FanStateResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static FanStateResponse create() => FanStateResponse._(); - FanStateResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static FanStateResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static FanStateResponse? _defaultInstance; - - @$pb.TagNumber(1) - $core.int get key => $_getIZ(0); - @$pb.TagNumber(1) - set key($core.int v) { $_setUnsignedInt32(0, v); } - @$pb.TagNumber(1) - $core.bool hasKey() => $_has(0); - @$pb.TagNumber(1) - void clearKey() => clearField(1); - - @$pb.TagNumber(2) - $core.bool get state => $_getBF(1); - @$pb.TagNumber(2) - set state($core.bool v) { $_setBool(1, v); } - @$pb.TagNumber(2) - $core.bool hasState() => $_has(1); - @$pb.TagNumber(2) - void clearState() => clearField(2); - - @$pb.TagNumber(3) - $core.bool get oscillating => $_getBF(2); - @$pb.TagNumber(3) - set oscillating($core.bool v) { $_setBool(2, v); } - @$pb.TagNumber(3) - $core.bool hasOscillating() => $_has(2); - @$pb.TagNumber(3) - void clearOscillating() => clearField(3); - - @$core.Deprecated('This field is deprecated.') - @$pb.TagNumber(4) - FanSpeed get speed => $_getN(3); - @$core.Deprecated('This field is deprecated.') - @$pb.TagNumber(4) - set speed(FanSpeed v) { setField(4, v); } - @$core.Deprecated('This field is deprecated.') - @$pb.TagNumber(4) - $core.bool hasSpeed() => $_has(3); - @$core.Deprecated('This field is deprecated.') - @$pb.TagNumber(4) - void clearSpeed() => clearField(4); - - @$pb.TagNumber(5) - FanDirection get direction => $_getN(4); - @$pb.TagNumber(5) - set direction(FanDirection v) { setField(5, v); } - @$pb.TagNumber(5) - $core.bool hasDirection() => $_has(4); - @$pb.TagNumber(5) - void clearDirection() => clearField(5); - - @$pb.TagNumber(6) - $core.int get speedLevel => $_getIZ(5); - @$pb.TagNumber(6) - set speedLevel($core.int v) { $_setSignedInt32(5, v); } - @$pb.TagNumber(6) - $core.bool hasSpeedLevel() => $_has(5); - @$pb.TagNumber(6) - void clearSpeedLevel() => clearField(6); -} - -class FanCommandRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'FanCommandRequest', createEmptyInstance: create) - ..a<$core.int>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'key', $pb.PbFieldType.OF3) - ..aOB(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'hasState') - ..aOB(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'state') - ..aOB(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'hasSpeed') - ..e(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'speed', $pb.PbFieldType.OE, defaultOrMaker: FanSpeed.FAN_SPEED_LOW, valueOf: FanSpeed.valueOf, enumValues: FanSpeed.values) - ..aOB(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'hasOscillating') - ..aOB(7, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'oscillating') - ..aOB(8, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'hasDirection') - ..e(9, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'direction', $pb.PbFieldType.OE, defaultOrMaker: FanDirection.FAN_DIRECTION_FORWARD, valueOf: FanDirection.valueOf, enumValues: FanDirection.values) - ..aOB(10, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'hasSpeedLevel') - ..a<$core.int>(11, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'speedLevel', $pb.PbFieldType.O3) - ..hasRequiredFields = false - ; - - FanCommandRequest._() : super(); - factory FanCommandRequest({ - $core.int? key, - $core.bool? hasState, - $core.bool? state_3, - @$core.Deprecated('This field is deprecated.') - $core.bool? hasSpeed, - @$core.Deprecated('This field is deprecated.') - FanSpeed? speed_5, - $core.bool? hasOscillating, - $core.bool? oscillating_7, - $core.bool? hasDirection, - FanDirection? direction_9, - $core.bool? hasSpeedLevel, - $core.int? speedLevel_11, - }) { - final _result = create(); - if (key != null) { - _result.key = key; - } - if (hasState != null) { - _result.hasState = hasState; - } - if (state_3 != null) { - _result.state_3 = state_3; - } - if (hasSpeed != null) { - // ignore: deprecated_member_use_from_same_package - _result.hasSpeed = hasSpeed; - } - if (speed_5 != null) { - // ignore: deprecated_member_use_from_same_package - _result.speed_5 = speed_5; - } - if (hasOscillating != null) { - _result.hasOscillating = hasOscillating; - } - if (oscillating_7 != null) { - _result.oscillating_7 = oscillating_7; - } - if (hasDirection != null) { - _result.hasDirection = hasDirection; - } - if (direction_9 != null) { - _result.direction_9 = direction_9; - } - if (hasSpeedLevel != null) { - _result.hasSpeedLevel = hasSpeedLevel; - } - if (speedLevel_11 != null) { - _result.speedLevel_11 = speedLevel_11; - } - return _result; - } - factory FanCommandRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory FanCommandRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - FanCommandRequest clone() => FanCommandRequest()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - FanCommandRequest copyWith(void Function(FanCommandRequest) updates) => super.copyWith((message) => updates(message as FanCommandRequest)) as FanCommandRequest; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static FanCommandRequest create() => FanCommandRequest._(); - FanCommandRequest createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static FanCommandRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static FanCommandRequest? _defaultInstance; - - @$pb.TagNumber(1) - $core.int get key => $_getIZ(0); - @$pb.TagNumber(1) - set key($core.int v) { $_setUnsignedInt32(0, v); } - @$pb.TagNumber(1) - $core.bool hasKey() => $_has(0); - @$pb.TagNumber(1) - void clearKey() => clearField(1); - - @$pb.TagNumber(2) - $core.bool get hasState => $_getBF(1); - @$pb.TagNumber(2) - set hasState($core.bool v) { $_setBool(1, v); } - @$pb.TagNumber(2) - $core.bool hasHasState() => $_has(1); - @$pb.TagNumber(2) - void clearHasState() => clearField(2); - - @$pb.TagNumber(3) - $core.bool get state_3 => $_getBF(2); - @$pb.TagNumber(3) - set state_3($core.bool v) { $_setBool(2, v); } - @$pb.TagNumber(3) - $core.bool hasState_3() => $_has(2); - @$pb.TagNumber(3) - void clearState_3() => clearField(3); - - @$core.Deprecated('This field is deprecated.') - @$pb.TagNumber(4) - $core.bool get hasSpeed => $_getBF(3); - @$core.Deprecated('This field is deprecated.') - @$pb.TagNumber(4) - set hasSpeed($core.bool v) { $_setBool(3, v); } - @$core.Deprecated('This field is deprecated.') - @$pb.TagNumber(4) - $core.bool hasHasSpeed() => $_has(3); - @$core.Deprecated('This field is deprecated.') - @$pb.TagNumber(4) - void clearHasSpeed() => clearField(4); - - @$core.Deprecated('This field is deprecated.') - @$pb.TagNumber(5) - FanSpeed get speed_5 => $_getN(4); - @$core.Deprecated('This field is deprecated.') - @$pb.TagNumber(5) - set speed_5(FanSpeed v) { setField(5, v); } - @$core.Deprecated('This field is deprecated.') - @$pb.TagNumber(5) - $core.bool hasSpeed_5() => $_has(4); - @$core.Deprecated('This field is deprecated.') - @$pb.TagNumber(5) - void clearSpeed_5() => clearField(5); - - @$pb.TagNumber(6) - $core.bool get hasOscillating => $_getBF(5); - @$pb.TagNumber(6) - set hasOscillating($core.bool v) { $_setBool(5, v); } - @$pb.TagNumber(6) - $core.bool hasHasOscillating() => $_has(5); - @$pb.TagNumber(6) - void clearHasOscillating() => clearField(6); - - @$pb.TagNumber(7) - $core.bool get oscillating_7 => $_getBF(6); - @$pb.TagNumber(7) - set oscillating_7($core.bool v) { $_setBool(6, v); } - @$pb.TagNumber(7) - $core.bool hasOscillating_7() => $_has(6); - @$pb.TagNumber(7) - void clearOscillating_7() => clearField(7); - - @$pb.TagNumber(8) - $core.bool get hasDirection => $_getBF(7); - @$pb.TagNumber(8) - set hasDirection($core.bool v) { $_setBool(7, v); } - @$pb.TagNumber(8) - $core.bool hasHasDirection() => $_has(7); - @$pb.TagNumber(8) - void clearHasDirection() => clearField(8); - - @$pb.TagNumber(9) - FanDirection get direction_9 => $_getN(8); - @$pb.TagNumber(9) - set direction_9(FanDirection v) { setField(9, v); } - @$pb.TagNumber(9) - $core.bool hasDirection_9() => $_has(8); - @$pb.TagNumber(9) - void clearDirection_9() => clearField(9); - - @$pb.TagNumber(10) - $core.bool get hasSpeedLevel => $_getBF(9); - @$pb.TagNumber(10) - set hasSpeedLevel($core.bool v) { $_setBool(9, v); } - @$pb.TagNumber(10) - $core.bool hasHasSpeedLevel() => $_has(9); - @$pb.TagNumber(10) - void clearHasSpeedLevel() => clearField(10); - - @$pb.TagNumber(11) - $core.int get speedLevel_11 => $_getIZ(10); - @$pb.TagNumber(11) - set speedLevel_11($core.int v) { $_setSignedInt32(10, v); } - @$pb.TagNumber(11) - $core.bool hasSpeedLevel_11() => $_has(10); - @$pb.TagNumber(11) - void clearSpeedLevel_11() => clearField(11); -} - -class ListEntitiesLightResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ListEntitiesLightResponse', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'objectId') - ..a<$core.int>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'key', $pb.PbFieldType.OF3) - ..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name') - ..aOS(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'uniqueId') - ..aOB(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'supportsBrightness') - ..aOB(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'supportsRgb') - ..aOB(7, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'supportsWhiteValue') - ..aOB(8, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'supportsColorTemperature') - ..a<$core.double>(9, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'minMireds', $pb.PbFieldType.OF) - ..a<$core.double>(10, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'maxMireds', $pb.PbFieldType.OF) - ..pPS(11, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'effects') - ..hasRequiredFields = false - ; - - ListEntitiesLightResponse._() : super(); - factory ListEntitiesLightResponse({ - $core.String? objectId, - $core.int? key, - $core.String? name, - $core.String? uniqueId, - $core.bool? supportsBrightness, - $core.bool? supportsRgb, - $core.bool? supportsWhiteValue, - $core.bool? supportsColorTemperature, - $core.double? minMireds, - $core.double? maxMireds, - $core.Iterable<$core.String>? effects, - }) { - final _result = create(); - if (objectId != null) { - _result.objectId = objectId; - } - if (key != null) { - _result.key = key; - } - if (name != null) { - _result.name = name; - } - if (uniqueId != null) { - _result.uniqueId = uniqueId; - } - if (supportsBrightness != null) { - _result.supportsBrightness = supportsBrightness; - } - if (supportsRgb != null) { - _result.supportsRgb = supportsRgb; - } - if (supportsWhiteValue != null) { - _result.supportsWhiteValue = supportsWhiteValue; - } - if (supportsColorTemperature != null) { - _result.supportsColorTemperature = supportsColorTemperature; - } - if (minMireds != null) { - _result.minMireds = minMireds; - } - if (maxMireds != null) { - _result.maxMireds = maxMireds; - } - if (effects != null) { - _result.effects.addAll(effects); - } - return _result; - } - factory ListEntitiesLightResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory ListEntitiesLightResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - ListEntitiesLightResponse clone() => ListEntitiesLightResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - ListEntitiesLightResponse copyWith(void Function(ListEntitiesLightResponse) updates) => super.copyWith((message) => updates(message as ListEntitiesLightResponse)) as ListEntitiesLightResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static ListEntitiesLightResponse create() => ListEntitiesLightResponse._(); - ListEntitiesLightResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static ListEntitiesLightResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static ListEntitiesLightResponse? _defaultInstance; - - @$pb.TagNumber(1) - $core.String get objectId => $_getSZ(0); - @$pb.TagNumber(1) - set objectId($core.String v) { $_setString(0, v); } - @$pb.TagNumber(1) - $core.bool hasObjectId() => $_has(0); - @$pb.TagNumber(1) - void clearObjectId() => clearField(1); - - @$pb.TagNumber(2) - $core.int get key => $_getIZ(1); - @$pb.TagNumber(2) - set key($core.int v) { $_setUnsignedInt32(1, v); } - @$pb.TagNumber(2) - $core.bool hasKey() => $_has(1); - @$pb.TagNumber(2) - void clearKey() => clearField(2); - - @$pb.TagNumber(3) - $core.String get name => $_getSZ(2); - @$pb.TagNumber(3) - set name($core.String v) { $_setString(2, v); } - @$pb.TagNumber(3) - $core.bool hasName() => $_has(2); - @$pb.TagNumber(3) - void clearName() => clearField(3); - - @$pb.TagNumber(4) - $core.String get uniqueId => $_getSZ(3); - @$pb.TagNumber(4) - set uniqueId($core.String v) { $_setString(3, v); } - @$pb.TagNumber(4) - $core.bool hasUniqueId() => $_has(3); - @$pb.TagNumber(4) - void clearUniqueId() => clearField(4); - - @$pb.TagNumber(5) - $core.bool get supportsBrightness => $_getBF(4); - @$pb.TagNumber(5) - set supportsBrightness($core.bool v) { $_setBool(4, v); } - @$pb.TagNumber(5) - $core.bool hasSupportsBrightness() => $_has(4); - @$pb.TagNumber(5) - void clearSupportsBrightness() => clearField(5); - - @$pb.TagNumber(6) - $core.bool get supportsRgb => $_getBF(5); - @$pb.TagNumber(6) - set supportsRgb($core.bool v) { $_setBool(5, v); } - @$pb.TagNumber(6) - $core.bool hasSupportsRgb() => $_has(5); - @$pb.TagNumber(6) - void clearSupportsRgb() => clearField(6); - - @$pb.TagNumber(7) - $core.bool get supportsWhiteValue => $_getBF(6); - @$pb.TagNumber(7) - set supportsWhiteValue($core.bool v) { $_setBool(6, v); } - @$pb.TagNumber(7) - $core.bool hasSupportsWhiteValue() => $_has(6); - @$pb.TagNumber(7) - void clearSupportsWhiteValue() => clearField(7); - - @$pb.TagNumber(8) - $core.bool get supportsColorTemperature => $_getBF(7); - @$pb.TagNumber(8) - set supportsColorTemperature($core.bool v) { $_setBool(7, v); } - @$pb.TagNumber(8) - $core.bool hasSupportsColorTemperature() => $_has(7); - @$pb.TagNumber(8) - void clearSupportsColorTemperature() => clearField(8); - - @$pb.TagNumber(9) - $core.double get minMireds => $_getN(8); - @$pb.TagNumber(9) - set minMireds($core.double v) { $_setFloat(8, v); } - @$pb.TagNumber(9) - $core.bool hasMinMireds() => $_has(8); - @$pb.TagNumber(9) - void clearMinMireds() => clearField(9); - - @$pb.TagNumber(10) - $core.double get maxMireds => $_getN(9); - @$pb.TagNumber(10) - set maxMireds($core.double v) { $_setFloat(9, v); } - @$pb.TagNumber(10) - $core.bool hasMaxMireds() => $_has(9); - @$pb.TagNumber(10) - void clearMaxMireds() => clearField(10); - - @$pb.TagNumber(11) - $core.List<$core.String> get effects => $_getList(10); -} - -class LightStateResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'LightStateResponse', createEmptyInstance: create) - ..a<$core.int>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'key', $pb.PbFieldType.OF3) - ..aOB(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'state') - ..a<$core.double>(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'brightness', $pb.PbFieldType.OF) - ..a<$core.double>(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'red', $pb.PbFieldType.OF) - ..a<$core.double>(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'green', $pb.PbFieldType.OF) - ..a<$core.double>(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'blue', $pb.PbFieldType.OF) - ..a<$core.double>(7, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'white', $pb.PbFieldType.OF) - ..a<$core.double>(8, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'colorTemperature', $pb.PbFieldType.OF) - ..aOS(9, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'effect') - ..hasRequiredFields = false - ; - - LightStateResponse._() : super(); - factory LightStateResponse({ - $core.int? key, - $core.bool? state, - $core.double? brightness, - $core.double? red, - $core.double? green, - $core.double? blue, - $core.double? white, - $core.double? colorTemperature, - $core.String? effect, - }) { - final _result = create(); - if (key != null) { - _result.key = key; - } - if (state != null) { - _result.state = state; - } - if (brightness != null) { - _result.brightness = brightness; - } - if (red != null) { - _result.red = red; - } - if (green != null) { - _result.green = green; - } - if (blue != null) { - _result.blue = blue; - } - if (white != null) { - _result.white = white; - } - if (colorTemperature != null) { - _result.colorTemperature = colorTemperature; - } - if (effect != null) { - _result.effect = effect; - } - return _result; - } - factory LightStateResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory LightStateResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - LightStateResponse clone() => LightStateResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - LightStateResponse copyWith(void Function(LightStateResponse) updates) => super.copyWith((message) => updates(message as LightStateResponse)) as LightStateResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static LightStateResponse create() => LightStateResponse._(); - LightStateResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static LightStateResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static LightStateResponse? _defaultInstance; - - @$pb.TagNumber(1) - $core.int get key => $_getIZ(0); - @$pb.TagNumber(1) - set key($core.int v) { $_setUnsignedInt32(0, v); } - @$pb.TagNumber(1) - $core.bool hasKey() => $_has(0); - @$pb.TagNumber(1) - void clearKey() => clearField(1); - - @$pb.TagNumber(2) - $core.bool get state => $_getBF(1); - @$pb.TagNumber(2) - set state($core.bool v) { $_setBool(1, v); } - @$pb.TagNumber(2) - $core.bool hasState() => $_has(1); - @$pb.TagNumber(2) - void clearState() => clearField(2); - - @$pb.TagNumber(3) - $core.double get brightness => $_getN(2); - @$pb.TagNumber(3) - set brightness($core.double v) { $_setFloat(2, v); } - @$pb.TagNumber(3) - $core.bool hasBrightness() => $_has(2); - @$pb.TagNumber(3) - void clearBrightness() => clearField(3); - - @$pb.TagNumber(4) - $core.double get red => $_getN(3); - @$pb.TagNumber(4) - set red($core.double v) { $_setFloat(3, v); } - @$pb.TagNumber(4) - $core.bool hasRed() => $_has(3); - @$pb.TagNumber(4) - void clearRed() => clearField(4); - - @$pb.TagNumber(5) - $core.double get green => $_getN(4); - @$pb.TagNumber(5) - set green($core.double v) { $_setFloat(4, v); } - @$pb.TagNumber(5) - $core.bool hasGreen() => $_has(4); - @$pb.TagNumber(5) - void clearGreen() => clearField(5); - - @$pb.TagNumber(6) - $core.double get blue => $_getN(5); - @$pb.TagNumber(6) - set blue($core.double v) { $_setFloat(5, v); } - @$pb.TagNumber(6) - $core.bool hasBlue() => $_has(5); - @$pb.TagNumber(6) - void clearBlue() => clearField(6); - - @$pb.TagNumber(7) - $core.double get white => $_getN(6); - @$pb.TagNumber(7) - set white($core.double v) { $_setFloat(6, v); } - @$pb.TagNumber(7) - $core.bool hasWhite() => $_has(6); - @$pb.TagNumber(7) - void clearWhite() => clearField(7); - - @$pb.TagNumber(8) - $core.double get colorTemperature => $_getN(7); - @$pb.TagNumber(8) - set colorTemperature($core.double v) { $_setFloat(7, v); } - @$pb.TagNumber(8) - $core.bool hasColorTemperature() => $_has(7); - @$pb.TagNumber(8) - void clearColorTemperature() => clearField(8); - - @$pb.TagNumber(9) - $core.String get effect => $_getSZ(8); - @$pb.TagNumber(9) - set effect($core.String v) { $_setString(8, v); } - @$pb.TagNumber(9) - $core.bool hasEffect() => $_has(8); - @$pb.TagNumber(9) - void clearEffect() => clearField(9); -} - -class LightCommandRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'LightCommandRequest', createEmptyInstance: create) - ..a<$core.int>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'key', $pb.PbFieldType.OF3) - ..aOB(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'hasState') - ..aOB(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'state') - ..aOB(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'hasBrightness') - ..a<$core.double>(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'brightness', $pb.PbFieldType.OF) - ..aOB(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'hasRgb') - ..a<$core.double>(7, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'red', $pb.PbFieldType.OF) - ..a<$core.double>(8, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'green', $pb.PbFieldType.OF) - ..a<$core.double>(9, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'blue', $pb.PbFieldType.OF) - ..aOB(10, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'hasWhite') - ..a<$core.double>(11, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'white', $pb.PbFieldType.OF) - ..aOB(12, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'hasColorTemperature') - ..a<$core.double>(13, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'colorTemperature', $pb.PbFieldType.OF) - ..aOB(14, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'hasTransitionLength') - ..a<$core.int>(15, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'transitionLength', $pb.PbFieldType.OU3) - ..aOB(16, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'hasFlashLength') - ..a<$core.int>(17, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'flashLength', $pb.PbFieldType.OU3) - ..aOB(18, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'hasEffect') - ..aOS(19, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'effect') - ..hasRequiredFields = false - ; - - LightCommandRequest._() : super(); - factory LightCommandRequest({ - $core.int? key, - $core.bool? hasState, - $core.bool? state_3, - $core.bool? hasBrightness, - $core.double? brightness_5, - $core.bool? hasRgb, - $core.double? red, - $core.double? green, - $core.double? blue, - $core.bool? hasWhite, - $core.double? white_11, - $core.bool? hasColorTemperature, - $core.double? colorTemperature_13, - $core.bool? hasTransitionLength, - $core.int? transitionLength_15, - $core.bool? hasFlashLength, - $core.int? flashLength_17, - $core.bool? hasEffect, - $core.String? effect_19, - }) { - final _result = create(); - if (key != null) { - _result.key = key; - } - if (hasState != null) { - _result.hasState = hasState; - } - if (state_3 != null) { - _result.state_3 = state_3; - } - if (hasBrightness != null) { - _result.hasBrightness = hasBrightness; - } - if (brightness_5 != null) { - _result.brightness_5 = brightness_5; - } - if (hasRgb != null) { - _result.hasRgb = hasRgb; - } - if (red != null) { - _result.red = red; - } - if (green != null) { - _result.green = green; - } - if (blue != null) { - _result.blue = blue; - } - if (hasWhite != null) { - _result.hasWhite = hasWhite; - } - if (white_11 != null) { - _result.white_11 = white_11; - } - if (hasColorTemperature != null) { - _result.hasColorTemperature = hasColorTemperature; - } - if (colorTemperature_13 != null) { - _result.colorTemperature_13 = colorTemperature_13; - } - if (hasTransitionLength != null) { - _result.hasTransitionLength = hasTransitionLength; - } - if (transitionLength_15 != null) { - _result.transitionLength_15 = transitionLength_15; - } - if (hasFlashLength != null) { - _result.hasFlashLength = hasFlashLength; - } - if (flashLength_17 != null) { - _result.flashLength_17 = flashLength_17; - } - if (hasEffect != null) { - _result.hasEffect = hasEffect; - } - if (effect_19 != null) { - _result.effect_19 = effect_19; - } - return _result; - } - factory LightCommandRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory LightCommandRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - LightCommandRequest clone() => LightCommandRequest()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - LightCommandRequest copyWith(void Function(LightCommandRequest) updates) => super.copyWith((message) => updates(message as LightCommandRequest)) as LightCommandRequest; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static LightCommandRequest create() => LightCommandRequest._(); - LightCommandRequest createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static LightCommandRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static LightCommandRequest? _defaultInstance; - - @$pb.TagNumber(1) - $core.int get key => $_getIZ(0); - @$pb.TagNumber(1) - set key($core.int v) { $_setUnsignedInt32(0, v); } - @$pb.TagNumber(1) - $core.bool hasKey() => $_has(0); - @$pb.TagNumber(1) - void clearKey() => clearField(1); - - @$pb.TagNumber(2) - $core.bool get hasState => $_getBF(1); - @$pb.TagNumber(2) - set hasState($core.bool v) { $_setBool(1, v); } - @$pb.TagNumber(2) - $core.bool hasHasState() => $_has(1); - @$pb.TagNumber(2) - void clearHasState() => clearField(2); - - @$pb.TagNumber(3) - $core.bool get state_3 => $_getBF(2); - @$pb.TagNumber(3) - set state_3($core.bool v) { $_setBool(2, v); } - @$pb.TagNumber(3) - $core.bool hasState_3() => $_has(2); - @$pb.TagNumber(3) - void clearState_3() => clearField(3); - - @$pb.TagNumber(4) - $core.bool get hasBrightness => $_getBF(3); - @$pb.TagNumber(4) - set hasBrightness($core.bool v) { $_setBool(3, v); } - @$pb.TagNumber(4) - $core.bool hasHasBrightness() => $_has(3); - @$pb.TagNumber(4) - void clearHasBrightness() => clearField(4); - - @$pb.TagNumber(5) - $core.double get brightness_5 => $_getN(4); - @$pb.TagNumber(5) - set brightness_5($core.double v) { $_setFloat(4, v); } - @$pb.TagNumber(5) - $core.bool hasBrightness_5() => $_has(4); - @$pb.TagNumber(5) - void clearBrightness_5() => clearField(5); - - @$pb.TagNumber(6) - $core.bool get hasRgb => $_getBF(5); - @$pb.TagNumber(6) - set hasRgb($core.bool v) { $_setBool(5, v); } - @$pb.TagNumber(6) - $core.bool hasHasRgb() => $_has(5); - @$pb.TagNumber(6) - void clearHasRgb() => clearField(6); - - @$pb.TagNumber(7) - $core.double get red => $_getN(6); - @$pb.TagNumber(7) - set red($core.double v) { $_setFloat(6, v); } - @$pb.TagNumber(7) - $core.bool hasRed() => $_has(6); - @$pb.TagNumber(7) - void clearRed() => clearField(7); - - @$pb.TagNumber(8) - $core.double get green => $_getN(7); - @$pb.TagNumber(8) - set green($core.double v) { $_setFloat(7, v); } - @$pb.TagNumber(8) - $core.bool hasGreen() => $_has(7); - @$pb.TagNumber(8) - void clearGreen() => clearField(8); - - @$pb.TagNumber(9) - $core.double get blue => $_getN(8); - @$pb.TagNumber(9) - set blue($core.double v) { $_setFloat(8, v); } - @$pb.TagNumber(9) - $core.bool hasBlue() => $_has(8); - @$pb.TagNumber(9) - void clearBlue() => clearField(9); - - @$pb.TagNumber(10) - $core.bool get hasWhite => $_getBF(9); - @$pb.TagNumber(10) - set hasWhite($core.bool v) { $_setBool(9, v); } - @$pb.TagNumber(10) - $core.bool hasHasWhite() => $_has(9); - @$pb.TagNumber(10) - void clearHasWhite() => clearField(10); - - @$pb.TagNumber(11) - $core.double get white_11 => $_getN(10); - @$pb.TagNumber(11) - set white_11($core.double v) { $_setFloat(10, v); } - @$pb.TagNumber(11) - $core.bool hasWhite_11() => $_has(10); - @$pb.TagNumber(11) - void clearWhite_11() => clearField(11); - - @$pb.TagNumber(12) - $core.bool get hasColorTemperature => $_getBF(11); - @$pb.TagNumber(12) - set hasColorTemperature($core.bool v) { $_setBool(11, v); } - @$pb.TagNumber(12) - $core.bool hasHasColorTemperature() => $_has(11); - @$pb.TagNumber(12) - void clearHasColorTemperature() => clearField(12); - - @$pb.TagNumber(13) - $core.double get colorTemperature_13 => $_getN(12); - @$pb.TagNumber(13) - set colorTemperature_13($core.double v) { $_setFloat(12, v); } - @$pb.TagNumber(13) - $core.bool hasColorTemperature_13() => $_has(12); - @$pb.TagNumber(13) - void clearColorTemperature_13() => clearField(13); - - @$pb.TagNumber(14) - $core.bool get hasTransitionLength => $_getBF(13); - @$pb.TagNumber(14) - set hasTransitionLength($core.bool v) { $_setBool(13, v); } - @$pb.TagNumber(14) - $core.bool hasHasTransitionLength() => $_has(13); - @$pb.TagNumber(14) - void clearHasTransitionLength() => clearField(14); - - @$pb.TagNumber(15) - $core.int get transitionLength_15 => $_getIZ(14); - @$pb.TagNumber(15) - set transitionLength_15($core.int v) { $_setUnsignedInt32(14, v); } - @$pb.TagNumber(15) - $core.bool hasTransitionLength_15() => $_has(14); - @$pb.TagNumber(15) - void clearTransitionLength_15() => clearField(15); - - @$pb.TagNumber(16) - $core.bool get hasFlashLength => $_getBF(15); - @$pb.TagNumber(16) - set hasFlashLength($core.bool v) { $_setBool(15, v); } - @$pb.TagNumber(16) - $core.bool hasHasFlashLength() => $_has(15); - @$pb.TagNumber(16) - void clearHasFlashLength() => clearField(16); - - @$pb.TagNumber(17) - $core.int get flashLength_17 => $_getIZ(16); - @$pb.TagNumber(17) - set flashLength_17($core.int v) { $_setUnsignedInt32(16, v); } - @$pb.TagNumber(17) - $core.bool hasFlashLength_17() => $_has(16); - @$pb.TagNumber(17) - void clearFlashLength_17() => clearField(17); - - @$pb.TagNumber(18) - $core.bool get hasEffect => $_getBF(17); - @$pb.TagNumber(18) - set hasEffect($core.bool v) { $_setBool(17, v); } - @$pb.TagNumber(18) - $core.bool hasHasEffect() => $_has(17); - @$pb.TagNumber(18) - void clearHasEffect() => clearField(18); - - @$pb.TagNumber(19) - $core.String get effect_19 => $_getSZ(18); - @$pb.TagNumber(19) - set effect_19($core.String v) { $_setString(18, v); } - @$pb.TagNumber(19) - $core.bool hasEffect_19() => $_has(18); - @$pb.TagNumber(19) - void clearEffect_19() => clearField(19); -} - -class ListEntitiesSensorResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ListEntitiesSensorResponse', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'objectId') - ..a<$core.int>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'key', $pb.PbFieldType.OF3) - ..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name') - ..aOS(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'uniqueId') - ..aOS(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'icon') - ..aOS(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'unitOfMeasurement') - ..a<$core.int>(7, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'accuracyDecimals', $pb.PbFieldType.O3) - ..aOB(8, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'forceUpdate') - ..aOS(9, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'deviceClass') - ..e(10, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'stateClass', $pb.PbFieldType.OE, defaultOrMaker: SensorStateClass.STATE_CLASS_NONE, valueOf: SensorStateClass.valueOf, enumValues: SensorStateClass.values) - ..hasRequiredFields = false - ; - - ListEntitiesSensorResponse._() : super(); - factory ListEntitiesSensorResponse({ - $core.String? objectId, - $core.int? key, - $core.String? name, - $core.String? uniqueId, - $core.String? icon, - $core.String? unitOfMeasurement, - $core.int? accuracyDecimals, - $core.bool? forceUpdate, - $core.String? deviceClass, - SensorStateClass? stateClass, - }) { - final _result = create(); - if (objectId != null) { - _result.objectId = objectId; - } - if (key != null) { - _result.key = key; - } - if (name != null) { - _result.name = name; - } - if (uniqueId != null) { - _result.uniqueId = uniqueId; - } - if (icon != null) { - _result.icon = icon; - } - if (unitOfMeasurement != null) { - _result.unitOfMeasurement = unitOfMeasurement; - } - if (accuracyDecimals != null) { - _result.accuracyDecimals = accuracyDecimals; - } - if (forceUpdate != null) { - _result.forceUpdate = forceUpdate; - } - if (deviceClass != null) { - _result.deviceClass = deviceClass; - } - if (stateClass != null) { - _result.stateClass = stateClass; - } - return _result; - } - factory ListEntitiesSensorResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory ListEntitiesSensorResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - ListEntitiesSensorResponse clone() => ListEntitiesSensorResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - ListEntitiesSensorResponse copyWith(void Function(ListEntitiesSensorResponse) updates) => super.copyWith((message) => updates(message as ListEntitiesSensorResponse)) as ListEntitiesSensorResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static ListEntitiesSensorResponse create() => ListEntitiesSensorResponse._(); - ListEntitiesSensorResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static ListEntitiesSensorResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static ListEntitiesSensorResponse? _defaultInstance; - - @$pb.TagNumber(1) - $core.String get objectId => $_getSZ(0); - @$pb.TagNumber(1) - set objectId($core.String v) { $_setString(0, v); } - @$pb.TagNumber(1) - $core.bool hasObjectId() => $_has(0); - @$pb.TagNumber(1) - void clearObjectId() => clearField(1); - - @$pb.TagNumber(2) - $core.int get key => $_getIZ(1); - @$pb.TagNumber(2) - set key($core.int v) { $_setUnsignedInt32(1, v); } - @$pb.TagNumber(2) - $core.bool hasKey() => $_has(1); - @$pb.TagNumber(2) - void clearKey() => clearField(2); - - @$pb.TagNumber(3) - $core.String get name => $_getSZ(2); - @$pb.TagNumber(3) - set name($core.String v) { $_setString(2, v); } - @$pb.TagNumber(3) - $core.bool hasName() => $_has(2); - @$pb.TagNumber(3) - void clearName() => clearField(3); - - @$pb.TagNumber(4) - $core.String get uniqueId => $_getSZ(3); - @$pb.TagNumber(4) - set uniqueId($core.String v) { $_setString(3, v); } - @$pb.TagNumber(4) - $core.bool hasUniqueId() => $_has(3); - @$pb.TagNumber(4) - void clearUniqueId() => clearField(4); - - @$pb.TagNumber(5) - $core.String get icon => $_getSZ(4); - @$pb.TagNumber(5) - set icon($core.String v) { $_setString(4, v); } - @$pb.TagNumber(5) - $core.bool hasIcon() => $_has(4); - @$pb.TagNumber(5) - void clearIcon() => clearField(5); - - @$pb.TagNumber(6) - $core.String get unitOfMeasurement => $_getSZ(5); - @$pb.TagNumber(6) - set unitOfMeasurement($core.String v) { $_setString(5, v); } - @$pb.TagNumber(6) - $core.bool hasUnitOfMeasurement() => $_has(5); - @$pb.TagNumber(6) - void clearUnitOfMeasurement() => clearField(6); - - @$pb.TagNumber(7) - $core.int get accuracyDecimals => $_getIZ(6); - @$pb.TagNumber(7) - set accuracyDecimals($core.int v) { $_setSignedInt32(6, v); } - @$pb.TagNumber(7) - $core.bool hasAccuracyDecimals() => $_has(6); - @$pb.TagNumber(7) - void clearAccuracyDecimals() => clearField(7); - - @$pb.TagNumber(8) - $core.bool get forceUpdate => $_getBF(7); - @$pb.TagNumber(8) - set forceUpdate($core.bool v) { $_setBool(7, v); } - @$pb.TagNumber(8) - $core.bool hasForceUpdate() => $_has(7); - @$pb.TagNumber(8) - void clearForceUpdate() => clearField(8); - - @$pb.TagNumber(9) - $core.String get deviceClass => $_getSZ(8); - @$pb.TagNumber(9) - set deviceClass($core.String v) { $_setString(8, v); } - @$pb.TagNumber(9) - $core.bool hasDeviceClass() => $_has(8); - @$pb.TagNumber(9) - void clearDeviceClass() => clearField(9); - - @$pb.TagNumber(10) - SensorStateClass get stateClass => $_getN(9); - @$pb.TagNumber(10) - set stateClass(SensorStateClass v) { setField(10, v); } - @$pb.TagNumber(10) - $core.bool hasStateClass() => $_has(9); - @$pb.TagNumber(10) - void clearStateClass() => clearField(10); -} - -class SensorStateResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'SensorStateResponse', createEmptyInstance: create) - ..a<$core.int>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'key', $pb.PbFieldType.OF3) - ..a<$core.double>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'state', $pb.PbFieldType.OF) - ..aOB(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'missingState') - ..hasRequiredFields = false - ; - - SensorStateResponse._() : super(); - factory SensorStateResponse({ - $core.int? key, - $core.double? state, - $core.bool? missingState, - }) { - final _result = create(); - if (key != null) { - _result.key = key; - } - if (state != null) { - _result.state = state; - } - if (missingState != null) { - _result.missingState = missingState; - } - return _result; - } - factory SensorStateResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory SensorStateResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - SensorStateResponse clone() => SensorStateResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - SensorStateResponse copyWith(void Function(SensorStateResponse) updates) => super.copyWith((message) => updates(message as SensorStateResponse)) as SensorStateResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static SensorStateResponse create() => SensorStateResponse._(); - SensorStateResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static SensorStateResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static SensorStateResponse? _defaultInstance; - - @$pb.TagNumber(1) - $core.int get key => $_getIZ(0); - @$pb.TagNumber(1) - set key($core.int v) { $_setUnsignedInt32(0, v); } - @$pb.TagNumber(1) - $core.bool hasKey() => $_has(0); - @$pb.TagNumber(1) - void clearKey() => clearField(1); - - @$pb.TagNumber(2) - $core.double get state => $_getN(1); - @$pb.TagNumber(2) - set state($core.double v) { $_setFloat(1, v); } - @$pb.TagNumber(2) - $core.bool hasState() => $_has(1); - @$pb.TagNumber(2) - void clearState() => clearField(2); - - @$pb.TagNumber(3) - $core.bool get missingState => $_getBF(2); - @$pb.TagNumber(3) - set missingState($core.bool v) { $_setBool(2, v); } - @$pb.TagNumber(3) - $core.bool hasMissingState() => $_has(2); - @$pb.TagNumber(3) - void clearMissingState() => clearField(3); -} - -class ListEntitiesSwitchResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ListEntitiesSwitchResponse', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'objectId') - ..a<$core.int>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'key', $pb.PbFieldType.OF3) - ..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name') - ..aOS(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'uniqueId') - ..aOS(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'icon') - ..aOB(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'assumedState') - ..hasRequiredFields = false - ; - - ListEntitiesSwitchResponse._() : super(); - factory ListEntitiesSwitchResponse({ - $core.String? objectId, - $core.int? key, - $core.String? name, - $core.String? uniqueId, - $core.String? icon, - $core.bool? assumedState, - }) { - final _result = create(); - if (objectId != null) { - _result.objectId = objectId; - } - if (key != null) { - _result.key = key; - } - if (name != null) { - _result.name = name; - } - if (uniqueId != null) { - _result.uniqueId = uniqueId; - } - if (icon != null) { - _result.icon = icon; - } - if (assumedState != null) { - _result.assumedState = assumedState; - } - return _result; - } - factory ListEntitiesSwitchResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory ListEntitiesSwitchResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - ListEntitiesSwitchResponse clone() => ListEntitiesSwitchResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - ListEntitiesSwitchResponse copyWith(void Function(ListEntitiesSwitchResponse) updates) => super.copyWith((message) => updates(message as ListEntitiesSwitchResponse)) as ListEntitiesSwitchResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static ListEntitiesSwitchResponse create() => ListEntitiesSwitchResponse._(); - ListEntitiesSwitchResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static ListEntitiesSwitchResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static ListEntitiesSwitchResponse? _defaultInstance; - - @$pb.TagNumber(1) - $core.String get objectId => $_getSZ(0); - @$pb.TagNumber(1) - set objectId($core.String v) { $_setString(0, v); } - @$pb.TagNumber(1) - $core.bool hasObjectId() => $_has(0); - @$pb.TagNumber(1) - void clearObjectId() => clearField(1); - - @$pb.TagNumber(2) - $core.int get key => $_getIZ(1); - @$pb.TagNumber(2) - set key($core.int v) { $_setUnsignedInt32(1, v); } - @$pb.TagNumber(2) - $core.bool hasKey() => $_has(1); - @$pb.TagNumber(2) - void clearKey() => clearField(2); - - @$pb.TagNumber(3) - $core.String get name => $_getSZ(2); - @$pb.TagNumber(3) - set name($core.String v) { $_setString(2, v); } - @$pb.TagNumber(3) - $core.bool hasName() => $_has(2); - @$pb.TagNumber(3) - void clearName() => clearField(3); - - @$pb.TagNumber(4) - $core.String get uniqueId => $_getSZ(3); - @$pb.TagNumber(4) - set uniqueId($core.String v) { $_setString(3, v); } - @$pb.TagNumber(4) - $core.bool hasUniqueId() => $_has(3); - @$pb.TagNumber(4) - void clearUniqueId() => clearField(4); - - @$pb.TagNumber(5) - $core.String get icon => $_getSZ(4); - @$pb.TagNumber(5) - set icon($core.String v) { $_setString(4, v); } - @$pb.TagNumber(5) - $core.bool hasIcon() => $_has(4); - @$pb.TagNumber(5) - void clearIcon() => clearField(5); - - @$pb.TagNumber(6) - $core.bool get assumedState => $_getBF(5); - @$pb.TagNumber(6) - set assumedState($core.bool v) { $_setBool(5, v); } - @$pb.TagNumber(6) - $core.bool hasAssumedState() => $_has(5); - @$pb.TagNumber(6) - void clearAssumedState() => clearField(6); -} - -class SwitchStateResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'SwitchStateResponse', createEmptyInstance: create) - ..a<$core.int>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'key', $pb.PbFieldType.OF3) - ..aOB(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'state') - ..hasRequiredFields = false - ; - - SwitchStateResponse._() : super(); - factory SwitchStateResponse({ - $core.int? key, - $core.bool? state, - }) { - final _result = create(); - if (key != null) { - _result.key = key; - } - if (state != null) { - _result.state = state; - } - return _result; - } - factory SwitchStateResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory SwitchStateResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - SwitchStateResponse clone() => SwitchStateResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - SwitchStateResponse copyWith(void Function(SwitchStateResponse) updates) => super.copyWith((message) => updates(message as SwitchStateResponse)) as SwitchStateResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static SwitchStateResponse create() => SwitchStateResponse._(); - SwitchStateResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static SwitchStateResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static SwitchStateResponse? _defaultInstance; - - @$pb.TagNumber(1) - $core.int get key => $_getIZ(0); - @$pb.TagNumber(1) - set key($core.int v) { $_setUnsignedInt32(0, v); } - @$pb.TagNumber(1) - $core.bool hasKey() => $_has(0); - @$pb.TagNumber(1) - void clearKey() => clearField(1); - - @$pb.TagNumber(2) - $core.bool get state => $_getBF(1); - @$pb.TagNumber(2) - set state($core.bool v) { $_setBool(1, v); } - @$pb.TagNumber(2) - $core.bool hasState() => $_has(1); - @$pb.TagNumber(2) - void clearState() => clearField(2); -} - -class SwitchCommandRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'SwitchCommandRequest', createEmptyInstance: create) - ..a<$core.int>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'key', $pb.PbFieldType.OF3) - ..aOB(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'state') - ..hasRequiredFields = false - ; - - SwitchCommandRequest._() : super(); - factory SwitchCommandRequest({ - $core.int? key, - $core.bool? state, - }) { - final _result = create(); - if (key != null) { - _result.key = key; - } - if (state != null) { - _result.state = state; - } - return _result; - } - factory SwitchCommandRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory SwitchCommandRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - SwitchCommandRequest clone() => SwitchCommandRequest()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - SwitchCommandRequest copyWith(void Function(SwitchCommandRequest) updates) => super.copyWith((message) => updates(message as SwitchCommandRequest)) as SwitchCommandRequest; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static SwitchCommandRequest create() => SwitchCommandRequest._(); - SwitchCommandRequest createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static SwitchCommandRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static SwitchCommandRequest? _defaultInstance; - - @$pb.TagNumber(1) - $core.int get key => $_getIZ(0); - @$pb.TagNumber(1) - set key($core.int v) { $_setUnsignedInt32(0, v); } - @$pb.TagNumber(1) - $core.bool hasKey() => $_has(0); - @$pb.TagNumber(1) - void clearKey() => clearField(1); - - @$pb.TagNumber(2) - $core.bool get state => $_getBF(1); - @$pb.TagNumber(2) - set state($core.bool v) { $_setBool(1, v); } - @$pb.TagNumber(2) - $core.bool hasState() => $_has(1); - @$pb.TagNumber(2) - void clearState() => clearField(2); -} - -class ListEntitiesTextSensorResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ListEntitiesTextSensorResponse', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'objectId') - ..a<$core.int>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'key', $pb.PbFieldType.OF3) - ..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name') - ..aOS(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'uniqueId') - ..aOS(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'icon') - ..hasRequiredFields = false - ; - - ListEntitiesTextSensorResponse._() : super(); - factory ListEntitiesTextSensorResponse({ - $core.String? objectId, - $core.int? key, - $core.String? name, - $core.String? uniqueId, - $core.String? icon, - }) { - final _result = create(); - if (objectId != null) { - _result.objectId = objectId; - } - if (key != null) { - _result.key = key; - } - if (name != null) { - _result.name = name; - } - if (uniqueId != null) { - _result.uniqueId = uniqueId; - } - if (icon != null) { - _result.icon = icon; - } - return _result; - } - factory ListEntitiesTextSensorResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory ListEntitiesTextSensorResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - ListEntitiesTextSensorResponse clone() => ListEntitiesTextSensorResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - ListEntitiesTextSensorResponse copyWith(void Function(ListEntitiesTextSensorResponse) updates) => super.copyWith((message) => updates(message as ListEntitiesTextSensorResponse)) as ListEntitiesTextSensorResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static ListEntitiesTextSensorResponse create() => ListEntitiesTextSensorResponse._(); - ListEntitiesTextSensorResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static ListEntitiesTextSensorResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static ListEntitiesTextSensorResponse? _defaultInstance; - - @$pb.TagNumber(1) - $core.String get objectId => $_getSZ(0); - @$pb.TagNumber(1) - set objectId($core.String v) { $_setString(0, v); } - @$pb.TagNumber(1) - $core.bool hasObjectId() => $_has(0); - @$pb.TagNumber(1) - void clearObjectId() => clearField(1); - - @$pb.TagNumber(2) - $core.int get key => $_getIZ(1); - @$pb.TagNumber(2) - set key($core.int v) { $_setUnsignedInt32(1, v); } - @$pb.TagNumber(2) - $core.bool hasKey() => $_has(1); - @$pb.TagNumber(2) - void clearKey() => clearField(2); - - @$pb.TagNumber(3) - $core.String get name => $_getSZ(2); - @$pb.TagNumber(3) - set name($core.String v) { $_setString(2, v); } - @$pb.TagNumber(3) - $core.bool hasName() => $_has(2); - @$pb.TagNumber(3) - void clearName() => clearField(3); - - @$pb.TagNumber(4) - $core.String get uniqueId => $_getSZ(3); - @$pb.TagNumber(4) - set uniqueId($core.String v) { $_setString(3, v); } - @$pb.TagNumber(4) - $core.bool hasUniqueId() => $_has(3); - @$pb.TagNumber(4) - void clearUniqueId() => clearField(4); - - @$pb.TagNumber(5) - $core.String get icon => $_getSZ(4); - @$pb.TagNumber(5) - set icon($core.String v) { $_setString(4, v); } - @$pb.TagNumber(5) - $core.bool hasIcon() => $_has(4); - @$pb.TagNumber(5) - void clearIcon() => clearField(5); -} - -class TextSensorStateResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'TextSensorStateResponse', createEmptyInstance: create) - ..a<$core.int>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'key', $pb.PbFieldType.OF3) - ..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'state') - ..aOB(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'missingState') - ..hasRequiredFields = false - ; - - TextSensorStateResponse._() : super(); - factory TextSensorStateResponse({ - $core.int? key, - $core.String? state, - $core.bool? missingState, - }) { - final _result = create(); - if (key != null) { - _result.key = key; - } - if (state != null) { - _result.state = state; - } - if (missingState != null) { - _result.missingState = missingState; - } - return _result; - } - factory TextSensorStateResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory TextSensorStateResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - TextSensorStateResponse clone() => TextSensorStateResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - TextSensorStateResponse copyWith(void Function(TextSensorStateResponse) updates) => super.copyWith((message) => updates(message as TextSensorStateResponse)) as TextSensorStateResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static TextSensorStateResponse create() => TextSensorStateResponse._(); - TextSensorStateResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static TextSensorStateResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static TextSensorStateResponse? _defaultInstance; - - @$pb.TagNumber(1) - $core.int get key => $_getIZ(0); - @$pb.TagNumber(1) - set key($core.int v) { $_setUnsignedInt32(0, v); } - @$pb.TagNumber(1) - $core.bool hasKey() => $_has(0); - @$pb.TagNumber(1) - void clearKey() => clearField(1); - - @$pb.TagNumber(2) - $core.String get state => $_getSZ(1); - @$pb.TagNumber(2) - set state($core.String v) { $_setString(1, v); } - @$pb.TagNumber(2) - $core.bool hasState() => $_has(1); - @$pb.TagNumber(2) - void clearState() => clearField(2); - - @$pb.TagNumber(3) - $core.bool get missingState => $_getBF(2); - @$pb.TagNumber(3) - set missingState($core.bool v) { $_setBool(2, v); } - @$pb.TagNumber(3) - $core.bool hasMissingState() => $_has(2); - @$pb.TagNumber(3) - void clearMissingState() => clearField(3); -} - -class SubscribeLogsRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'SubscribeLogsRequest', createEmptyInstance: create) - ..e(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'level', $pb.PbFieldType.OE, defaultOrMaker: LogLevel.LOG_LEVEL_NONE, valueOf: LogLevel.valueOf, enumValues: LogLevel.values) - ..aOB(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'dumpConfig') - ..hasRequiredFields = false - ; - - SubscribeLogsRequest._() : super(); - factory SubscribeLogsRequest({ - LogLevel? level, - $core.bool? dumpConfig, - }) { - final _result = create(); - if (level != null) { - _result.level = level; - } - if (dumpConfig != null) { - _result.dumpConfig = dumpConfig; - } - return _result; - } - factory SubscribeLogsRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory SubscribeLogsRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - SubscribeLogsRequest clone() => SubscribeLogsRequest()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - SubscribeLogsRequest copyWith(void Function(SubscribeLogsRequest) updates) => super.copyWith((message) => updates(message as SubscribeLogsRequest)) as SubscribeLogsRequest; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static SubscribeLogsRequest create() => SubscribeLogsRequest._(); - SubscribeLogsRequest createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static SubscribeLogsRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static SubscribeLogsRequest? _defaultInstance; - - @$pb.TagNumber(1) - LogLevel get level => $_getN(0); - @$pb.TagNumber(1) - set level(LogLevel v) { setField(1, v); } - @$pb.TagNumber(1) - $core.bool hasLevel() => $_has(0); - @$pb.TagNumber(1) - void clearLevel() => clearField(1); - - @$pb.TagNumber(2) - $core.bool get dumpConfig => $_getBF(1); - @$pb.TagNumber(2) - set dumpConfig($core.bool v) { $_setBool(1, v); } - @$pb.TagNumber(2) - $core.bool hasDumpConfig() => $_has(1); - @$pb.TagNumber(2) - void clearDumpConfig() => clearField(2); -} - -class SubscribeLogsResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'SubscribeLogsResponse', createEmptyInstance: create) - ..e(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'level', $pb.PbFieldType.OE, defaultOrMaker: LogLevel.LOG_LEVEL_NONE, valueOf: LogLevel.valueOf, enumValues: LogLevel.values) - ..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'tag') - ..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'message') - ..aOB(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'sendFailed') - ..hasRequiredFields = false - ; - - SubscribeLogsResponse._() : super(); - factory SubscribeLogsResponse({ - LogLevel? level, - $core.String? tag, - $core.String? message, - $core.bool? sendFailed, - }) { - final _result = create(); - if (level != null) { - _result.level = level; - } - if (tag != null) { - _result.tag = tag; - } - if (message != null) { - _result.message = message; - } - if (sendFailed != null) { - _result.sendFailed = sendFailed; - } - return _result; - } - factory SubscribeLogsResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory SubscribeLogsResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - SubscribeLogsResponse clone() => SubscribeLogsResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - SubscribeLogsResponse copyWith(void Function(SubscribeLogsResponse) updates) => super.copyWith((message) => updates(message as SubscribeLogsResponse)) as SubscribeLogsResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static SubscribeLogsResponse create() => SubscribeLogsResponse._(); - SubscribeLogsResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static SubscribeLogsResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static SubscribeLogsResponse? _defaultInstance; - - @$pb.TagNumber(1) - LogLevel get level => $_getN(0); - @$pb.TagNumber(1) - set level(LogLevel v) { setField(1, v); } - @$pb.TagNumber(1) - $core.bool hasLevel() => $_has(0); - @$pb.TagNumber(1) - void clearLevel() => clearField(1); - - @$pb.TagNumber(2) - $core.String get tag => $_getSZ(1); - @$pb.TagNumber(2) - set tag($core.String v) { $_setString(1, v); } - @$pb.TagNumber(2) - $core.bool hasTag() => $_has(1); - @$pb.TagNumber(2) - void clearTag() => clearField(2); - - @$pb.TagNumber(3) - $core.String get message => $_getSZ(2); - @$pb.TagNumber(3) - set message($core.String v) { $_setString(2, v); } - @$pb.TagNumber(3) - $core.bool hasMessage() => $_has(2); - @$pb.TagNumber(3) - void clearMessage() => clearField(3); - - @$pb.TagNumber(4) - $core.bool get sendFailed => $_getBF(3); - @$pb.TagNumber(4) - set sendFailed($core.bool v) { $_setBool(3, v); } - @$pb.TagNumber(4) - $core.bool hasSendFailed() => $_has(3); - @$pb.TagNumber(4) - void clearSendFailed() => clearField(4); -} - -class SubscribeHomeassistantServicesRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'SubscribeHomeassistantServicesRequest', createEmptyInstance: create) - ..hasRequiredFields = false - ; - - SubscribeHomeassistantServicesRequest._() : super(); - factory SubscribeHomeassistantServicesRequest() => create(); - factory SubscribeHomeassistantServicesRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory SubscribeHomeassistantServicesRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - SubscribeHomeassistantServicesRequest clone() => SubscribeHomeassistantServicesRequest()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - SubscribeHomeassistantServicesRequest copyWith(void Function(SubscribeHomeassistantServicesRequest) updates) => super.copyWith((message) => updates(message as SubscribeHomeassistantServicesRequest)) as SubscribeHomeassistantServicesRequest; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static SubscribeHomeassistantServicesRequest create() => SubscribeHomeassistantServicesRequest._(); - SubscribeHomeassistantServicesRequest createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static SubscribeHomeassistantServicesRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static SubscribeHomeassistantServicesRequest? _defaultInstance; -} - -class HomeassistantServiceMap extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'HomeassistantServiceMap', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'key') - ..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'value') - ..hasRequiredFields = false - ; - - HomeassistantServiceMap._() : super(); - factory HomeassistantServiceMap({ - $core.String? key, - $core.String? value, - }) { - final _result = create(); - if (key != null) { - _result.key = key; - } - if (value != null) { - _result.value = value; - } - return _result; - } - factory HomeassistantServiceMap.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory HomeassistantServiceMap.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - HomeassistantServiceMap clone() => HomeassistantServiceMap()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - HomeassistantServiceMap copyWith(void Function(HomeassistantServiceMap) updates) => super.copyWith((message) => updates(message as HomeassistantServiceMap)) as HomeassistantServiceMap; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static HomeassistantServiceMap create() => HomeassistantServiceMap._(); - HomeassistantServiceMap createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static HomeassistantServiceMap getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static HomeassistantServiceMap? _defaultInstance; - - @$pb.TagNumber(1) - $core.String get key => $_getSZ(0); - @$pb.TagNumber(1) - set key($core.String v) { $_setString(0, v); } - @$pb.TagNumber(1) - $core.bool hasKey() => $_has(0); - @$pb.TagNumber(1) - void clearKey() => clearField(1); - - @$pb.TagNumber(2) - $core.String get value => $_getSZ(1); - @$pb.TagNumber(2) - set value($core.String v) { $_setString(1, v); } - @$pb.TagNumber(2) - $core.bool hasValue() => $_has(1); - @$pb.TagNumber(2) - void clearValue() => clearField(2); -} - -class HomeassistantServiceResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'HomeassistantServiceResponse', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'service') - ..pc(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'data', $pb.PbFieldType.PM, subBuilder: HomeassistantServiceMap.create) - ..pc(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'dataTemplate', $pb.PbFieldType.PM, subBuilder: HomeassistantServiceMap.create) - ..pc(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'variables', $pb.PbFieldType.PM, subBuilder: HomeassistantServiceMap.create) - ..aOB(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'isEvent') - ..hasRequiredFields = false - ; - - HomeassistantServiceResponse._() : super(); - factory HomeassistantServiceResponse({ - $core.String? service, - $core.Iterable? data, - $core.Iterable? dataTemplate, - $core.Iterable? variables, - $core.bool? isEvent, - }) { - final _result = create(); - if (service != null) { - _result.service = service; - } - if (data != null) { - _result.data.addAll(data); - } - if (dataTemplate != null) { - _result.dataTemplate.addAll(dataTemplate); - } - if (variables != null) { - _result.variables.addAll(variables); - } - if (isEvent != null) { - _result.isEvent = isEvent; - } - return _result; - } - factory HomeassistantServiceResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory HomeassistantServiceResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - HomeassistantServiceResponse clone() => HomeassistantServiceResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - HomeassistantServiceResponse copyWith(void Function(HomeassistantServiceResponse) updates) => super.copyWith((message) => updates(message as HomeassistantServiceResponse)) as HomeassistantServiceResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static HomeassistantServiceResponse create() => HomeassistantServiceResponse._(); - HomeassistantServiceResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static HomeassistantServiceResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static HomeassistantServiceResponse? _defaultInstance; - - @$pb.TagNumber(1) - $core.String get service => $_getSZ(0); - @$pb.TagNumber(1) - set service($core.String v) { $_setString(0, v); } - @$pb.TagNumber(1) - $core.bool hasService() => $_has(0); - @$pb.TagNumber(1) - void clearService() => clearField(1); - - @$pb.TagNumber(2) - $core.List get data => $_getList(1); - - @$pb.TagNumber(3) - $core.List get dataTemplate => $_getList(2); - - @$pb.TagNumber(4) - $core.List get variables => $_getList(3); - - @$pb.TagNumber(5) - $core.bool get isEvent => $_getBF(4); - @$pb.TagNumber(5) - set isEvent($core.bool v) { $_setBool(4, v); } - @$pb.TagNumber(5) - $core.bool hasIsEvent() => $_has(4); - @$pb.TagNumber(5) - void clearIsEvent() => clearField(5); -} - -class SubscribeHomeAssistantStatesRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'SubscribeHomeAssistantStatesRequest', createEmptyInstance: create) - ..hasRequiredFields = false - ; - - SubscribeHomeAssistantStatesRequest._() : super(); - factory SubscribeHomeAssistantStatesRequest() => create(); - factory SubscribeHomeAssistantStatesRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory SubscribeHomeAssistantStatesRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - SubscribeHomeAssistantStatesRequest clone() => SubscribeHomeAssistantStatesRequest()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - SubscribeHomeAssistantStatesRequest copyWith(void Function(SubscribeHomeAssistantStatesRequest) updates) => super.copyWith((message) => updates(message as SubscribeHomeAssistantStatesRequest)) as SubscribeHomeAssistantStatesRequest; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static SubscribeHomeAssistantStatesRequest create() => SubscribeHomeAssistantStatesRequest._(); - SubscribeHomeAssistantStatesRequest createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static SubscribeHomeAssistantStatesRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static SubscribeHomeAssistantStatesRequest? _defaultInstance; -} - -class SubscribeHomeAssistantStateResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'SubscribeHomeAssistantStateResponse', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'entityId') - ..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'attribute') - ..hasRequiredFields = false - ; - - SubscribeHomeAssistantStateResponse._() : super(); - factory SubscribeHomeAssistantStateResponse({ - $core.String? entityId, - $core.String? attribute, - }) { - final _result = create(); - if (entityId != null) { - _result.entityId = entityId; - } - if (attribute != null) { - _result.attribute = attribute; - } - return _result; - } - factory SubscribeHomeAssistantStateResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory SubscribeHomeAssistantStateResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - SubscribeHomeAssistantStateResponse clone() => SubscribeHomeAssistantStateResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - SubscribeHomeAssistantStateResponse copyWith(void Function(SubscribeHomeAssistantStateResponse) updates) => super.copyWith((message) => updates(message as SubscribeHomeAssistantStateResponse)) as SubscribeHomeAssistantStateResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static SubscribeHomeAssistantStateResponse create() => SubscribeHomeAssistantStateResponse._(); - SubscribeHomeAssistantStateResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static SubscribeHomeAssistantStateResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static SubscribeHomeAssistantStateResponse? _defaultInstance; - - @$pb.TagNumber(1) - $core.String get entityId => $_getSZ(0); - @$pb.TagNumber(1) - set entityId($core.String v) { $_setString(0, v); } - @$pb.TagNumber(1) - $core.bool hasEntityId() => $_has(0); - @$pb.TagNumber(1) - void clearEntityId() => clearField(1); - - @$pb.TagNumber(2) - $core.String get attribute => $_getSZ(1); - @$pb.TagNumber(2) - set attribute($core.String v) { $_setString(1, v); } - @$pb.TagNumber(2) - $core.bool hasAttribute() => $_has(1); - @$pb.TagNumber(2) - void clearAttribute() => clearField(2); -} - -class HomeAssistantStateResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'HomeAssistantStateResponse', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'entityId') - ..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'state') - ..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'attribute') - ..hasRequiredFields = false - ; - - HomeAssistantStateResponse._() : super(); - factory HomeAssistantStateResponse({ - $core.String? entityId, - $core.String? state, - $core.String? attribute, - }) { - final _result = create(); - if (entityId != null) { - _result.entityId = entityId; - } - if (state != null) { - _result.state = state; - } - if (attribute != null) { - _result.attribute = attribute; - } - return _result; - } - factory HomeAssistantStateResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory HomeAssistantStateResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - HomeAssistantStateResponse clone() => HomeAssistantStateResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - HomeAssistantStateResponse copyWith(void Function(HomeAssistantStateResponse) updates) => super.copyWith((message) => updates(message as HomeAssistantStateResponse)) as HomeAssistantStateResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static HomeAssistantStateResponse create() => HomeAssistantStateResponse._(); - HomeAssistantStateResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static HomeAssistantStateResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static HomeAssistantStateResponse? _defaultInstance; - - @$pb.TagNumber(1) - $core.String get entityId => $_getSZ(0); - @$pb.TagNumber(1) - set entityId($core.String v) { $_setString(0, v); } - @$pb.TagNumber(1) - $core.bool hasEntityId() => $_has(0); - @$pb.TagNumber(1) - void clearEntityId() => clearField(1); - - @$pb.TagNumber(2) - $core.String get state => $_getSZ(1); - @$pb.TagNumber(2) - set state($core.String v) { $_setString(1, v); } - @$pb.TagNumber(2) - $core.bool hasState() => $_has(1); - @$pb.TagNumber(2) - void clearState() => clearField(2); - - @$pb.TagNumber(3) - $core.String get attribute => $_getSZ(2); - @$pb.TagNumber(3) - set attribute($core.String v) { $_setString(2, v); } - @$pb.TagNumber(3) - $core.bool hasAttribute() => $_has(2); - @$pb.TagNumber(3) - void clearAttribute() => clearField(3); -} - -class GetTimeRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'GetTimeRequest', createEmptyInstance: create) - ..hasRequiredFields = false - ; - - GetTimeRequest._() : super(); - factory GetTimeRequest() => create(); - factory GetTimeRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory GetTimeRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - GetTimeRequest clone() => GetTimeRequest()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - GetTimeRequest copyWith(void Function(GetTimeRequest) updates) => super.copyWith((message) => updates(message as GetTimeRequest)) as GetTimeRequest; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static GetTimeRequest create() => GetTimeRequest._(); - GetTimeRequest createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static GetTimeRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static GetTimeRequest? _defaultInstance; -} - -class GetTimeResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'GetTimeResponse', createEmptyInstance: create) - ..a<$core.int>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'epochSeconds', $pb.PbFieldType.OF3) - ..hasRequiredFields = false - ; - - GetTimeResponse._() : super(); - factory GetTimeResponse({ - $core.int? epochSeconds, - }) { - final _result = create(); - if (epochSeconds != null) { - _result.epochSeconds = epochSeconds; - } - return _result; - } - factory GetTimeResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory GetTimeResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - GetTimeResponse clone() => GetTimeResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - GetTimeResponse copyWith(void Function(GetTimeResponse) updates) => super.copyWith((message) => updates(message as GetTimeResponse)) as GetTimeResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static GetTimeResponse create() => GetTimeResponse._(); - GetTimeResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static GetTimeResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static GetTimeResponse? _defaultInstance; - - @$pb.TagNumber(1) - $core.int get epochSeconds => $_getIZ(0); - @$pb.TagNumber(1) - set epochSeconds($core.int v) { $_setUnsignedInt32(0, v); } - @$pb.TagNumber(1) - $core.bool hasEpochSeconds() => $_has(0); - @$pb.TagNumber(1) - void clearEpochSeconds() => clearField(1); -} - -class ListEntitiesServicesArgument extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ListEntitiesServicesArgument', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name') - ..e(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'type', $pb.PbFieldType.OE, defaultOrMaker: ServiceArgType.SERVICE_ARG_TYPE_BOOL, valueOf: ServiceArgType.valueOf, enumValues: ServiceArgType.values) - ..hasRequiredFields = false - ; - - ListEntitiesServicesArgument._() : super(); - factory ListEntitiesServicesArgument({ - $core.String? name, - ServiceArgType? type, - }) { - final _result = create(); - if (name != null) { - _result.name = name; - } - if (type != null) { - _result.type = type; - } - return _result; - } - factory ListEntitiesServicesArgument.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory ListEntitiesServicesArgument.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - ListEntitiesServicesArgument clone() => ListEntitiesServicesArgument()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - ListEntitiesServicesArgument copyWith(void Function(ListEntitiesServicesArgument) updates) => super.copyWith((message) => updates(message as ListEntitiesServicesArgument)) as ListEntitiesServicesArgument; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static ListEntitiesServicesArgument create() => ListEntitiesServicesArgument._(); - ListEntitiesServicesArgument createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static ListEntitiesServicesArgument getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static ListEntitiesServicesArgument? _defaultInstance; - - @$pb.TagNumber(1) - $core.String get name => $_getSZ(0); - @$pb.TagNumber(1) - set name($core.String v) { $_setString(0, v); } - @$pb.TagNumber(1) - $core.bool hasName() => $_has(0); - @$pb.TagNumber(1) - void clearName() => clearField(1); - - @$pb.TagNumber(2) - ServiceArgType get type => $_getN(1); - @$pb.TagNumber(2) - set type(ServiceArgType v) { setField(2, v); } - @$pb.TagNumber(2) - $core.bool hasType() => $_has(1); - @$pb.TagNumber(2) - void clearType() => clearField(2); -} - -class ListEntitiesServicesResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ListEntitiesServicesResponse', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name') - ..a<$core.int>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'key', $pb.PbFieldType.OF3) - ..pc(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'args', $pb.PbFieldType.PM, subBuilder: ListEntitiesServicesArgument.create) - ..hasRequiredFields = false - ; - - ListEntitiesServicesResponse._() : super(); - factory ListEntitiesServicesResponse({ - $core.String? name, - $core.int? key, - $core.Iterable? args, - }) { - final _result = create(); - if (name != null) { - _result.name = name; - } - if (key != null) { - _result.key = key; - } - if (args != null) { - _result.args.addAll(args); - } - return _result; - } - factory ListEntitiesServicesResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory ListEntitiesServicesResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - ListEntitiesServicesResponse clone() => ListEntitiesServicesResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - ListEntitiesServicesResponse copyWith(void Function(ListEntitiesServicesResponse) updates) => super.copyWith((message) => updates(message as ListEntitiesServicesResponse)) as ListEntitiesServicesResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static ListEntitiesServicesResponse create() => ListEntitiesServicesResponse._(); - ListEntitiesServicesResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static ListEntitiesServicesResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static ListEntitiesServicesResponse? _defaultInstance; - - @$pb.TagNumber(1) - $core.String get name => $_getSZ(0); - @$pb.TagNumber(1) - set name($core.String v) { $_setString(0, v); } - @$pb.TagNumber(1) - $core.bool hasName() => $_has(0); - @$pb.TagNumber(1) - void clearName() => clearField(1); - - @$pb.TagNumber(2) - $core.int get key => $_getIZ(1); - @$pb.TagNumber(2) - set key($core.int v) { $_setUnsignedInt32(1, v); } - @$pb.TagNumber(2) - $core.bool hasKey() => $_has(1); - @$pb.TagNumber(2) - void clearKey() => clearField(2); - - @$pb.TagNumber(3) - $core.List get args => $_getList(2); -} - -class ExecuteServiceArgument extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ExecuteServiceArgument', createEmptyInstance: create) - ..aOB(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'bool', protoName: 'bool_') - ..a<$core.int>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'legacyInt', $pb.PbFieldType.O3) - ..a<$core.double>(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'float', $pb.PbFieldType.OF, protoName: 'float_') - ..aOS(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'string', protoName: 'string_') - ..a<$core.int>(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'int', $pb.PbFieldType.OS3, protoName: 'int_') - ..p<$core.bool>(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'boolArray', $pb.PbFieldType.PB) - ..p<$core.int>(7, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'intArray', $pb.PbFieldType.PS3) - ..p<$core.double>(8, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'floatArray', $pb.PbFieldType.PF) - ..pPS(9, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'stringArray') - ..hasRequiredFields = false - ; - - ExecuteServiceArgument._() : super(); - factory ExecuteServiceArgument({ - $core.bool? bool_1, - $core.int? legacyInt, - $core.double? float, - $core.String? string, - $core.int? int_5, - $core.Iterable<$core.bool>? boolArray, - $core.Iterable<$core.int>? intArray, - $core.Iterable<$core.double>? floatArray, - $core.Iterable<$core.String>? stringArray, - }) { - final _result = create(); - if (bool_1 != null) { - _result.bool_1 = bool_1; - } - if (legacyInt != null) { - _result.legacyInt = legacyInt; - } - if (float != null) { - _result.float = float; - } - if (string != null) { - _result.string = string; - } - if (int_5 != null) { - _result.int_5 = int_5; - } - if (boolArray != null) { - _result.boolArray.addAll(boolArray); - } - if (intArray != null) { - _result.intArray.addAll(intArray); - } - if (floatArray != null) { - _result.floatArray.addAll(floatArray); - } - if (stringArray != null) { - _result.stringArray.addAll(stringArray); - } - return _result; - } - factory ExecuteServiceArgument.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory ExecuteServiceArgument.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - ExecuteServiceArgument clone() => ExecuteServiceArgument()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - ExecuteServiceArgument copyWith(void Function(ExecuteServiceArgument) updates) => super.copyWith((message) => updates(message as ExecuteServiceArgument)) as ExecuteServiceArgument; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static ExecuteServiceArgument create() => ExecuteServiceArgument._(); - ExecuteServiceArgument createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static ExecuteServiceArgument getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static ExecuteServiceArgument? _defaultInstance; - - @$pb.TagNumber(1) - $core.bool get bool_1 => $_getBF(0); - @$pb.TagNumber(1) - set bool_1($core.bool v) { $_setBool(0, v); } - @$pb.TagNumber(1) - $core.bool hasBool_1() => $_has(0); - @$pb.TagNumber(1) - void clearBool_1() => clearField(1); - - @$pb.TagNumber(2) - $core.int get legacyInt => $_getIZ(1); - @$pb.TagNumber(2) - set legacyInt($core.int v) { $_setSignedInt32(1, v); } - @$pb.TagNumber(2) - $core.bool hasLegacyInt() => $_has(1); - @$pb.TagNumber(2) - void clearLegacyInt() => clearField(2); - - @$pb.TagNumber(3) - $core.double get float => $_getN(2); - @$pb.TagNumber(3) - set float($core.double v) { $_setFloat(2, v); } - @$pb.TagNumber(3) - $core.bool hasFloat() => $_has(2); - @$pb.TagNumber(3) - void clearFloat() => clearField(3); - - @$pb.TagNumber(4) - $core.String get string => $_getSZ(3); - @$pb.TagNumber(4) - set string($core.String v) { $_setString(3, v); } - @$pb.TagNumber(4) - $core.bool hasString() => $_has(3); - @$pb.TagNumber(4) - void clearString() => clearField(4); - - @$pb.TagNumber(5) - $core.int get int_5 => $_getIZ(4); - @$pb.TagNumber(5) - set int_5($core.int v) { $_setSignedInt32(4, v); } - @$pb.TagNumber(5) - $core.bool hasInt_5() => $_has(4); - @$pb.TagNumber(5) - void clearInt_5() => clearField(5); - - @$pb.TagNumber(6) - $core.List<$core.bool> get boolArray => $_getList(5); - - @$pb.TagNumber(7) - $core.List<$core.int> get intArray => $_getList(6); - - @$pb.TagNumber(8) - $core.List<$core.double> get floatArray => $_getList(7); - - @$pb.TagNumber(9) - $core.List<$core.String> get stringArray => $_getList(8); -} - -class ExecuteServiceRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ExecuteServiceRequest', createEmptyInstance: create) - ..a<$core.int>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'key', $pb.PbFieldType.OF3) - ..pc(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'args', $pb.PbFieldType.PM, subBuilder: ExecuteServiceArgument.create) - ..hasRequiredFields = false - ; - - ExecuteServiceRequest._() : super(); - factory ExecuteServiceRequest({ - $core.int? key, - $core.Iterable? args, - }) { - final _result = create(); - if (key != null) { - _result.key = key; - } - if (args != null) { - _result.args.addAll(args); - } - return _result; - } - factory ExecuteServiceRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory ExecuteServiceRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - ExecuteServiceRequest clone() => ExecuteServiceRequest()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - ExecuteServiceRequest copyWith(void Function(ExecuteServiceRequest) updates) => super.copyWith((message) => updates(message as ExecuteServiceRequest)) as ExecuteServiceRequest; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static ExecuteServiceRequest create() => ExecuteServiceRequest._(); - ExecuteServiceRequest createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static ExecuteServiceRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static ExecuteServiceRequest? _defaultInstance; - - @$pb.TagNumber(1) - $core.int get key => $_getIZ(0); - @$pb.TagNumber(1) - set key($core.int v) { $_setUnsignedInt32(0, v); } - @$pb.TagNumber(1) - $core.bool hasKey() => $_has(0); - @$pb.TagNumber(1) - void clearKey() => clearField(1); - - @$pb.TagNumber(2) - $core.List get args => $_getList(1); -} - -class ListEntitiesCameraResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ListEntitiesCameraResponse', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'objectId') - ..a<$core.int>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'key', $pb.PbFieldType.OF3) - ..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name') - ..aOS(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'uniqueId') - ..hasRequiredFields = false - ; - - ListEntitiesCameraResponse._() : super(); - factory ListEntitiesCameraResponse({ - $core.String? objectId, - $core.int? key, - $core.String? name, - $core.String? uniqueId, - }) { - final _result = create(); - if (objectId != null) { - _result.objectId = objectId; - } - if (key != null) { - _result.key = key; - } - if (name != null) { - _result.name = name; - } - if (uniqueId != null) { - _result.uniqueId = uniqueId; - } - return _result; - } - factory ListEntitiesCameraResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory ListEntitiesCameraResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - ListEntitiesCameraResponse clone() => ListEntitiesCameraResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - ListEntitiesCameraResponse copyWith(void Function(ListEntitiesCameraResponse) updates) => super.copyWith((message) => updates(message as ListEntitiesCameraResponse)) as ListEntitiesCameraResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static ListEntitiesCameraResponse create() => ListEntitiesCameraResponse._(); - ListEntitiesCameraResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static ListEntitiesCameraResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static ListEntitiesCameraResponse? _defaultInstance; - - @$pb.TagNumber(1) - $core.String get objectId => $_getSZ(0); - @$pb.TagNumber(1) - set objectId($core.String v) { $_setString(0, v); } - @$pb.TagNumber(1) - $core.bool hasObjectId() => $_has(0); - @$pb.TagNumber(1) - void clearObjectId() => clearField(1); - - @$pb.TagNumber(2) - $core.int get key => $_getIZ(1); - @$pb.TagNumber(2) - set key($core.int v) { $_setUnsignedInt32(1, v); } - @$pb.TagNumber(2) - $core.bool hasKey() => $_has(1); - @$pb.TagNumber(2) - void clearKey() => clearField(2); - - @$pb.TagNumber(3) - $core.String get name => $_getSZ(2); - @$pb.TagNumber(3) - set name($core.String v) { $_setString(2, v); } - @$pb.TagNumber(3) - $core.bool hasName() => $_has(2); - @$pb.TagNumber(3) - void clearName() => clearField(3); - - @$pb.TagNumber(4) - $core.String get uniqueId => $_getSZ(3); - @$pb.TagNumber(4) - set uniqueId($core.String v) { $_setString(3, v); } - @$pb.TagNumber(4) - $core.bool hasUniqueId() => $_has(3); - @$pb.TagNumber(4) - void clearUniqueId() => clearField(4); -} - -class CameraImageResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CameraImageResponse', createEmptyInstance: create) - ..a<$core.int>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'key', $pb.PbFieldType.OF3) - ..a<$core.List<$core.int>>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'data', $pb.PbFieldType.OY) - ..aOB(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'done') - ..hasRequiredFields = false - ; - - CameraImageResponse._() : super(); - factory CameraImageResponse({ - $core.int? key, - $core.List<$core.int>? data, - $core.bool? done, - }) { - final _result = create(); - if (key != null) { - _result.key = key; - } - if (data != null) { - _result.data = data; - } - if (done != null) { - _result.done = done; - } - return _result; - } - factory CameraImageResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory CameraImageResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - CameraImageResponse clone() => CameraImageResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - CameraImageResponse copyWith(void Function(CameraImageResponse) updates) => super.copyWith((message) => updates(message as CameraImageResponse)) as CameraImageResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static CameraImageResponse create() => CameraImageResponse._(); - CameraImageResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static CameraImageResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static CameraImageResponse? _defaultInstance; - - @$pb.TagNumber(1) - $core.int get key => $_getIZ(0); - @$pb.TagNumber(1) - set key($core.int v) { $_setUnsignedInt32(0, v); } - @$pb.TagNumber(1) - $core.bool hasKey() => $_has(0); - @$pb.TagNumber(1) - void clearKey() => clearField(1); - - @$pb.TagNumber(2) - $core.List<$core.int> get data => $_getN(1); - @$pb.TagNumber(2) - set data($core.List<$core.int> v) { $_setBytes(1, v); } - @$pb.TagNumber(2) - $core.bool hasData() => $_has(1); - @$pb.TagNumber(2) - void clearData() => clearField(2); - - @$pb.TagNumber(3) - $core.bool get done => $_getBF(2); - @$pb.TagNumber(3) - set done($core.bool v) { $_setBool(2, v); } - @$pb.TagNumber(3) - $core.bool hasDone() => $_has(2); - @$pb.TagNumber(3) - void clearDone() => clearField(3); -} - -class CameraImageRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CameraImageRequest', createEmptyInstance: create) - ..aOB(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'single') - ..aOB(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'stream') - ..hasRequiredFields = false - ; - - CameraImageRequest._() : super(); - factory CameraImageRequest({ - $core.bool? single, - $core.bool? stream, - }) { - final _result = create(); - if (single != null) { - _result.single = single; - } - if (stream != null) { - _result.stream = stream; - } - return _result; - } - factory CameraImageRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory CameraImageRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - CameraImageRequest clone() => CameraImageRequest()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - CameraImageRequest copyWith(void Function(CameraImageRequest) updates) => super.copyWith((message) => updates(message as CameraImageRequest)) as CameraImageRequest; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static CameraImageRequest create() => CameraImageRequest._(); - CameraImageRequest createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static CameraImageRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static CameraImageRequest? _defaultInstance; - - @$pb.TagNumber(1) - $core.bool get single => $_getBF(0); - @$pb.TagNumber(1) - set single($core.bool v) { $_setBool(0, v); } - @$pb.TagNumber(1) - $core.bool hasSingle() => $_has(0); - @$pb.TagNumber(1) - void clearSingle() => clearField(1); - - @$pb.TagNumber(2) - $core.bool get stream => $_getBF(1); - @$pb.TagNumber(2) - set stream($core.bool v) { $_setBool(1, v); } - @$pb.TagNumber(2) - $core.bool hasStream() => $_has(1); - @$pb.TagNumber(2) - void clearStream() => clearField(2); -} - -class ListEntitiesClimateResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ListEntitiesClimateResponse', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'objectId') - ..a<$core.int>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'key', $pb.PbFieldType.OF3) - ..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name') - ..aOS(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'uniqueId') - ..aOB(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'supportsCurrentTemperature') - ..aOB(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'supportsTwoPointTargetTemperature') - ..pc(7, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'supportedModes', $pb.PbFieldType.KE, valueOf: ClimateMode.valueOf, enumValues: ClimateMode.values, defaultEnumValue: ClimateMode.CLIMATE_MODE_OFF) - ..a<$core.double>(8, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'visualMinTemperature', $pb.PbFieldType.OF) - ..a<$core.double>(9, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'visualMaxTemperature', $pb.PbFieldType.OF) - ..a<$core.double>(10, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'visualTemperatureStep', $pb.PbFieldType.OF) - ..aOB(11, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'legacySupportsAway') - ..aOB(12, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'supportsAction') - ..pc(13, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'supportedFanModes', $pb.PbFieldType.KE, valueOf: ClimateFanMode.valueOf, enumValues: ClimateFanMode.values, defaultEnumValue: ClimateFanMode.CLIMATE_FAN_ON) - ..pc(14, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'supportedSwingModes', $pb.PbFieldType.KE, valueOf: ClimateSwingMode.valueOf, enumValues: ClimateSwingMode.values, defaultEnumValue: ClimateSwingMode.CLIMATE_SWING_OFF) - ..pPS(15, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'supportedCustomFanModes') - ..pc(16, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'supportedPresets', $pb.PbFieldType.KE, valueOf: ClimatePreset.valueOf, enumValues: ClimatePreset.values, defaultEnumValue: ClimatePreset.CLIMATE_PRESET_NONE) - ..pPS(17, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'supportedCustomPresets') - ..hasRequiredFields = false - ; - - ListEntitiesClimateResponse._() : super(); - factory ListEntitiesClimateResponse({ - $core.String? objectId, - $core.int? key, - $core.String? name, - $core.String? uniqueId, - $core.bool? supportsCurrentTemperature, - $core.bool? supportsTwoPointTargetTemperature, - $core.Iterable? supportedModes, - $core.double? visualMinTemperature, - $core.double? visualMaxTemperature, - $core.double? visualTemperatureStep, - $core.bool? legacySupportsAway, - $core.bool? supportsAction, - $core.Iterable? supportedFanModes, - $core.Iterable? supportedSwingModes, - $core.Iterable<$core.String>? supportedCustomFanModes, - $core.Iterable? supportedPresets, - $core.Iterable<$core.String>? supportedCustomPresets, - }) { - final _result = create(); - if (objectId != null) { - _result.objectId = objectId; - } - if (key != null) { - _result.key = key; - } - if (name != null) { - _result.name = name; - } - if (uniqueId != null) { - _result.uniqueId = uniqueId; - } - if (supportsCurrentTemperature != null) { - _result.supportsCurrentTemperature = supportsCurrentTemperature; - } - if (supportsTwoPointTargetTemperature != null) { - _result.supportsTwoPointTargetTemperature = supportsTwoPointTargetTemperature; - } - if (supportedModes != null) { - _result.supportedModes.addAll(supportedModes); - } - if (visualMinTemperature != null) { - _result.visualMinTemperature = visualMinTemperature; - } - if (visualMaxTemperature != null) { - _result.visualMaxTemperature = visualMaxTemperature; - } - if (visualTemperatureStep != null) { - _result.visualTemperatureStep = visualTemperatureStep; - } - if (legacySupportsAway != null) { - _result.legacySupportsAway = legacySupportsAway; - } - if (supportsAction != null) { - _result.supportsAction = supportsAction; - } - if (supportedFanModes != null) { - _result.supportedFanModes.addAll(supportedFanModes); - } - if (supportedSwingModes != null) { - _result.supportedSwingModes.addAll(supportedSwingModes); - } - if (supportedCustomFanModes != null) { - _result.supportedCustomFanModes.addAll(supportedCustomFanModes); - } - if (supportedPresets != null) { - _result.supportedPresets.addAll(supportedPresets); - } - if (supportedCustomPresets != null) { - _result.supportedCustomPresets.addAll(supportedCustomPresets); - } - return _result; - } - factory ListEntitiesClimateResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory ListEntitiesClimateResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - ListEntitiesClimateResponse clone() => ListEntitiesClimateResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - ListEntitiesClimateResponse copyWith(void Function(ListEntitiesClimateResponse) updates) => super.copyWith((message) => updates(message as ListEntitiesClimateResponse)) as ListEntitiesClimateResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static ListEntitiesClimateResponse create() => ListEntitiesClimateResponse._(); - ListEntitiesClimateResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static ListEntitiesClimateResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static ListEntitiesClimateResponse? _defaultInstance; - - @$pb.TagNumber(1) - $core.String get objectId => $_getSZ(0); - @$pb.TagNumber(1) - set objectId($core.String v) { $_setString(0, v); } - @$pb.TagNumber(1) - $core.bool hasObjectId() => $_has(0); - @$pb.TagNumber(1) - void clearObjectId() => clearField(1); - - @$pb.TagNumber(2) - $core.int get key => $_getIZ(1); - @$pb.TagNumber(2) - set key($core.int v) { $_setUnsignedInt32(1, v); } - @$pb.TagNumber(2) - $core.bool hasKey() => $_has(1); - @$pb.TagNumber(2) - void clearKey() => clearField(2); - - @$pb.TagNumber(3) - $core.String get name => $_getSZ(2); - @$pb.TagNumber(3) - set name($core.String v) { $_setString(2, v); } - @$pb.TagNumber(3) - $core.bool hasName() => $_has(2); - @$pb.TagNumber(3) - void clearName() => clearField(3); - - @$pb.TagNumber(4) - $core.String get uniqueId => $_getSZ(3); - @$pb.TagNumber(4) - set uniqueId($core.String v) { $_setString(3, v); } - @$pb.TagNumber(4) - $core.bool hasUniqueId() => $_has(3); - @$pb.TagNumber(4) - void clearUniqueId() => clearField(4); - - @$pb.TagNumber(5) - $core.bool get supportsCurrentTemperature => $_getBF(4); - @$pb.TagNumber(5) - set supportsCurrentTemperature($core.bool v) { $_setBool(4, v); } - @$pb.TagNumber(5) - $core.bool hasSupportsCurrentTemperature() => $_has(4); - @$pb.TagNumber(5) - void clearSupportsCurrentTemperature() => clearField(5); - - @$pb.TagNumber(6) - $core.bool get supportsTwoPointTargetTemperature => $_getBF(5); - @$pb.TagNumber(6) - set supportsTwoPointTargetTemperature($core.bool v) { $_setBool(5, v); } - @$pb.TagNumber(6) - $core.bool hasSupportsTwoPointTargetTemperature() => $_has(5); - @$pb.TagNumber(6) - void clearSupportsTwoPointTargetTemperature() => clearField(6); - - @$pb.TagNumber(7) - $core.List get supportedModes => $_getList(6); - - @$pb.TagNumber(8) - $core.double get visualMinTemperature => $_getN(7); - @$pb.TagNumber(8) - set visualMinTemperature($core.double v) { $_setFloat(7, v); } - @$pb.TagNumber(8) - $core.bool hasVisualMinTemperature() => $_has(7); - @$pb.TagNumber(8) - void clearVisualMinTemperature() => clearField(8); - - @$pb.TagNumber(9) - $core.double get visualMaxTemperature => $_getN(8); - @$pb.TagNumber(9) - set visualMaxTemperature($core.double v) { $_setFloat(8, v); } - @$pb.TagNumber(9) - $core.bool hasVisualMaxTemperature() => $_has(8); - @$pb.TagNumber(9) - void clearVisualMaxTemperature() => clearField(9); - - @$pb.TagNumber(10) - $core.double get visualTemperatureStep => $_getN(9); - @$pb.TagNumber(10) - set visualTemperatureStep($core.double v) { $_setFloat(9, v); } - @$pb.TagNumber(10) - $core.bool hasVisualTemperatureStep() => $_has(9); - @$pb.TagNumber(10) - void clearVisualTemperatureStep() => clearField(10); - - @$pb.TagNumber(11) - $core.bool get legacySupportsAway => $_getBF(10); - @$pb.TagNumber(11) - set legacySupportsAway($core.bool v) { $_setBool(10, v); } - @$pb.TagNumber(11) - $core.bool hasLegacySupportsAway() => $_has(10); - @$pb.TagNumber(11) - void clearLegacySupportsAway() => clearField(11); - - @$pb.TagNumber(12) - $core.bool get supportsAction => $_getBF(11); - @$pb.TagNumber(12) - set supportsAction($core.bool v) { $_setBool(11, v); } - @$pb.TagNumber(12) - $core.bool hasSupportsAction() => $_has(11); - @$pb.TagNumber(12) - void clearSupportsAction() => clearField(12); - - @$pb.TagNumber(13) - $core.List get supportedFanModes => $_getList(12); - - @$pb.TagNumber(14) - $core.List get supportedSwingModes => $_getList(13); - - @$pb.TagNumber(15) - $core.List<$core.String> get supportedCustomFanModes => $_getList(14); - - @$pb.TagNumber(16) - $core.List get supportedPresets => $_getList(15); - - @$pb.TagNumber(17) - $core.List<$core.String> get supportedCustomPresets => $_getList(16); -} - -class ClimateStateResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ClimateStateResponse', createEmptyInstance: create) - ..a<$core.int>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'key', $pb.PbFieldType.OF3) - ..e(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'mode', $pb.PbFieldType.OE, defaultOrMaker: ClimateMode.CLIMATE_MODE_OFF, valueOf: ClimateMode.valueOf, enumValues: ClimateMode.values) - ..a<$core.double>(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'currentTemperature', $pb.PbFieldType.OF) - ..a<$core.double>(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'targetTemperature', $pb.PbFieldType.OF) - ..a<$core.double>(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'targetTemperatureLow', $pb.PbFieldType.OF) - ..a<$core.double>(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'targetTemperatureHigh', $pb.PbFieldType.OF) - ..aOB(7, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'legacyAway') - ..e(8, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'action', $pb.PbFieldType.OE, defaultOrMaker: ClimateAction.CLIMATE_ACTION_OFF, valueOf: ClimateAction.valueOf, enumValues: ClimateAction.values) - ..e(9, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'fanMode', $pb.PbFieldType.OE, defaultOrMaker: ClimateFanMode.CLIMATE_FAN_ON, valueOf: ClimateFanMode.valueOf, enumValues: ClimateFanMode.values) - ..e(10, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'swingMode', $pb.PbFieldType.OE, defaultOrMaker: ClimateSwingMode.CLIMATE_SWING_OFF, valueOf: ClimateSwingMode.valueOf, enumValues: ClimateSwingMode.values) - ..aOS(11, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'customFanMode') - ..e(12, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'preset', $pb.PbFieldType.OE, defaultOrMaker: ClimatePreset.CLIMATE_PRESET_NONE, valueOf: ClimatePreset.valueOf, enumValues: ClimatePreset.values) - ..aOS(13, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'customPreset') - ..hasRequiredFields = false - ; - - ClimateStateResponse._() : super(); - factory ClimateStateResponse({ - $core.int? key, - ClimateMode? mode, - $core.double? currentTemperature, - $core.double? targetTemperature, - $core.double? targetTemperatureLow, - $core.double? targetTemperatureHigh, - $core.bool? legacyAway, - ClimateAction? action, - ClimateFanMode? fanMode, - ClimateSwingMode? swingMode, - $core.String? customFanMode, - ClimatePreset? preset, - $core.String? customPreset, - }) { - final _result = create(); - if (key != null) { - _result.key = key; - } - if (mode != null) { - _result.mode = mode; - } - if (currentTemperature != null) { - _result.currentTemperature = currentTemperature; - } - if (targetTemperature != null) { - _result.targetTemperature = targetTemperature; - } - if (targetTemperatureLow != null) { - _result.targetTemperatureLow = targetTemperatureLow; - } - if (targetTemperatureHigh != null) { - _result.targetTemperatureHigh = targetTemperatureHigh; - } - if (legacyAway != null) { - _result.legacyAway = legacyAway; - } - if (action != null) { - _result.action = action; - } - if (fanMode != null) { - _result.fanMode = fanMode; - } - if (swingMode != null) { - _result.swingMode = swingMode; - } - if (customFanMode != null) { - _result.customFanMode = customFanMode; - } - if (preset != null) { - _result.preset = preset; - } - if (customPreset != null) { - _result.customPreset = customPreset; - } - return _result; - } - factory ClimateStateResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory ClimateStateResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - ClimateStateResponse clone() => ClimateStateResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - ClimateStateResponse copyWith(void Function(ClimateStateResponse) updates) => super.copyWith((message) => updates(message as ClimateStateResponse)) as ClimateStateResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static ClimateStateResponse create() => ClimateStateResponse._(); - ClimateStateResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static ClimateStateResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static ClimateStateResponse? _defaultInstance; - - @$pb.TagNumber(1) - $core.int get key => $_getIZ(0); - @$pb.TagNumber(1) - set key($core.int v) { $_setUnsignedInt32(0, v); } - @$pb.TagNumber(1) - $core.bool hasKey() => $_has(0); - @$pb.TagNumber(1) - void clearKey() => clearField(1); - - @$pb.TagNumber(2) - ClimateMode get mode => $_getN(1); - @$pb.TagNumber(2) - set mode(ClimateMode v) { setField(2, v); } - @$pb.TagNumber(2) - $core.bool hasMode() => $_has(1); - @$pb.TagNumber(2) - void clearMode() => clearField(2); - - @$pb.TagNumber(3) - $core.double get currentTemperature => $_getN(2); - @$pb.TagNumber(3) - set currentTemperature($core.double v) { $_setFloat(2, v); } - @$pb.TagNumber(3) - $core.bool hasCurrentTemperature() => $_has(2); - @$pb.TagNumber(3) - void clearCurrentTemperature() => clearField(3); - - @$pb.TagNumber(4) - $core.double get targetTemperature => $_getN(3); - @$pb.TagNumber(4) - set targetTemperature($core.double v) { $_setFloat(3, v); } - @$pb.TagNumber(4) - $core.bool hasTargetTemperature() => $_has(3); - @$pb.TagNumber(4) - void clearTargetTemperature() => clearField(4); - - @$pb.TagNumber(5) - $core.double get targetTemperatureLow => $_getN(4); - @$pb.TagNumber(5) - set targetTemperatureLow($core.double v) { $_setFloat(4, v); } - @$pb.TagNumber(5) - $core.bool hasTargetTemperatureLow() => $_has(4); - @$pb.TagNumber(5) - void clearTargetTemperatureLow() => clearField(5); - - @$pb.TagNumber(6) - $core.double get targetTemperatureHigh => $_getN(5); - @$pb.TagNumber(6) - set targetTemperatureHigh($core.double v) { $_setFloat(5, v); } - @$pb.TagNumber(6) - $core.bool hasTargetTemperatureHigh() => $_has(5); - @$pb.TagNumber(6) - void clearTargetTemperatureHigh() => clearField(6); - - @$pb.TagNumber(7) - $core.bool get legacyAway => $_getBF(6); - @$pb.TagNumber(7) - set legacyAway($core.bool v) { $_setBool(6, v); } - @$pb.TagNumber(7) - $core.bool hasLegacyAway() => $_has(6); - @$pb.TagNumber(7) - void clearLegacyAway() => clearField(7); - - @$pb.TagNumber(8) - ClimateAction get action => $_getN(7); - @$pb.TagNumber(8) - set action(ClimateAction v) { setField(8, v); } - @$pb.TagNumber(8) - $core.bool hasAction() => $_has(7); - @$pb.TagNumber(8) - void clearAction() => clearField(8); - - @$pb.TagNumber(9) - ClimateFanMode get fanMode => $_getN(8); - @$pb.TagNumber(9) - set fanMode(ClimateFanMode v) { setField(9, v); } - @$pb.TagNumber(9) - $core.bool hasFanMode() => $_has(8); - @$pb.TagNumber(9) - void clearFanMode() => clearField(9); - - @$pb.TagNumber(10) - ClimateSwingMode get swingMode => $_getN(9); - @$pb.TagNumber(10) - set swingMode(ClimateSwingMode v) { setField(10, v); } - @$pb.TagNumber(10) - $core.bool hasSwingMode() => $_has(9); - @$pb.TagNumber(10) - void clearSwingMode() => clearField(10); - - @$pb.TagNumber(11) - $core.String get customFanMode => $_getSZ(10); - @$pb.TagNumber(11) - set customFanMode($core.String v) { $_setString(10, v); } - @$pb.TagNumber(11) - $core.bool hasCustomFanMode() => $_has(10); - @$pb.TagNumber(11) - void clearCustomFanMode() => clearField(11); - - @$pb.TagNumber(12) - ClimatePreset get preset => $_getN(11); - @$pb.TagNumber(12) - set preset(ClimatePreset v) { setField(12, v); } - @$pb.TagNumber(12) - $core.bool hasPreset() => $_has(11); - @$pb.TagNumber(12) - void clearPreset() => clearField(12); - - @$pb.TagNumber(13) - $core.String get customPreset => $_getSZ(12); - @$pb.TagNumber(13) - set customPreset($core.String v) { $_setString(12, v); } - @$pb.TagNumber(13) - $core.bool hasCustomPreset() => $_has(12); - @$pb.TagNumber(13) - void clearCustomPreset() => clearField(13); -} - -class ClimateCommandRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ClimateCommandRequest', createEmptyInstance: create) - ..a<$core.int>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'key', $pb.PbFieldType.OF3) - ..aOB(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'hasMode') - ..e(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'mode', $pb.PbFieldType.OE, defaultOrMaker: ClimateMode.CLIMATE_MODE_OFF, valueOf: ClimateMode.valueOf, enumValues: ClimateMode.values) - ..aOB(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'hasTargetTemperature') - ..a<$core.double>(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'targetTemperature', $pb.PbFieldType.OF) - ..aOB(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'hasTargetTemperatureLow') - ..a<$core.double>(7, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'targetTemperatureLow', $pb.PbFieldType.OF) - ..aOB(8, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'hasTargetTemperatureHigh') - ..a<$core.double>(9, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'targetTemperatureHigh', $pb.PbFieldType.OF) - ..aOB(10, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'hasLegacyAway') - ..aOB(11, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'legacyAway') - ..aOB(12, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'hasFanMode') - ..e(13, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'fanMode', $pb.PbFieldType.OE, defaultOrMaker: ClimateFanMode.CLIMATE_FAN_ON, valueOf: ClimateFanMode.valueOf, enumValues: ClimateFanMode.values) - ..aOB(14, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'hasSwingMode') - ..e(15, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'swingMode', $pb.PbFieldType.OE, defaultOrMaker: ClimateSwingMode.CLIMATE_SWING_OFF, valueOf: ClimateSwingMode.valueOf, enumValues: ClimateSwingMode.values) - ..aOB(16, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'hasCustomFanMode') - ..aOS(17, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'customFanMode') - ..aOB(18, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'hasPreset') - ..e(19, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'preset', $pb.PbFieldType.OE, defaultOrMaker: ClimatePreset.CLIMATE_PRESET_NONE, valueOf: ClimatePreset.valueOf, enumValues: ClimatePreset.values) - ..aOB(20, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'hasCustomPreset') - ..aOS(21, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'customPreset') - ..hasRequiredFields = false - ; - - ClimateCommandRequest._() : super(); - factory ClimateCommandRequest({ - $core.int? key, - $core.bool? hasMode, - ClimateMode? mode_3, - $core.bool? hasTargetTemperature, - $core.double? targetTemperature_5, - $core.bool? hasTargetTemperatureLow, - $core.double? targetTemperatureLow_7, - $core.bool? hasTargetTemperatureHigh, - $core.double? targetTemperatureHigh_9, - $core.bool? hasLegacyAway, - $core.bool? legacyAway_11, - $core.bool? hasFanMode, - ClimateFanMode? fanMode_13, - $core.bool? hasSwingMode, - ClimateSwingMode? swingMode_15, - $core.bool? hasCustomFanMode, - $core.String? customFanMode_17, - $core.bool? hasPreset, - ClimatePreset? preset_19, - $core.bool? hasCustomPreset, - $core.String? customPreset_21, - }) { - final _result = create(); - if (key != null) { - _result.key = key; - } - if (hasMode != null) { - _result.hasMode = hasMode; - } - if (mode_3 != null) { - _result.mode_3 = mode_3; - } - if (hasTargetTemperature != null) { - _result.hasTargetTemperature = hasTargetTemperature; - } - if (targetTemperature_5 != null) { - _result.targetTemperature_5 = targetTemperature_5; - } - if (hasTargetTemperatureLow != null) { - _result.hasTargetTemperatureLow = hasTargetTemperatureLow; - } - if (targetTemperatureLow_7 != null) { - _result.targetTemperatureLow_7 = targetTemperatureLow_7; - } - if (hasTargetTemperatureHigh != null) { - _result.hasTargetTemperatureHigh = hasTargetTemperatureHigh; - } - if (targetTemperatureHigh_9 != null) { - _result.targetTemperatureHigh_9 = targetTemperatureHigh_9; - } - if (hasLegacyAway != null) { - _result.hasLegacyAway = hasLegacyAway; - } - if (legacyAway_11 != null) { - _result.legacyAway_11 = legacyAway_11; - } - if (hasFanMode != null) { - _result.hasFanMode = hasFanMode; - } - if (fanMode_13 != null) { - _result.fanMode_13 = fanMode_13; - } - if (hasSwingMode != null) { - _result.hasSwingMode = hasSwingMode; - } - if (swingMode_15 != null) { - _result.swingMode_15 = swingMode_15; - } - if (hasCustomFanMode != null) { - _result.hasCustomFanMode = hasCustomFanMode; - } - if (customFanMode_17 != null) { - _result.customFanMode_17 = customFanMode_17; - } - if (hasPreset != null) { - _result.hasPreset = hasPreset; - } - if (preset_19 != null) { - _result.preset_19 = preset_19; - } - if (hasCustomPreset != null) { - _result.hasCustomPreset = hasCustomPreset; - } - if (customPreset_21 != null) { - _result.customPreset_21 = customPreset_21; - } - return _result; - } - factory ClimateCommandRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory ClimateCommandRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - ClimateCommandRequest clone() => ClimateCommandRequest()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - ClimateCommandRequest copyWith(void Function(ClimateCommandRequest) updates) => super.copyWith((message) => updates(message as ClimateCommandRequest)) as ClimateCommandRequest; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static ClimateCommandRequest create() => ClimateCommandRequest._(); - ClimateCommandRequest createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static ClimateCommandRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static ClimateCommandRequest? _defaultInstance; - - @$pb.TagNumber(1) - $core.int get key => $_getIZ(0); - @$pb.TagNumber(1) - set key($core.int v) { $_setUnsignedInt32(0, v); } - @$pb.TagNumber(1) - $core.bool hasKey() => $_has(0); - @$pb.TagNumber(1) - void clearKey() => clearField(1); - - @$pb.TagNumber(2) - $core.bool get hasMode => $_getBF(1); - @$pb.TagNumber(2) - set hasMode($core.bool v) { $_setBool(1, v); } - @$pb.TagNumber(2) - $core.bool hasHasMode() => $_has(1); - @$pb.TagNumber(2) - void clearHasMode() => clearField(2); - - @$pb.TagNumber(3) - ClimateMode get mode_3 => $_getN(2); - @$pb.TagNumber(3) - set mode_3(ClimateMode v) { setField(3, v); } - @$pb.TagNumber(3) - $core.bool hasMode_3() => $_has(2); - @$pb.TagNumber(3) - void clearMode_3() => clearField(3); - - @$pb.TagNumber(4) - $core.bool get hasTargetTemperature => $_getBF(3); - @$pb.TagNumber(4) - set hasTargetTemperature($core.bool v) { $_setBool(3, v); } - @$pb.TagNumber(4) - $core.bool hasHasTargetTemperature() => $_has(3); - @$pb.TagNumber(4) - void clearHasTargetTemperature() => clearField(4); - - @$pb.TagNumber(5) - $core.double get targetTemperature_5 => $_getN(4); - @$pb.TagNumber(5) - set targetTemperature_5($core.double v) { $_setFloat(4, v); } - @$pb.TagNumber(5) - $core.bool hasTargetTemperature_5() => $_has(4); - @$pb.TagNumber(5) - void clearTargetTemperature_5() => clearField(5); - - @$pb.TagNumber(6) - $core.bool get hasTargetTemperatureLow => $_getBF(5); - @$pb.TagNumber(6) - set hasTargetTemperatureLow($core.bool v) { $_setBool(5, v); } - @$pb.TagNumber(6) - $core.bool hasHasTargetTemperatureLow() => $_has(5); - @$pb.TagNumber(6) - void clearHasTargetTemperatureLow() => clearField(6); - - @$pb.TagNumber(7) - $core.double get targetTemperatureLow_7 => $_getN(6); - @$pb.TagNumber(7) - set targetTemperatureLow_7($core.double v) { $_setFloat(6, v); } - @$pb.TagNumber(7) - $core.bool hasTargetTemperatureLow_7() => $_has(6); - @$pb.TagNumber(7) - void clearTargetTemperatureLow_7() => clearField(7); - - @$pb.TagNumber(8) - $core.bool get hasTargetTemperatureHigh => $_getBF(7); - @$pb.TagNumber(8) - set hasTargetTemperatureHigh($core.bool v) { $_setBool(7, v); } - @$pb.TagNumber(8) - $core.bool hasHasTargetTemperatureHigh() => $_has(7); - @$pb.TagNumber(8) - void clearHasTargetTemperatureHigh() => clearField(8); - - @$pb.TagNumber(9) - $core.double get targetTemperatureHigh_9 => $_getN(8); - @$pb.TagNumber(9) - set targetTemperatureHigh_9($core.double v) { $_setFloat(8, v); } - @$pb.TagNumber(9) - $core.bool hasTargetTemperatureHigh_9() => $_has(8); - @$pb.TagNumber(9) - void clearTargetTemperatureHigh_9() => clearField(9); - - @$pb.TagNumber(10) - $core.bool get hasLegacyAway => $_getBF(9); - @$pb.TagNumber(10) - set hasLegacyAway($core.bool v) { $_setBool(9, v); } - @$pb.TagNumber(10) - $core.bool hasHasLegacyAway() => $_has(9); - @$pb.TagNumber(10) - void clearHasLegacyAway() => clearField(10); - - @$pb.TagNumber(11) - $core.bool get legacyAway_11 => $_getBF(10); - @$pb.TagNumber(11) - set legacyAway_11($core.bool v) { $_setBool(10, v); } - @$pb.TagNumber(11) - $core.bool hasLegacyAway_11() => $_has(10); - @$pb.TagNumber(11) - void clearLegacyAway_11() => clearField(11); - - @$pb.TagNumber(12) - $core.bool get hasFanMode => $_getBF(11); - @$pb.TagNumber(12) - set hasFanMode($core.bool v) { $_setBool(11, v); } - @$pb.TagNumber(12) - $core.bool hasHasFanMode() => $_has(11); - @$pb.TagNumber(12) - void clearHasFanMode() => clearField(12); - - @$pb.TagNumber(13) - ClimateFanMode get fanMode_13 => $_getN(12); - @$pb.TagNumber(13) - set fanMode_13(ClimateFanMode v) { setField(13, v); } - @$pb.TagNumber(13) - $core.bool hasFanMode_13() => $_has(12); - @$pb.TagNumber(13) - void clearFanMode_13() => clearField(13); - - @$pb.TagNumber(14) - $core.bool get hasSwingMode => $_getBF(13); - @$pb.TagNumber(14) - set hasSwingMode($core.bool v) { $_setBool(13, v); } - @$pb.TagNumber(14) - $core.bool hasHasSwingMode() => $_has(13); - @$pb.TagNumber(14) - void clearHasSwingMode() => clearField(14); - - @$pb.TagNumber(15) - ClimateSwingMode get swingMode_15 => $_getN(14); - @$pb.TagNumber(15) - set swingMode_15(ClimateSwingMode v) { setField(15, v); } - @$pb.TagNumber(15) - $core.bool hasSwingMode_15() => $_has(14); - @$pb.TagNumber(15) - void clearSwingMode_15() => clearField(15); - - @$pb.TagNumber(16) - $core.bool get hasCustomFanMode => $_getBF(15); - @$pb.TagNumber(16) - set hasCustomFanMode($core.bool v) { $_setBool(15, v); } - @$pb.TagNumber(16) - $core.bool hasHasCustomFanMode() => $_has(15); - @$pb.TagNumber(16) - void clearHasCustomFanMode() => clearField(16); - - @$pb.TagNumber(17) - $core.String get customFanMode_17 => $_getSZ(16); - @$pb.TagNumber(17) - set customFanMode_17($core.String v) { $_setString(16, v); } - @$pb.TagNumber(17) - $core.bool hasCustomFanMode_17() => $_has(16); - @$pb.TagNumber(17) - void clearCustomFanMode_17() => clearField(17); - - @$pb.TagNumber(18) - $core.bool get hasPreset => $_getBF(17); - @$pb.TagNumber(18) - set hasPreset($core.bool v) { $_setBool(17, v); } - @$pb.TagNumber(18) - $core.bool hasHasPreset() => $_has(17); - @$pb.TagNumber(18) - void clearHasPreset() => clearField(18); - - @$pb.TagNumber(19) - ClimatePreset get preset_19 => $_getN(18); - @$pb.TagNumber(19) - set preset_19(ClimatePreset v) { setField(19, v); } - @$pb.TagNumber(19) - $core.bool hasPreset_19() => $_has(18); - @$pb.TagNumber(19) - void clearPreset_19() => clearField(19); - - @$pb.TagNumber(20) - $core.bool get hasCustomPreset => $_getBF(19); - @$pb.TagNumber(20) - set hasCustomPreset($core.bool v) { $_setBool(19, v); } - @$pb.TagNumber(20) - $core.bool hasHasCustomPreset() => $_has(19); - @$pb.TagNumber(20) - void clearHasCustomPreset() => clearField(20); - - @$pb.TagNumber(21) - $core.String get customPreset_21 => $_getSZ(20); - @$pb.TagNumber(21) - set customPreset_21($core.String v) { $_setString(20, v); } - @$pb.TagNumber(21) - $core.bool hasCustomPreset_21() => $_has(20); - @$pb.TagNumber(21) - void clearCustomPreset_21() => clearField(21); -} - -class ListEntitiesNumberResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ListEntitiesNumberResponse', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'objectId') - ..a<$core.int>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'key', $pb.PbFieldType.OF3) - ..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name') - ..aOS(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'uniqueId') - ..aOS(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'icon') - ..a<$core.double>(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'minValue', $pb.PbFieldType.OF) - ..a<$core.double>(7, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'maxValue', $pb.PbFieldType.OF) - ..a<$core.double>(8, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'step', $pb.PbFieldType.OF) - ..hasRequiredFields = false - ; - - ListEntitiesNumberResponse._() : super(); - factory ListEntitiesNumberResponse({ - $core.String? objectId, - $core.int? key, - $core.String? name, - $core.String? uniqueId, - $core.String? icon, - $core.double? minValue, - $core.double? maxValue, - $core.double? step, - }) { - final _result = create(); - if (objectId != null) { - _result.objectId = objectId; - } - if (key != null) { - _result.key = key; - } - if (name != null) { - _result.name = name; - } - if (uniqueId != null) { - _result.uniqueId = uniqueId; - } - if (icon != null) { - _result.icon = icon; - } - if (minValue != null) { - _result.minValue = minValue; - } - if (maxValue != null) { - _result.maxValue = maxValue; - } - if (step != null) { - _result.step = step; - } - return _result; - } - factory ListEntitiesNumberResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory ListEntitiesNumberResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - ListEntitiesNumberResponse clone() => ListEntitiesNumberResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - ListEntitiesNumberResponse copyWith(void Function(ListEntitiesNumberResponse) updates) => super.copyWith((message) => updates(message as ListEntitiesNumberResponse)) as ListEntitiesNumberResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static ListEntitiesNumberResponse create() => ListEntitiesNumberResponse._(); - ListEntitiesNumberResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static ListEntitiesNumberResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static ListEntitiesNumberResponse? _defaultInstance; - - @$pb.TagNumber(1) - $core.String get objectId => $_getSZ(0); - @$pb.TagNumber(1) - set objectId($core.String v) { $_setString(0, v); } - @$pb.TagNumber(1) - $core.bool hasObjectId() => $_has(0); - @$pb.TagNumber(1) - void clearObjectId() => clearField(1); - - @$pb.TagNumber(2) - $core.int get key => $_getIZ(1); - @$pb.TagNumber(2) - set key($core.int v) { $_setUnsignedInt32(1, v); } - @$pb.TagNumber(2) - $core.bool hasKey() => $_has(1); - @$pb.TagNumber(2) - void clearKey() => clearField(2); - - @$pb.TagNumber(3) - $core.String get name => $_getSZ(2); - @$pb.TagNumber(3) - set name($core.String v) { $_setString(2, v); } - @$pb.TagNumber(3) - $core.bool hasName() => $_has(2); - @$pb.TagNumber(3) - void clearName() => clearField(3); - - @$pb.TagNumber(4) - $core.String get uniqueId => $_getSZ(3); - @$pb.TagNumber(4) - set uniqueId($core.String v) { $_setString(3, v); } - @$pb.TagNumber(4) - $core.bool hasUniqueId() => $_has(3); - @$pb.TagNumber(4) - void clearUniqueId() => clearField(4); - - @$pb.TagNumber(5) - $core.String get icon => $_getSZ(4); - @$pb.TagNumber(5) - set icon($core.String v) { $_setString(4, v); } - @$pb.TagNumber(5) - $core.bool hasIcon() => $_has(4); - @$pb.TagNumber(5) - void clearIcon() => clearField(5); - - @$pb.TagNumber(6) - $core.double get minValue => $_getN(5); - @$pb.TagNumber(6) - set minValue($core.double v) { $_setFloat(5, v); } - @$pb.TagNumber(6) - $core.bool hasMinValue() => $_has(5); - @$pb.TagNumber(6) - void clearMinValue() => clearField(6); - - @$pb.TagNumber(7) - $core.double get maxValue => $_getN(6); - @$pb.TagNumber(7) - set maxValue($core.double v) { $_setFloat(6, v); } - @$pb.TagNumber(7) - $core.bool hasMaxValue() => $_has(6); - @$pb.TagNumber(7) - void clearMaxValue() => clearField(7); - - @$pb.TagNumber(8) - $core.double get step => $_getN(7); - @$pb.TagNumber(8) - set step($core.double v) { $_setFloat(7, v); } - @$pb.TagNumber(8) - $core.bool hasStep() => $_has(7); - @$pb.TagNumber(8) - void clearStep() => clearField(8); -} - -class NumberStateResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'NumberStateResponse', createEmptyInstance: create) - ..a<$core.int>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'key', $pb.PbFieldType.OF3) - ..a<$core.double>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'state', $pb.PbFieldType.OF) - ..aOB(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'missingState') - ..hasRequiredFields = false - ; - - NumberStateResponse._() : super(); - factory NumberStateResponse({ - $core.int? key, - $core.double? state, - $core.bool? missingState, - }) { - final _result = create(); - if (key != null) { - _result.key = key; - } - if (state != null) { - _result.state = state; - } - if (missingState != null) { - _result.missingState = missingState; - } - return _result; - } - factory NumberStateResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory NumberStateResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - NumberStateResponse clone() => NumberStateResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - NumberStateResponse copyWith(void Function(NumberStateResponse) updates) => super.copyWith((message) => updates(message as NumberStateResponse)) as NumberStateResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static NumberStateResponse create() => NumberStateResponse._(); - NumberStateResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static NumberStateResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static NumberStateResponse? _defaultInstance; - - @$pb.TagNumber(1) - $core.int get key => $_getIZ(0); - @$pb.TagNumber(1) - set key($core.int v) { $_setUnsignedInt32(0, v); } - @$pb.TagNumber(1) - $core.bool hasKey() => $_has(0); - @$pb.TagNumber(1) - void clearKey() => clearField(1); - - @$pb.TagNumber(2) - $core.double get state => $_getN(1); - @$pb.TagNumber(2) - set state($core.double v) { $_setFloat(1, v); } - @$pb.TagNumber(2) - $core.bool hasState() => $_has(1); - @$pb.TagNumber(2) - void clearState() => clearField(2); - - @$pb.TagNumber(3) - $core.bool get missingState => $_getBF(2); - @$pb.TagNumber(3) - set missingState($core.bool v) { $_setBool(2, v); } - @$pb.TagNumber(3) - $core.bool hasMissingState() => $_has(2); - @$pb.TagNumber(3) - void clearMissingState() => clearField(3); -} - -class NumberCommandRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'NumberCommandRequest', createEmptyInstance: create) - ..a<$core.int>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'key', $pb.PbFieldType.OF3) - ..a<$core.double>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'state', $pb.PbFieldType.OF) - ..hasRequiredFields = false - ; - - NumberCommandRequest._() : super(); - factory NumberCommandRequest({ - $core.int? key, - $core.double? state, - }) { - final _result = create(); - if (key != null) { - _result.key = key; - } - if (state != null) { - _result.state = state; - } - return _result; - } - factory NumberCommandRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory NumberCommandRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - NumberCommandRequest clone() => NumberCommandRequest()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - NumberCommandRequest copyWith(void Function(NumberCommandRequest) updates) => super.copyWith((message) => updates(message as NumberCommandRequest)) as NumberCommandRequest; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static NumberCommandRequest create() => NumberCommandRequest._(); - NumberCommandRequest createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static NumberCommandRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static NumberCommandRequest? _defaultInstance; - - @$pb.TagNumber(1) - $core.int get key => $_getIZ(0); - @$pb.TagNumber(1) - set key($core.int v) { $_setUnsignedInt32(0, v); } - @$pb.TagNumber(1) - $core.bool hasKey() => $_has(0); - @$pb.TagNumber(1) - void clearKey() => clearField(1); - - @$pb.TagNumber(2) - $core.double get state => $_getN(1); - @$pb.TagNumber(2) - set state($core.double v) { $_setFloat(1, v); } - @$pb.TagNumber(2) - $core.bool hasState() => $_has(1); - @$pb.TagNumber(2) - void clearState() => clearField(2); -} - -class APIConnectionApi { - $pb.RpcClient _client; - APIConnectionApi(this._client); - - $async.Future hello($pb.ClientContext? ctx, HelloRequest request) { - var emptyResponse = HelloResponse(); - return _client.invoke(ctx, 'APIConnection', 'hello', request, emptyResponse); - } - $async.Future connect($pb.ClientContext? ctx, ConnectRequest request) { - var emptyResponse = ConnectResponse(); - return _client.invoke(ctx, 'APIConnection', 'connect', request, emptyResponse); - } - $async.Future disconnect($pb.ClientContext? ctx, DisconnectRequest request) { - var emptyResponse = DisconnectResponse(); - return _client.invoke(ctx, 'APIConnection', 'disconnect', request, emptyResponse); - } - $async.Future ping($pb.ClientContext? ctx, PingRequest request) { - var emptyResponse = PingResponse(); - return _client.invoke(ctx, 'APIConnection', 'ping', request, emptyResponse); - } - $async.Future device_info($pb.ClientContext? ctx, DeviceInfoRequest request) { - var emptyResponse = DeviceInfoResponse(); - return _client.invoke(ctx, 'APIConnection', 'device_info', request, emptyResponse); - } - $async.Future<$0.void_> list_entities($pb.ClientContext? ctx, ListEntitiesRequest request) { - var emptyResponse = $0.void_(); - return _client.invoke<$0.void_>(ctx, 'APIConnection', 'list_entities', request, emptyResponse); - } - $async.Future<$0.void_> subscribe_states($pb.ClientContext? ctx, SubscribeStatesRequest request) { - var emptyResponse = $0.void_(); - return _client.invoke<$0.void_>(ctx, 'APIConnection', 'subscribe_states', request, emptyResponse); - } - $async.Future<$0.void_> subscribe_logs($pb.ClientContext? ctx, SubscribeLogsRequest request) { - var emptyResponse = $0.void_(); - return _client.invoke<$0.void_>(ctx, 'APIConnection', 'subscribe_logs', request, emptyResponse); - } - $async.Future<$0.void_> subscribe_homeassistant_services($pb.ClientContext? ctx, SubscribeHomeassistantServicesRequest request) { - var emptyResponse = $0.void_(); - return _client.invoke<$0.void_>(ctx, 'APIConnection', 'subscribe_homeassistant_services', request, emptyResponse); - } - $async.Future<$0.void_> subscribe_home_assistant_states($pb.ClientContext? ctx, SubscribeHomeAssistantStatesRequest request) { - var emptyResponse = $0.void_(); - return _client.invoke<$0.void_>(ctx, 'APIConnection', 'subscribe_home_assistant_states', request, emptyResponse); - } - $async.Future get_time($pb.ClientContext? ctx, GetTimeRequest request) { - var emptyResponse = GetTimeResponse(); - return _client.invoke(ctx, 'APIConnection', 'get_time', request, emptyResponse); - } - $async.Future<$0.void_> execute_service($pb.ClientContext? ctx, ExecuteServiceRequest request) { - var emptyResponse = $0.void_(); - return _client.invoke<$0.void_>(ctx, 'APIConnection', 'execute_service', request, emptyResponse); - } - $async.Future<$0.void_> cover_command($pb.ClientContext? ctx, CoverCommandRequest request) { - var emptyResponse = $0.void_(); - return _client.invoke<$0.void_>(ctx, 'APIConnection', 'cover_command', request, emptyResponse); - } - $async.Future<$0.void_> fan_command($pb.ClientContext? ctx, FanCommandRequest request) { - var emptyResponse = $0.void_(); - return _client.invoke<$0.void_>(ctx, 'APIConnection', 'fan_command', request, emptyResponse); - } - $async.Future<$0.void_> light_command($pb.ClientContext? ctx, LightCommandRequest request) { - var emptyResponse = $0.void_(); - return _client.invoke<$0.void_>(ctx, 'APIConnection', 'light_command', request, emptyResponse); - } - $async.Future<$0.void_> switch_command($pb.ClientContext? ctx, SwitchCommandRequest request) { - var emptyResponse = $0.void_(); - return _client.invoke<$0.void_>(ctx, 'APIConnection', 'switch_command', request, emptyResponse); - } - $async.Future<$0.void_> camera_image($pb.ClientContext? ctx, CameraImageRequest request) { - var emptyResponse = $0.void_(); - return _client.invoke<$0.void_>(ctx, 'APIConnection', 'camera_image', request, emptyResponse); - } - $async.Future<$0.void_> climate_command($pb.ClientContext? ctx, ClimateCommandRequest request) { - var emptyResponse = $0.void_(); - return _client.invoke<$0.void_>(ctx, 'APIConnection', 'climate_command', request, emptyResponse); - } - $async.Future<$0.void_> number_command($pb.ClientContext? ctx, NumberCommandRequest request) { - var emptyResponse = $0.void_(); - return _client.invoke<$0.void_>(ctx, 'APIConnection', 'number_command', request, emptyResponse); - } -} - diff --git a/lib/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api.pbenum.dart b/lib/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api.pbenum.dart deleted file mode 100644 index 901d2991..00000000 --- a/lib/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api.pbenum.dart +++ /dev/null @@ -1,282 +0,0 @@ -/// -// Generated code. Do not modify. -// source: aioesphomeapi/api.proto -// -// @dart = 2.12 -// ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name - -// ignore_for_file: UNDEFINED_SHOWN_NAME -import 'dart:core' as $core; -import 'package:protobuf/protobuf.dart' as $pb; - -class LegacyCoverState extends $pb.ProtobufEnum { - static const LegacyCoverState LEGACY_COVER_STATE_OPEN = LegacyCoverState._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'LEGACY_COVER_STATE_OPEN'); - static const LegacyCoverState LEGACY_COVER_STATE_CLOSED = LegacyCoverState._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'LEGACY_COVER_STATE_CLOSED'); - - static const $core.List values = [ - LEGACY_COVER_STATE_OPEN, - LEGACY_COVER_STATE_CLOSED, - ]; - - static final $core.Map<$core.int, LegacyCoverState> _byValue = $pb.ProtobufEnum.initByValue(values); - static LegacyCoverState? valueOf($core.int value) => _byValue[value]; - - const LegacyCoverState._($core.int v, $core.String n) : super(v, n); -} - -class CoverOperation extends $pb.ProtobufEnum { - static const CoverOperation COVER_OPERATION_IDLE = CoverOperation._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'COVER_OPERATION_IDLE'); - static const CoverOperation COVER_OPERATION_IS_OPENING = CoverOperation._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'COVER_OPERATION_IS_OPENING'); - static const CoverOperation COVER_OPERATION_IS_CLOSING = CoverOperation._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'COVER_OPERATION_IS_CLOSING'); - - static const $core.List values = [ - COVER_OPERATION_IDLE, - COVER_OPERATION_IS_OPENING, - COVER_OPERATION_IS_CLOSING, - ]; - - static final $core.Map<$core.int, CoverOperation> _byValue = $pb.ProtobufEnum.initByValue(values); - static CoverOperation? valueOf($core.int value) => _byValue[value]; - - const CoverOperation._($core.int v, $core.String n) : super(v, n); -} - -class LegacyCoverCommand extends $pb.ProtobufEnum { - static const LegacyCoverCommand LEGACY_COVER_COMMAND_OPEN = LegacyCoverCommand._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'LEGACY_COVER_COMMAND_OPEN'); - static const LegacyCoverCommand LEGACY_COVER_COMMAND_CLOSE = LegacyCoverCommand._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'LEGACY_COVER_COMMAND_CLOSE'); - static const LegacyCoverCommand LEGACY_COVER_COMMAND_STOP = LegacyCoverCommand._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'LEGACY_COVER_COMMAND_STOP'); - - static const $core.List values = [ - LEGACY_COVER_COMMAND_OPEN, - LEGACY_COVER_COMMAND_CLOSE, - LEGACY_COVER_COMMAND_STOP, - ]; - - static final $core.Map<$core.int, LegacyCoverCommand> _byValue = $pb.ProtobufEnum.initByValue(values); - static LegacyCoverCommand? valueOf($core.int value) => _byValue[value]; - - const LegacyCoverCommand._($core.int v, $core.String n) : super(v, n); -} - -class FanSpeed extends $pb.ProtobufEnum { - static const FanSpeed FAN_SPEED_LOW = FanSpeed._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'FAN_SPEED_LOW'); - static const FanSpeed FAN_SPEED_MEDIUM = FanSpeed._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'FAN_SPEED_MEDIUM'); - static const FanSpeed FAN_SPEED_HIGH = FanSpeed._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'FAN_SPEED_HIGH'); - - static const $core.List values = [ - FAN_SPEED_LOW, - FAN_SPEED_MEDIUM, - FAN_SPEED_HIGH, - ]; - - static final $core.Map<$core.int, FanSpeed> _byValue = $pb.ProtobufEnum.initByValue(values); - static FanSpeed? valueOf($core.int value) => _byValue[value]; - - const FanSpeed._($core.int v, $core.String n) : super(v, n); -} - -class FanDirection extends $pb.ProtobufEnum { - static const FanDirection FAN_DIRECTION_FORWARD = FanDirection._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'FAN_DIRECTION_FORWARD'); - static const FanDirection FAN_DIRECTION_REVERSE = FanDirection._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'FAN_DIRECTION_REVERSE'); - - static const $core.List values = [ - FAN_DIRECTION_FORWARD, - FAN_DIRECTION_REVERSE, - ]; - - static final $core.Map<$core.int, FanDirection> _byValue = $pb.ProtobufEnum.initByValue(values); - static FanDirection? valueOf($core.int value) => _byValue[value]; - - const FanDirection._($core.int v, $core.String n) : super(v, n); -} - -class SensorStateClass extends $pb.ProtobufEnum { - static const SensorStateClass STATE_CLASS_NONE = SensorStateClass._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'STATE_CLASS_NONE'); - static const SensorStateClass STATE_CLASS_MEASUREMENT = SensorStateClass._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'STATE_CLASS_MEASUREMENT'); - - static const $core.List values = [ - STATE_CLASS_NONE, - STATE_CLASS_MEASUREMENT, - ]; - - static final $core.Map<$core.int, SensorStateClass> _byValue = $pb.ProtobufEnum.initByValue(values); - static SensorStateClass? valueOf($core.int value) => _byValue[value]; - - const SensorStateClass._($core.int v, $core.String n) : super(v, n); -} - -class LogLevel extends $pb.ProtobufEnum { - static const LogLevel LOG_LEVEL_NONE = LogLevel._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'LOG_LEVEL_NONE'); - static const LogLevel LOG_LEVEL_ERROR = LogLevel._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'LOG_LEVEL_ERROR'); - static const LogLevel LOG_LEVEL_WARN = LogLevel._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'LOG_LEVEL_WARN'); - static const LogLevel LOG_LEVEL_INFO = LogLevel._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'LOG_LEVEL_INFO'); - static const LogLevel LOG_LEVEL_DEBUG = LogLevel._(4, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'LOG_LEVEL_DEBUG'); - static const LogLevel LOG_LEVEL_VERBOSE = LogLevel._(5, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'LOG_LEVEL_VERBOSE'); - static const LogLevel LOG_LEVEL_VERY_VERBOSE = LogLevel._(6, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'LOG_LEVEL_VERY_VERBOSE'); - - static const $core.List values = [ - LOG_LEVEL_NONE, - LOG_LEVEL_ERROR, - LOG_LEVEL_WARN, - LOG_LEVEL_INFO, - LOG_LEVEL_DEBUG, - LOG_LEVEL_VERBOSE, - LOG_LEVEL_VERY_VERBOSE, - ]; - - static final $core.Map<$core.int, LogLevel> _byValue = $pb.ProtobufEnum.initByValue(values); - static LogLevel? valueOf($core.int value) => _byValue[value]; - - const LogLevel._($core.int v, $core.String n) : super(v, n); -} - -class ServiceArgType extends $pb.ProtobufEnum { - static const ServiceArgType SERVICE_ARG_TYPE_BOOL = ServiceArgType._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'SERVICE_ARG_TYPE_BOOL'); - static const ServiceArgType SERVICE_ARG_TYPE_INT = ServiceArgType._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'SERVICE_ARG_TYPE_INT'); - static const ServiceArgType SERVICE_ARG_TYPE_FLOAT = ServiceArgType._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'SERVICE_ARG_TYPE_FLOAT'); - static const ServiceArgType SERVICE_ARG_TYPE_STRING = ServiceArgType._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'SERVICE_ARG_TYPE_STRING'); - static const ServiceArgType SERVICE_ARG_TYPE_BOOL_ARRAY = ServiceArgType._(4, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'SERVICE_ARG_TYPE_BOOL_ARRAY'); - static const ServiceArgType SERVICE_ARG_TYPE_INT_ARRAY = ServiceArgType._(5, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'SERVICE_ARG_TYPE_INT_ARRAY'); - static const ServiceArgType SERVICE_ARG_TYPE_FLOAT_ARRAY = ServiceArgType._(6, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'SERVICE_ARG_TYPE_FLOAT_ARRAY'); - static const ServiceArgType SERVICE_ARG_TYPE_STRING_ARRAY = ServiceArgType._(7, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'SERVICE_ARG_TYPE_STRING_ARRAY'); - - static const $core.List values = [ - SERVICE_ARG_TYPE_BOOL, - SERVICE_ARG_TYPE_INT, - SERVICE_ARG_TYPE_FLOAT, - SERVICE_ARG_TYPE_STRING, - SERVICE_ARG_TYPE_BOOL_ARRAY, - SERVICE_ARG_TYPE_INT_ARRAY, - SERVICE_ARG_TYPE_FLOAT_ARRAY, - SERVICE_ARG_TYPE_STRING_ARRAY, - ]; - - static final $core.Map<$core.int, ServiceArgType> _byValue = $pb.ProtobufEnum.initByValue(values); - static ServiceArgType? valueOf($core.int value) => _byValue[value]; - - const ServiceArgType._($core.int v, $core.String n) : super(v, n); -} - -class ClimateMode extends $pb.ProtobufEnum { - static const ClimateMode CLIMATE_MODE_OFF = ClimateMode._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_MODE_OFF'); - static const ClimateMode CLIMATE_MODE_HEAT_COOL = ClimateMode._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_MODE_HEAT_COOL'); - static const ClimateMode CLIMATE_MODE_COOL = ClimateMode._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_MODE_COOL'); - static const ClimateMode CLIMATE_MODE_HEAT = ClimateMode._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_MODE_HEAT'); - static const ClimateMode CLIMATE_MODE_FAN_ONLY = ClimateMode._(4, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_MODE_FAN_ONLY'); - static const ClimateMode CLIMATE_MODE_DRY = ClimateMode._(5, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_MODE_DRY'); - static const ClimateMode CLIMATE_MODE_AUTO = ClimateMode._(6, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_MODE_AUTO'); - - static const $core.List values = [ - CLIMATE_MODE_OFF, - CLIMATE_MODE_HEAT_COOL, - CLIMATE_MODE_COOL, - CLIMATE_MODE_HEAT, - CLIMATE_MODE_FAN_ONLY, - CLIMATE_MODE_DRY, - CLIMATE_MODE_AUTO, - ]; - - static final $core.Map<$core.int, ClimateMode> _byValue = $pb.ProtobufEnum.initByValue(values); - static ClimateMode? valueOf($core.int value) => _byValue[value]; - - const ClimateMode._($core.int v, $core.String n) : super(v, n); -} - -class ClimateFanMode extends $pb.ProtobufEnum { - static const ClimateFanMode CLIMATE_FAN_ON = ClimateFanMode._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_FAN_ON'); - static const ClimateFanMode CLIMATE_FAN_OFF = ClimateFanMode._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_FAN_OFF'); - static const ClimateFanMode CLIMATE_FAN_AUTO = ClimateFanMode._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_FAN_AUTO'); - static const ClimateFanMode CLIMATE_FAN_LOW = ClimateFanMode._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_FAN_LOW'); - static const ClimateFanMode CLIMATE_FAN_MEDIUM = ClimateFanMode._(4, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_FAN_MEDIUM'); - static const ClimateFanMode CLIMATE_FAN_HIGH = ClimateFanMode._(5, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_FAN_HIGH'); - static const ClimateFanMode CLIMATE_FAN_MIDDLE = ClimateFanMode._(6, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_FAN_MIDDLE'); - static const ClimateFanMode CLIMATE_FAN_FOCUS = ClimateFanMode._(7, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_FAN_FOCUS'); - static const ClimateFanMode CLIMATE_FAN_DIFFUSE = ClimateFanMode._(8, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_FAN_DIFFUSE'); - - static const $core.List values = [ - CLIMATE_FAN_ON, - CLIMATE_FAN_OFF, - CLIMATE_FAN_AUTO, - CLIMATE_FAN_LOW, - CLIMATE_FAN_MEDIUM, - CLIMATE_FAN_HIGH, - CLIMATE_FAN_MIDDLE, - CLIMATE_FAN_FOCUS, - CLIMATE_FAN_DIFFUSE, - ]; - - static final $core.Map<$core.int, ClimateFanMode> _byValue = $pb.ProtobufEnum.initByValue(values); - static ClimateFanMode? valueOf($core.int value) => _byValue[value]; - - const ClimateFanMode._($core.int v, $core.String n) : super(v, n); -} - -class ClimateSwingMode extends $pb.ProtobufEnum { - static const ClimateSwingMode CLIMATE_SWING_OFF = ClimateSwingMode._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_SWING_OFF'); - static const ClimateSwingMode CLIMATE_SWING_BOTH = ClimateSwingMode._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_SWING_BOTH'); - static const ClimateSwingMode CLIMATE_SWING_VERTICAL = ClimateSwingMode._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_SWING_VERTICAL'); - static const ClimateSwingMode CLIMATE_SWING_HORIZONTAL = ClimateSwingMode._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_SWING_HORIZONTAL'); - - static const $core.List values = [ - CLIMATE_SWING_OFF, - CLIMATE_SWING_BOTH, - CLIMATE_SWING_VERTICAL, - CLIMATE_SWING_HORIZONTAL, - ]; - - static final $core.Map<$core.int, ClimateSwingMode> _byValue = $pb.ProtobufEnum.initByValue(values); - static ClimateSwingMode? valueOf($core.int value) => _byValue[value]; - - const ClimateSwingMode._($core.int v, $core.String n) : super(v, n); -} - -class ClimateAction extends $pb.ProtobufEnum { - static const ClimateAction CLIMATE_ACTION_OFF = ClimateAction._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_ACTION_OFF'); - static const ClimateAction CLIMATE_ACTION_COOLING = ClimateAction._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_ACTION_COOLING'); - static const ClimateAction CLIMATE_ACTION_HEATING = ClimateAction._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_ACTION_HEATING'); - static const ClimateAction CLIMATE_ACTION_IDLE = ClimateAction._(4, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_ACTION_IDLE'); - static const ClimateAction CLIMATE_ACTION_DRYING = ClimateAction._(5, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_ACTION_DRYING'); - static const ClimateAction CLIMATE_ACTION_FAN = ClimateAction._(6, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_ACTION_FAN'); - - static const $core.List values = [ - CLIMATE_ACTION_OFF, - CLIMATE_ACTION_COOLING, - CLIMATE_ACTION_HEATING, - CLIMATE_ACTION_IDLE, - CLIMATE_ACTION_DRYING, - CLIMATE_ACTION_FAN, - ]; - - static final $core.Map<$core.int, ClimateAction> _byValue = $pb.ProtobufEnum.initByValue(values); - static ClimateAction? valueOf($core.int value) => _byValue[value]; - - const ClimateAction._($core.int v, $core.String n) : super(v, n); -} - -class ClimatePreset extends $pb.ProtobufEnum { - static const ClimatePreset CLIMATE_PRESET_NONE = ClimatePreset._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_PRESET_NONE'); - static const ClimatePreset CLIMATE_PRESET_HOME = ClimatePreset._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_PRESET_HOME'); - static const ClimatePreset CLIMATE_PRESET_AWAY = ClimatePreset._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_PRESET_AWAY'); - static const ClimatePreset CLIMATE_PRESET_BOOST = ClimatePreset._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_PRESET_BOOST'); - static const ClimatePreset CLIMATE_PRESET_COMFORT = ClimatePreset._(4, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_PRESET_COMFORT'); - static const ClimatePreset CLIMATE_PRESET_ECO = ClimatePreset._(5, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_PRESET_ECO'); - static const ClimatePreset CLIMATE_PRESET_SLEEP = ClimatePreset._(6, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_PRESET_SLEEP'); - static const ClimatePreset CLIMATE_PRESET_ACTIVITY = ClimatePreset._(7, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CLIMATE_PRESET_ACTIVITY'); - - static const $core.List values = [ - CLIMATE_PRESET_NONE, - CLIMATE_PRESET_HOME, - CLIMATE_PRESET_AWAY, - CLIMATE_PRESET_BOOST, - CLIMATE_PRESET_COMFORT, - CLIMATE_PRESET_ECO, - CLIMATE_PRESET_SLEEP, - CLIMATE_PRESET_ACTIVITY, - ]; - - static final $core.Map<$core.int, ClimatePreset> _byValue = $pb.ProtobufEnum.initByValue(values); - static ClimatePreset? valueOf($core.int value) => _byValue[value]; - - const ClimatePreset._($core.int v, $core.String n) : super(v, n); -} - diff --git a/lib/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api.pbjson.dart b/lib/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api.pbjson.dart deleted file mode 100644 index a30a1bae..00000000 --- a/lib/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api.pbjson.dart +++ /dev/null @@ -1,1058 +0,0 @@ -/// -// Generated code. Do not modify. -// source: aioesphomeapi/api.proto -// -// @dart = 2.12 -// ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,deprecated_member_use_from_same_package,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name - -import 'dart:core' as $core; -import 'dart:convert' as $convert; -import 'dart:typed_data' as $typed_data; -import 'api_options.pbjson.dart' as $0; - -@$core.Deprecated('Use legacyCoverStateDescriptor instead') -const LegacyCoverState$json = const { - '1': 'LegacyCoverState', - '2': const [ - const {'1': 'LEGACY_COVER_STATE_OPEN', '2': 0}, - const {'1': 'LEGACY_COVER_STATE_CLOSED', '2': 1}, - ], -}; - -/// Descriptor for `LegacyCoverState`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List legacyCoverStateDescriptor = $convert.base64Decode('ChBMZWdhY3lDb3ZlclN0YXRlEhsKF0xFR0FDWV9DT1ZFUl9TVEFURV9PUEVOEAASHQoZTEVHQUNZX0NPVkVSX1NUQVRFX0NMT1NFRBAB'); -@$core.Deprecated('Use coverOperationDescriptor instead') -const CoverOperation$json = const { - '1': 'CoverOperation', - '2': const [ - const {'1': 'COVER_OPERATION_IDLE', '2': 0}, - const {'1': 'COVER_OPERATION_IS_OPENING', '2': 1}, - const {'1': 'COVER_OPERATION_IS_CLOSING', '2': 2}, - ], -}; - -/// Descriptor for `CoverOperation`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List coverOperationDescriptor = $convert.base64Decode('Cg5Db3Zlck9wZXJhdGlvbhIYChRDT1ZFUl9PUEVSQVRJT05fSURMRRAAEh4KGkNPVkVSX09QRVJBVElPTl9JU19PUEVOSU5HEAESHgoaQ09WRVJfT1BFUkFUSU9OX0lTX0NMT1NJTkcQAg=='); -@$core.Deprecated('Use legacyCoverCommandDescriptor instead') -const LegacyCoverCommand$json = const { - '1': 'LegacyCoverCommand', - '2': const [ - const {'1': 'LEGACY_COVER_COMMAND_OPEN', '2': 0}, - const {'1': 'LEGACY_COVER_COMMAND_CLOSE', '2': 1}, - const {'1': 'LEGACY_COVER_COMMAND_STOP', '2': 2}, - ], -}; - -/// Descriptor for `LegacyCoverCommand`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List legacyCoverCommandDescriptor = $convert.base64Decode('ChJMZWdhY3lDb3ZlckNvbW1hbmQSHQoZTEVHQUNZX0NPVkVSX0NPTU1BTkRfT1BFThAAEh4KGkxFR0FDWV9DT1ZFUl9DT01NQU5EX0NMT1NFEAESHQoZTEVHQUNZX0NPVkVSX0NPTU1BTkRfU1RPUBAC'); -@$core.Deprecated('Use fanSpeedDescriptor instead') -const FanSpeed$json = const { - '1': 'FanSpeed', - '2': const [ - const {'1': 'FAN_SPEED_LOW', '2': 0}, - const {'1': 'FAN_SPEED_MEDIUM', '2': 1}, - const {'1': 'FAN_SPEED_HIGH', '2': 2}, - ], -}; - -/// Descriptor for `FanSpeed`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List fanSpeedDescriptor = $convert.base64Decode('CghGYW5TcGVlZBIRCg1GQU5fU1BFRURfTE9XEAASFAoQRkFOX1NQRUVEX01FRElVTRABEhIKDkZBTl9TUEVFRF9ISUdIEAI='); -@$core.Deprecated('Use fanDirectionDescriptor instead') -const FanDirection$json = const { - '1': 'FanDirection', - '2': const [ - const {'1': 'FAN_DIRECTION_FORWARD', '2': 0}, - const {'1': 'FAN_DIRECTION_REVERSE', '2': 1}, - ], -}; - -/// Descriptor for `FanDirection`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List fanDirectionDescriptor = $convert.base64Decode('CgxGYW5EaXJlY3Rpb24SGQoVRkFOX0RJUkVDVElPTl9GT1JXQVJEEAASGQoVRkFOX0RJUkVDVElPTl9SRVZFUlNFEAE='); -@$core.Deprecated('Use sensorStateClassDescriptor instead') -const SensorStateClass$json = const { - '1': 'SensorStateClass', - '2': const [ - const {'1': 'STATE_CLASS_NONE', '2': 0}, - const {'1': 'STATE_CLASS_MEASUREMENT', '2': 1}, - ], -}; - -/// Descriptor for `SensorStateClass`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List sensorStateClassDescriptor = $convert.base64Decode('ChBTZW5zb3JTdGF0ZUNsYXNzEhQKEFNUQVRFX0NMQVNTX05PTkUQABIbChdTVEFURV9DTEFTU19NRUFTVVJFTUVOVBAB'); -@$core.Deprecated('Use logLevelDescriptor instead') -const LogLevel$json = const { - '1': 'LogLevel', - '2': const [ - const {'1': 'LOG_LEVEL_NONE', '2': 0}, - const {'1': 'LOG_LEVEL_ERROR', '2': 1}, - const {'1': 'LOG_LEVEL_WARN', '2': 2}, - const {'1': 'LOG_LEVEL_INFO', '2': 3}, - const {'1': 'LOG_LEVEL_DEBUG', '2': 4}, - const {'1': 'LOG_LEVEL_VERBOSE', '2': 5}, - const {'1': 'LOG_LEVEL_VERY_VERBOSE', '2': 6}, - ], -}; - -/// Descriptor for `LogLevel`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List logLevelDescriptor = $convert.base64Decode('CghMb2dMZXZlbBISCg5MT0dfTEVWRUxfTk9ORRAAEhMKD0xPR19MRVZFTF9FUlJPUhABEhIKDkxPR19MRVZFTF9XQVJOEAISEgoOTE9HX0xFVkVMX0lORk8QAxITCg9MT0dfTEVWRUxfREVCVUcQBBIVChFMT0dfTEVWRUxfVkVSQk9TRRAFEhoKFkxPR19MRVZFTF9WRVJZX1ZFUkJPU0UQBg=='); -@$core.Deprecated('Use serviceArgTypeDescriptor instead') -const ServiceArgType$json = const { - '1': 'ServiceArgType', - '2': const [ - const {'1': 'SERVICE_ARG_TYPE_BOOL', '2': 0}, - const {'1': 'SERVICE_ARG_TYPE_INT', '2': 1}, - const {'1': 'SERVICE_ARG_TYPE_FLOAT', '2': 2}, - const {'1': 'SERVICE_ARG_TYPE_STRING', '2': 3}, - const {'1': 'SERVICE_ARG_TYPE_BOOL_ARRAY', '2': 4}, - const {'1': 'SERVICE_ARG_TYPE_INT_ARRAY', '2': 5}, - const {'1': 'SERVICE_ARG_TYPE_FLOAT_ARRAY', '2': 6}, - const {'1': 'SERVICE_ARG_TYPE_STRING_ARRAY', '2': 7}, - ], -}; - -/// Descriptor for `ServiceArgType`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List serviceArgTypeDescriptor = $convert.base64Decode('Cg5TZXJ2aWNlQXJnVHlwZRIZChVTRVJWSUNFX0FSR19UWVBFX0JPT0wQABIYChRTRVJWSUNFX0FSR19UWVBFX0lOVBABEhoKFlNFUlZJQ0VfQVJHX1RZUEVfRkxPQVQQAhIbChdTRVJWSUNFX0FSR19UWVBFX1NUUklORxADEh8KG1NFUlZJQ0VfQVJHX1RZUEVfQk9PTF9BUlJBWRAEEh4KGlNFUlZJQ0VfQVJHX1RZUEVfSU5UX0FSUkFZEAUSIAocU0VSVklDRV9BUkdfVFlQRV9GTE9BVF9BUlJBWRAGEiEKHVNFUlZJQ0VfQVJHX1RZUEVfU1RSSU5HX0FSUkFZEAc='); -@$core.Deprecated('Use climateModeDescriptor instead') -const ClimateMode$json = const { - '1': 'ClimateMode', - '2': const [ - const {'1': 'CLIMATE_MODE_OFF', '2': 0}, - const {'1': 'CLIMATE_MODE_HEAT_COOL', '2': 1}, - const {'1': 'CLIMATE_MODE_COOL', '2': 2}, - const {'1': 'CLIMATE_MODE_HEAT', '2': 3}, - const {'1': 'CLIMATE_MODE_FAN_ONLY', '2': 4}, - const {'1': 'CLIMATE_MODE_DRY', '2': 5}, - const {'1': 'CLIMATE_MODE_AUTO', '2': 6}, - ], -}; - -/// Descriptor for `ClimateMode`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List climateModeDescriptor = $convert.base64Decode('CgtDbGltYXRlTW9kZRIUChBDTElNQVRFX01PREVfT0ZGEAASGgoWQ0xJTUFURV9NT0RFX0hFQVRfQ09PTBABEhUKEUNMSU1BVEVfTU9ERV9DT09MEAISFQoRQ0xJTUFURV9NT0RFX0hFQVQQAxIZChVDTElNQVRFX01PREVfRkFOX09OTFkQBBIUChBDTElNQVRFX01PREVfRFJZEAUSFQoRQ0xJTUFURV9NT0RFX0FVVE8QBg=='); -@$core.Deprecated('Use climateFanModeDescriptor instead') -const ClimateFanMode$json = const { - '1': 'ClimateFanMode', - '2': const [ - const {'1': 'CLIMATE_FAN_ON', '2': 0}, - const {'1': 'CLIMATE_FAN_OFF', '2': 1}, - const {'1': 'CLIMATE_FAN_AUTO', '2': 2}, - const {'1': 'CLIMATE_FAN_LOW', '2': 3}, - const {'1': 'CLIMATE_FAN_MEDIUM', '2': 4}, - const {'1': 'CLIMATE_FAN_HIGH', '2': 5}, - const {'1': 'CLIMATE_FAN_MIDDLE', '2': 6}, - const {'1': 'CLIMATE_FAN_FOCUS', '2': 7}, - const {'1': 'CLIMATE_FAN_DIFFUSE', '2': 8}, - ], -}; - -/// Descriptor for `ClimateFanMode`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List climateFanModeDescriptor = $convert.base64Decode('Cg5DbGltYXRlRmFuTW9kZRISCg5DTElNQVRFX0ZBTl9PThAAEhMKD0NMSU1BVEVfRkFOX09GRhABEhQKEENMSU1BVEVfRkFOX0FVVE8QAhITCg9DTElNQVRFX0ZBTl9MT1cQAxIWChJDTElNQVRFX0ZBTl9NRURJVU0QBBIUChBDTElNQVRFX0ZBTl9ISUdIEAUSFgoSQ0xJTUFURV9GQU5fTUlERExFEAYSFQoRQ0xJTUFURV9GQU5fRk9DVVMQBxIXChNDTElNQVRFX0ZBTl9ESUZGVVNFEAg='); -@$core.Deprecated('Use climateSwingModeDescriptor instead') -const ClimateSwingMode$json = const { - '1': 'ClimateSwingMode', - '2': const [ - const {'1': 'CLIMATE_SWING_OFF', '2': 0}, - const {'1': 'CLIMATE_SWING_BOTH', '2': 1}, - const {'1': 'CLIMATE_SWING_VERTICAL', '2': 2}, - const {'1': 'CLIMATE_SWING_HORIZONTAL', '2': 3}, - ], -}; - -/// Descriptor for `ClimateSwingMode`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List climateSwingModeDescriptor = $convert.base64Decode('ChBDbGltYXRlU3dpbmdNb2RlEhUKEUNMSU1BVEVfU1dJTkdfT0ZGEAASFgoSQ0xJTUFURV9TV0lOR19CT1RIEAESGgoWQ0xJTUFURV9TV0lOR19WRVJUSUNBTBACEhwKGENMSU1BVEVfU1dJTkdfSE9SSVpPTlRBTBAD'); -@$core.Deprecated('Use climateActionDescriptor instead') -const ClimateAction$json = const { - '1': 'ClimateAction', - '2': const [ - const {'1': 'CLIMATE_ACTION_OFF', '2': 0}, - const {'1': 'CLIMATE_ACTION_COOLING', '2': 2}, - const {'1': 'CLIMATE_ACTION_HEATING', '2': 3}, - const {'1': 'CLIMATE_ACTION_IDLE', '2': 4}, - const {'1': 'CLIMATE_ACTION_DRYING', '2': 5}, - const {'1': 'CLIMATE_ACTION_FAN', '2': 6}, - ], -}; - -/// Descriptor for `ClimateAction`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List climateActionDescriptor = $convert.base64Decode('Cg1DbGltYXRlQWN0aW9uEhYKEkNMSU1BVEVfQUNUSU9OX09GRhAAEhoKFkNMSU1BVEVfQUNUSU9OX0NPT0xJTkcQAhIaChZDTElNQVRFX0FDVElPTl9IRUFUSU5HEAMSFwoTQ0xJTUFURV9BQ1RJT05fSURMRRAEEhkKFUNMSU1BVEVfQUNUSU9OX0RSWUlORxAFEhYKEkNMSU1BVEVfQUNUSU9OX0ZBThAG'); -@$core.Deprecated('Use climatePresetDescriptor instead') -const ClimatePreset$json = const { - '1': 'ClimatePreset', - '2': const [ - const {'1': 'CLIMATE_PRESET_NONE', '2': 0}, - const {'1': 'CLIMATE_PRESET_HOME', '2': 1}, - const {'1': 'CLIMATE_PRESET_AWAY', '2': 2}, - const {'1': 'CLIMATE_PRESET_BOOST', '2': 3}, - const {'1': 'CLIMATE_PRESET_COMFORT', '2': 4}, - const {'1': 'CLIMATE_PRESET_ECO', '2': 5}, - const {'1': 'CLIMATE_PRESET_SLEEP', '2': 6}, - const {'1': 'CLIMATE_PRESET_ACTIVITY', '2': 7}, - ], -}; - -/// Descriptor for `ClimatePreset`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List climatePresetDescriptor = $convert.base64Decode('Cg1DbGltYXRlUHJlc2V0EhcKE0NMSU1BVEVfUFJFU0VUX05PTkUQABIXChNDTElNQVRFX1BSRVNFVF9IT01FEAESFwoTQ0xJTUFURV9QUkVTRVRfQVdBWRACEhgKFENMSU1BVEVfUFJFU0VUX0JPT1NUEAMSGgoWQ0xJTUFURV9QUkVTRVRfQ09NRk9SVBAEEhYKEkNMSU1BVEVfUFJFU0VUX0VDTxAFEhgKFENMSU1BVEVfUFJFU0VUX1NMRUVQEAYSGwoXQ0xJTUFURV9QUkVTRVRfQUNUSVZJVFkQBw=='); -@$core.Deprecated('Use helloRequestDescriptor instead') -const HelloRequest$json = const { - '1': 'HelloRequest', - '2': const [ - const {'1': 'client_info', '3': 1, '4': 1, '5': 9, '10': 'clientInfo'}, - ], - '7': const {}, -}; - -/// Descriptor for `HelloRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List helloRequestDescriptor = $convert.base64Decode('CgxIZWxsb1JlcXVlc3QSHwoLY2xpZW50X2luZm8YASABKAlSCmNsaWVudEluZm86CeBAAehAAoBBAQ=='); -@$core.Deprecated('Use helloResponseDescriptor instead') -const HelloResponse$json = const { - '1': 'HelloResponse', - '2': const [ - const {'1': 'api_version_major', '3': 1, '4': 1, '5': 13, '10': 'apiVersionMajor'}, - const {'1': 'api_version_minor', '3': 2, '4': 1, '5': 13, '10': 'apiVersionMinor'}, - const {'1': 'server_info', '3': 3, '4': 1, '5': 9, '10': 'serverInfo'}, - ], - '7': const {}, -}; - -/// Descriptor for `HelloResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List helloResponseDescriptor = $convert.base64Decode('Cg1IZWxsb1Jlc3BvbnNlEioKEWFwaV92ZXJzaW9uX21ham9yGAEgASgNUg9hcGlWZXJzaW9uTWFqb3ISKgoRYXBpX3ZlcnNpb25fbWlub3IYAiABKA1SD2FwaVZlcnNpb25NaW5vchIfCgtzZXJ2ZXJfaW5mbxgDIAEoCVIKc2VydmVySW5mbzoJ4EAC6EABgEEB'); -@$core.Deprecated('Use connectRequestDescriptor instead') -const ConnectRequest$json = const { - '1': 'ConnectRequest', - '2': const [ - const {'1': 'password', '3': 1, '4': 1, '5': 9, '10': 'password'}, - ], - '7': const {}, -}; - -/// Descriptor for `ConnectRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List connectRequestDescriptor = $convert.base64Decode('Cg5Db25uZWN0UmVxdWVzdBIaCghwYXNzd29yZBgBIAEoCVIIcGFzc3dvcmQ6CeBAA+hAAoBBAQ=='); -@$core.Deprecated('Use connectResponseDescriptor instead') -const ConnectResponse$json = const { - '1': 'ConnectResponse', - '2': const [ - const {'1': 'invalid_password', '3': 1, '4': 1, '5': 8, '10': 'invalidPassword'}, - ], - '7': const {}, -}; - -/// Descriptor for `ConnectResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List connectResponseDescriptor = $convert.base64Decode('Cg9Db25uZWN0UmVzcG9uc2USKQoQaW52YWxpZF9wYXNzd29yZBgBIAEoCFIPaW52YWxpZFBhc3N3b3JkOgngQAToQAGAQQE='); -@$core.Deprecated('Use disconnectRequestDescriptor instead') -const DisconnectRequest$json = const { - '1': 'DisconnectRequest', - '7': const {}, -}; - -/// Descriptor for `DisconnectRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List disconnectRequestDescriptor = $convert.base64Decode('ChFEaXNjb25uZWN0UmVxdWVzdDoJ4EAF6EAAgEEB'); -@$core.Deprecated('Use disconnectResponseDescriptor instead') -const DisconnectResponse$json = const { - '1': 'DisconnectResponse', - '7': const {}, -}; - -/// Descriptor for `DisconnectResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List disconnectResponseDescriptor = $convert.base64Decode('ChJEaXNjb25uZWN0UmVzcG9uc2U6CeBABuhAAIBBAQ=='); -@$core.Deprecated('Use pingRequestDescriptor instead') -const PingRequest$json = const { - '1': 'PingRequest', - '7': const {}, -}; - -/// Descriptor for `PingRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List pingRequestDescriptor = $convert.base64Decode('CgtQaW5nUmVxdWVzdDoG4EAH6EAA'); -@$core.Deprecated('Use pingResponseDescriptor instead') -const PingResponse$json = const { - '1': 'PingResponse', - '7': const {}, -}; - -/// Descriptor for `PingResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List pingResponseDescriptor = $convert.base64Decode('CgxQaW5nUmVzcG9uc2U6BuBACOhAAA=='); -@$core.Deprecated('Use deviceInfoRequestDescriptor instead') -const DeviceInfoRequest$json = const { - '1': 'DeviceInfoRequest', - '7': const {}, -}; - -/// Descriptor for `DeviceInfoRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List deviceInfoRequestDescriptor = $convert.base64Decode('ChFEZXZpY2VJbmZvUmVxdWVzdDoG4EAJ6EAC'); -@$core.Deprecated('Use deviceInfoResponseDescriptor instead') -const DeviceInfoResponse$json = const { - '1': 'DeviceInfoResponse', - '2': const [ - const {'1': 'uses_password', '3': 1, '4': 1, '5': 8, '10': 'usesPassword'}, - const {'1': 'name', '3': 2, '4': 1, '5': 9, '10': 'name'}, - const {'1': 'mac_address', '3': 3, '4': 1, '5': 9, '10': 'macAddress'}, - const {'1': 'esphome_version', '3': 4, '4': 1, '5': 9, '10': 'esphomeVersion'}, - const {'1': 'compilation_time', '3': 5, '4': 1, '5': 9, '10': 'compilationTime'}, - const {'1': 'model', '3': 6, '4': 1, '5': 9, '10': 'model'}, - const {'1': 'has_deep_sleep', '3': 7, '4': 1, '5': 8, '10': 'hasDeepSleep'}, - const {'1': 'project_name', '3': 8, '4': 1, '5': 9, '10': 'projectName'}, - const {'1': 'project_version', '3': 9, '4': 1, '5': 9, '10': 'projectVersion'}, - ], - '7': const {}, -}; - -/// Descriptor for `DeviceInfoResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List deviceInfoResponseDescriptor = $convert.base64Decode('ChJEZXZpY2VJbmZvUmVzcG9uc2USIwoNdXNlc19wYXNzd29yZBgBIAEoCFIMdXNlc1Bhc3N3b3JkEhIKBG5hbWUYAiABKAlSBG5hbWUSHwoLbWFjX2FkZHJlc3MYAyABKAlSCm1hY0FkZHJlc3MSJwoPZXNwaG9tZV92ZXJzaW9uGAQgASgJUg5lc3Bob21lVmVyc2lvbhIpChBjb21waWxhdGlvbl90aW1lGAUgASgJUg9jb21waWxhdGlvblRpbWUSFAoFbW9kZWwYBiABKAlSBW1vZGVsEiQKDmhhc19kZWVwX3NsZWVwGAcgASgIUgxoYXNEZWVwU2xlZXASIQoMcHJvamVjdF9uYW1lGAggASgJUgtwcm9qZWN0TmFtZRInCg9wcm9qZWN0X3ZlcnNpb24YCSABKAlSDnByb2plY3RWZXJzaW9uOgbgQAroQAE='); -@$core.Deprecated('Use listEntitiesRequestDescriptor instead') -const ListEntitiesRequest$json = const { - '1': 'ListEntitiesRequest', - '7': const {}, -}; - -/// Descriptor for `ListEntitiesRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List listEntitiesRequestDescriptor = $convert.base64Decode('ChNMaXN0RW50aXRpZXNSZXF1ZXN0OgbgQAvoQAI='); -@$core.Deprecated('Use listEntitiesDoneResponseDescriptor instead') -const ListEntitiesDoneResponse$json = const { - '1': 'ListEntitiesDoneResponse', - '7': const {}, -}; - -/// Descriptor for `ListEntitiesDoneResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List listEntitiesDoneResponseDescriptor = $convert.base64Decode('ChhMaXN0RW50aXRpZXNEb25lUmVzcG9uc2U6CeBAE+hAAYBBAQ=='); -@$core.Deprecated('Use subscribeStatesRequestDescriptor instead') -const SubscribeStatesRequest$json = const { - '1': 'SubscribeStatesRequest', - '7': const {}, -}; - -/// Descriptor for `SubscribeStatesRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List subscribeStatesRequestDescriptor = $convert.base64Decode('ChZTdWJzY3JpYmVTdGF0ZXNSZXF1ZXN0OgbgQBToQAI='); -@$core.Deprecated('Use listEntitiesBinarySensorResponseDescriptor instead') -const ListEntitiesBinarySensorResponse$json = const { - '1': 'ListEntitiesBinarySensorResponse', - '2': const [ - const {'1': 'object_id', '3': 1, '4': 1, '5': 9, '10': 'objectId'}, - const {'1': 'key', '3': 2, '4': 1, '5': 7, '10': 'key'}, - const {'1': 'name', '3': 3, '4': 1, '5': 9, '10': 'name'}, - const {'1': 'unique_id', '3': 4, '4': 1, '5': 9, '10': 'uniqueId'}, - const {'1': 'device_class', '3': 5, '4': 1, '5': 9, '10': 'deviceClass'}, - const {'1': 'is_status_binary_sensor', '3': 6, '4': 1, '5': 8, '10': 'isStatusBinarySensor'}, - ], - '7': const {}, -}; - -/// Descriptor for `ListEntitiesBinarySensorResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List listEntitiesBinarySensorResponseDescriptor = $convert.base64Decode('CiBMaXN0RW50aXRpZXNCaW5hcnlTZW5zb3JSZXNwb25zZRIbCglvYmplY3RfaWQYASABKAlSCG9iamVjdElkEhAKA2tleRgCIAEoB1IDa2V5EhIKBG5hbWUYAyABKAlSBG5hbWUSGwoJdW5pcXVlX2lkGAQgASgJUgh1bmlxdWVJZBIhCgxkZXZpY2VfY2xhc3MYBSABKAlSC2RldmljZUNsYXNzEjUKF2lzX3N0YXR1c19iaW5hcnlfc2Vuc29yGAYgASgIUhRpc1N0YXR1c0JpbmFyeVNlbnNvcjoa4EAM6EAB8kARVVNFX0JJTkFSWV9TRU5TT1I='); -@$core.Deprecated('Use binarySensorStateResponseDescriptor instead') -const BinarySensorStateResponse$json = const { - '1': 'BinarySensorStateResponse', - '2': const [ - const {'1': 'key', '3': 1, '4': 1, '5': 7, '10': 'key'}, - const {'1': 'state', '3': 2, '4': 1, '5': 8, '10': 'state'}, - const {'1': 'missing_state', '3': 3, '4': 1, '5': 8, '10': 'missingState'}, - ], - '7': const {}, -}; - -/// Descriptor for `BinarySensorStateResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List binarySensorStateResponseDescriptor = $convert.base64Decode('ChlCaW5hcnlTZW5zb3JTdGF0ZVJlc3BvbnNlEhAKA2tleRgBIAEoB1IDa2V5EhQKBXN0YXRlGAIgASgIUgVzdGF0ZRIjCg1taXNzaW5nX3N0YXRlGAMgASgIUgxtaXNzaW5nU3RhdGU6HeBAFehAAfJAEVVTRV9CSU5BUllfU0VOU09SgEEB'); -@$core.Deprecated('Use listEntitiesCoverResponseDescriptor instead') -const ListEntitiesCoverResponse$json = const { - '1': 'ListEntitiesCoverResponse', - '2': const [ - const {'1': 'object_id', '3': 1, '4': 1, '5': 9, '10': 'objectId'}, - const {'1': 'key', '3': 2, '4': 1, '5': 7, '10': 'key'}, - const {'1': 'name', '3': 3, '4': 1, '5': 9, '10': 'name'}, - const {'1': 'unique_id', '3': 4, '4': 1, '5': 9, '10': 'uniqueId'}, - const {'1': 'assumed_state', '3': 5, '4': 1, '5': 8, '10': 'assumedState'}, - const {'1': 'supports_position', '3': 6, '4': 1, '5': 8, '10': 'supportsPosition'}, - const {'1': 'supports_tilt', '3': 7, '4': 1, '5': 8, '10': 'supportsTilt'}, - const {'1': 'device_class', '3': 8, '4': 1, '5': 9, '10': 'deviceClass'}, - ], - '7': const {}, -}; - -/// Descriptor for `ListEntitiesCoverResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List listEntitiesCoverResponseDescriptor = $convert.base64Decode('ChlMaXN0RW50aXRpZXNDb3ZlclJlc3BvbnNlEhsKCW9iamVjdF9pZBgBIAEoCVIIb2JqZWN0SWQSEAoDa2V5GAIgASgHUgNrZXkSEgoEbmFtZRgDIAEoCVIEbmFtZRIbCgl1bmlxdWVfaWQYBCABKAlSCHVuaXF1ZUlkEiMKDWFzc3VtZWRfc3RhdGUYBSABKAhSDGFzc3VtZWRTdGF0ZRIrChFzdXBwb3J0c19wb3NpdGlvbhgGIAEoCFIQc3VwcG9ydHNQb3NpdGlvbhIjCg1zdXBwb3J0c190aWx0GAcgASgIUgxzdXBwb3J0c1RpbHQSIQoMZGV2aWNlX2NsYXNzGAggASgJUgtkZXZpY2VDbGFzczoS4EAN6EAB8kAJVVNFX0NPVkVS'); -@$core.Deprecated('Use coverStateResponseDescriptor instead') -const CoverStateResponse$json = const { - '1': 'CoverStateResponse', - '2': const [ - const {'1': 'key', '3': 1, '4': 1, '5': 7, '10': 'key'}, - const {'1': 'legacy_state', '3': 2, '4': 1, '5': 14, '6': '.LegacyCoverState', '10': 'legacyState'}, - const {'1': 'position', '3': 3, '4': 1, '5': 2, '10': 'position'}, - const {'1': 'tilt', '3': 4, '4': 1, '5': 2, '10': 'tilt'}, - const {'1': 'current_operation', '3': 5, '4': 1, '5': 14, '6': '.CoverOperation', '10': 'currentOperation'}, - ], - '7': const {}, -}; - -/// Descriptor for `CoverStateResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List coverStateResponseDescriptor = $convert.base64Decode('ChJDb3ZlclN0YXRlUmVzcG9uc2USEAoDa2V5GAEgASgHUgNrZXkSNAoMbGVnYWN5X3N0YXRlGAIgASgOMhEuTGVnYWN5Q292ZXJTdGF0ZVILbGVnYWN5U3RhdGUSGgoIcG9zaXRpb24YAyABKAJSCHBvc2l0aW9uEhIKBHRpbHQYBCABKAJSBHRpbHQSPAoRY3VycmVudF9vcGVyYXRpb24YBSABKA4yDy5Db3Zlck9wZXJhdGlvblIQY3VycmVudE9wZXJhdGlvbjoV4EAW6EAB8kAJVVNFX0NPVkVSgEEB'); -@$core.Deprecated('Use coverCommandRequestDescriptor instead') -const CoverCommandRequest$json = const { - '1': 'CoverCommandRequest', - '2': const [ - const {'1': 'key', '3': 1, '4': 1, '5': 7, '10': 'key'}, - const {'1': 'has_legacy_command', '3': 2, '4': 1, '5': 8, '10': 'hasLegacyCommand'}, - const {'1': 'legacy_command', '3': 3, '4': 1, '5': 14, '6': '.LegacyCoverCommand', '10': 'legacyCommand'}, - const {'1': 'has_position', '3': 4, '4': 1, '5': 8, '10': 'hasPosition'}, - const {'1': 'position', '3': 5, '4': 1, '5': 2, '10': 'position'}, - const {'1': 'has_tilt', '3': 6, '4': 1, '5': 8, '10': 'hasTilt'}, - const {'1': 'tilt', '3': 7, '4': 1, '5': 2, '10': 'tilt'}, - const {'1': 'stop', '3': 8, '4': 1, '5': 8, '10': 'stop'}, - ], - '7': const {}, -}; - -/// Descriptor for `CoverCommandRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List coverCommandRequestDescriptor = $convert.base64Decode('ChNDb3ZlckNvbW1hbmRSZXF1ZXN0EhAKA2tleRgBIAEoB1IDa2V5EiwKEmhhc19sZWdhY3lfY29tbWFuZBgCIAEoCFIQaGFzTGVnYWN5Q29tbWFuZBI6Cg5sZWdhY3lfY29tbWFuZBgDIAEoDjITLkxlZ2FjeUNvdmVyQ29tbWFuZFINbGVnYWN5Q29tbWFuZBIhCgxoYXNfcG9zaXRpb24YBCABKAhSC2hhc1Bvc2l0aW9uEhoKCHBvc2l0aW9uGAUgASgCUghwb3NpdGlvbhIZCghoYXNfdGlsdBgGIAEoCFIHaGFzVGlsdBISCgR0aWx0GAcgASgCUgR0aWx0EhIKBHN0b3AYCCABKAhSBHN0b3A6FeBAHuhAAvJACVVTRV9DT1ZFUoBBAQ=='); -@$core.Deprecated('Use listEntitiesFanResponseDescriptor instead') -const ListEntitiesFanResponse$json = const { - '1': 'ListEntitiesFanResponse', - '2': const [ - const {'1': 'object_id', '3': 1, '4': 1, '5': 9, '10': 'objectId'}, - const {'1': 'key', '3': 2, '4': 1, '5': 7, '10': 'key'}, - const {'1': 'name', '3': 3, '4': 1, '5': 9, '10': 'name'}, - const {'1': 'unique_id', '3': 4, '4': 1, '5': 9, '10': 'uniqueId'}, - const {'1': 'supports_oscillation', '3': 5, '4': 1, '5': 8, '10': 'supportsOscillation'}, - const {'1': 'supports_speed', '3': 6, '4': 1, '5': 8, '10': 'supportsSpeed'}, - const {'1': 'supports_direction', '3': 7, '4': 1, '5': 8, '10': 'supportsDirection'}, - const {'1': 'supported_speed_levels', '3': 8, '4': 1, '5': 5, '10': 'supportedSpeedLevels'}, - ], - '7': const {}, -}; - -/// Descriptor for `ListEntitiesFanResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List listEntitiesFanResponseDescriptor = $convert.base64Decode('ChdMaXN0RW50aXRpZXNGYW5SZXNwb25zZRIbCglvYmplY3RfaWQYASABKAlSCG9iamVjdElkEhAKA2tleRgCIAEoB1IDa2V5EhIKBG5hbWUYAyABKAlSBG5hbWUSGwoJdW5pcXVlX2lkGAQgASgJUgh1bmlxdWVJZBIxChRzdXBwb3J0c19vc2NpbGxhdGlvbhgFIAEoCFITc3VwcG9ydHNPc2NpbGxhdGlvbhIlCg5zdXBwb3J0c19zcGVlZBgGIAEoCFINc3VwcG9ydHNTcGVlZBItChJzdXBwb3J0c19kaXJlY3Rpb24YByABKAhSEXN1cHBvcnRzRGlyZWN0aW9uEjQKFnN1cHBvcnRlZF9zcGVlZF9sZXZlbHMYCCABKAVSFHN1cHBvcnRlZFNwZWVkTGV2ZWxzOhDgQA7oQAHyQAdVU0VfRkFO'); -@$core.Deprecated('Use fanStateResponseDescriptor instead') -const FanStateResponse$json = const { - '1': 'FanStateResponse', - '2': const [ - const {'1': 'key', '3': 1, '4': 1, '5': 7, '10': 'key'}, - const {'1': 'state', '3': 2, '4': 1, '5': 8, '10': 'state'}, - const {'1': 'oscillating', '3': 3, '4': 1, '5': 8, '10': 'oscillating'}, - const { - '1': 'speed', - '3': 4, - '4': 1, - '5': 14, - '6': '.FanSpeed', - '8': const {'3': true}, - '10': 'speed', - }, - const {'1': 'direction', '3': 5, '4': 1, '5': 14, '6': '.FanDirection', '10': 'direction'}, - const {'1': 'speed_level', '3': 6, '4': 1, '5': 5, '10': 'speedLevel'}, - ], - '7': const {}, -}; - -/// Descriptor for `FanStateResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List fanStateResponseDescriptor = $convert.base64Decode('ChBGYW5TdGF0ZVJlc3BvbnNlEhAKA2tleRgBIAEoB1IDa2V5EhQKBXN0YXRlGAIgASgIUgVzdGF0ZRIgCgtvc2NpbGxhdGluZxgDIAEoCFILb3NjaWxsYXRpbmcSIwoFc3BlZWQYBCABKA4yCS5GYW5TcGVlZEICGAFSBXNwZWVkEisKCWRpcmVjdGlvbhgFIAEoDjINLkZhbkRpcmVjdGlvblIJZGlyZWN0aW9uEh8KC3NwZWVkX2xldmVsGAYgASgFUgpzcGVlZExldmVsOhPgQBfoQAHyQAdVU0VfRkFOgEEB'); -@$core.Deprecated('Use fanCommandRequestDescriptor instead') -const FanCommandRequest$json = const { - '1': 'FanCommandRequest', - '2': const [ - const {'1': 'key', '3': 1, '4': 1, '5': 7, '10': 'key'}, - const {'1': 'has_state', '3': 2, '4': 1, '5': 8, '10': 'hasState'}, - const {'1': 'state', '3': 3, '4': 1, '5': 8, '10': 'state'}, - const { - '1': 'has_speed', - '3': 4, - '4': 1, - '5': 8, - '8': const {'3': true}, - '10': 'hasSpeed', - }, - const { - '1': 'speed', - '3': 5, - '4': 1, - '5': 14, - '6': '.FanSpeed', - '8': const {'3': true}, - '10': 'speed', - }, - const {'1': 'has_oscillating', '3': 6, '4': 1, '5': 8, '10': 'hasOscillating'}, - const {'1': 'oscillating', '3': 7, '4': 1, '5': 8, '10': 'oscillating'}, - const {'1': 'has_direction', '3': 8, '4': 1, '5': 8, '10': 'hasDirection'}, - const {'1': 'direction', '3': 9, '4': 1, '5': 14, '6': '.FanDirection', '10': 'direction'}, - const {'1': 'has_speed_level', '3': 10, '4': 1, '5': 8, '10': 'hasSpeedLevel'}, - const {'1': 'speed_level', '3': 11, '4': 1, '5': 5, '10': 'speedLevel'}, - ], - '7': const {}, -}; - -/// Descriptor for `FanCommandRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List fanCommandRequestDescriptor = $convert.base64Decode('ChFGYW5Db21tYW5kUmVxdWVzdBIQCgNrZXkYASABKAdSA2tleRIbCgloYXNfc3RhdGUYAiABKAhSCGhhc1N0YXRlEhQKBXN0YXRlGAMgASgIUgVzdGF0ZRIfCgloYXNfc3BlZWQYBCABKAhCAhgBUghoYXNTcGVlZBIjCgVzcGVlZBgFIAEoDjIJLkZhblNwZWVkQgIYAVIFc3BlZWQSJwoPaGFzX29zY2lsbGF0aW5nGAYgASgIUg5oYXNPc2NpbGxhdGluZxIgCgtvc2NpbGxhdGluZxgHIAEoCFILb3NjaWxsYXRpbmcSIwoNaGFzX2RpcmVjdGlvbhgIIAEoCFIMaGFzRGlyZWN0aW9uEisKCWRpcmVjdGlvbhgJIAEoDjINLkZhbkRpcmVjdGlvblIJZGlyZWN0aW9uEiYKD2hhc19zcGVlZF9sZXZlbBgKIAEoCFINaGFzU3BlZWRMZXZlbBIfCgtzcGVlZF9sZXZlbBgLIAEoBVIKc3BlZWRMZXZlbDoT4EAf6EAC8kAHVVNFX0ZBToBBAQ=='); -@$core.Deprecated('Use listEntitiesLightResponseDescriptor instead') -const ListEntitiesLightResponse$json = const { - '1': 'ListEntitiesLightResponse', - '2': const [ - const {'1': 'object_id', '3': 1, '4': 1, '5': 9, '10': 'objectId'}, - const {'1': 'key', '3': 2, '4': 1, '5': 7, '10': 'key'}, - const {'1': 'name', '3': 3, '4': 1, '5': 9, '10': 'name'}, - const {'1': 'unique_id', '3': 4, '4': 1, '5': 9, '10': 'uniqueId'}, - const {'1': 'supports_brightness', '3': 5, '4': 1, '5': 8, '10': 'supportsBrightness'}, - const {'1': 'supports_rgb', '3': 6, '4': 1, '5': 8, '10': 'supportsRgb'}, - const {'1': 'supports_white_value', '3': 7, '4': 1, '5': 8, '10': 'supportsWhiteValue'}, - const {'1': 'supports_color_temperature', '3': 8, '4': 1, '5': 8, '10': 'supportsColorTemperature'}, - const {'1': 'min_mireds', '3': 9, '4': 1, '5': 2, '10': 'minMireds'}, - const {'1': 'max_mireds', '3': 10, '4': 1, '5': 2, '10': 'maxMireds'}, - const {'1': 'effects', '3': 11, '4': 3, '5': 9, '10': 'effects'}, - ], - '7': const {}, -}; - -/// Descriptor for `ListEntitiesLightResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List listEntitiesLightResponseDescriptor = $convert.base64Decode('ChlMaXN0RW50aXRpZXNMaWdodFJlc3BvbnNlEhsKCW9iamVjdF9pZBgBIAEoCVIIb2JqZWN0SWQSEAoDa2V5GAIgASgHUgNrZXkSEgoEbmFtZRgDIAEoCVIEbmFtZRIbCgl1bmlxdWVfaWQYBCABKAlSCHVuaXF1ZUlkEi8KE3N1cHBvcnRzX2JyaWdodG5lc3MYBSABKAhSEnN1cHBvcnRzQnJpZ2h0bmVzcxIhCgxzdXBwb3J0c19yZ2IYBiABKAhSC3N1cHBvcnRzUmdiEjAKFHN1cHBvcnRzX3doaXRlX3ZhbHVlGAcgASgIUhJzdXBwb3J0c1doaXRlVmFsdWUSPAoac3VwcG9ydHNfY29sb3JfdGVtcGVyYXR1cmUYCCABKAhSGHN1cHBvcnRzQ29sb3JUZW1wZXJhdHVyZRIdCgptaW5fbWlyZWRzGAkgASgCUgltaW5NaXJlZHMSHQoKbWF4X21pcmVkcxgKIAEoAlIJbWF4TWlyZWRzEhgKB2VmZmVjdHMYCyADKAlSB2VmZmVjdHM6EuBAD+hAAfJACVVTRV9MSUdIVA=='); -@$core.Deprecated('Use lightStateResponseDescriptor instead') -const LightStateResponse$json = const { - '1': 'LightStateResponse', - '2': const [ - const {'1': 'key', '3': 1, '4': 1, '5': 7, '10': 'key'}, - const {'1': 'state', '3': 2, '4': 1, '5': 8, '10': 'state'}, - const {'1': 'brightness', '3': 3, '4': 1, '5': 2, '10': 'brightness'}, - const {'1': 'red', '3': 4, '4': 1, '5': 2, '10': 'red'}, - const {'1': 'green', '3': 5, '4': 1, '5': 2, '10': 'green'}, - const {'1': 'blue', '3': 6, '4': 1, '5': 2, '10': 'blue'}, - const {'1': 'white', '3': 7, '4': 1, '5': 2, '10': 'white'}, - const {'1': 'color_temperature', '3': 8, '4': 1, '5': 2, '10': 'colorTemperature'}, - const {'1': 'effect', '3': 9, '4': 1, '5': 9, '10': 'effect'}, - ], - '7': const {}, -}; - -/// Descriptor for `LightStateResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List lightStateResponseDescriptor = $convert.base64Decode('ChJMaWdodFN0YXRlUmVzcG9uc2USEAoDa2V5GAEgASgHUgNrZXkSFAoFc3RhdGUYAiABKAhSBXN0YXRlEh4KCmJyaWdodG5lc3MYAyABKAJSCmJyaWdodG5lc3MSEAoDcmVkGAQgASgCUgNyZWQSFAoFZ3JlZW4YBSABKAJSBWdyZWVuEhIKBGJsdWUYBiABKAJSBGJsdWUSFAoFd2hpdGUYByABKAJSBXdoaXRlEisKEWNvbG9yX3RlbXBlcmF0dXJlGAggASgCUhBjb2xvclRlbXBlcmF0dXJlEhYKBmVmZmVjdBgJIAEoCVIGZWZmZWN0OhXgQBjoQAHyQAlVU0VfTElHSFSAQQE='); -@$core.Deprecated('Use lightCommandRequestDescriptor instead') -const LightCommandRequest$json = const { - '1': 'LightCommandRequest', - '2': const [ - const {'1': 'key', '3': 1, '4': 1, '5': 7, '10': 'key'}, - const {'1': 'has_state', '3': 2, '4': 1, '5': 8, '10': 'hasState'}, - const {'1': 'state', '3': 3, '4': 1, '5': 8, '10': 'state'}, - const {'1': 'has_brightness', '3': 4, '4': 1, '5': 8, '10': 'hasBrightness'}, - const {'1': 'brightness', '3': 5, '4': 1, '5': 2, '10': 'brightness'}, - const {'1': 'has_rgb', '3': 6, '4': 1, '5': 8, '10': 'hasRgb'}, - const {'1': 'red', '3': 7, '4': 1, '5': 2, '10': 'red'}, - const {'1': 'green', '3': 8, '4': 1, '5': 2, '10': 'green'}, - const {'1': 'blue', '3': 9, '4': 1, '5': 2, '10': 'blue'}, - const {'1': 'has_white', '3': 10, '4': 1, '5': 8, '10': 'hasWhite'}, - const {'1': 'white', '3': 11, '4': 1, '5': 2, '10': 'white'}, - const {'1': 'has_color_temperature', '3': 12, '4': 1, '5': 8, '10': 'hasColorTemperature'}, - const {'1': 'color_temperature', '3': 13, '4': 1, '5': 2, '10': 'colorTemperature'}, - const {'1': 'has_transition_length', '3': 14, '4': 1, '5': 8, '10': 'hasTransitionLength'}, - const {'1': 'transition_length', '3': 15, '4': 1, '5': 13, '10': 'transitionLength'}, - const {'1': 'has_flash_length', '3': 16, '4': 1, '5': 8, '10': 'hasFlashLength'}, - const {'1': 'flash_length', '3': 17, '4': 1, '5': 13, '10': 'flashLength'}, - const {'1': 'has_effect', '3': 18, '4': 1, '5': 8, '10': 'hasEffect'}, - const {'1': 'effect', '3': 19, '4': 1, '5': 9, '10': 'effect'}, - ], - '7': const {}, -}; - -/// Descriptor for `LightCommandRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List lightCommandRequestDescriptor = $convert.base64Decode('ChNMaWdodENvbW1hbmRSZXF1ZXN0EhAKA2tleRgBIAEoB1IDa2V5EhsKCWhhc19zdGF0ZRgCIAEoCFIIaGFzU3RhdGUSFAoFc3RhdGUYAyABKAhSBXN0YXRlEiUKDmhhc19icmlnaHRuZXNzGAQgASgIUg1oYXNCcmlnaHRuZXNzEh4KCmJyaWdodG5lc3MYBSABKAJSCmJyaWdodG5lc3MSFwoHaGFzX3JnYhgGIAEoCFIGaGFzUmdiEhAKA3JlZBgHIAEoAlIDcmVkEhQKBWdyZWVuGAggASgCUgVncmVlbhISCgRibHVlGAkgASgCUgRibHVlEhsKCWhhc193aGl0ZRgKIAEoCFIIaGFzV2hpdGUSFAoFd2hpdGUYCyABKAJSBXdoaXRlEjIKFWhhc19jb2xvcl90ZW1wZXJhdHVyZRgMIAEoCFITaGFzQ29sb3JUZW1wZXJhdHVyZRIrChFjb2xvcl90ZW1wZXJhdHVyZRgNIAEoAlIQY29sb3JUZW1wZXJhdHVyZRIyChVoYXNfdHJhbnNpdGlvbl9sZW5ndGgYDiABKAhSE2hhc1RyYW5zaXRpb25MZW5ndGgSKwoRdHJhbnNpdGlvbl9sZW5ndGgYDyABKA1SEHRyYW5zaXRpb25MZW5ndGgSKAoQaGFzX2ZsYXNoX2xlbmd0aBgQIAEoCFIOaGFzRmxhc2hMZW5ndGgSIQoMZmxhc2hfbGVuZ3RoGBEgASgNUgtmbGFzaExlbmd0aBIdCgpoYXNfZWZmZWN0GBIgASgIUgloYXNFZmZlY3QSFgoGZWZmZWN0GBMgASgJUgZlZmZlY3Q6FeBAIOhAAvJACVVTRV9MSUdIVIBBAQ=='); -@$core.Deprecated('Use listEntitiesSensorResponseDescriptor instead') -const ListEntitiesSensorResponse$json = const { - '1': 'ListEntitiesSensorResponse', - '2': const [ - const {'1': 'object_id', '3': 1, '4': 1, '5': 9, '10': 'objectId'}, - const {'1': 'key', '3': 2, '4': 1, '5': 7, '10': 'key'}, - const {'1': 'name', '3': 3, '4': 1, '5': 9, '10': 'name'}, - const {'1': 'unique_id', '3': 4, '4': 1, '5': 9, '10': 'uniqueId'}, - const {'1': 'icon', '3': 5, '4': 1, '5': 9, '10': 'icon'}, - const {'1': 'unit_of_measurement', '3': 6, '4': 1, '5': 9, '10': 'unitOfMeasurement'}, - const {'1': 'accuracy_decimals', '3': 7, '4': 1, '5': 5, '10': 'accuracyDecimals'}, - const {'1': 'force_update', '3': 8, '4': 1, '5': 8, '10': 'forceUpdate'}, - const {'1': 'device_class', '3': 9, '4': 1, '5': 9, '10': 'deviceClass'}, - const {'1': 'state_class', '3': 10, '4': 1, '5': 14, '6': '.SensorStateClass', '10': 'stateClass'}, - ], - '7': const {}, -}; - -/// Descriptor for `ListEntitiesSensorResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List listEntitiesSensorResponseDescriptor = $convert.base64Decode('ChpMaXN0RW50aXRpZXNTZW5zb3JSZXNwb25zZRIbCglvYmplY3RfaWQYASABKAlSCG9iamVjdElkEhAKA2tleRgCIAEoB1IDa2V5EhIKBG5hbWUYAyABKAlSBG5hbWUSGwoJdW5pcXVlX2lkGAQgASgJUgh1bmlxdWVJZBISCgRpY29uGAUgASgJUgRpY29uEi4KE3VuaXRfb2ZfbWVhc3VyZW1lbnQYBiABKAlSEXVuaXRPZk1lYXN1cmVtZW50EisKEWFjY3VyYWN5X2RlY2ltYWxzGAcgASgFUhBhY2N1cmFjeURlY2ltYWxzEiEKDGZvcmNlX3VwZGF0ZRgIIAEoCFILZm9yY2VVcGRhdGUSIQoMZGV2aWNlX2NsYXNzGAkgASgJUgtkZXZpY2VDbGFzcxIyCgtzdGF0ZV9jbGFzcxgKIAEoDjIRLlNlbnNvclN0YXRlQ2xhc3NSCnN0YXRlQ2xhc3M6E+BAEOhAAfJAClVTRV9TRU5TT1I='); -@$core.Deprecated('Use sensorStateResponseDescriptor instead') -const SensorStateResponse$json = const { - '1': 'SensorStateResponse', - '2': const [ - const {'1': 'key', '3': 1, '4': 1, '5': 7, '10': 'key'}, - const {'1': 'state', '3': 2, '4': 1, '5': 2, '10': 'state'}, - const {'1': 'missing_state', '3': 3, '4': 1, '5': 8, '10': 'missingState'}, - ], - '7': const {}, -}; - -/// Descriptor for `SensorStateResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List sensorStateResponseDescriptor = $convert.base64Decode('ChNTZW5zb3JTdGF0ZVJlc3BvbnNlEhAKA2tleRgBIAEoB1IDa2V5EhQKBXN0YXRlGAIgASgCUgVzdGF0ZRIjCg1taXNzaW5nX3N0YXRlGAMgASgIUgxtaXNzaW5nU3RhdGU6FuBAGehAAfJAClVTRV9TRU5TT1KAQQE='); -@$core.Deprecated('Use listEntitiesSwitchResponseDescriptor instead') -const ListEntitiesSwitchResponse$json = const { - '1': 'ListEntitiesSwitchResponse', - '2': const [ - const {'1': 'object_id', '3': 1, '4': 1, '5': 9, '10': 'objectId'}, - const {'1': 'key', '3': 2, '4': 1, '5': 7, '10': 'key'}, - const {'1': 'name', '3': 3, '4': 1, '5': 9, '10': 'name'}, - const {'1': 'unique_id', '3': 4, '4': 1, '5': 9, '10': 'uniqueId'}, - const {'1': 'icon', '3': 5, '4': 1, '5': 9, '10': 'icon'}, - const {'1': 'assumed_state', '3': 6, '4': 1, '5': 8, '10': 'assumedState'}, - ], - '7': const {}, -}; - -/// Descriptor for `ListEntitiesSwitchResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List listEntitiesSwitchResponseDescriptor = $convert.base64Decode('ChpMaXN0RW50aXRpZXNTd2l0Y2hSZXNwb25zZRIbCglvYmplY3RfaWQYASABKAlSCG9iamVjdElkEhAKA2tleRgCIAEoB1IDa2V5EhIKBG5hbWUYAyABKAlSBG5hbWUSGwoJdW5pcXVlX2lkGAQgASgJUgh1bmlxdWVJZBISCgRpY29uGAUgASgJUgRpY29uEiMKDWFzc3VtZWRfc3RhdGUYBiABKAhSDGFzc3VtZWRTdGF0ZToT4EAR6EAB8kAKVVNFX1NXSVRDSA=='); -@$core.Deprecated('Use switchStateResponseDescriptor instead') -const SwitchStateResponse$json = const { - '1': 'SwitchStateResponse', - '2': const [ - const {'1': 'key', '3': 1, '4': 1, '5': 7, '10': 'key'}, - const {'1': 'state', '3': 2, '4': 1, '5': 8, '10': 'state'}, - ], - '7': const {}, -}; - -/// Descriptor for `SwitchStateResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List switchStateResponseDescriptor = $convert.base64Decode('ChNTd2l0Y2hTdGF0ZVJlc3BvbnNlEhAKA2tleRgBIAEoB1IDa2V5EhQKBXN0YXRlGAIgASgIUgVzdGF0ZToW4EAa6EAB8kAKVVNFX1NXSVRDSIBBAQ=='); -@$core.Deprecated('Use switchCommandRequestDescriptor instead') -const SwitchCommandRequest$json = const { - '1': 'SwitchCommandRequest', - '2': const [ - const {'1': 'key', '3': 1, '4': 1, '5': 7, '10': 'key'}, - const {'1': 'state', '3': 2, '4': 1, '5': 8, '10': 'state'}, - ], - '7': const {}, -}; - -/// Descriptor for `SwitchCommandRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List switchCommandRequestDescriptor = $convert.base64Decode('ChRTd2l0Y2hDb21tYW5kUmVxdWVzdBIQCgNrZXkYASABKAdSA2tleRIUCgVzdGF0ZRgCIAEoCFIFc3RhdGU6FuBAIehAAvJAClVTRV9TV0lUQ0iAQQE='); -@$core.Deprecated('Use listEntitiesTextSensorResponseDescriptor instead') -const ListEntitiesTextSensorResponse$json = const { - '1': 'ListEntitiesTextSensorResponse', - '2': const [ - const {'1': 'object_id', '3': 1, '4': 1, '5': 9, '10': 'objectId'}, - const {'1': 'key', '3': 2, '4': 1, '5': 7, '10': 'key'}, - const {'1': 'name', '3': 3, '4': 1, '5': 9, '10': 'name'}, - const {'1': 'unique_id', '3': 4, '4': 1, '5': 9, '10': 'uniqueId'}, - const {'1': 'icon', '3': 5, '4': 1, '5': 9, '10': 'icon'}, - ], - '7': const {}, -}; - -/// Descriptor for `ListEntitiesTextSensorResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List listEntitiesTextSensorResponseDescriptor = $convert.base64Decode('Ch5MaXN0RW50aXRpZXNUZXh0U2Vuc29yUmVzcG9uc2USGwoJb2JqZWN0X2lkGAEgASgJUghvYmplY3RJZBIQCgNrZXkYAiABKAdSA2tleRISCgRuYW1lGAMgASgJUgRuYW1lEhsKCXVuaXF1ZV9pZBgEIAEoCVIIdW5pcXVlSWQSEgoEaWNvbhgFIAEoCVIEaWNvbjoY4EAS6EAB8kAPVVNFX1RFWFRfU0VOU09S'); -@$core.Deprecated('Use textSensorStateResponseDescriptor instead') -const TextSensorStateResponse$json = const { - '1': 'TextSensorStateResponse', - '2': const [ - const {'1': 'key', '3': 1, '4': 1, '5': 7, '10': 'key'}, - const {'1': 'state', '3': 2, '4': 1, '5': 9, '10': 'state'}, - const {'1': 'missing_state', '3': 3, '4': 1, '5': 8, '10': 'missingState'}, - ], - '7': const {}, -}; - -/// Descriptor for `TextSensorStateResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List textSensorStateResponseDescriptor = $convert.base64Decode('ChdUZXh0U2Vuc29yU3RhdGVSZXNwb25zZRIQCgNrZXkYASABKAdSA2tleRIUCgVzdGF0ZRgCIAEoCVIFc3RhdGUSIwoNbWlzc2luZ19zdGF0ZRgDIAEoCFIMbWlzc2luZ1N0YXRlOhvgQBvoQAHyQA9VU0VfVEVYVF9TRU5TT1KAQQE='); -@$core.Deprecated('Use subscribeLogsRequestDescriptor instead') -const SubscribeLogsRequest$json = const { - '1': 'SubscribeLogsRequest', - '2': const [ - const {'1': 'level', '3': 1, '4': 1, '5': 14, '6': '.LogLevel', '10': 'level'}, - const {'1': 'dump_config', '3': 2, '4': 1, '5': 8, '10': 'dumpConfig'}, - ], - '7': const {}, -}; - -/// Descriptor for `SubscribeLogsRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List subscribeLogsRequestDescriptor = $convert.base64Decode('ChRTdWJzY3JpYmVMb2dzUmVxdWVzdBIfCgVsZXZlbBgBIAEoDjIJLkxvZ0xldmVsUgVsZXZlbBIfCgtkdW1wX2NvbmZpZxgCIAEoCFIKZHVtcENvbmZpZzoG4EAc6EAC'); -@$core.Deprecated('Use subscribeLogsResponseDescriptor instead') -const SubscribeLogsResponse$json = const { - '1': 'SubscribeLogsResponse', - '2': const [ - const {'1': 'level', '3': 1, '4': 1, '5': 14, '6': '.LogLevel', '10': 'level'}, - const {'1': 'tag', '3': 2, '4': 1, '5': 9, '10': 'tag'}, - const {'1': 'message', '3': 3, '4': 1, '5': 9, '10': 'message'}, - const {'1': 'send_failed', '3': 4, '4': 1, '5': 8, '10': 'sendFailed'}, - ], - '7': const {}, -}; - -/// Descriptor for `SubscribeLogsResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List subscribeLogsResponseDescriptor = $convert.base64Decode('ChVTdWJzY3JpYmVMb2dzUmVzcG9uc2USHwoFbGV2ZWwYASABKA4yCS5Mb2dMZXZlbFIFbGV2ZWwSEAoDdGFnGAIgASgJUgN0YWcSGAoHbWVzc2FnZRgDIAEoCVIHbWVzc2FnZRIfCgtzZW5kX2ZhaWxlZBgEIAEoCFIKc2VuZEZhaWxlZDoM4EAd6EAB+EAAgEEA'); -@$core.Deprecated('Use subscribeHomeassistantServicesRequestDescriptor instead') -const SubscribeHomeassistantServicesRequest$json = const { - '1': 'SubscribeHomeassistantServicesRequest', - '7': const {}, -}; - -/// Descriptor for `SubscribeHomeassistantServicesRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List subscribeHomeassistantServicesRequestDescriptor = $convert.base64Decode('CiVTdWJzY3JpYmVIb21lYXNzaXN0YW50U2VydmljZXNSZXF1ZXN0OgbgQCLoQAI='); -@$core.Deprecated('Use homeassistantServiceMapDescriptor instead') -const HomeassistantServiceMap$json = const { - '1': 'HomeassistantServiceMap', - '2': const [ - const {'1': 'key', '3': 1, '4': 1, '5': 9, '10': 'key'}, - const {'1': 'value', '3': 2, '4': 1, '5': 9, '10': 'value'}, - ], -}; - -/// Descriptor for `HomeassistantServiceMap`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List homeassistantServiceMapDescriptor = $convert.base64Decode('ChdIb21lYXNzaXN0YW50U2VydmljZU1hcBIQCgNrZXkYASABKAlSA2tleRIUCgV2YWx1ZRgCIAEoCVIFdmFsdWU='); -@$core.Deprecated('Use homeassistantServiceResponseDescriptor instead') -const HomeassistantServiceResponse$json = const { - '1': 'HomeassistantServiceResponse', - '2': const [ - const {'1': 'service', '3': 1, '4': 1, '5': 9, '10': 'service'}, - const {'1': 'data', '3': 2, '4': 3, '5': 11, '6': '.HomeassistantServiceMap', '10': 'data'}, - const {'1': 'data_template', '3': 3, '4': 3, '5': 11, '6': '.HomeassistantServiceMap', '10': 'dataTemplate'}, - const {'1': 'variables', '3': 4, '4': 3, '5': 11, '6': '.HomeassistantServiceMap', '10': 'variables'}, - const {'1': 'is_event', '3': 5, '4': 1, '5': 8, '10': 'isEvent'}, - ], - '7': const {}, -}; - -/// Descriptor for `HomeassistantServiceResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List homeassistantServiceResponseDescriptor = $convert.base64Decode('ChxIb21lYXNzaXN0YW50U2VydmljZVJlc3BvbnNlEhgKB3NlcnZpY2UYASABKAlSB3NlcnZpY2USLAoEZGF0YRgCIAMoCzIYLkhvbWVhc3Npc3RhbnRTZXJ2aWNlTWFwUgRkYXRhEj0KDWRhdGFfdGVtcGxhdGUYAyADKAsyGC5Ib21lYXNzaXN0YW50U2VydmljZU1hcFIMZGF0YVRlbXBsYXRlEjYKCXZhcmlhYmxlcxgEIAMoCzIYLkhvbWVhc3Npc3RhbnRTZXJ2aWNlTWFwUgl2YXJpYWJsZXMSGQoIaXNfZXZlbnQYBSABKAhSB2lzRXZlbnQ6CeBAI+hAAYBBAQ=='); -@$core.Deprecated('Use subscribeHomeAssistantStatesRequestDescriptor instead') -const SubscribeHomeAssistantStatesRequest$json = const { - '1': 'SubscribeHomeAssistantStatesRequest', - '7': const {}, -}; - -/// Descriptor for `SubscribeHomeAssistantStatesRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List subscribeHomeAssistantStatesRequestDescriptor = $convert.base64Decode('CiNTdWJzY3JpYmVIb21lQXNzaXN0YW50U3RhdGVzUmVxdWVzdDoG4EAm6EAC'); -@$core.Deprecated('Use subscribeHomeAssistantStateResponseDescriptor instead') -const SubscribeHomeAssistantStateResponse$json = const { - '1': 'SubscribeHomeAssistantStateResponse', - '2': const [ - const {'1': 'entity_id', '3': 1, '4': 1, '5': 9, '10': 'entityId'}, - const {'1': 'attribute', '3': 2, '4': 1, '5': 9, '10': 'attribute'}, - ], - '7': const {}, -}; - -/// Descriptor for `SubscribeHomeAssistantStateResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List subscribeHomeAssistantStateResponseDescriptor = $convert.base64Decode('CiNTdWJzY3JpYmVIb21lQXNzaXN0YW50U3RhdGVSZXNwb25zZRIbCgllbnRpdHlfaWQYASABKAlSCGVudGl0eUlkEhwKCWF0dHJpYnV0ZRgCIAEoCVIJYXR0cmlidXRlOgbgQCfoQAE='); -@$core.Deprecated('Use homeAssistantStateResponseDescriptor instead') -const HomeAssistantStateResponse$json = const { - '1': 'HomeAssistantStateResponse', - '2': const [ - const {'1': 'entity_id', '3': 1, '4': 1, '5': 9, '10': 'entityId'}, - const {'1': 'state', '3': 2, '4': 1, '5': 9, '10': 'state'}, - const {'1': 'attribute', '3': 3, '4': 1, '5': 9, '10': 'attribute'}, - ], - '7': const {}, -}; - -/// Descriptor for `HomeAssistantStateResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List homeAssistantStateResponseDescriptor = $convert.base64Decode('ChpIb21lQXNzaXN0YW50U3RhdGVSZXNwb25zZRIbCgllbnRpdHlfaWQYASABKAlSCGVudGl0eUlkEhQKBXN0YXRlGAIgASgJUgVzdGF0ZRIcCglhdHRyaWJ1dGUYAyABKAlSCWF0dHJpYnV0ZToJ4EAo6EACgEEB'); -@$core.Deprecated('Use getTimeRequestDescriptor instead') -const GetTimeRequest$json = const { - '1': 'GetTimeRequest', - '7': const {}, -}; - -/// Descriptor for `GetTimeRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List getTimeRequestDescriptor = $convert.base64Decode('Cg5HZXRUaW1lUmVxdWVzdDoG4EAk6EAA'); -@$core.Deprecated('Use getTimeResponseDescriptor instead') -const GetTimeResponse$json = const { - '1': 'GetTimeResponse', - '2': const [ - const {'1': 'epoch_seconds', '3': 1, '4': 1, '5': 7, '10': 'epochSeconds'}, - ], - '7': const {}, -}; - -/// Descriptor for `GetTimeResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List getTimeResponseDescriptor = $convert.base64Decode('Cg9HZXRUaW1lUmVzcG9uc2USIwoNZXBvY2hfc2Vjb25kcxgBIAEoB1IMZXBvY2hTZWNvbmRzOgngQCXoQACAQQE='); -@$core.Deprecated('Use listEntitiesServicesArgumentDescriptor instead') -const ListEntitiesServicesArgument$json = const { - '1': 'ListEntitiesServicesArgument', - '2': const [ - const {'1': 'name', '3': 1, '4': 1, '5': 9, '10': 'name'}, - const {'1': 'type', '3': 2, '4': 1, '5': 14, '6': '.ServiceArgType', '10': 'type'}, - ], -}; - -/// Descriptor for `ListEntitiesServicesArgument`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List listEntitiesServicesArgumentDescriptor = $convert.base64Decode('ChxMaXN0RW50aXRpZXNTZXJ2aWNlc0FyZ3VtZW50EhIKBG5hbWUYASABKAlSBG5hbWUSIwoEdHlwZRgCIAEoDjIPLlNlcnZpY2VBcmdUeXBlUgR0eXBl'); -@$core.Deprecated('Use listEntitiesServicesResponseDescriptor instead') -const ListEntitiesServicesResponse$json = const { - '1': 'ListEntitiesServicesResponse', - '2': const [ - const {'1': 'name', '3': 1, '4': 1, '5': 9, '10': 'name'}, - const {'1': 'key', '3': 2, '4': 1, '5': 7, '10': 'key'}, - const {'1': 'args', '3': 3, '4': 3, '5': 11, '6': '.ListEntitiesServicesArgument', '10': 'args'}, - ], - '7': const {}, -}; - -/// Descriptor for `ListEntitiesServicesResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List listEntitiesServicesResponseDescriptor = $convert.base64Decode('ChxMaXN0RW50aXRpZXNTZXJ2aWNlc1Jlc3BvbnNlEhIKBG5hbWUYASABKAlSBG5hbWUSEAoDa2V5GAIgASgHUgNrZXkSMQoEYXJncxgDIAMoCzIdLkxpc3RFbnRpdGllc1NlcnZpY2VzQXJndW1lbnRSBGFyZ3M6BuBAKehAAQ=='); -@$core.Deprecated('Use executeServiceArgumentDescriptor instead') -const ExecuteServiceArgument$json = const { - '1': 'ExecuteServiceArgument', - '2': const [ - const {'1': 'bool_', '3': 1, '4': 1, '5': 8, '10': 'bool'}, - const {'1': 'legacy_int', '3': 2, '4': 1, '5': 5, '10': 'legacyInt'}, - const {'1': 'float_', '3': 3, '4': 1, '5': 2, '10': 'float'}, - const {'1': 'string_', '3': 4, '4': 1, '5': 9, '10': 'string'}, - const {'1': 'int_', '3': 5, '4': 1, '5': 17, '10': 'int'}, - const { - '1': 'bool_array', - '3': 6, - '4': 3, - '5': 8, - '8': const {'2': false}, - '10': 'boolArray', - }, - const { - '1': 'int_array', - '3': 7, - '4': 3, - '5': 17, - '8': const {'2': false}, - '10': 'intArray', - }, - const { - '1': 'float_array', - '3': 8, - '4': 3, - '5': 2, - '8': const {'2': false}, - '10': 'floatArray', - }, - const {'1': 'string_array', '3': 9, '4': 3, '5': 9, '10': 'stringArray'}, - ], -}; - -/// Descriptor for `ExecuteServiceArgument`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List executeServiceArgumentDescriptor = $convert.base64Decode('ChZFeGVjdXRlU2VydmljZUFyZ3VtZW50EhMKBWJvb2xfGAEgASgIUgRib29sEh0KCmxlZ2FjeV9pbnQYAiABKAVSCWxlZ2FjeUludBIVCgZmbG9hdF8YAyABKAJSBWZsb2F0EhcKB3N0cmluZ18YBCABKAlSBnN0cmluZxIRCgRpbnRfGAUgASgRUgNpbnQSIQoKYm9vbF9hcnJheRgGIAMoCEICEABSCWJvb2xBcnJheRIfCglpbnRfYXJyYXkYByADKBFCAhAAUghpbnRBcnJheRIjCgtmbG9hdF9hcnJheRgIIAMoAkICEABSCmZsb2F0QXJyYXkSIQoMc3RyaW5nX2FycmF5GAkgAygJUgtzdHJpbmdBcnJheQ=='); -@$core.Deprecated('Use executeServiceRequestDescriptor instead') -const ExecuteServiceRequest$json = const { - '1': 'ExecuteServiceRequest', - '2': const [ - const {'1': 'key', '3': 1, '4': 1, '5': 7, '10': 'key'}, - const {'1': 'args', '3': 2, '4': 3, '5': 11, '6': '.ExecuteServiceArgument', '10': 'args'}, - ], - '7': const {}, -}; - -/// Descriptor for `ExecuteServiceRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List executeServiceRequestDescriptor = $convert.base64Decode('ChVFeGVjdXRlU2VydmljZVJlcXVlc3QSEAoDa2V5GAEgASgHUgNrZXkSKwoEYXJncxgCIAMoCzIXLkV4ZWN1dGVTZXJ2aWNlQXJndW1lbnRSBGFyZ3M6CeBAKuhAAoBBAQ=='); -@$core.Deprecated('Use listEntitiesCameraResponseDescriptor instead') -const ListEntitiesCameraResponse$json = const { - '1': 'ListEntitiesCameraResponse', - '2': const [ - const {'1': 'object_id', '3': 1, '4': 1, '5': 9, '10': 'objectId'}, - const {'1': 'key', '3': 2, '4': 1, '5': 7, '10': 'key'}, - const {'1': 'name', '3': 3, '4': 1, '5': 9, '10': 'name'}, - const {'1': 'unique_id', '3': 4, '4': 1, '5': 9, '10': 'uniqueId'}, - ], - '7': const {}, -}; - -/// Descriptor for `ListEntitiesCameraResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List listEntitiesCameraResponseDescriptor = $convert.base64Decode('ChpMaXN0RW50aXRpZXNDYW1lcmFSZXNwb25zZRIbCglvYmplY3RfaWQYASABKAlSCG9iamVjdElkEhAKA2tleRgCIAEoB1IDa2V5EhIKBG5hbWUYAyABKAlSBG5hbWUSGwoJdW5pcXVlX2lkGAQgASgJUgh1bmlxdWVJZDoZ4EAr6EAB8kAQVVNFX0VTUDMyX0NBTUVSQQ=='); -@$core.Deprecated('Use cameraImageResponseDescriptor instead') -const CameraImageResponse$json = const { - '1': 'CameraImageResponse', - '2': const [ - const {'1': 'key', '3': 1, '4': 1, '5': 7, '10': 'key'}, - const {'1': 'data', '3': 2, '4': 1, '5': 12, '10': 'data'}, - const {'1': 'done', '3': 3, '4': 1, '5': 8, '10': 'done'}, - ], - '7': const {}, -}; - -/// Descriptor for `CameraImageResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List cameraImageResponseDescriptor = $convert.base64Decode('ChNDYW1lcmFJbWFnZVJlc3BvbnNlEhAKA2tleRgBIAEoB1IDa2V5EhIKBGRhdGEYAiABKAxSBGRhdGESEgoEZG9uZRgDIAEoCFIEZG9uZToZ4EAs6EAB8kAQVVNFX0VTUDMyX0NBTUVSQQ=='); -@$core.Deprecated('Use cameraImageRequestDescriptor instead') -const CameraImageRequest$json = const { - '1': 'CameraImageRequest', - '2': const [ - const {'1': 'single', '3': 1, '4': 1, '5': 8, '10': 'single'}, - const {'1': 'stream', '3': 2, '4': 1, '5': 8, '10': 'stream'}, - ], - '7': const {}, -}; - -/// Descriptor for `CameraImageRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List cameraImageRequestDescriptor = $convert.base64Decode('ChJDYW1lcmFJbWFnZVJlcXVlc3QSFgoGc2luZ2xlGAEgASgIUgZzaW5nbGUSFgoGc3RyZWFtGAIgASgIUgZzdHJlYW06HOBALehAAvJAEFVTRV9FU1AzMl9DQU1FUkGAQQE='); -@$core.Deprecated('Use listEntitiesClimateResponseDescriptor instead') -const ListEntitiesClimateResponse$json = const { - '1': 'ListEntitiesClimateResponse', - '2': const [ - const {'1': 'object_id', '3': 1, '4': 1, '5': 9, '10': 'objectId'}, - const {'1': 'key', '3': 2, '4': 1, '5': 7, '10': 'key'}, - const {'1': 'name', '3': 3, '4': 1, '5': 9, '10': 'name'}, - const {'1': 'unique_id', '3': 4, '4': 1, '5': 9, '10': 'uniqueId'}, - const {'1': 'supports_current_temperature', '3': 5, '4': 1, '5': 8, '10': 'supportsCurrentTemperature'}, - const {'1': 'supports_two_point_target_temperature', '3': 6, '4': 1, '5': 8, '10': 'supportsTwoPointTargetTemperature'}, - const {'1': 'supported_modes', '3': 7, '4': 3, '5': 14, '6': '.ClimateMode', '10': 'supportedModes'}, - const {'1': 'visual_min_temperature', '3': 8, '4': 1, '5': 2, '10': 'visualMinTemperature'}, - const {'1': 'visual_max_temperature', '3': 9, '4': 1, '5': 2, '10': 'visualMaxTemperature'}, - const {'1': 'visual_temperature_step', '3': 10, '4': 1, '5': 2, '10': 'visualTemperatureStep'}, - const {'1': 'legacy_supports_away', '3': 11, '4': 1, '5': 8, '10': 'legacySupportsAway'}, - const {'1': 'supports_action', '3': 12, '4': 1, '5': 8, '10': 'supportsAction'}, - const {'1': 'supported_fan_modes', '3': 13, '4': 3, '5': 14, '6': '.ClimateFanMode', '10': 'supportedFanModes'}, - const {'1': 'supported_swing_modes', '3': 14, '4': 3, '5': 14, '6': '.ClimateSwingMode', '10': 'supportedSwingModes'}, - const {'1': 'supported_custom_fan_modes', '3': 15, '4': 3, '5': 9, '10': 'supportedCustomFanModes'}, - const {'1': 'supported_presets', '3': 16, '4': 3, '5': 14, '6': '.ClimatePreset', '10': 'supportedPresets'}, - const {'1': 'supported_custom_presets', '3': 17, '4': 3, '5': 9, '10': 'supportedCustomPresets'}, - ], - '7': const {}, -}; - -/// Descriptor for `ListEntitiesClimateResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List listEntitiesClimateResponseDescriptor = $convert.base64Decode('ChtMaXN0RW50aXRpZXNDbGltYXRlUmVzcG9uc2USGwoJb2JqZWN0X2lkGAEgASgJUghvYmplY3RJZBIQCgNrZXkYAiABKAdSA2tleRISCgRuYW1lGAMgASgJUgRuYW1lEhsKCXVuaXF1ZV9pZBgEIAEoCVIIdW5pcXVlSWQSQAocc3VwcG9ydHNfY3VycmVudF90ZW1wZXJhdHVyZRgFIAEoCFIac3VwcG9ydHNDdXJyZW50VGVtcGVyYXR1cmUSUAolc3VwcG9ydHNfdHdvX3BvaW50X3RhcmdldF90ZW1wZXJhdHVyZRgGIAEoCFIhc3VwcG9ydHNUd29Qb2ludFRhcmdldFRlbXBlcmF0dXJlEjUKD3N1cHBvcnRlZF9tb2RlcxgHIAMoDjIMLkNsaW1hdGVNb2RlUg5zdXBwb3J0ZWRNb2RlcxI0ChZ2aXN1YWxfbWluX3RlbXBlcmF0dXJlGAggASgCUhR2aXN1YWxNaW5UZW1wZXJhdHVyZRI0ChZ2aXN1YWxfbWF4X3RlbXBlcmF0dXJlGAkgASgCUhR2aXN1YWxNYXhUZW1wZXJhdHVyZRI2Chd2aXN1YWxfdGVtcGVyYXR1cmVfc3RlcBgKIAEoAlIVdmlzdWFsVGVtcGVyYXR1cmVTdGVwEjAKFGxlZ2FjeV9zdXBwb3J0c19hd2F5GAsgASgIUhJsZWdhY3lTdXBwb3J0c0F3YXkSJwoPc3VwcG9ydHNfYWN0aW9uGAwgASgIUg5zdXBwb3J0c0FjdGlvbhI/ChNzdXBwb3J0ZWRfZmFuX21vZGVzGA0gAygOMg8uQ2xpbWF0ZUZhbk1vZGVSEXN1cHBvcnRlZEZhbk1vZGVzEkUKFXN1cHBvcnRlZF9zd2luZ19tb2RlcxgOIAMoDjIRLkNsaW1hdGVTd2luZ01vZGVSE3N1cHBvcnRlZFN3aW5nTW9kZXMSOwoac3VwcG9ydGVkX2N1c3RvbV9mYW5fbW9kZXMYDyADKAlSF3N1cHBvcnRlZEN1c3RvbUZhbk1vZGVzEjsKEXN1cHBvcnRlZF9wcmVzZXRzGBAgAygOMg4uQ2xpbWF0ZVByZXNldFIQc3VwcG9ydGVkUHJlc2V0cxI4ChhzdXBwb3J0ZWRfY3VzdG9tX3ByZXNldHMYESADKAlSFnN1cHBvcnRlZEN1c3RvbVByZXNldHM6FOBALuhAAfJAC1VTRV9DTElNQVRF'); -@$core.Deprecated('Use climateStateResponseDescriptor instead') -const ClimateStateResponse$json = const { - '1': 'ClimateStateResponse', - '2': const [ - const {'1': 'key', '3': 1, '4': 1, '5': 7, '10': 'key'}, - const {'1': 'mode', '3': 2, '4': 1, '5': 14, '6': '.ClimateMode', '10': 'mode'}, - const {'1': 'current_temperature', '3': 3, '4': 1, '5': 2, '10': 'currentTemperature'}, - const {'1': 'target_temperature', '3': 4, '4': 1, '5': 2, '10': 'targetTemperature'}, - const {'1': 'target_temperature_low', '3': 5, '4': 1, '5': 2, '10': 'targetTemperatureLow'}, - const {'1': 'target_temperature_high', '3': 6, '4': 1, '5': 2, '10': 'targetTemperatureHigh'}, - const {'1': 'legacy_away', '3': 7, '4': 1, '5': 8, '10': 'legacyAway'}, - const {'1': 'action', '3': 8, '4': 1, '5': 14, '6': '.ClimateAction', '10': 'action'}, - const {'1': 'fan_mode', '3': 9, '4': 1, '5': 14, '6': '.ClimateFanMode', '10': 'fanMode'}, - const {'1': 'swing_mode', '3': 10, '4': 1, '5': 14, '6': '.ClimateSwingMode', '10': 'swingMode'}, - const {'1': 'custom_fan_mode', '3': 11, '4': 1, '5': 9, '10': 'customFanMode'}, - const {'1': 'preset', '3': 12, '4': 1, '5': 14, '6': '.ClimatePreset', '10': 'preset'}, - const {'1': 'custom_preset', '3': 13, '4': 1, '5': 9, '10': 'customPreset'}, - ], - '7': const {}, -}; - -/// Descriptor for `ClimateStateResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List climateStateResponseDescriptor = $convert.base64Decode('ChRDbGltYXRlU3RhdGVSZXNwb25zZRIQCgNrZXkYASABKAdSA2tleRIgCgRtb2RlGAIgASgOMgwuQ2xpbWF0ZU1vZGVSBG1vZGUSLwoTY3VycmVudF90ZW1wZXJhdHVyZRgDIAEoAlISY3VycmVudFRlbXBlcmF0dXJlEi0KEnRhcmdldF90ZW1wZXJhdHVyZRgEIAEoAlIRdGFyZ2V0VGVtcGVyYXR1cmUSNAoWdGFyZ2V0X3RlbXBlcmF0dXJlX2xvdxgFIAEoAlIUdGFyZ2V0VGVtcGVyYXR1cmVMb3cSNgoXdGFyZ2V0X3RlbXBlcmF0dXJlX2hpZ2gYBiABKAJSFXRhcmdldFRlbXBlcmF0dXJlSGlnaBIfCgtsZWdhY3lfYXdheRgHIAEoCFIKbGVnYWN5QXdheRImCgZhY3Rpb24YCCABKA4yDi5DbGltYXRlQWN0aW9uUgZhY3Rpb24SKgoIZmFuX21vZGUYCSABKA4yDy5DbGltYXRlRmFuTW9kZVIHZmFuTW9kZRIwCgpzd2luZ19tb2RlGAogASgOMhEuQ2xpbWF0ZVN3aW5nTW9kZVIJc3dpbmdNb2RlEiYKD2N1c3RvbV9mYW5fbW9kZRgLIAEoCVINY3VzdG9tRmFuTW9kZRImCgZwcmVzZXQYDCABKA4yDi5DbGltYXRlUHJlc2V0UgZwcmVzZXQSIwoNY3VzdG9tX3ByZXNldBgNIAEoCVIMY3VzdG9tUHJlc2V0OhfgQC/oQAHyQAtVU0VfQ0xJTUFURYBBAQ=='); -@$core.Deprecated('Use climateCommandRequestDescriptor instead') -const ClimateCommandRequest$json = const { - '1': 'ClimateCommandRequest', - '2': const [ - const {'1': 'key', '3': 1, '4': 1, '5': 7, '10': 'key'}, - const {'1': 'has_mode', '3': 2, '4': 1, '5': 8, '10': 'hasMode'}, - const {'1': 'mode', '3': 3, '4': 1, '5': 14, '6': '.ClimateMode', '10': 'mode'}, - const {'1': 'has_target_temperature', '3': 4, '4': 1, '5': 8, '10': 'hasTargetTemperature'}, - const {'1': 'target_temperature', '3': 5, '4': 1, '5': 2, '10': 'targetTemperature'}, - const {'1': 'has_target_temperature_low', '3': 6, '4': 1, '5': 8, '10': 'hasTargetTemperatureLow'}, - const {'1': 'target_temperature_low', '3': 7, '4': 1, '5': 2, '10': 'targetTemperatureLow'}, - const {'1': 'has_target_temperature_high', '3': 8, '4': 1, '5': 8, '10': 'hasTargetTemperatureHigh'}, - const {'1': 'target_temperature_high', '3': 9, '4': 1, '5': 2, '10': 'targetTemperatureHigh'}, - const {'1': 'has_legacy_away', '3': 10, '4': 1, '5': 8, '10': 'hasLegacyAway'}, - const {'1': 'legacy_away', '3': 11, '4': 1, '5': 8, '10': 'legacyAway'}, - const {'1': 'has_fan_mode', '3': 12, '4': 1, '5': 8, '10': 'hasFanMode'}, - const {'1': 'fan_mode', '3': 13, '4': 1, '5': 14, '6': '.ClimateFanMode', '10': 'fanMode'}, - const {'1': 'has_swing_mode', '3': 14, '4': 1, '5': 8, '10': 'hasSwingMode'}, - const {'1': 'swing_mode', '3': 15, '4': 1, '5': 14, '6': '.ClimateSwingMode', '10': 'swingMode'}, - const {'1': 'has_custom_fan_mode', '3': 16, '4': 1, '5': 8, '10': 'hasCustomFanMode'}, - const {'1': 'custom_fan_mode', '3': 17, '4': 1, '5': 9, '10': 'customFanMode'}, - const {'1': 'has_preset', '3': 18, '4': 1, '5': 8, '10': 'hasPreset'}, - const {'1': 'preset', '3': 19, '4': 1, '5': 14, '6': '.ClimatePreset', '10': 'preset'}, - const {'1': 'has_custom_preset', '3': 20, '4': 1, '5': 8, '10': 'hasCustomPreset'}, - const {'1': 'custom_preset', '3': 21, '4': 1, '5': 9, '10': 'customPreset'}, - ], - '7': const {}, -}; - -/// Descriptor for `ClimateCommandRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List climateCommandRequestDescriptor = $convert.base64Decode('ChVDbGltYXRlQ29tbWFuZFJlcXVlc3QSEAoDa2V5GAEgASgHUgNrZXkSGQoIaGFzX21vZGUYAiABKAhSB2hhc01vZGUSIAoEbW9kZRgDIAEoDjIMLkNsaW1hdGVNb2RlUgRtb2RlEjQKFmhhc190YXJnZXRfdGVtcGVyYXR1cmUYBCABKAhSFGhhc1RhcmdldFRlbXBlcmF0dXJlEi0KEnRhcmdldF90ZW1wZXJhdHVyZRgFIAEoAlIRdGFyZ2V0VGVtcGVyYXR1cmUSOwoaaGFzX3RhcmdldF90ZW1wZXJhdHVyZV9sb3cYBiABKAhSF2hhc1RhcmdldFRlbXBlcmF0dXJlTG93EjQKFnRhcmdldF90ZW1wZXJhdHVyZV9sb3cYByABKAJSFHRhcmdldFRlbXBlcmF0dXJlTG93Ej0KG2hhc190YXJnZXRfdGVtcGVyYXR1cmVfaGlnaBgIIAEoCFIYaGFzVGFyZ2V0VGVtcGVyYXR1cmVIaWdoEjYKF3RhcmdldF90ZW1wZXJhdHVyZV9oaWdoGAkgASgCUhV0YXJnZXRUZW1wZXJhdHVyZUhpZ2gSJgoPaGFzX2xlZ2FjeV9hd2F5GAogASgIUg1oYXNMZWdhY3lBd2F5Eh8KC2xlZ2FjeV9hd2F5GAsgASgIUgpsZWdhY3lBd2F5EiAKDGhhc19mYW5fbW9kZRgMIAEoCFIKaGFzRmFuTW9kZRIqCghmYW5fbW9kZRgNIAEoDjIPLkNsaW1hdGVGYW5Nb2RlUgdmYW5Nb2RlEiQKDmhhc19zd2luZ19tb2RlGA4gASgIUgxoYXNTd2luZ01vZGUSMAoKc3dpbmdfbW9kZRgPIAEoDjIRLkNsaW1hdGVTd2luZ01vZGVSCXN3aW5nTW9kZRItChNoYXNfY3VzdG9tX2Zhbl9tb2RlGBAgASgIUhBoYXNDdXN0b21GYW5Nb2RlEiYKD2N1c3RvbV9mYW5fbW9kZRgRIAEoCVINY3VzdG9tRmFuTW9kZRIdCgpoYXNfcHJlc2V0GBIgASgIUgloYXNQcmVzZXQSJgoGcHJlc2V0GBMgASgOMg4uQ2xpbWF0ZVByZXNldFIGcHJlc2V0EioKEWhhc19jdXN0b21fcHJlc2V0GBQgASgIUg9oYXNDdXN0b21QcmVzZXQSIwoNY3VzdG9tX3ByZXNldBgVIAEoCVIMY3VzdG9tUHJlc2V0OhfgQDDoQALyQAtVU0VfQ0xJTUFURYBBAQ=='); -@$core.Deprecated('Use listEntitiesNumberResponseDescriptor instead') -const ListEntitiesNumberResponse$json = const { - '1': 'ListEntitiesNumberResponse', - '2': const [ - const {'1': 'object_id', '3': 1, '4': 1, '5': 9, '10': 'objectId'}, - const {'1': 'key', '3': 2, '4': 1, '5': 7, '10': 'key'}, - const {'1': 'name', '3': 3, '4': 1, '5': 9, '10': 'name'}, - const {'1': 'unique_id', '3': 4, '4': 1, '5': 9, '10': 'uniqueId'}, - const {'1': 'icon', '3': 5, '4': 1, '5': 9, '10': 'icon'}, - const {'1': 'min_value', '3': 6, '4': 1, '5': 2, '10': 'minValue'}, - const {'1': 'max_value', '3': 7, '4': 1, '5': 2, '10': 'maxValue'}, - const {'1': 'step', '3': 8, '4': 1, '5': 2, '10': 'step'}, - ], - '7': const {}, -}; - -/// Descriptor for `ListEntitiesNumberResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List listEntitiesNumberResponseDescriptor = $convert.base64Decode('ChpMaXN0RW50aXRpZXNOdW1iZXJSZXNwb25zZRIbCglvYmplY3RfaWQYASABKAlSCG9iamVjdElkEhAKA2tleRgCIAEoB1IDa2V5EhIKBG5hbWUYAyABKAlSBG5hbWUSGwoJdW5pcXVlX2lkGAQgASgJUgh1bmlxdWVJZBISCgRpY29uGAUgASgJUgRpY29uEhsKCW1pbl92YWx1ZRgGIAEoAlIIbWluVmFsdWUSGwoJbWF4X3ZhbHVlGAcgASgCUghtYXhWYWx1ZRISCgRzdGVwGAggASgCUgRzdGVwOhPgQDHoQAHyQApVU0VfTlVNQkVS'); -@$core.Deprecated('Use numberStateResponseDescriptor instead') -const NumberStateResponse$json = const { - '1': 'NumberStateResponse', - '2': const [ - const {'1': 'key', '3': 1, '4': 1, '5': 7, '10': 'key'}, - const {'1': 'state', '3': 2, '4': 1, '5': 2, '10': 'state'}, - const {'1': 'missing_state', '3': 3, '4': 1, '5': 8, '10': 'missingState'}, - ], - '7': const {}, -}; - -/// Descriptor for `NumberStateResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List numberStateResponseDescriptor = $convert.base64Decode('ChNOdW1iZXJTdGF0ZVJlc3BvbnNlEhAKA2tleRgBIAEoB1IDa2V5EhQKBXN0YXRlGAIgASgCUgVzdGF0ZRIjCg1taXNzaW5nX3N0YXRlGAMgASgIUgxtaXNzaW5nU3RhdGU6FuBAMuhAAfJAClVTRV9OVU1CRVKAQQE='); -@$core.Deprecated('Use numberCommandRequestDescriptor instead') -const NumberCommandRequest$json = const { - '1': 'NumberCommandRequest', - '2': const [ - const {'1': 'key', '3': 1, '4': 1, '5': 7, '10': 'key'}, - const {'1': 'state', '3': 2, '4': 1, '5': 2, '10': 'state'}, - ], - '7': const {}, -}; - -/// Descriptor for `NumberCommandRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List numberCommandRequestDescriptor = $convert.base64Decode('ChROdW1iZXJDb21tYW5kUmVxdWVzdBIQCgNrZXkYASABKAdSA2tleRIUCgVzdGF0ZRgCIAEoAlIFc3RhdGU6FuBAM+hAAvJAClVTRV9OVU1CRVKAQQE='); -const $core.Map<$core.String, $core.dynamic> APIConnectionServiceBase$json = const { - '1': 'APIConnection', - '2': const [ - const {'1': 'hello', '2': '.HelloRequest', '3': '.HelloResponse', '4': const {}}, - const {'1': 'connect', '2': '.ConnectRequest', '3': '.ConnectResponse', '4': const {}}, - const {'1': 'disconnect', '2': '.DisconnectRequest', '3': '.DisconnectResponse', '4': const {}}, - const {'1': 'ping', '2': '.PingRequest', '3': '.PingResponse', '4': const {}}, - const {'1': 'device_info', '2': '.DeviceInfoRequest', '3': '.DeviceInfoResponse', '4': const {}}, - const {'1': 'list_entities', '2': '.ListEntitiesRequest', '3': '.void', '4': const {}}, - const {'1': 'subscribe_states', '2': '.SubscribeStatesRequest', '3': '.void', '4': const {}}, - const {'1': 'subscribe_logs', '2': '.SubscribeLogsRequest', '3': '.void', '4': const {}}, - const {'1': 'subscribe_homeassistant_services', '2': '.SubscribeHomeassistantServicesRequest', '3': '.void', '4': const {}}, - const {'1': 'subscribe_home_assistant_states', '2': '.SubscribeHomeAssistantStatesRequest', '3': '.void', '4': const {}}, - const {'1': 'get_time', '2': '.GetTimeRequest', '3': '.GetTimeResponse', '4': const {}}, - const {'1': 'execute_service', '2': '.ExecuteServiceRequest', '3': '.void', '4': const {}}, - const {'1': 'cover_command', '2': '.CoverCommandRequest', '3': '.void', '4': const {}}, - const {'1': 'fan_command', '2': '.FanCommandRequest', '3': '.void', '4': const {}}, - const {'1': 'light_command', '2': '.LightCommandRequest', '3': '.void', '4': const {}}, - const {'1': 'switch_command', '2': '.SwitchCommandRequest', '3': '.void', '4': const {}}, - const {'1': 'camera_image', '2': '.CameraImageRequest', '3': '.void', '4': const {}}, - const {'1': 'climate_command', '2': '.ClimateCommandRequest', '3': '.void', '4': const {}}, - const {'1': 'number_command', '2': '.NumberCommandRequest', '3': '.void', '4': const {}}, - ], -}; - -@$core.Deprecated('Use aPIConnectionServiceDescriptor instead') -const $core.Map<$core.String, $core.Map<$core.String, $core.dynamic>> APIConnectionServiceBase$messageJson = const { - '.HelloRequest': HelloRequest$json, - '.HelloResponse': HelloResponse$json, - '.ConnectRequest': ConnectRequest$json, - '.ConnectResponse': ConnectResponse$json, - '.DisconnectRequest': DisconnectRequest$json, - '.DisconnectResponse': DisconnectResponse$json, - '.PingRequest': PingRequest$json, - '.PingResponse': PingResponse$json, - '.DeviceInfoRequest': DeviceInfoRequest$json, - '.DeviceInfoResponse': DeviceInfoResponse$json, - '.ListEntitiesRequest': ListEntitiesRequest$json, - '.void': $0.void_$json, - '.SubscribeStatesRequest': SubscribeStatesRequest$json, - '.SubscribeLogsRequest': SubscribeLogsRequest$json, - '.SubscribeHomeassistantServicesRequest': SubscribeHomeassistantServicesRequest$json, - '.SubscribeHomeAssistantStatesRequest': SubscribeHomeAssistantStatesRequest$json, - '.GetTimeRequest': GetTimeRequest$json, - '.GetTimeResponse': GetTimeResponse$json, - '.ExecuteServiceRequest': ExecuteServiceRequest$json, - '.ExecuteServiceArgument': ExecuteServiceArgument$json, - '.CoverCommandRequest': CoverCommandRequest$json, - '.FanCommandRequest': FanCommandRequest$json, - '.LightCommandRequest': LightCommandRequest$json, - '.SwitchCommandRequest': SwitchCommandRequest$json, - '.CameraImageRequest': CameraImageRequest$json, - '.ClimateCommandRequest': ClimateCommandRequest$json, - '.NumberCommandRequest': NumberCommandRequest$json, -}; - -/// Descriptor for `APIConnection`. Decode as a `google.protobuf.ServiceDescriptorProto`. -final $typed_data.Uint8List aPIConnectionServiceDescriptor = $convert.base64Decode('Cg1BUElDb25uZWN0aW9uEi4KBWhlbGxvEg0uSGVsbG9SZXF1ZXN0Gg4uSGVsbG9SZXNwb25zZSIG8EAA+EAAEjQKB2Nvbm5lY3QSDy5Db25uZWN0UmVxdWVzdBoQLkNvbm5lY3RSZXNwb25zZSIG8EAA+EAAEj0KCmRpc2Nvbm5lY3QSEi5EaXNjb25uZWN0UmVxdWVzdBoTLkRpc2Nvbm5lY3RSZXNwb25zZSIG8EAA+EAAEisKBHBpbmcSDC5QaW5nUmVxdWVzdBoNLlBpbmdSZXNwb25zZSIG8EAA+EAAEjsKC2RldmljZV9pbmZvEhIuRGV2aWNlSW5mb1JlcXVlc3QaEy5EZXZpY2VJbmZvUmVzcG9uc2UiA/hAABIuCg1saXN0X2VudGl0aWVzEhQuTGlzdEVudGl0aWVzUmVxdWVzdBoFLnZvaWQiABI0ChBzdWJzY3JpYmVfc3RhdGVzEhcuU3Vic2NyaWJlU3RhdGVzUmVxdWVzdBoFLnZvaWQiABIwCg5zdWJzY3JpYmVfbG9ncxIVLlN1YnNjcmliZUxvZ3NSZXF1ZXN0GgUudm9pZCIAElMKIHN1YnNjcmliZV9ob21lYXNzaXN0YW50X3NlcnZpY2VzEiYuU3Vic2NyaWJlSG9tZWFzc2lzdGFudFNlcnZpY2VzUmVxdWVzdBoFLnZvaWQiABJQCh9zdWJzY3JpYmVfaG9tZV9hc3Npc3RhbnRfc3RhdGVzEiQuU3Vic2NyaWJlSG9tZUFzc2lzdGFudFN0YXRlc1JlcXVlc3QaBS52b2lkIgASMgoIZ2V0X3RpbWUSDy5HZXRUaW1lUmVxdWVzdBoQLkdldFRpbWVSZXNwb25zZSID+EAAEjIKD2V4ZWN1dGVfc2VydmljZRIWLkV4ZWN1dGVTZXJ2aWNlUmVxdWVzdBoFLnZvaWQiABIuCg1jb3Zlcl9jb21tYW5kEhQuQ292ZXJDb21tYW5kUmVxdWVzdBoFLnZvaWQiABIqCgtmYW5fY29tbWFuZBISLkZhbkNvbW1hbmRSZXF1ZXN0GgUudm9pZCIAEi4KDWxpZ2h0X2NvbW1hbmQSFC5MaWdodENvbW1hbmRSZXF1ZXN0GgUudm9pZCIAEjAKDnN3aXRjaF9jb21tYW5kEhUuU3dpdGNoQ29tbWFuZFJlcXVlc3QaBS52b2lkIgASLAoMY2FtZXJhX2ltYWdlEhMuQ2FtZXJhSW1hZ2VSZXF1ZXN0GgUudm9pZCIAEjIKD2NsaW1hdGVfY29tbWFuZBIWLkNsaW1hdGVDb21tYW5kUmVxdWVzdBoFLnZvaWQiABIwCg5udW1iZXJfY29tbWFuZBIVLk51bWJlckNvbW1hbmRSZXF1ZXN0GgUudm9pZCIA'); diff --git a/lib/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api.pbserver.dart b/lib/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api.pbserver.dart deleted file mode 100644 index be762e8a..00000000 --- a/lib/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api.pbserver.dart +++ /dev/null @@ -1,93 +0,0 @@ -/// -// Generated code. Do not modify. -// source: aioesphomeapi/api.proto -// -// @dart = 2.12 -// ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,deprecated_member_use_from_same_package,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name - -import 'dart:async' as $async; - -import 'package:protobuf/protobuf.dart' as $pb; - -import 'dart:core' as $core; -import 'api.pb.dart' as $1; -import 'api_options.pb.dart' as $0; -import 'api.pbjson.dart'; - -export 'api.pb.dart'; - -abstract class APIConnectionServiceBase extends $pb.GeneratedService { - $async.Future<$1.HelloResponse> hello($pb.ServerContext ctx, $1.HelloRequest request); - $async.Future<$1.ConnectResponse> connect($pb.ServerContext ctx, $1.ConnectRequest request); - $async.Future<$1.DisconnectResponse> disconnect($pb.ServerContext ctx, $1.DisconnectRequest request); - $async.Future<$1.PingResponse> ping($pb.ServerContext ctx, $1.PingRequest request); - $async.Future<$1.DeviceInfoResponse> device_info($pb.ServerContext ctx, $1.DeviceInfoRequest request); - $async.Future<$0.void_> list_entities($pb.ServerContext ctx, $1.ListEntitiesRequest request); - $async.Future<$0.void_> subscribe_states($pb.ServerContext ctx, $1.SubscribeStatesRequest request); - $async.Future<$0.void_> subscribe_logs($pb.ServerContext ctx, $1.SubscribeLogsRequest request); - $async.Future<$0.void_> subscribe_homeassistant_services($pb.ServerContext ctx, $1.SubscribeHomeassistantServicesRequest request); - $async.Future<$0.void_> subscribe_home_assistant_states($pb.ServerContext ctx, $1.SubscribeHomeAssistantStatesRequest request); - $async.Future<$1.GetTimeResponse> get_time($pb.ServerContext ctx, $1.GetTimeRequest request); - $async.Future<$0.void_> execute_service($pb.ServerContext ctx, $1.ExecuteServiceRequest request); - $async.Future<$0.void_> cover_command($pb.ServerContext ctx, $1.CoverCommandRequest request); - $async.Future<$0.void_> fan_command($pb.ServerContext ctx, $1.FanCommandRequest request); - $async.Future<$0.void_> light_command($pb.ServerContext ctx, $1.LightCommandRequest request); - $async.Future<$0.void_> switch_command($pb.ServerContext ctx, $1.SwitchCommandRequest request); - $async.Future<$0.void_> camera_image($pb.ServerContext ctx, $1.CameraImageRequest request); - $async.Future<$0.void_> climate_command($pb.ServerContext ctx, $1.ClimateCommandRequest request); - $async.Future<$0.void_> number_command($pb.ServerContext ctx, $1.NumberCommandRequest request); - - $pb.GeneratedMessage createRequest($core.String method) { - switch (method) { - case 'hello': return $1.HelloRequest(); - case 'connect': return $1.ConnectRequest(); - case 'disconnect': return $1.DisconnectRequest(); - case 'ping': return $1.PingRequest(); - case 'device_info': return $1.DeviceInfoRequest(); - case 'list_entities': return $1.ListEntitiesRequest(); - case 'subscribe_states': return $1.SubscribeStatesRequest(); - case 'subscribe_logs': return $1.SubscribeLogsRequest(); - case 'subscribe_homeassistant_services': return $1.SubscribeHomeassistantServicesRequest(); - case 'subscribe_home_assistant_states': return $1.SubscribeHomeAssistantStatesRequest(); - case 'get_time': return $1.GetTimeRequest(); - case 'execute_service': return $1.ExecuteServiceRequest(); - case 'cover_command': return $1.CoverCommandRequest(); - case 'fan_command': return $1.FanCommandRequest(); - case 'light_command': return $1.LightCommandRequest(); - case 'switch_command': return $1.SwitchCommandRequest(); - case 'camera_image': return $1.CameraImageRequest(); - case 'climate_command': return $1.ClimateCommandRequest(); - case 'number_command': return $1.NumberCommandRequest(); - default: throw $core.ArgumentError('Unknown method: $method'); - } - } - - $async.Future<$pb.GeneratedMessage> handleCall($pb.ServerContext ctx, $core.String method, $pb.GeneratedMessage request) { - switch (method) { - case 'hello': return this.hello(ctx, request as $1.HelloRequest); - case 'connect': return this.connect(ctx, request as $1.ConnectRequest); - case 'disconnect': return this.disconnect(ctx, request as $1.DisconnectRequest); - case 'ping': return this.ping(ctx, request as $1.PingRequest); - case 'device_info': return this.device_info(ctx, request as $1.DeviceInfoRequest); - case 'list_entities': return this.list_entities(ctx, request as $1.ListEntitiesRequest); - case 'subscribe_states': return this.subscribe_states(ctx, request as $1.SubscribeStatesRequest); - case 'subscribe_logs': return this.subscribe_logs(ctx, request as $1.SubscribeLogsRequest); - case 'subscribe_homeassistant_services': return this.subscribe_homeassistant_services(ctx, request as $1.SubscribeHomeassistantServicesRequest); - case 'subscribe_home_assistant_states': return this.subscribe_home_assistant_states(ctx, request as $1.SubscribeHomeAssistantStatesRequest); - case 'get_time': return this.get_time(ctx, request as $1.GetTimeRequest); - case 'execute_service': return this.execute_service(ctx, request as $1.ExecuteServiceRequest); - case 'cover_command': return this.cover_command(ctx, request as $1.CoverCommandRequest); - case 'fan_command': return this.fan_command(ctx, request as $1.FanCommandRequest); - case 'light_command': return this.light_command(ctx, request as $1.LightCommandRequest); - case 'switch_command': return this.switch_command(ctx, request as $1.SwitchCommandRequest); - case 'camera_image': return this.camera_image(ctx, request as $1.CameraImageRequest); - case 'climate_command': return this.climate_command(ctx, request as $1.ClimateCommandRequest); - case 'number_command': return this.number_command(ctx, request as $1.NumberCommandRequest); - default: throw $core.ArgumentError('Unknown method: $method'); - } - } - - $core.Map<$core.String, $core.dynamic> get $json => APIConnectionServiceBase$json; - $core.Map<$core.String, $core.Map<$core.String, $core.dynamic>> get $messageJson => APIConnectionServiceBase$messageJson; -} - diff --git a/lib/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api_options.pb.dart b/lib/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api_options.pb.dart deleted file mode 100644 index c4b4b879..00000000 --- a/lib/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api_options.pb.dart +++ /dev/null @@ -1,63 +0,0 @@ -/// -// Generated code. Do not modify. -// source: aioesphomeapi/api_options.proto -// -// @dart = 2.12 -// ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name - -import 'dart:core' as $core; - -import 'package:protobuf/protobuf.dart' as $pb; - -import 'api_options.pbenum.dart'; - -export 'api_options.pbenum.dart'; - -class void_ extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'void', createEmptyInstance: create) - ..hasRequiredFields = false - ; - - void_._() : super(); - factory void_() => create(); - factory void_.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory void_.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - void_ clone() => void_()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - void_ copyWith(void Function(void_) updates) => super.copyWith((message) => updates(message as void_)) as void_; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static void_ create() => void_._(); - void_ createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static void_ getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static void_? _defaultInstance; -} - -class Api_options { - static final needsSetupConnection = $pb.Extension<$core.bool>(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'google.protobuf.MethodOptions', const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'needsSetupConnection', 1038, $pb.PbFieldType.OB, defaultOrMaker: true); - static final needsAuthentication = $pb.Extension<$core.bool>(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'google.protobuf.MethodOptions', const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'needsAuthentication', 1039, $pb.PbFieldType.OB, defaultOrMaker: true); - static final id = $pb.Extension<$core.int>(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'google.protobuf.MessageOptions', const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'id', 1036, $pb.PbFieldType.OU3); - static final source = $pb.Extension(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'google.protobuf.MessageOptions', const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'source', 1037, $pb.PbFieldType.OE, defaultOrMaker: APISourceType.SOURCE_BOTH, valueOf: APISourceType.valueOf, enumValues: APISourceType.values); - static final ifdef = $pb.Extension<$core.String>(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'google.protobuf.MessageOptions', const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'ifdef', 1038, $pb.PbFieldType.OS); - static final log = $pb.Extension<$core.bool>(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'google.protobuf.MessageOptions', const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'log', 1039, $pb.PbFieldType.OB, defaultOrMaker: true); - static final noDelay = $pb.Extension<$core.bool>(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'google.protobuf.MessageOptions', const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'noDelay', 1040, $pb.PbFieldType.OB); - static void registerAllExtensions($pb.ExtensionRegistry registry) { - registry.add(needsSetupConnection); - registry.add(needsAuthentication); - registry.add(id); - registry.add(source); - registry.add(ifdef); - registry.add(log); - registry.add(noDelay); - } -} - diff --git a/lib/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api_options.pbenum.dart b/lib/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api_options.pbenum.dart deleted file mode 100644 index 024efcca..00000000 --- a/lib/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api_options.pbenum.dart +++ /dev/null @@ -1,28 +0,0 @@ -/// -// Generated code. Do not modify. -// source: aioesphomeapi/api_options.proto -// -// @dart = 2.12 -// ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name - -// ignore_for_file: UNDEFINED_SHOWN_NAME -import 'dart:core' as $core; -import 'package:protobuf/protobuf.dart' as $pb; - -class APISourceType extends $pb.ProtobufEnum { - static const APISourceType SOURCE_BOTH = APISourceType._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'SOURCE_BOTH'); - static const APISourceType SOURCE_SERVER = APISourceType._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'SOURCE_SERVER'); - static const APISourceType SOURCE_CLIENT = APISourceType._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'SOURCE_CLIENT'); - - static const $core.List values = [ - SOURCE_BOTH, - SOURCE_SERVER, - SOURCE_CLIENT, - ]; - - static final $core.Map<$core.int, APISourceType> _byValue = $pb.ProtobufEnum.initByValue(values); - static APISourceType? valueOf($core.int value) => _byValue[value]; - - const APISourceType._($core.int v, $core.String n) : super(v, n); -} - diff --git a/lib/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api_options.pbjson.dart b/lib/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api_options.pbjson.dart deleted file mode 100644 index a212d133..00000000 --- a/lib/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api_options.pbjson.dart +++ /dev/null @@ -1,29 +0,0 @@ -/// -// Generated code. Do not modify. -// source: aioesphomeapi/api_options.proto -// -// @dart = 2.12 -// ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,deprecated_member_use_from_same_package,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name - -import 'dart:core' as $core; -import 'dart:convert' as $convert; -import 'dart:typed_data' as $typed_data; -@$core.Deprecated('Use aPISourceTypeDescriptor instead') -const APISourceType$json = const { - '1': 'APISourceType', - '2': const [ - const {'1': 'SOURCE_BOTH', '2': 0}, - const {'1': 'SOURCE_SERVER', '2': 1}, - const {'1': 'SOURCE_CLIENT', '2': 2}, - ], -}; - -/// Descriptor for `APISourceType`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List aPISourceTypeDescriptor = $convert.base64Decode('Cg1BUElTb3VyY2VUeXBlEg8KC1NPVVJDRV9CT1RIEAASEQoNU09VUkNFX1NFUlZFUhABEhEKDVNPVVJDRV9DTElFTlQQAg=='); -@$core.Deprecated('Use void_Descriptor instead') -const void_$json = const { - '1': 'void', -}; - -/// Descriptor for `void`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List void_Descriptor = $convert.base64Decode('CgR2b2lk'); diff --git a/lib/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api_options.pbserver.dart b/lib/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api_options.pbserver.dart deleted file mode 100644 index 00bb31d0..00000000 --- a/lib/infrastructure/gen/aioesphomeapi/protoc_as_dart/aioesphomeapi/api_options.pbserver.dart +++ /dev/null @@ -1,9 +0,0 @@ -/// -// Generated code. Do not modify. -// source: aioesphomeapi/api_options.proto -// -// @dart = 2.12 -// ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,deprecated_member_use_from_same_package,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name - -export 'api_options.pb.dart'; - diff --git a/lib/infrastructure/gen/cbj_hub_server/proto_gen_date.dart b/lib/infrastructure/gen/cbj_hub_server/proto_gen_date.dart deleted file mode 100644 index e28cba40..00000000 --- a/lib/infrastructure/gen/cbj_hub_server/proto_gen_date.dart +++ /dev/null @@ -1 +0,0 @@ -const hubServerProtocGenDate = '25/03/23'; diff --git a/lib/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pb.dart b/lib/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pb.dart deleted file mode 100644 index e233f9a1..00000000 --- a/lib/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pb.dart +++ /dev/null @@ -1,1258 +0,0 @@ -/// -// Generated code. Do not modify. -// source: cbj_hub_server.proto -// -// @dart = 2.12 -// ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name - -import 'dart:core' as $core; - -import 'package:protobuf/protobuf.dart' as $pb; - -import 'cbj_hub_server.pbenum.dart'; - -export 'cbj_hub_server.pbenum.dart'; - -class ClientStatusRequests extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ClientStatusRequests', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjHub'), createEmptyInstance: create) - ..e(41, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'sendingType', $pb.PbFieldType.OE, protoName: 'sendingType', defaultOrMaker: SendingType.undefinedType, valueOf: SendingType.valueOf, enumValues: SendingType.values) - ..aOS(42, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'allRemoteCommands', protoName: 'allRemoteCommands') - ..hasRequiredFields = false - ; - - ClientStatusRequests._() : super(); - factory ClientStatusRequests({ - SendingType? sendingType, - $core.String? allRemoteCommands, - }) { - final _result = create(); - if (sendingType != null) { - _result.sendingType = sendingType; - } - if (allRemoteCommands != null) { - _result.allRemoteCommands = allRemoteCommands; - } - return _result; - } - factory ClientStatusRequests.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory ClientStatusRequests.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - ClientStatusRequests clone() => ClientStatusRequests()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - ClientStatusRequests copyWith(void Function(ClientStatusRequests) updates) => super.copyWith((message) => updates(message as ClientStatusRequests)) as ClientStatusRequests; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static ClientStatusRequests create() => ClientStatusRequests._(); - ClientStatusRequests createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static ClientStatusRequests getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static ClientStatusRequests? _defaultInstance; - - @$pb.TagNumber(41) - SendingType get sendingType => $_getN(0); - @$pb.TagNumber(41) - set sendingType(SendingType v) { setField(41, v); } - @$pb.TagNumber(41) - $core.bool hasSendingType() => $_has(0); - @$pb.TagNumber(41) - void clearSendingType() => clearField(41); - - @$pb.TagNumber(42) - $core.String get allRemoteCommands => $_getSZ(1); - @$pb.TagNumber(42) - set allRemoteCommands($core.String v) { $_setString(1, v); } - @$pb.TagNumber(42) - $core.bool hasAllRemoteCommands() => $_has(1); - @$pb.TagNumber(42) - void clearAllRemoteCommands() => clearField(42); -} - -class RequestsAndStatusFromHub extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'RequestsAndStatusFromHub', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjHub'), createEmptyInstance: create) - ..e(43, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'sendingType', $pb.PbFieldType.OE, protoName: 'sendingType', defaultOrMaker: SendingType.undefinedType, valueOf: SendingType.valueOf, enumValues: SendingType.values) - ..aOS(44, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'allRemoteCommands', protoName: 'allRemoteCommands') - ..hasRequiredFields = false - ; - - RequestsAndStatusFromHub._() : super(); - factory RequestsAndStatusFromHub({ - SendingType? sendingType, - $core.String? allRemoteCommands, - }) { - final _result = create(); - if (sendingType != null) { - _result.sendingType = sendingType; - } - if (allRemoteCommands != null) { - _result.allRemoteCommands = allRemoteCommands; - } - return _result; - } - factory RequestsAndStatusFromHub.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory RequestsAndStatusFromHub.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - RequestsAndStatusFromHub clone() => RequestsAndStatusFromHub()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - RequestsAndStatusFromHub copyWith(void Function(RequestsAndStatusFromHub) updates) => super.copyWith((message) => updates(message as RequestsAndStatusFromHub)) as RequestsAndStatusFromHub; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static RequestsAndStatusFromHub create() => RequestsAndStatusFromHub._(); - RequestsAndStatusFromHub createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static RequestsAndStatusFromHub getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static RequestsAndStatusFromHub? _defaultInstance; - - @$pb.TagNumber(43) - SendingType get sendingType => $_getN(0); - @$pb.TagNumber(43) - set sendingType(SendingType v) { setField(43, v); } - @$pb.TagNumber(43) - $core.bool hasSendingType() => $_has(0); - @$pb.TagNumber(43) - void clearSendingType() => clearField(43); - - @$pb.TagNumber(44) - $core.String get allRemoteCommands => $_getSZ(1); - @$pb.TagNumber(44) - set allRemoteCommands($core.String v) { $_setString(1, v); } - @$pb.TagNumber(44) - $core.bool hasAllRemoteCommands() => $_has(1); - @$pb.TagNumber(44) - void clearAllRemoteCommands() => clearField(44); -} - -class AllRemoteCommands extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'AllRemoteCommands', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjHub'), createEmptyInstance: create) - ..aOM(40, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'smartEntityInfo', protoName: 'smartEntityInfo', subBuilder: SmartEntityInfo.create) - ..hasRequiredFields = false - ; - - AllRemoteCommands._() : super(); - factory AllRemoteCommands({ - SmartEntityInfo? smartEntityInfo, - }) { - final _result = create(); - if (smartEntityInfo != null) { - _result.smartEntityInfo = smartEntityInfo; - } - return _result; - } - factory AllRemoteCommands.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory AllRemoteCommands.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - AllRemoteCommands clone() => AllRemoteCommands()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - AllRemoteCommands copyWith(void Function(AllRemoteCommands) updates) => super.copyWith((message) => updates(message as AllRemoteCommands)) as AllRemoteCommands; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static AllRemoteCommands create() => AllRemoteCommands._(); - AllRemoteCommands createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static AllRemoteCommands getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static AllRemoteCommands? _defaultInstance; - - @$pb.TagNumber(40) - SmartEntityInfo get smartEntityInfo => $_getN(0); - @$pb.TagNumber(40) - set smartEntityInfo(SmartEntityInfo v) { setField(40, v); } - @$pb.TagNumber(40) - $core.bool hasSmartEntityInfo() => $_has(0); - @$pb.TagNumber(40) - void clearSmartEntityInfo() => clearField(40); - @$pb.TagNumber(40) - SmartEntityInfo ensureSmartEntityInfo() => $_ensure(0); -} - -class FirstSetupMessage extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'FirstSetupMessage', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjHub'), createEmptyInstance: create) - ..aOM(38, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'compInfo', protoName: 'compInfo', subBuilder: CompHubInfo.create) - ..aOM(39, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'cloudAccountInformation', protoName: 'cloudAccountInformation', subBuilder: CloudAccountInformation.create) - ..hasRequiredFields = false - ; - - FirstSetupMessage._() : super(); - factory FirstSetupMessage({ - CompHubInfo? compInfo, - CloudAccountInformation? cloudAccountInformation, - }) { - final _result = create(); - if (compInfo != null) { - _result.compInfo = compInfo; - } - if (cloudAccountInformation != null) { - _result.cloudAccountInformation = cloudAccountInformation; - } - return _result; - } - factory FirstSetupMessage.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory FirstSetupMessage.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - FirstSetupMessage clone() => FirstSetupMessage()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - FirstSetupMessage copyWith(void Function(FirstSetupMessage) updates) => super.copyWith((message) => updates(message as FirstSetupMessage)) as FirstSetupMessage; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static FirstSetupMessage create() => FirstSetupMessage._(); - FirstSetupMessage createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static FirstSetupMessage getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static FirstSetupMessage? _defaultInstance; - - @$pb.TagNumber(38) - CompHubInfo get compInfo => $_getN(0); - @$pb.TagNumber(38) - set compInfo(CompHubInfo v) { setField(38, v); } - @$pb.TagNumber(38) - $core.bool hasCompInfo() => $_has(0); - @$pb.TagNumber(38) - void clearCompInfo() => clearField(38); - @$pb.TagNumber(38) - CompHubInfo ensureCompInfo() => $_ensure(0); - - @$pb.TagNumber(39) - CloudAccountInformation get cloudAccountInformation => $_getN(1); - @$pb.TagNumber(39) - set cloudAccountInformation(CloudAccountInformation v) { setField(39, v); } - @$pb.TagNumber(39) - $core.bool hasCloudAccountInformation() => $_has(1); - @$pb.TagNumber(39) - void clearCloudAccountInformation() => clearField(39); - @$pb.TagNumber(39) - CloudAccountInformation ensureCloudAccountInformation() => $_ensure(1); -} - -class CompHubInfo extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CompHubInfo', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjHub'), createEmptyInstance: create) - ..aOM(21, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'compSpecs', protoName: 'compSpecs', subBuilder: CompHubSpecs.create) - ..aOM(47, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'cbjInfo', protoName: 'cbjInfo', subBuilder: CbjHubIno.create) - ..hasRequiredFields = false - ; - - CompHubInfo._() : super(); - factory CompHubInfo({ - CompHubSpecs? compSpecs, - CbjHubIno? cbjInfo, - }) { - final _result = create(); - if (compSpecs != null) { - _result.compSpecs = compSpecs; - } - if (cbjInfo != null) { - _result.cbjInfo = cbjInfo; - } - return _result; - } - factory CompHubInfo.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory CompHubInfo.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - CompHubInfo clone() => CompHubInfo()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - CompHubInfo copyWith(void Function(CompHubInfo) updates) => super.copyWith((message) => updates(message as CompHubInfo)) as CompHubInfo; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static CompHubInfo create() => CompHubInfo._(); - CompHubInfo createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static CompHubInfo getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static CompHubInfo? _defaultInstance; - - @$pb.TagNumber(21) - CompHubSpecs get compSpecs => $_getN(0); - @$pb.TagNumber(21) - set compSpecs(CompHubSpecs v) { setField(21, v); } - @$pb.TagNumber(21) - $core.bool hasCompSpecs() => $_has(0); - @$pb.TagNumber(21) - void clearCompSpecs() => clearField(21); - @$pb.TagNumber(21) - CompHubSpecs ensureCompSpecs() => $_ensure(0); - - @$pb.TagNumber(47) - CbjHubIno get cbjInfo => $_getN(1); - @$pb.TagNumber(47) - set cbjInfo(CbjHubIno v) { setField(47, v); } - @$pb.TagNumber(47) - $core.bool hasCbjInfo() => $_has(1); - @$pb.TagNumber(47) - void clearCbjInfo() => clearField(47); - @$pb.TagNumber(47) - CbjHubIno ensureCbjInfo() => $_ensure(1); -} - -class CbjHubIno extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjHubIno', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjHub'), createEmptyInstance: create) - ..aOS(27, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'pubspecYamlVersion', protoName: 'pubspecYamlVersion') - ..aOS(48, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'entityName', protoName: 'entityName') - ..aOS(49, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'protoLastGenDate', protoName: 'protoLastGenDate') - ..aOS(51, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'pubspecYamlBuildNumber', protoName: 'pubspecYamlBuildNumber') - ..aOS(52, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'dartSdkVersion', protoName: 'dartSdkVersion') - ..hasRequiredFields = false - ; - - CbjHubIno._() : super(); - factory CbjHubIno({ - $core.String? pubspecYamlVersion, - $core.String? entityName, - $core.String? protoLastGenDate, - $core.String? pubspecYamlBuildNumber, - $core.String? dartSdkVersion, - }) { - final _result = create(); - if (pubspecYamlVersion != null) { - _result.pubspecYamlVersion = pubspecYamlVersion; - } - if (entityName != null) { - _result.entityName = entityName; - } - if (protoLastGenDate != null) { - _result.protoLastGenDate = protoLastGenDate; - } - if (pubspecYamlBuildNumber != null) { - _result.pubspecYamlBuildNumber = pubspecYamlBuildNumber; - } - if (dartSdkVersion != null) { - _result.dartSdkVersion = dartSdkVersion; - } - return _result; - } - factory CbjHubIno.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory CbjHubIno.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - CbjHubIno clone() => CbjHubIno()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - CbjHubIno copyWith(void Function(CbjHubIno) updates) => super.copyWith((message) => updates(message as CbjHubIno)) as CbjHubIno; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static CbjHubIno create() => CbjHubIno._(); - CbjHubIno createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static CbjHubIno getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static CbjHubIno? _defaultInstance; - - @$pb.TagNumber(27) - $core.String get pubspecYamlVersion => $_getSZ(0); - @$pb.TagNumber(27) - set pubspecYamlVersion($core.String v) { $_setString(0, v); } - @$pb.TagNumber(27) - $core.bool hasPubspecYamlVersion() => $_has(0); - @$pb.TagNumber(27) - void clearPubspecYamlVersion() => clearField(27); - - @$pb.TagNumber(48) - $core.String get entityName => $_getSZ(1); - @$pb.TagNumber(48) - set entityName($core.String v) { $_setString(1, v); } - @$pb.TagNumber(48) - $core.bool hasEntityName() => $_has(1); - @$pb.TagNumber(48) - void clearEntityName() => clearField(48); - - @$pb.TagNumber(49) - $core.String get protoLastGenDate => $_getSZ(2); - @$pb.TagNumber(49) - set protoLastGenDate($core.String v) { $_setString(2, v); } - @$pb.TagNumber(49) - $core.bool hasProtoLastGenDate() => $_has(2); - @$pb.TagNumber(49) - void clearProtoLastGenDate() => clearField(49); - - @$pb.TagNumber(51) - $core.String get pubspecYamlBuildNumber => $_getSZ(3); - @$pb.TagNumber(51) - set pubspecYamlBuildNumber($core.String v) { $_setString(3, v); } - @$pb.TagNumber(51) - $core.bool hasPubspecYamlBuildNumber() => $_has(3); - @$pb.TagNumber(51) - void clearPubspecYamlBuildNumber() => clearField(51); - - @$pb.TagNumber(52) - $core.String get dartSdkVersion => $_getSZ(4); - @$pb.TagNumber(52) - set dartSdkVersion($core.String v) { $_setString(4, v); } - @$pb.TagNumber(52) - $core.bool hasDartSdkVersion() => $_has(4); - @$pb.TagNumber(52) - void clearDartSdkVersion() => clearField(52); -} - -class CompHubSpecs extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CompHubSpecs', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjHub'), createEmptyInstance: create) - ..aOS(22, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'compId', protoName: 'compId') - ..aOS(23, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'compUuid', protoName: 'compUuid') - ..aOS(24, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'compOs', protoName: 'compOs') - ..aOS(25, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'compModel', protoName: 'compModel') - ..aOS(26, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'compType', protoName: 'compType') - ..aOS(50, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'compIp', protoName: 'compIp') - ..hasRequiredFields = false - ; - - CompHubSpecs._() : super(); - factory CompHubSpecs({ - $core.String? compId, - $core.String? compUuid, - $core.String? compOs, - $core.String? compModel, - $core.String? compType, - $core.String? compIp, - }) { - final _result = create(); - if (compId != null) { - _result.compId = compId; - } - if (compUuid != null) { - _result.compUuid = compUuid; - } - if (compOs != null) { - _result.compOs = compOs; - } - if (compModel != null) { - _result.compModel = compModel; - } - if (compType != null) { - _result.compType = compType; - } - if (compIp != null) { - _result.compIp = compIp; - } - return _result; - } - factory CompHubSpecs.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory CompHubSpecs.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - CompHubSpecs clone() => CompHubSpecs()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - CompHubSpecs copyWith(void Function(CompHubSpecs) updates) => super.copyWith((message) => updates(message as CompHubSpecs)) as CompHubSpecs; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static CompHubSpecs create() => CompHubSpecs._(); - CompHubSpecs createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static CompHubSpecs getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static CompHubSpecs? _defaultInstance; - - @$pb.TagNumber(22) - $core.String get compId => $_getSZ(0); - @$pb.TagNumber(22) - set compId($core.String v) { $_setString(0, v); } - @$pb.TagNumber(22) - $core.bool hasCompId() => $_has(0); - @$pb.TagNumber(22) - void clearCompId() => clearField(22); - - @$pb.TagNumber(23) - $core.String get compUuid => $_getSZ(1); - @$pb.TagNumber(23) - set compUuid($core.String v) { $_setString(1, v); } - @$pb.TagNumber(23) - $core.bool hasCompUuid() => $_has(1); - @$pb.TagNumber(23) - void clearCompUuid() => clearField(23); - - @$pb.TagNumber(24) - $core.String get compOs => $_getSZ(2); - @$pb.TagNumber(24) - set compOs($core.String v) { $_setString(2, v); } - @$pb.TagNumber(24) - $core.bool hasCompOs() => $_has(2); - @$pb.TagNumber(24) - void clearCompOs() => clearField(24); - - @$pb.TagNumber(25) - $core.String get compModel => $_getSZ(3); - @$pb.TagNumber(25) - set compModel($core.String v) { $_setString(3, v); } - @$pb.TagNumber(25) - $core.bool hasCompModel() => $_has(3); - @$pb.TagNumber(25) - void clearCompModel() => clearField(25); - - @$pb.TagNumber(26) - $core.String get compType => $_getSZ(4); - @$pb.TagNumber(26) - set compType($core.String v) { $_setString(4, v); } - @$pb.TagNumber(26) - $core.bool hasCompType() => $_has(4); - @$pb.TagNumber(26) - void clearCompType() => clearField(26); - - @$pb.TagNumber(50) - $core.String get compIp => $_getSZ(5); - @$pb.TagNumber(50) - set compIp($core.String v) { $_setString(5, v); } - @$pb.TagNumber(50) - $core.bool hasCompIp() => $_has(5); - @$pb.TagNumber(50) - void clearCompIp() => clearField(50); -} - -class MicrocontrollerSpecs extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'MicrocontrollerSpecs', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjHub'), createEmptyInstance: create) - ..aOS(31, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'microcontrollerModel', protoName: 'microcontrollerModel') - ..aOS(32, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'microcontrollerType', protoName: 'microcontrollerType') - ..aOS(33, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'softwareVersion', protoName: 'softwareVersion') - ..hasRequiredFields = false - ; - - MicrocontrollerSpecs._() : super(); - factory MicrocontrollerSpecs({ - $core.String? microcontrollerModel, - $core.String? microcontrollerType, - $core.String? softwareVersion, - }) { - final _result = create(); - if (microcontrollerModel != null) { - _result.microcontrollerModel = microcontrollerModel; - } - if (microcontrollerType != null) { - _result.microcontrollerType = microcontrollerType; - } - if (softwareVersion != null) { - _result.softwareVersion = softwareVersion; - } - return _result; - } - factory MicrocontrollerSpecs.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory MicrocontrollerSpecs.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - MicrocontrollerSpecs clone() => MicrocontrollerSpecs()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - MicrocontrollerSpecs copyWith(void Function(MicrocontrollerSpecs) updates) => super.copyWith((message) => updates(message as MicrocontrollerSpecs)) as MicrocontrollerSpecs; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static MicrocontrollerSpecs create() => MicrocontrollerSpecs._(); - MicrocontrollerSpecs createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static MicrocontrollerSpecs getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static MicrocontrollerSpecs? _defaultInstance; - - @$pb.TagNumber(31) - $core.String get microcontrollerModel => $_getSZ(0); - @$pb.TagNumber(31) - set microcontrollerModel($core.String v) { $_setString(0, v); } - @$pb.TagNumber(31) - $core.bool hasMicrocontrollerModel() => $_has(0); - @$pb.TagNumber(31) - void clearMicrocontrollerModel() => clearField(31); - - @$pb.TagNumber(32) - $core.String get microcontrollerType => $_getSZ(1); - @$pb.TagNumber(32) - set microcontrollerType($core.String v) { $_setString(1, v); } - @$pb.TagNumber(32) - $core.bool hasMicrocontrollerType() => $_has(1); - @$pb.TagNumber(32) - void clearMicrocontrollerType() => clearField(32); - - @$pb.TagNumber(33) - $core.String get softwareVersion => $_getSZ(2); - @$pb.TagNumber(33) - set softwareVersion($core.String v) { $_setString(2, v); } - @$pb.TagNumber(33) - $core.bool hasSoftwareVersion() => $_has(2); - @$pb.TagNumber(33) - void clearSoftwareVersion() => clearField(33); -} - -class SmartEntityInfo extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'SmartEntityInfo', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjHub'), createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'id') - ..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'state') - ..aOS(14, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'defaultName', protoName: 'defaultName') - ..aOS(15, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'roomId', protoName: 'roomId') - ..aOS(16, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'senderDeviceModel', protoName: 'senderDeviceModel') - ..aOS(17, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'senderDeviceOs', protoName: 'senderDeviceOs') - ..aOS(18, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'senderId', protoName: 'senderId') - ..aOS(19, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'serverTimeStamp', protoName: 'serverTimeStamp') - ..aOS(20, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'stateMassage', protoName: 'stateMassage') - ..aOB(29, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'isComputer', protoName: 'isComputer') - ..aOM(30, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'compSpecs', protoName: 'compSpecs', subBuilder: CompHubSpecs.create) - ..aOM(31, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'microcontrollerSpecsSpecs', protoName: 'microcontrollerSpecsSpecs', subBuilder: MicrocontrollerSpecs.create) - ..aOM(34, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'entityTypesActions', protoName: 'entityTypesActions', subBuilder: EntityTypesActions.create) - ..aOM(43, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'mqttMassage', protoName: 'mqttMassage', subBuilder: MqttMassage.create) - ..hasRequiredFields = false - ; - - SmartEntityInfo._() : super(); - factory SmartEntityInfo({ - $core.String? id, - $core.String? state, - $core.String? defaultName, - $core.String? roomId, - $core.String? senderDeviceModel, - $core.String? senderDeviceOs, - $core.String? senderId, - $core.String? serverTimeStamp, - $core.String? stateMassage, - $core.bool? isComputer, - CompHubSpecs? compSpecs, - MicrocontrollerSpecs? microcontrollerSpecsSpecs, - EntityTypesActions? entityTypesActions, - MqttMassage? mqttMassage, - }) { - final _result = create(); - if (id != null) { - _result.id = id; - } - if (state != null) { - _result.state = state; - } - if (defaultName != null) { - _result.defaultName = defaultName; - } - if (roomId != null) { - _result.roomId = roomId; - } - if (senderDeviceModel != null) { - _result.senderDeviceModel = senderDeviceModel; - } - if (senderDeviceOs != null) { - _result.senderDeviceOs = senderDeviceOs; - } - if (senderId != null) { - _result.senderId = senderId; - } - if (serverTimeStamp != null) { - _result.serverTimeStamp = serverTimeStamp; - } - if (stateMassage != null) { - _result.stateMassage = stateMassage; - } - if (isComputer != null) { - _result.isComputer = isComputer; - } - if (compSpecs != null) { - _result.compSpecs = compSpecs; - } - if (microcontrollerSpecsSpecs != null) { - _result.microcontrollerSpecsSpecs = microcontrollerSpecsSpecs; - } - if (entityTypesActions != null) { - _result.entityTypesActions = entityTypesActions; - } - if (mqttMassage != null) { - _result.mqttMassage = mqttMassage; - } - return _result; - } - factory SmartEntityInfo.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory SmartEntityInfo.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - SmartEntityInfo clone() => SmartEntityInfo()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - SmartEntityInfo copyWith(void Function(SmartEntityInfo) updates) => super.copyWith((message) => updates(message as SmartEntityInfo)) as SmartEntityInfo; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static SmartEntityInfo create() => SmartEntityInfo._(); - SmartEntityInfo createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static SmartEntityInfo getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static SmartEntityInfo? _defaultInstance; - - @$pb.TagNumber(1) - $core.String get id => $_getSZ(0); - @$pb.TagNumber(1) - set id($core.String v) { $_setString(0, v); } - @$pb.TagNumber(1) - $core.bool hasId() => $_has(0); - @$pb.TagNumber(1) - void clearId() => clearField(1); - - @$pb.TagNumber(3) - $core.String get state => $_getSZ(1); - @$pb.TagNumber(3) - set state($core.String v) { $_setString(1, v); } - @$pb.TagNumber(3) - $core.bool hasState() => $_has(1); - @$pb.TagNumber(3) - void clearState() => clearField(3); - - @$pb.TagNumber(14) - $core.String get defaultName => $_getSZ(2); - @$pb.TagNumber(14) - set defaultName($core.String v) { $_setString(2, v); } - @$pb.TagNumber(14) - $core.bool hasDefaultName() => $_has(2); - @$pb.TagNumber(14) - void clearDefaultName() => clearField(14); - - @$pb.TagNumber(15) - $core.String get roomId => $_getSZ(3); - @$pb.TagNumber(15) - set roomId($core.String v) { $_setString(3, v); } - @$pb.TagNumber(15) - $core.bool hasRoomId() => $_has(3); - @$pb.TagNumber(15) - void clearRoomId() => clearField(15); - - @$pb.TagNumber(16) - $core.String get senderDeviceModel => $_getSZ(4); - @$pb.TagNumber(16) - set senderDeviceModel($core.String v) { $_setString(4, v); } - @$pb.TagNumber(16) - $core.bool hasSenderDeviceModel() => $_has(4); - @$pb.TagNumber(16) - void clearSenderDeviceModel() => clearField(16); - - @$pb.TagNumber(17) - $core.String get senderDeviceOs => $_getSZ(5); - @$pb.TagNumber(17) - set senderDeviceOs($core.String v) { $_setString(5, v); } - @$pb.TagNumber(17) - $core.bool hasSenderDeviceOs() => $_has(5); - @$pb.TagNumber(17) - void clearSenderDeviceOs() => clearField(17); - - @$pb.TagNumber(18) - $core.String get senderId => $_getSZ(6); - @$pb.TagNumber(18) - set senderId($core.String v) { $_setString(6, v); } - @$pb.TagNumber(18) - $core.bool hasSenderId() => $_has(6); - @$pb.TagNumber(18) - void clearSenderId() => clearField(18); - - @$pb.TagNumber(19) - $core.String get serverTimeStamp => $_getSZ(7); - @$pb.TagNumber(19) - set serverTimeStamp($core.String v) { $_setString(7, v); } - @$pb.TagNumber(19) - $core.bool hasServerTimeStamp() => $_has(7); - @$pb.TagNumber(19) - void clearServerTimeStamp() => clearField(19); - - @$pb.TagNumber(20) - $core.String get stateMassage => $_getSZ(8); - @$pb.TagNumber(20) - set stateMassage($core.String v) { $_setString(8, v); } - @$pb.TagNumber(20) - $core.bool hasStateMassage() => $_has(8); - @$pb.TagNumber(20) - void clearStateMassage() => clearField(20); - - @$pb.TagNumber(29) - $core.bool get isComputer => $_getBF(9); - @$pb.TagNumber(29) - set isComputer($core.bool v) { $_setBool(9, v); } - @$pb.TagNumber(29) - $core.bool hasIsComputer() => $_has(9); - @$pb.TagNumber(29) - void clearIsComputer() => clearField(29); - - @$pb.TagNumber(30) - CompHubSpecs get compSpecs => $_getN(10); - @$pb.TagNumber(30) - set compSpecs(CompHubSpecs v) { setField(30, v); } - @$pb.TagNumber(30) - $core.bool hasCompSpecs() => $_has(10); - @$pb.TagNumber(30) - void clearCompSpecs() => clearField(30); - @$pb.TagNumber(30) - CompHubSpecs ensureCompSpecs() => $_ensure(10); - - @$pb.TagNumber(31) - MicrocontrollerSpecs get microcontrollerSpecsSpecs => $_getN(11); - @$pb.TagNumber(31) - set microcontrollerSpecsSpecs(MicrocontrollerSpecs v) { setField(31, v); } - @$pb.TagNumber(31) - $core.bool hasMicrocontrollerSpecsSpecs() => $_has(11); - @$pb.TagNumber(31) - void clearMicrocontrollerSpecsSpecs() => clearField(31); - @$pb.TagNumber(31) - MicrocontrollerSpecs ensureMicrocontrollerSpecsSpecs() => $_ensure(11); - - @$pb.TagNumber(34) - EntityTypesActions get entityTypesActions => $_getN(12); - @$pb.TagNumber(34) - set entityTypesActions(EntityTypesActions v) { setField(34, v); } - @$pb.TagNumber(34) - $core.bool hasEntityTypesActions() => $_has(12); - @$pb.TagNumber(34) - void clearEntityTypesActions() => clearField(34); - @$pb.TagNumber(34) - EntityTypesActions ensureEntityTypesActions() => $_ensure(12); - - @$pb.TagNumber(43) - MqttMassage get mqttMassage => $_getN(13); - @$pb.TagNumber(43) - set mqttMassage(MqttMassage v) { setField(43, v); } - @$pb.TagNumber(43) - $core.bool hasMqttMassage() => $_has(13); - @$pb.TagNumber(43) - void clearMqttMassage() => clearField(43); - @$pb.TagNumber(43) - MqttMassage ensureMqttMassage() => $_ensure(13); -} - -class SmartEntityStatus extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'SmartEntityStatus', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjHub'), createEmptyInstance: create) - ..aOB(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'onOffState', protoName: 'onOffState') - ..hasRequiredFields = false - ; - - SmartEntityStatus._() : super(); - factory SmartEntityStatus({ - $core.bool? onOffState, - }) { - final _result = create(); - if (onOffState != null) { - _result.onOffState = onOffState; - } - return _result; - } - factory SmartEntityStatus.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory SmartEntityStatus.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - SmartEntityStatus clone() => SmartEntityStatus()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - SmartEntityStatus copyWith(void Function(SmartEntityStatus) updates) => super.copyWith((message) => updates(message as SmartEntityStatus)) as SmartEntityStatus; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static SmartEntityStatus create() => SmartEntityStatus._(); - SmartEntityStatus createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static SmartEntityStatus getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static SmartEntityStatus? _defaultInstance; - - @$pb.TagNumber(4) - $core.bool get onOffState => $_getBF(0); - @$pb.TagNumber(4) - set onOffState($core.bool v) { $_setBool(0, v); } - @$pb.TagNumber(4) - $core.bool hasOnOffState() => $_has(0); - @$pb.TagNumber(4) - void clearOnOffState() => clearField(4); -} - -class MqttMassage extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'MqttMassage', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjHub'), createEmptyInstance: create) - ..aOS(44, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'mqttTopic', protoName: 'mqttTopic') - ..aOS(45, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'mqttMassage', protoName: 'mqttMassage') - ..hasRequiredFields = false - ; - - MqttMassage._() : super(); - factory MqttMassage({ - $core.String? mqttTopic, - $core.String? mqttMassage, - }) { - final _result = create(); - if (mqttTopic != null) { - _result.mqttTopic = mqttTopic; - } - if (mqttMassage != null) { - _result.mqttMassage = mqttMassage; - } - return _result; - } - factory MqttMassage.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory MqttMassage.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - MqttMassage clone() => MqttMassage()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - MqttMassage copyWith(void Function(MqttMassage) updates) => super.copyWith((message) => updates(message as MqttMassage)) as MqttMassage; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static MqttMassage create() => MqttMassage._(); - MqttMassage createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static MqttMassage getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static MqttMassage? _defaultInstance; - - @$pb.TagNumber(44) - $core.String get mqttTopic => $_getSZ(0); - @$pb.TagNumber(44) - set mqttTopic($core.String v) { $_setString(0, v); } - @$pb.TagNumber(44) - $core.bool hasMqttTopic() => $_has(0); - @$pb.TagNumber(44) - void clearMqttTopic() => clearField(44); - - @$pb.TagNumber(45) - $core.String get mqttMassage => $_getSZ(1); - @$pb.TagNumber(45) - set mqttMassage($core.String v) { $_setString(1, v); } - @$pb.TagNumber(45) - $core.bool hasMqttMassage() => $_has(1); - @$pb.TagNumber(45) - void clearMqttMassage() => clearField(45); -} - -class CommendStatus extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CommendStatus', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjHub'), createEmptyInstance: create) - ..aOB(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'success') - ..hasRequiredFields = false - ; - - CommendStatus._() : super(); - factory CommendStatus({ - $core.bool? success, - }) { - final _result = create(); - if (success != null) { - _result.success = success; - } - return _result; - } - factory CommendStatus.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory CommendStatus.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - CommendStatus clone() => CommendStatus()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - CommendStatus copyWith(void Function(CommendStatus) updates) => super.copyWith((message) => updates(message as CommendStatus)) as CommendStatus; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static CommendStatus create() => CommendStatus._(); - CommendStatus createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static CommendStatus getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static CommendStatus? _defaultInstance; - - @$pb.TagNumber(5) - $core.bool get success => $_getBF(0); - @$pb.TagNumber(5) - set success($core.bool v) { $_setBool(0, v); } - @$pb.TagNumber(5) - $core.bool hasSuccess() => $_has(0); - @$pb.TagNumber(5) - void clearSuccess() => clearField(5); -} - -class SmartEntitiesUpdateDetails extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'SmartEntitiesUpdateDetails', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjHub'), createEmptyInstance: create) - ..aOM(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'smartEntity', protoName: 'smartEntity', subBuilder: SmartEntityInfo.create) - ..aOS(7, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'newName', protoName: 'newName') - ..hasRequiredFields = false - ; - - SmartEntitiesUpdateDetails._() : super(); - factory SmartEntitiesUpdateDetails({ - SmartEntityInfo? smartEntity, - $core.String? newName, - }) { - final _result = create(); - if (smartEntity != null) { - _result.smartEntity = smartEntity; - } - if (newName != null) { - _result.newName = newName; - } - return _result; - } - factory SmartEntitiesUpdateDetails.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory SmartEntitiesUpdateDetails.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - SmartEntitiesUpdateDetails clone() => SmartEntitiesUpdateDetails()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - SmartEntitiesUpdateDetails copyWith(void Function(SmartEntitiesUpdateDetails) updates) => super.copyWith((message) => updates(message as SmartEntitiesUpdateDetails)) as SmartEntitiesUpdateDetails; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static SmartEntitiesUpdateDetails create() => SmartEntitiesUpdateDetails._(); - SmartEntitiesUpdateDetails createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static SmartEntitiesUpdateDetails getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static SmartEntitiesUpdateDetails? _defaultInstance; - - @$pb.TagNumber(6) - SmartEntityInfo get smartEntity => $_getN(0); - @$pb.TagNumber(6) - set smartEntity(SmartEntityInfo v) { setField(6, v); } - @$pb.TagNumber(6) - $core.bool hasSmartEntity() => $_has(0); - @$pb.TagNumber(6) - void clearSmartEntity() => clearField(6); - @$pb.TagNumber(6) - SmartEntityInfo ensureSmartEntity() => $_ensure(0); - - @$pb.TagNumber(7) - $core.String get newName => $_getSZ(1); - @$pb.TagNumber(7) - set newName($core.String v) { $_setString(1, v); } - @$pb.TagNumber(7) - $core.bool hasNewName() => $_has(1); - @$pb.TagNumber(7) - void clearNewName() => clearField(7); -} - -class CloudAccountInformation extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CloudAccountInformation', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjHub'), createEmptyInstance: create) - ..aOS(8, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'cloudProjectId', protoName: 'cloudProjectId') - ..aOS(9, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'cloudApiKey', protoName: 'cloudApiKey') - ..aOS(10, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'userEmail', protoName: 'userEmail') - ..aOS(11, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'userPassword', protoName: 'userPassword') - ..aOS(12, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'homeId', protoName: 'homeId') - ..hasRequiredFields = false - ; - - CloudAccountInformation._() : super(); - factory CloudAccountInformation({ - $core.String? cloudProjectId, - $core.String? cloudApiKey, - $core.String? userEmail, - $core.String? userPassword, - $core.String? homeId, - }) { - final _result = create(); - if (cloudProjectId != null) { - _result.cloudProjectId = cloudProjectId; - } - if (cloudApiKey != null) { - _result.cloudApiKey = cloudApiKey; - } - if (userEmail != null) { - _result.userEmail = userEmail; - } - if (userPassword != null) { - _result.userPassword = userPassword; - } - if (homeId != null) { - _result.homeId = homeId; - } - return _result; - } - factory CloudAccountInformation.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory CloudAccountInformation.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - CloudAccountInformation clone() => CloudAccountInformation()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - CloudAccountInformation copyWith(void Function(CloudAccountInformation) updates) => super.copyWith((message) => updates(message as CloudAccountInformation)) as CloudAccountInformation; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static CloudAccountInformation create() => CloudAccountInformation._(); - CloudAccountInformation createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static CloudAccountInformation getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static CloudAccountInformation? _defaultInstance; - - @$pb.TagNumber(8) - $core.String get cloudProjectId => $_getSZ(0); - @$pb.TagNumber(8) - set cloudProjectId($core.String v) { $_setString(0, v); } - @$pb.TagNumber(8) - $core.bool hasCloudProjectId() => $_has(0); - @$pb.TagNumber(8) - void clearCloudProjectId() => clearField(8); - - @$pb.TagNumber(9) - $core.String get cloudApiKey => $_getSZ(1); - @$pb.TagNumber(9) - set cloudApiKey($core.String v) { $_setString(1, v); } - @$pb.TagNumber(9) - $core.bool hasCloudApiKey() => $_has(1); - @$pb.TagNumber(9) - void clearCloudApiKey() => clearField(9); - - @$pb.TagNumber(10) - $core.String get userEmail => $_getSZ(2); - @$pb.TagNumber(10) - set userEmail($core.String v) { $_setString(2, v); } - @$pb.TagNumber(10) - $core.bool hasUserEmail() => $_has(2); - @$pb.TagNumber(10) - void clearUserEmail() => clearField(10); - - @$pb.TagNumber(11) - $core.String get userPassword => $_getSZ(3); - @$pb.TagNumber(11) - set userPassword($core.String v) { $_setString(3, v); } - @$pb.TagNumber(11) - $core.bool hasUserPassword() => $_has(3); - @$pb.TagNumber(11) - void clearUserPassword() => clearField(11); - - @$pb.TagNumber(12) - $core.String get homeId => $_getSZ(4); - @$pb.TagNumber(12) - set homeId($core.String v) { $_setString(4, v); } - @$pb.TagNumber(12) - $core.bool hasHomeId() => $_has(4); - @$pb.TagNumber(12) - void clearHomeId() => clearField(12); -} - -class EntityTypesActions extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'EntityTypesActions', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjHub'), createEmptyInstance: create) - ..e(35, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'entityType', $pb.PbFieldType.OE, protoName: 'entityType', defaultOrMaker: EntityTypes.smartTypeNotSupported, valueOf: EntityTypes.valueOf, enumValues: EntityTypes.values) - ..e(36, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'entityAction', $pb.PbFieldType.OE, protoName: 'entityAction', defaultOrMaker: EntityActions.actionNotSupported, valueOf: EntityActions.valueOf, enumValues: EntityActions.values) - ..e(37, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'entityStateGRPC', $pb.PbFieldType.OE, protoName: 'entityStateGRPC', defaultOrMaker: EntityStateGRPC.stateNotSupported, valueOf: EntityStateGRPC.valueOf, enumValues: EntityStateGRPC.values) - ..e(46, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'vendorsAndServices', $pb.PbFieldType.OE, protoName: 'vendorsAndServices', defaultOrMaker: VendorsAndServices.vendorsAndServicesNotSupported, valueOf: VendorsAndServices.valueOf, enumValues: VendorsAndServices.values) - ..hasRequiredFields = false - ; - - EntityTypesActions._() : super(); - factory EntityTypesActions({ - EntityTypes? entityType, - EntityActions? entityAction, - EntityStateGRPC? entityStateGRPC, - VendorsAndServices? vendorsAndServices, - }) { - final _result = create(); - if (entityType != null) { - _result.entityType = entityType; - } - if (entityAction != null) { - _result.entityAction = entityAction; - } - if (entityStateGRPC != null) { - _result.entityStateGRPC = entityStateGRPC; - } - if (vendorsAndServices != null) { - _result.vendorsAndServices = vendorsAndServices; - } - return _result; - } - factory EntityTypesActions.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory EntityTypesActions.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - EntityTypesActions clone() => EntityTypesActions()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - EntityTypesActions copyWith(void Function(EntityTypesActions) updates) => super.copyWith((message) => updates(message as EntityTypesActions)) as EntityTypesActions; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static EntityTypesActions create() => EntityTypesActions._(); - EntityTypesActions createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static EntityTypesActions getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static EntityTypesActions? _defaultInstance; - - @$pb.TagNumber(35) - EntityTypes get entityType => $_getN(0); - @$pb.TagNumber(35) - set entityType(EntityTypes v) { setField(35, v); } - @$pb.TagNumber(35) - $core.bool hasEntityType() => $_has(0); - @$pb.TagNumber(35) - void clearEntityType() => clearField(35); - - @$pb.TagNumber(36) - EntityActions get entityAction => $_getN(1); - @$pb.TagNumber(36) - set entityAction(EntityActions v) { setField(36, v); } - @$pb.TagNumber(36) - $core.bool hasEntityAction() => $_has(1); - @$pb.TagNumber(36) - void clearEntityAction() => clearField(36); - - @$pb.TagNumber(37) - EntityStateGRPC get entityStateGRPC => $_getN(2); - @$pb.TagNumber(37) - set entityStateGRPC(EntityStateGRPC v) { setField(37, v); } - @$pb.TagNumber(37) - $core.bool hasEntityStateGRPC() => $_has(2); - @$pb.TagNumber(37) - void clearEntityStateGRPC() => clearField(37); - - @$pb.TagNumber(46) - VendorsAndServices get vendorsAndServices => $_getN(3); - @$pb.TagNumber(46) - set vendorsAndServices(VendorsAndServices v) { setField(46, v); } - @$pb.TagNumber(46) - $core.bool hasVendorsAndServices() => $_has(3); - @$pb.TagNumber(46) - void clearVendorsAndServices() => clearField(46); -} - diff --git a/lib/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbenum.dart b/lib/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbenum.dart deleted file mode 100644 index b2627854..00000000 --- a/lib/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbenum.dart +++ /dev/null @@ -1,498 +0,0 @@ -/// -// Generated code. Do not modify. -// source: cbj_hub_server.proto -// -// @dart = 2.12 -// ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name - -// ignore_for_file: UNDEFINED_SHOWN_NAME -import 'dart:core' as $core; -import 'package:protobuf/protobuf.dart' as $pb; - -class SendingType extends $pb.ProtobufEnum { - static const SendingType undefinedType = SendingType._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'undefinedType'); - static const SendingType stringType = SendingType._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'stringType'); - static const SendingType partialEntityType = SendingType._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'partialEntityType'); - static const SendingType entityType = SendingType._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'entityType'); - static const SendingType mqttMassageType = SendingType._(4, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'mqttMassageType'); - static const SendingType sceneType = SendingType._(5, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'sceneType'); - static const SendingType scheduleType = SendingType._(6, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'scheduleType'); - static const SendingType routineType = SendingType._(7, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'routineType'); - static const SendingType bindingsType = SendingType._(8, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'bindingsType'); - static const SendingType vendorLoginType = SendingType._(9, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'vendorLoginType'); - static const SendingType firstConnection = SendingType._(10, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'firstConnection'); - static const SendingType remotePipesInformation = SendingType._(11, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'remotePipesInformation'); - static const SendingType getHubEntityInfo = SendingType._(12, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'getHubEntityInfo'); - static const SendingType responseHubEntityInfo = SendingType._(13, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'responseHubEntityInfo'); - static const SendingType roomType = SendingType._(14, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'roomType'); - static const SendingType location = SendingType._(15, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'location'); - - static const $core.List values = [ - undefinedType, - stringType, - partialEntityType, - entityType, - mqttMassageType, - sceneType, - scheduleType, - routineType, - bindingsType, - vendorLoginType, - firstConnection, - remotePipesInformation, - getHubEntityInfo, - responseHubEntityInfo, - roomType, - location, - ]; - - static final $core.Map<$core.int, SendingType> _byValue = $pb.ProtobufEnum.initByValue(values); - static SendingType? valueOf($core.int value) => _byValue[value]; - - const SendingType._($core.int v, $core.String n) : super(v, n); -} - -class EntityStateGRPC extends $pb.ProtobufEnum { - static const EntityStateGRPC stateNotSupported = EntityStateGRPC._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'stateNotSupported'); - static const EntityStateGRPC cancelStateInProcess = EntityStateGRPC._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'cancelStateInProcess'); - static const EntityStateGRPC ack = EntityStateGRPC._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ack'); - static const EntityStateGRPC newStateFailed = EntityStateGRPC._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'newStateFailed'); - static const EntityStateGRPC waitingInCloud = EntityStateGRPC._(4, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'waitingInCloud'); - static const EntityStateGRPC waitingInComp = EntityStateGRPC._(5, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'waitingInComp'); - static const EntityStateGRPC noEntitiesToTransfer = EntityStateGRPC._(6, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'noEntitiesToTransfer'); - static const EntityStateGRPC pingNow = EntityStateGRPC._(7, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'pingNow'); - static const EntityStateGRPC addingNewScene = EntityStateGRPC._(8, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'addingNewScene'); - static const EntityStateGRPC addingNewRoutine = EntityStateGRPC._(9, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'addingNewRoutine'); - static const EntityStateGRPC addingNewBinding = EntityStateGRPC._(10, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'addingNewBinding'); - static const EntityStateGRPC updateHubEntityPropertiesFromRealEntity = EntityStateGRPC._(11, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'updateHubEntityPropertiesFromRealEntity'); - - static const $core.List values = [ - stateNotSupported, - cancelStateInProcess, - ack, - newStateFailed, - waitingInCloud, - waitingInComp, - noEntitiesToTransfer, - pingNow, - addingNewScene, - addingNewRoutine, - addingNewBinding, - updateHubEntityPropertiesFromRealEntity, - ]; - - static final $core.Map<$core.int, EntityStateGRPC> _byValue = $pb.ProtobufEnum.initByValue(values); - static EntityStateGRPC? valueOf($core.int value) => _byValue[value]; - - const EntityStateGRPC._($core.int v, $core.String n) : super(v, n); -} - -class VendorsAndServices extends $pb.ProtobufEnum { - static const VendorsAndServices vendorsAndServicesNotSupported = VendorsAndServices._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'vendorsAndServicesNotSupported'); - static const VendorsAndServices espHome = VendorsAndServices._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'espHome'); - static const VendorsAndServices switcherSmartHome = VendorsAndServices._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'switcherSmartHome'); - static const VendorsAndServices tasmota = VendorsAndServices._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'tasmota'); - static const VendorsAndServices yeelight = VendorsAndServices._(4, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'yeelight'); - static const VendorsAndServices google = VendorsAndServices._(5, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'google'); - static const VendorsAndServices miHome = VendorsAndServices._(6, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'miHome'); - static const VendorsAndServices lifx = VendorsAndServices._(7, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'lifx'); - static const VendorsAndServices tuyaSmart = VendorsAndServices._(8, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'tuyaSmart'); - static const VendorsAndServices smartLife = VendorsAndServices._(9, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'smartLife'); - static const VendorsAndServices jinvooSmart = VendorsAndServices._(10, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'jinvooSmart'); - static const VendorsAndServices shelly = VendorsAndServices._(11, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'shelly'); - static const VendorsAndServices wink = VendorsAndServices._(12, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'wink'); - static const VendorsAndServices ikea = VendorsAndServices._(13, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ikea'); - static const VendorsAndServices sonoffDiy = VendorsAndServices._(14, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'sonoffDiy'); - static const VendorsAndServices philipsHue = VendorsAndServices._(15, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'philipsHue'); - static const VendorsAndServices lg = VendorsAndServices._(16, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'lg'); - static const VendorsAndServices spotify = VendorsAndServices._(17, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'spotify'); - static const VendorsAndServices homeAssistant = VendorsAndServices._(18, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'homeAssistant'); - static const VendorsAndServices hp = VendorsAndServices._(19, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'hp'); - static const VendorsAndServices yeelink = VendorsAndServices._(20, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'yeelink'); - static const VendorsAndServices xiaomi = VendorsAndServices._(21, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'xiaomi'); - static const VendorsAndServices sonoffEweLink = VendorsAndServices._(22, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'sonoffEweLink'); - static const VendorsAndServices cbjDeviceSmartEntity = VendorsAndServices._(23, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'cbjDeviceSmartEntity'); - static const VendorsAndServices wiz = VendorsAndServices._(24, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'wiz'); - static const VendorsAndServices switchBot = VendorsAndServices._(25, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'switchBot'); - static const VendorsAndServices somfy = VendorsAndServices._(26, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'somfy'); - static const VendorsAndServices sensibo = VendorsAndServices._(27, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'sensibo'); - static const VendorsAndServices aqara = VendorsAndServices._(28, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'aqara'); - static const VendorsAndServices matter = VendorsAndServices._(29, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'matter'); - static const VendorsAndServices nest = VendorsAndServices._(30, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'nest'); - static const VendorsAndServices uniFi = VendorsAndServices._(31, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'uniFi'); - static const VendorsAndServices ring = VendorsAndServices._(32, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ring'); - static const VendorsAndServices myQ = VendorsAndServices._(33, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'myQ'); - static const VendorsAndServices wemo = VendorsAndServices._(34, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'wemo'); - static const VendorsAndServices tpLink = VendorsAndServices._(35, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'tpLink'); - static const VendorsAndServices nuki = VendorsAndServices._(36, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'nuki'); - static const VendorsAndServices homebridge = VendorsAndServices._(37, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'homebridge'); - static const VendorsAndServices homeKit = VendorsAndServices._(38, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'homeKit'); - static const VendorsAndServices twinkly = VendorsAndServices._(39, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'twinkly'); - static const VendorsAndServices samsung = VendorsAndServices._(40, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'samsung'); - static const VendorsAndServices tizen = VendorsAndServices._(41, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'tizen'); - static const VendorsAndServices zigbee = VendorsAndServices._(42, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'zigbee'); - static const VendorsAndServices zWave = VendorsAndServices._(43, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'zWave'); - static const VendorsAndServices ffmpeg = VendorsAndServices._(44, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ffmpeg'); - static const VendorsAndServices lightwaveRf = VendorsAndServices._(45, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'lightwaveRf'); - static const VendorsAndServices cololight = VendorsAndServices._(46, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'cololight'); - static const VendorsAndServices broadlink = VendorsAndServices._(47, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'broadlink'); - static const VendorsAndServices switchBee = VendorsAndServices._(48, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'switchBee'); - static const VendorsAndServices mycroft = VendorsAndServices._(49, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'mycroft'); - static const VendorsAndServices xiaomiMi = VendorsAndServices._(50, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'xiaomiMi'); - static const VendorsAndServices cyBearJinniAppSmartEntity = VendorsAndServices._(51, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'cyBearJinniAppSmartEntity'); - static const VendorsAndServices securityBear = VendorsAndServices._(52, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'securityBear'); - static const VendorsAndServices jinniAssistant = VendorsAndServices._(53, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'jinniAssistant'); - - static const $core.List values = [ - vendorsAndServicesNotSupported, - espHome, - switcherSmartHome, - tasmota, - yeelight, - google, - miHome, - lifx, - tuyaSmart, - smartLife, - jinvooSmart, - shelly, - wink, - ikea, - sonoffDiy, - philipsHue, - lg, - spotify, - homeAssistant, - hp, - yeelink, - xiaomi, - sonoffEweLink, - cbjDeviceSmartEntity, - wiz, - switchBot, - somfy, - sensibo, - aqara, - matter, - nest, - uniFi, - ring, - myQ, - wemo, - tpLink, - nuki, - homebridge, - homeKit, - twinkly, - samsung, - tizen, - zigbee, - zWave, - ffmpeg, - lightwaveRf, - cololight, - broadlink, - switchBee, - mycroft, - xiaomiMi, - cyBearJinniAppSmartEntity, - securityBear, - jinniAssistant, - ]; - - static final $core.Map<$core.int, VendorsAndServices> _byValue = $pb.ProtobufEnum.initByValue(values); - static VendorsAndServices? valueOf($core.int value) => _byValue[value]; - - const VendorsAndServices._($core.int v, $core.String n) : super(v, n); -} - -class EntityTypes extends $pb.ProtobufEnum { - static const EntityTypes smartTypeNotSupported = EntityTypes._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'smartTypeNotSupported'); - static const EntityTypes light = EntityTypes._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'light'); - static const EntityTypes blinds = EntityTypes._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'blinds'); - static const EntityTypes boiler = EntityTypes._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'boiler'); - static const EntityTypes button = EntityTypes._(4, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'button'); - static const EntityTypes buttonWithLight = EntityTypes._(5, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'buttonWithLight'); - static const EntityTypes hub = EntityTypes._(7, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'hub'); - static const EntityTypes phoneApp = EntityTypes._(8, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'phoneApp'); - static const EntityTypes computerApp = EntityTypes._(9, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'computerApp'); - static const EntityTypes browserApp = EntityTypes._(10, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'browserApp'); - static const EntityTypes switch_ = EntityTypes._(11, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'switch'); - static const EntityTypes dimmableLight = EntityTypes._(12, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'dimmableLight'); - static const EntityTypes cctLight = EntityTypes._(13, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'cctLight'); - static const EntityTypes rgbLights = EntityTypes._(14, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'rgbLights'); - static const EntityTypes rgbwLights = EntityTypes._(15, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'rgbwLights'); - static const EntityTypes rgbcctLights = EntityTypes._(16, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'rgbcctLights'); - static const EntityTypes smartTV = EntityTypes._(17, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'smartTV'); - static const EntityTypes smartSpeakers = EntityTypes._(18, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'smartSpeakers'); - static const EntityTypes coffeeMachine = EntityTypes._(19, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'coffeeMachine'); - static const EntityTypes kettle = EntityTypes._(20, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'kettle'); - static const EntityTypes teapot = EntityTypes._(21, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'teapot'); - static const EntityTypes washingMachine = EntityTypes._(22, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'washingMachine'); - static const EntityTypes dishwasher = EntityTypes._(23, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'dishwasher'); - static const EntityTypes toaster = EntityTypes._(24, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'toaster'); - static const EntityTypes vacuumCleaner = EntityTypes._(25, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'vacuumCleaner'); - static const EntityTypes refrigerator = EntityTypes._(26, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'refrigerator'); - static const EntityTypes bed = EntityTypes._(27, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'bed'); - static const EntityTypes oven = EntityTypes._(28, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'oven'); - static const EntityTypes AirConditioner = EntityTypes._(29, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'AirConditioner'); - static const EntityTypes smartWatch = EntityTypes._(30, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'smartWatch'); - static const EntityTypes smartWaterBottle = EntityTypes._(31, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'smartWaterBottle'); - static const EntityTypes microphone = EntityTypes._(32, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'microphone'); - static const EntityTypes securityCamera = EntityTypes._(33, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'securityCamera'); - static const EntityTypes babyMonitor = EntityTypes._(34, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'babyMonitor'); - static const EntityTypes motionSensor = EntityTypes._(35, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'motionSensor'); - static const EntityTypes temperatureSensor = EntityTypes._(36, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'temperatureSensor'); - static const EntityTypes humiditySensor = EntityTypes._(37, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'humiditySensor'); - static const EntityTypes lightSensor = EntityTypes._(38, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'lightSensor'); - static const EntityTypes soundSensor = EntityTypes._(39, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'soundSensor'); - static const EntityTypes smokeSensor = EntityTypes._(40, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'smokeSensor'); - static const EntityTypes smokeDetector = EntityTypes._(41, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'smokeDetector'); - static const EntityTypes oxygenSensor = EntityTypes._(42, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'oxygenSensor'); - static const EntityTypes smartPlug = EntityTypes._(43, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'smartPlug'); - static const EntityTypes printer = EntityTypes._(44, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'printer'); - static const EntityTypes scanner = EntityTypes._(45, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'scanner'); - static const EntityTypes printerWithScanner = EntityTypes._(46, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'printerWithScanner'); - static const EntityTypes smartComputer = EntityTypes._(47, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'smartComputer'); - static const EntityTypes emptyEntity = EntityTypes._(48, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'emptyEntity'); - static const EntityTypes pingEntity = EntityTypes._(49, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'pingEntity'); - static const EntityTypes routerEntity = EntityTypes._(50, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'routerEntity'); - static const EntityTypes playerEntity = EntityTypes._(51, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'playerEntity'); - static const EntityTypes voiceAssistant = EntityTypes._(52, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'voiceAssistant'); - - static const $core.List values = [ - smartTypeNotSupported, - light, - blinds, - boiler, - button, - buttonWithLight, - hub, - phoneApp, - computerApp, - browserApp, - switch_, - dimmableLight, - cctLight, - rgbLights, - rgbwLights, - rgbcctLights, - smartTV, - smartSpeakers, - coffeeMachine, - kettle, - teapot, - washingMachine, - dishwasher, - toaster, - vacuumCleaner, - refrigerator, - bed, - oven, - AirConditioner, - smartWatch, - smartWaterBottle, - microphone, - securityCamera, - babyMonitor, - motionSensor, - temperatureSensor, - humiditySensor, - lightSensor, - soundSensor, - smokeSensor, - smokeDetector, - oxygenSensor, - smartPlug, - printer, - scanner, - printerWithScanner, - smartComputer, - emptyEntity, - pingEntity, - routerEntity, - playerEntity, - voiceAssistant, - ]; - - static final $core.Map<$core.int, EntityTypes> _byValue = $pb.ProtobufEnum.initByValue(values); - static EntityTypes? valueOf($core.int value) => _byValue[value]; - - const EntityTypes._($core.int v, $core.String n) : super(v, n); -} - -class EntityActions extends $pb.ProtobufEnum { - static const EntityActions actionNotSupported = EntityActions._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'actionNotSupported'); - static const EntityActions on = EntityActions._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'on'); - static const EntityActions off = EntityActions._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'off'); - static const EntityActions moveUp = EntityActions._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'moveUp'); - static const EntityActions stop = EntityActions._(4, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'stop'); - static const EntityActions moveDown = EntityActions._(5, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'moveDown'); - static const EntityActions pressed = EntityActions._(6, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'pressed'); - static const EntityActions longPress = EntityActions._(7, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'longPress'); - static const EntityActions doubleTap = EntityActions._(8, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'doubleTap'); - static const EntityActions position = EntityActions._(9, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'position'); - static const EntityActions suspend = EntityActions._(10, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'suspend'); - static const EntityActions shutdown = EntityActions._(11, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'shutdown'); - static const EntityActions itIsFalse = EntityActions._(12, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'itIsFalse'); - static const EntityActions itIsTrue = EntityActions._(13, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'itIsTrue'); - static const EntityActions pausePlay = EntityActions._(14, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'pausePlay'); - static const EntityActions changeVolume = EntityActions._(15, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'changeVolume'); - static const EntityActions jump = EntityActions._(16, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'jump'); - static const EntityActions skip = EntityActions._(17, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'skip'); - static const EntityActions pause = EntityActions._(18, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'pause'); - static const EntityActions play = EntityActions._(19, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'play'); - static const EntityActions volumeUp = EntityActions._(20, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'volumeUp'); - static const EntityActions volumeDown = EntityActions._(21, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'volumeDown'); - static const EntityActions skipForeword = EntityActions._(22, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'skipForeword'); - static const EntityActions skipBackward = EntityActions._(23, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'skipBackward'); - static const EntityActions skipNextVid = EntityActions._(24, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'skipNextVid'); - static const EntityActions skipPreviousVid = EntityActions._(25, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'skipPreviousVid'); - static const EntityActions open = EntityActions._(26, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'open'); - static const EntityActions close = EntityActions._(27, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'close'); - static const EntityActions changeTemperature = EntityActions._(28, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'changeTemperature'); - static const EntityActions changeFanSpeed = EntityActions._(29, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'changeFanSpeed'); - static const EntityActions changeMod = EntityActions._(30, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'changeMod'); - - static const $core.List values = [ - actionNotSupported, - on, - off, - moveUp, - stop, - moveDown, - pressed, - longPress, - doubleTap, - position, - suspend, - shutdown, - itIsFalse, - itIsTrue, - pausePlay, - changeVolume, - jump, - skip, - pause, - play, - volumeUp, - volumeDown, - skipForeword, - skipBackward, - skipNextVid, - skipPreviousVid, - open, - close, - changeTemperature, - changeFanSpeed, - changeMod, - ]; - - static final $core.Map<$core.int, EntityActions> _byValue = $pb.ProtobufEnum.initByValue(values); - static EntityActions? valueOf($core.int value) => _byValue[value]; - - const EntityActions._($core.int v, $core.String n) : super(v, n); -} - -class WhenToExecute extends $pb.ProtobufEnum { - static const WhenToExecute undefined = WhenToExecute._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'undefined'); - static const WhenToExecute onOddNumberPress = WhenToExecute._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'onOddNumberPress'); - static const WhenToExecute evenNumberPress = WhenToExecute._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'evenNumberPress'); - static const WhenToExecute betweenSelectedTime = WhenToExecute._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'betweenSelectedTime'); - static const WhenToExecute doNotBetweenSelectedTime = WhenToExecute._(4, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'doNotBetweenSelectedTime'); - static const WhenToExecute allTheTime = WhenToExecute._(5, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'allTheTime'); - static const WhenToExecute never = WhenToExecute._(6, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'never'); - static const WhenToExecute onceNow = WhenToExecute._(7, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'onceNow'); - static const WhenToExecute onceInSelectedTime = WhenToExecute._(8, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'onceInSelectedTime'); - static const WhenToExecute onlyIfEntityListAreInActionListState = WhenToExecute._(9, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'onlyIfEntityListAreInActionListState'); - static const WhenToExecute atHome = WhenToExecute._(10, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'atHome'); - static const WhenToExecute outOfHome = WhenToExecute._(11, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'outOfHome'); - static const WhenToExecute atASpecificTime = WhenToExecute._(12, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'atASpecificTime'); - - static const $core.List values = [ - undefined, - onOddNumberPress, - evenNumberPress, - betweenSelectedTime, - doNotBetweenSelectedTime, - allTheTime, - never, - onceNow, - onceInSelectedTime, - onlyIfEntityListAreInActionListState, - atHome, - outOfHome, - atASpecificTime, - ]; - - static final $core.Map<$core.int, WhenToExecute> _byValue = $pb.ProtobufEnum.initByValue(values); - static WhenToExecute? valueOf($core.int value) => _byValue[value]; - - const WhenToExecute._($core.int v, $core.String n) : super(v, n); -} - -class AreaPurposesTypes extends $pb.ProtobufEnum { - static const AreaPurposesTypes bedroom = AreaPurposesTypes._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'bedroom'); - static const AreaPurposesTypes studyRoom = AreaPurposesTypes._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'studyRoom'); - static const AreaPurposesTypes workRoom = AreaPurposesTypes._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'workRoom'); - static const AreaPurposesTypes tvRoom = AreaPurposesTypes._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'tvRoom'); - static const AreaPurposesTypes videoGames = AreaPurposesTypes._(4, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'videoGames'); - static const AreaPurposesTypes livingRoom = AreaPurposesTypes._(5, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'livingRoom'); - static const AreaPurposesTypes diningRoom = AreaPurposesTypes._(6, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'diningRoom'); - static const AreaPurposesTypes kitchen = AreaPurposesTypes._(7, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'kitchen'); - static const AreaPurposesTypes outside = AreaPurposesTypes._(8, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'outside'); - static const AreaPurposesTypes outsidePrimary = AreaPurposesTypes._(9, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'outsidePrimary'); - static const AreaPurposesTypes outsideNotPrimary = AreaPurposesTypes._(10, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'outsideNotPrimary'); - static const AreaPurposesTypes toiletRoom = AreaPurposesTypes._(11, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'toiletRoom'); - static const AreaPurposesTypes shower = AreaPurposesTypes._(12, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'shower'); - static const AreaPurposesTypes trainingRoom = AreaPurposesTypes._(13, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'trainingRoom'); - static const AreaPurposesTypes meditation = AreaPurposesTypes._(14, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'meditation'); - static const AreaPurposesTypes romantic = AreaPurposesTypes._(15, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'romantic'); - static const AreaPurposesTypes stairsInside = AreaPurposesTypes._(16, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'stairsInside'); - static const AreaPurposesTypes stairsOutside = AreaPurposesTypes._(17, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'stairsOutside'); - static const AreaPurposesTypes childrenRoom = AreaPurposesTypes._(18, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'childrenRoom'); - static const AreaPurposesTypes cinemaRoom = AreaPurposesTypes._(19, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'cinemaRoom'); - static const AreaPurposesTypes boardGames = AreaPurposesTypes._(20, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'boardGames'); - static const AreaPurposesTypes bathtub = AreaPurposesTypes._(21, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'bathtub'); - static const AreaPurposesTypes laundryRoom = AreaPurposesTypes._(22, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'laundryRoom'); - static const AreaPurposesTypes protectedSpace = AreaPurposesTypes._(23, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'protectedSpace'); - static const AreaPurposesTypes safeRoom = AreaPurposesTypes._(24, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'safeRoom'); - static const AreaPurposesTypes attic = AreaPurposesTypes._(25, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'attic'); - static const AreaPurposesTypes holidayCabin = AreaPurposesTypes._(26, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'holidayCabin'); - - static const $core.List values = [ - bedroom, - studyRoom, - workRoom, - tvRoom, - videoGames, - livingRoom, - diningRoom, - kitchen, - outside, - outsidePrimary, - outsideNotPrimary, - toiletRoom, - shower, - trainingRoom, - meditation, - romantic, - stairsInside, - stairsOutside, - childrenRoom, - cinemaRoom, - boardGames, - bathtub, - laundryRoom, - protectedSpace, - safeRoom, - attic, - holidayCabin, - ]; - - static final $core.Map<$core.int, AreaPurposesTypes> _byValue = $pb.ProtobufEnum.initByValue(values); - static AreaPurposesTypes? valueOf($core.int value) => _byValue[value]; - - const AreaPurposesTypes._($core.int v, $core.String n) : super(v, n); -} - diff --git a/lib/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart b/lib/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart deleted file mode 100644 index 4f47c105..00000000 --- a/lib/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart +++ /dev/null @@ -1,103 +0,0 @@ -/// -// Generated code. Do not modify. -// source: cbj_hub_server.proto -// -// @dart = 2.12 -// ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name - -import 'dart:async' as $async; - -import 'dart:core' as $core; - -import 'package:grpc/service_api.dart' as $grpc; -import 'cbj_hub_server.pb.dart' as $0; -export 'cbj_hub_server.pb.dart'; - -class CbjHubClient extends $grpc.Client { - static final _$clientTransferEntities = - $grpc.ClientMethod<$0.ClientStatusRequests, $0.RequestsAndStatusFromHub>( - '/CbjHub.CbjHub/ClientTransferEntities', - ($0.ClientStatusRequests value) => value.writeToBuffer(), - ($core.List<$core.int> value) => - $0.RequestsAndStatusFromHub.fromBuffer(value)); - static final _$hubTransferEntities = - $grpc.ClientMethod<$0.RequestsAndStatusFromHub, $0.ClientStatusRequests>( - '/CbjHub.CbjHub/HubTransferEntities', - ($0.RequestsAndStatusFromHub value) => value.writeToBuffer(), - ($core.List<$core.int> value) => - $0.ClientStatusRequests.fromBuffer(value)); - static final _$getCompHubInfo = - $grpc.ClientMethod<$0.CompHubInfo, $0.CompHubInfo>( - '/CbjHub.CbjHub/getCompHubInfo', - ($0.CompHubInfo value) => value.writeToBuffer(), - ($core.List<$core.int> value) => $0.CompHubInfo.fromBuffer(value)); - - CbjHubClient($grpc.ClientChannel channel, - {$grpc.CallOptions? options, - $core.Iterable<$grpc.ClientInterceptor>? interceptors}) - : super(channel, options: options, interceptors: interceptors); - - $grpc.ResponseStream<$0.RequestsAndStatusFromHub> clientTransferEntities( - $async.Stream<$0.ClientStatusRequests> request, - {$grpc.CallOptions? options}) { - return $createStreamingCall(_$clientTransferEntities, request, - options: options); - } - - $grpc.ResponseStream<$0.ClientStatusRequests> hubTransferEntities( - $async.Stream<$0.RequestsAndStatusFromHub> request, - {$grpc.CallOptions? options}) { - return $createStreamingCall(_$hubTransferEntities, request, - options: options); - } - - $grpc.ResponseFuture<$0.CompHubInfo> getCompHubInfo($0.CompHubInfo request, - {$grpc.CallOptions? options}) { - return $createUnaryCall(_$getCompHubInfo, request, options: options); - } -} - -abstract class CbjHubServiceBase extends $grpc.Service { - $core.String get $name => 'CbjHub.CbjHub'; - - CbjHubServiceBase() { - $addMethod($grpc.ServiceMethod<$0.ClientStatusRequests, - $0.RequestsAndStatusFromHub>( - 'ClientTransferEntities', - clientTransferEntities, - true, - true, - ($core.List<$core.int> value) => - $0.ClientStatusRequests.fromBuffer(value), - ($0.RequestsAndStatusFromHub value) => value.writeToBuffer())); - $addMethod($grpc.ServiceMethod<$0.RequestsAndStatusFromHub, - $0.ClientStatusRequests>( - 'HubTransferEntities', - hubTransferEntities, - true, - true, - ($core.List<$core.int> value) => - $0.RequestsAndStatusFromHub.fromBuffer(value), - ($0.ClientStatusRequests value) => value.writeToBuffer())); - $addMethod($grpc.ServiceMethod<$0.CompHubInfo, $0.CompHubInfo>( - 'getCompHubInfo', - getCompHubInfo_Pre, - false, - false, - ($core.List<$core.int> value) => $0.CompHubInfo.fromBuffer(value), - ($0.CompHubInfo value) => value.writeToBuffer())); - } - - $async.Future<$0.CompHubInfo> getCompHubInfo_Pre( - $grpc.ServiceCall call, $async.Future<$0.CompHubInfo> request) async { - return getCompHubInfo(call, await request); - } - - $async.Stream<$0.RequestsAndStatusFromHub> clientTransferEntities( - $grpc.ServiceCall call, $async.Stream<$0.ClientStatusRequests> request); - $async.Stream<$0.ClientStatusRequests> hubTransferEntities( - $grpc.ServiceCall call, - $async.Stream<$0.RequestsAndStatusFromHub> request); - $async.Future<$0.CompHubInfo> getCompHubInfo( - $grpc.ServiceCall call, $0.CompHubInfo request); -} diff --git a/lib/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbjson.dart b/lib/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbjson.dart deleted file mode 100644 index 5a57a715..00000000 --- a/lib/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbjson.dart +++ /dev/null @@ -1,465 +0,0 @@ -/// -// Generated code. Do not modify. -// source: cbj_hub_server.proto -// -// @dart = 2.12 -// ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,deprecated_member_use_from_same_package,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name - -import 'dart:core' as $core; -import 'dart:convert' as $convert; -import 'dart:typed_data' as $typed_data; -@$core.Deprecated('Use sendingTypeDescriptor instead') -const SendingType$json = const { - '1': 'SendingType', - '2': const [ - const {'1': 'undefinedType', '2': 0}, - const {'1': 'stringType', '2': 1}, - const {'1': 'partialEntityType', '2': 2}, - const {'1': 'entityType', '2': 3}, - const {'1': 'mqttMassageType', '2': 4}, - const {'1': 'sceneType', '2': 5}, - const {'1': 'scheduleType', '2': 6}, - const {'1': 'routineType', '2': 7}, - const {'1': 'bindingsType', '2': 8}, - const {'1': 'vendorLoginType', '2': 9}, - const {'1': 'firstConnection', '2': 10}, - const {'1': 'remotePipesInformation', '2': 11}, - const {'1': 'getHubEntityInfo', '2': 12}, - const {'1': 'responseHubEntityInfo', '2': 13}, - const {'1': 'roomType', '2': 14}, - const {'1': 'location', '2': 15}, - ], -}; - -/// Descriptor for `SendingType`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List sendingTypeDescriptor = $convert.base64Decode('CgtTZW5kaW5nVHlwZRIRCg11bmRlZmluZWRUeXBlEAASDgoKc3RyaW5nVHlwZRABEhUKEXBhcnRpYWxFbnRpdHlUeXBlEAISDgoKZW50aXR5VHlwZRADEhMKD21xdHRNYXNzYWdlVHlwZRAEEg0KCXNjZW5lVHlwZRAFEhAKDHNjaGVkdWxlVHlwZRAGEg8KC3JvdXRpbmVUeXBlEAcSEAoMYmluZGluZ3NUeXBlEAgSEwoPdmVuZG9yTG9naW5UeXBlEAkSEwoPZmlyc3RDb25uZWN0aW9uEAoSGgoWcmVtb3RlUGlwZXNJbmZvcm1hdGlvbhALEhQKEGdldEh1YkVudGl0eUluZm8QDBIZChVyZXNwb25zZUh1YkVudGl0eUluZm8QDRIMCghyb29tVHlwZRAOEgwKCGxvY2F0aW9uEA8='); -@$core.Deprecated('Use entityStateGRPCDescriptor instead') -const EntityStateGRPC$json = const { - '1': 'EntityStateGRPC', - '2': const [ - const {'1': 'stateNotSupported', '2': 0}, - const {'1': 'cancelStateInProcess', '2': 1}, - const {'1': 'ack', '2': 2}, - const {'1': 'newStateFailed', '2': 3}, - const {'1': 'waitingInCloud', '2': 4}, - const {'1': 'waitingInComp', '2': 5}, - const {'1': 'noEntitiesToTransfer', '2': 6}, - const {'1': 'pingNow', '2': 7}, - const {'1': 'addingNewScene', '2': 8}, - const {'1': 'addingNewRoutine', '2': 9}, - const {'1': 'addingNewBinding', '2': 10}, - const {'1': 'updateHubEntityPropertiesFromRealEntity', '2': 11}, - ], -}; - -/// Descriptor for `EntityStateGRPC`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List entityStateGRPCDescriptor = $convert.base64Decode('Cg9FbnRpdHlTdGF0ZUdSUEMSFQoRc3RhdGVOb3RTdXBwb3J0ZWQQABIYChRjYW5jZWxTdGF0ZUluUHJvY2VzcxABEgcKA2FjaxACEhIKDm5ld1N0YXRlRmFpbGVkEAMSEgoOd2FpdGluZ0luQ2xvdWQQBBIRCg13YWl0aW5nSW5Db21wEAUSGAoUbm9FbnRpdGllc1RvVHJhbnNmZXIQBhILCgdwaW5nTm93EAcSEgoOYWRkaW5nTmV3U2NlbmUQCBIUChBhZGRpbmdOZXdSb3V0aW5lEAkSFAoQYWRkaW5nTmV3QmluZGluZxAKEisKJ3VwZGF0ZUh1YkVudGl0eVByb3BlcnRpZXNGcm9tUmVhbEVudGl0eRAL'); -@$core.Deprecated('Use vendorsAndServicesDescriptor instead') -const VendorsAndServices$json = const { - '1': 'VendorsAndServices', - '2': const [ - const {'1': 'vendorsAndServicesNotSupported', '2': 0}, - const {'1': 'espHome', '2': 1}, - const {'1': 'switcherSmartHome', '2': 2}, - const {'1': 'tasmota', '2': 3}, - const {'1': 'yeelight', '2': 4}, - const {'1': 'google', '2': 5}, - const {'1': 'miHome', '2': 6}, - const {'1': 'lifx', '2': 7}, - const {'1': 'tuyaSmart', '2': 8}, - const {'1': 'smartLife', '2': 9}, - const {'1': 'jinvooSmart', '2': 10}, - const {'1': 'shelly', '2': 11}, - const {'1': 'wink', '2': 12}, - const {'1': 'ikea', '2': 13}, - const {'1': 'sonoffDiy', '2': 14}, - const {'1': 'philipsHue', '2': 15}, - const {'1': 'lg', '2': 16}, - const {'1': 'spotify', '2': 17}, - const {'1': 'homeAssistant', '2': 18}, - const {'1': 'hp', '2': 19}, - const {'1': 'yeelink', '2': 20}, - const {'1': 'xiaomi', '2': 21}, - const {'1': 'sonoffEweLink', '2': 22}, - const {'1': 'cbjDeviceSmartEntity', '2': 23}, - const {'1': 'wiz', '2': 24}, - const {'1': 'switchBot', '2': 25}, - const {'1': 'somfy', '2': 26}, - const {'1': 'sensibo', '2': 27}, - const {'1': 'aqara', '2': 28}, - const {'1': 'matter', '2': 29}, - const {'1': 'nest', '2': 30}, - const {'1': 'uniFi', '2': 31}, - const {'1': 'ring', '2': 32}, - const {'1': 'myQ', '2': 33}, - const {'1': 'wemo', '2': 34}, - const {'1': 'tpLink', '2': 35}, - const {'1': 'nuki', '2': 36}, - const {'1': 'homebridge', '2': 37}, - const {'1': 'homeKit', '2': 38}, - const {'1': 'twinkly', '2': 39}, - const {'1': 'samsung', '2': 40}, - const {'1': 'tizen', '2': 41}, - const {'1': 'zigbee', '2': 42}, - const {'1': 'zWave', '2': 43}, - const {'1': 'ffmpeg', '2': 44}, - const {'1': 'lightwaveRf', '2': 45}, - const {'1': 'cololight', '2': 46}, - const {'1': 'broadlink', '2': 47}, - const {'1': 'switchBee', '2': 48}, - const {'1': 'mycroft', '2': 49}, - const {'1': 'xiaomiMi', '2': 50}, - const {'1': 'cyBearJinniAppSmartEntity', '2': 51}, - const {'1': 'securityBear', '2': 52}, - const {'1': 'jinniAssistant', '2': 53}, - ], -}; - -/// Descriptor for `VendorsAndServices`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List vendorsAndServicesDescriptor = $convert.base64Decode('ChJWZW5kb3JzQW5kU2VydmljZXMSIgoedmVuZG9yc0FuZFNlcnZpY2VzTm90U3VwcG9ydGVkEAASCwoHZXNwSG9tZRABEhUKEXN3aXRjaGVyU21hcnRIb21lEAISCwoHdGFzbW90YRADEgwKCHllZWxpZ2h0EAQSCgoGZ29vZ2xlEAUSCgoGbWlIb21lEAYSCAoEbGlmeBAHEg0KCXR1eWFTbWFydBAIEg0KCXNtYXJ0TGlmZRAJEg8KC2ppbnZvb1NtYXJ0EAoSCgoGc2hlbGx5EAsSCAoEd2luaxAMEggKBGlrZWEQDRINCglzb25vZmZEaXkQDhIOCgpwaGlsaXBzSHVlEA8SBgoCbGcQEBILCgdzcG90aWZ5EBESEQoNaG9tZUFzc2lzdGFudBASEgYKAmhwEBMSCwoHeWVlbGluaxAUEgoKBnhpYW9taRAVEhEKDXNvbm9mZkV3ZUxpbmsQFhIYChRjYmpEZXZpY2VTbWFydEVudGl0eRAXEgcKA3dpehAYEg0KCXN3aXRjaEJvdBAZEgkKBXNvbWZ5EBoSCwoHc2Vuc2libxAbEgkKBWFxYXJhEBwSCgoGbWF0dGVyEB0SCAoEbmVzdBAeEgkKBXVuaUZpEB8SCAoEcmluZxAgEgcKA215URAhEggKBHdlbW8QIhIKCgZ0cExpbmsQIxIICgRudWtpECQSDgoKaG9tZWJyaWRnZRAlEgsKB2hvbWVLaXQQJhILCgd0d2lua2x5ECcSCwoHc2Ftc3VuZxAoEgkKBXRpemVuECkSCgoGemlnYmVlECoSCQoFeldhdmUQKxIKCgZmZm1wZWcQLBIPCgtsaWdodHdhdmVSZhAtEg0KCWNvbG9saWdodBAuEg0KCWJyb2FkbGluaxAvEg0KCXN3aXRjaEJlZRAwEgsKB215Y3JvZnQQMRIMCgh4aWFvbWlNaRAyEh0KGWN5QmVhckppbm5pQXBwU21hcnRFbnRpdHkQMxIQCgxzZWN1cml0eUJlYXIQNBISCg5qaW5uaUFzc2lzdGFudBA1'); -@$core.Deprecated('Use entityTypesDescriptor instead') -const EntityTypes$json = const { - '1': 'EntityTypes', - '2': const [ - const {'1': 'smartTypeNotSupported', '2': 0}, - const {'1': 'light', '2': 1}, - const {'1': 'blinds', '2': 2}, - const {'1': 'boiler', '2': 3}, - const {'1': 'button', '2': 4}, - const {'1': 'buttonWithLight', '2': 5}, - const {'1': 'hub', '2': 7}, - const {'1': 'phoneApp', '2': 8}, - const {'1': 'computerApp', '2': 9}, - const {'1': 'browserApp', '2': 10}, - const {'1': 'switch', '2': 11}, - const {'1': 'dimmableLight', '2': 12}, - const {'1': 'cctLight', '2': 13}, - const {'1': 'rgbLights', '2': 14}, - const {'1': 'rgbwLights', '2': 15}, - const {'1': 'rgbcctLights', '2': 16}, - const {'1': 'smartTV', '2': 17}, - const {'1': 'smartSpeakers', '2': 18}, - const {'1': 'coffeeMachine', '2': 19}, - const {'1': 'kettle', '2': 20}, - const {'1': 'teapot', '2': 21}, - const {'1': 'washingMachine', '2': 22}, - const {'1': 'dishwasher', '2': 23}, - const {'1': 'toaster', '2': 24}, - const {'1': 'vacuumCleaner', '2': 25}, - const {'1': 'refrigerator', '2': 26}, - const {'1': 'bed', '2': 27}, - const {'1': 'oven', '2': 28}, - const {'1': 'AirConditioner', '2': 29}, - const {'1': 'smartWatch', '2': 30}, - const {'1': 'smartWaterBottle', '2': 31}, - const {'1': 'microphone', '2': 32}, - const {'1': 'securityCamera', '2': 33}, - const {'1': 'babyMonitor', '2': 34}, - const {'1': 'motionSensor', '2': 35}, - const {'1': 'temperatureSensor', '2': 36}, - const {'1': 'humiditySensor', '2': 37}, - const {'1': 'lightSensor', '2': 38}, - const {'1': 'soundSensor', '2': 39}, - const {'1': 'smokeSensor', '2': 40}, - const {'1': 'smokeDetector', '2': 41}, - const {'1': 'oxygenSensor', '2': 42}, - const {'1': 'smartPlug', '2': 43}, - const {'1': 'printer', '2': 44}, - const {'1': 'scanner', '2': 45}, - const {'1': 'printerWithScanner', '2': 46}, - const {'1': 'smartComputer', '2': 47}, - const {'1': 'emptyEntity', '2': 48}, - const {'1': 'pingEntity', '2': 49}, - const {'1': 'routerEntity', '2': 50}, - const {'1': 'playerEntity', '2': 51}, - const {'1': 'voiceAssistant', '2': 52}, - ], -}; - -/// Descriptor for `EntityTypes`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List entityTypesDescriptor = $convert.base64Decode('CgtFbnRpdHlUeXBlcxIZChVzbWFydFR5cGVOb3RTdXBwb3J0ZWQQABIJCgVsaWdodBABEgoKBmJsaW5kcxACEgoKBmJvaWxlchADEgoKBmJ1dHRvbhAEEhMKD2J1dHRvbldpdGhMaWdodBAFEgcKA2h1YhAHEgwKCHBob25lQXBwEAgSDwoLY29tcHV0ZXJBcHAQCRIOCgpicm93c2VyQXBwEAoSCgoGc3dpdGNoEAsSEQoNZGltbWFibGVMaWdodBAMEgwKCGNjdExpZ2h0EA0SDQoJcmdiTGlnaHRzEA4SDgoKcmdid0xpZ2h0cxAPEhAKDHJnYmNjdExpZ2h0cxAQEgsKB3NtYXJ0VFYQERIRCg1zbWFydFNwZWFrZXJzEBISEQoNY29mZmVlTWFjaGluZRATEgoKBmtldHRsZRAUEgoKBnRlYXBvdBAVEhIKDndhc2hpbmdNYWNoaW5lEBYSDgoKZGlzaHdhc2hlchAXEgsKB3RvYXN0ZXIQGBIRCg12YWN1dW1DbGVhbmVyEBkSEAoMcmVmcmlnZXJhdG9yEBoSBwoDYmVkEBsSCAoEb3ZlbhAcEhIKDkFpckNvbmRpdGlvbmVyEB0SDgoKc21hcnRXYXRjaBAeEhQKEHNtYXJ0V2F0ZXJCb3R0bGUQHxIOCgptaWNyb3Bob25lECASEgoOc2VjdXJpdHlDYW1lcmEQIRIPCgtiYWJ5TW9uaXRvchAiEhAKDG1vdGlvblNlbnNvchAjEhUKEXRlbXBlcmF0dXJlU2Vuc29yECQSEgoOaHVtaWRpdHlTZW5zb3IQJRIPCgtsaWdodFNlbnNvchAmEg8KC3NvdW5kU2Vuc29yECcSDwoLc21va2VTZW5zb3IQKBIRCg1zbW9rZURldGVjdG9yECkSEAoMb3h5Z2VuU2Vuc29yECoSDQoJc21hcnRQbHVnECsSCwoHcHJpbnRlchAsEgsKB3NjYW5uZXIQLRIWChJwcmludGVyV2l0aFNjYW5uZXIQLhIRCg1zbWFydENvbXB1dGVyEC8SDwoLZW1wdHlFbnRpdHkQMBIOCgpwaW5nRW50aXR5EDESEAoMcm91dGVyRW50aXR5EDISEAoMcGxheWVyRW50aXR5EDMSEgoOdm9pY2VBc3Npc3RhbnQQNA=='); -@$core.Deprecated('Use entityActionsDescriptor instead') -const EntityActions$json = const { - '1': 'EntityActions', - '2': const [ - const {'1': 'actionNotSupported', '2': 0}, - const {'1': 'on', '2': 1}, - const {'1': 'off', '2': 2}, - const {'1': 'moveUp', '2': 3}, - const {'1': 'stop', '2': 4}, - const {'1': 'moveDown', '2': 5}, - const {'1': 'pressed', '2': 6}, - const {'1': 'longPress', '2': 7}, - const {'1': 'doubleTap', '2': 8}, - const {'1': 'position', '2': 9}, - const {'1': 'suspend', '2': 10}, - const {'1': 'shutdown', '2': 11}, - const {'1': 'itIsFalse', '2': 12}, - const {'1': 'itIsTrue', '2': 13}, - const {'1': 'pausePlay', '2': 14}, - const {'1': 'changeVolume', '2': 15}, - const {'1': 'jump', '2': 16}, - const {'1': 'skip', '2': 17}, - const {'1': 'pause', '2': 18}, - const {'1': 'play', '2': 19}, - const {'1': 'volumeUp', '2': 20}, - const {'1': 'volumeDown', '2': 21}, - const {'1': 'skipForeword', '2': 22}, - const {'1': 'skipBackward', '2': 23}, - const {'1': 'skipNextVid', '2': 24}, - const {'1': 'skipPreviousVid', '2': 25}, - const {'1': 'open', '2': 26}, - const {'1': 'close', '2': 27}, - const {'1': 'changeTemperature', '2': 28}, - const {'1': 'changeFanSpeed', '2': 29}, - const {'1': 'changeMod', '2': 30}, - ], -}; - -/// Descriptor for `EntityActions`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List entityActionsDescriptor = $convert.base64Decode('Cg1FbnRpdHlBY3Rpb25zEhYKEmFjdGlvbk5vdFN1cHBvcnRlZBAAEgYKAm9uEAESBwoDb2ZmEAISCgoGbW92ZVVwEAMSCAoEc3RvcBAEEgwKCG1vdmVEb3duEAUSCwoHcHJlc3NlZBAGEg0KCWxvbmdQcmVzcxAHEg0KCWRvdWJsZVRhcBAIEgwKCHBvc2l0aW9uEAkSCwoHc3VzcGVuZBAKEgwKCHNodXRkb3duEAsSDQoJaXRJc0ZhbHNlEAwSDAoIaXRJc1RydWUQDRINCglwYXVzZVBsYXkQDhIQCgxjaGFuZ2VWb2x1bWUQDxIICgRqdW1wEBASCAoEc2tpcBAREgkKBXBhdXNlEBISCAoEcGxheRATEgwKCHZvbHVtZVVwEBQSDgoKdm9sdW1lRG93bhAVEhAKDHNraXBGb3Jld29yZBAWEhAKDHNraXBCYWNrd2FyZBAXEg8KC3NraXBOZXh0VmlkEBgSEwoPc2tpcFByZXZpb3VzVmlkEBkSCAoEb3BlbhAaEgkKBWNsb3NlEBsSFQoRY2hhbmdlVGVtcGVyYXR1cmUQHBISCg5jaGFuZ2VGYW5TcGVlZBAdEg0KCWNoYW5nZU1vZBAe'); -@$core.Deprecated('Use whenToExecuteDescriptor instead') -const WhenToExecute$json = const { - '1': 'WhenToExecute', - '2': const [ - const {'1': 'undefined', '2': 0}, - const {'1': 'onOddNumberPress', '2': 1}, - const {'1': 'evenNumberPress', '2': 2}, - const {'1': 'betweenSelectedTime', '2': 3}, - const {'1': 'doNotBetweenSelectedTime', '2': 4}, - const {'1': 'allTheTime', '2': 5}, - const {'1': 'never', '2': 6}, - const {'1': 'onceNow', '2': 7}, - const {'1': 'onceInSelectedTime', '2': 8}, - const {'1': 'onlyIfEntityListAreInActionListState', '2': 9}, - const {'1': 'atHome', '2': 10}, - const {'1': 'outOfHome', '2': 11}, - const {'1': 'atASpecificTime', '2': 12}, - ], -}; - -/// Descriptor for `WhenToExecute`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List whenToExecuteDescriptor = $convert.base64Decode('Cg1XaGVuVG9FeGVjdXRlEg0KCXVuZGVmaW5lZBAAEhQKEG9uT2RkTnVtYmVyUHJlc3MQARITCg9ldmVuTnVtYmVyUHJlc3MQAhIXChNiZXR3ZWVuU2VsZWN0ZWRUaW1lEAMSHAoYZG9Ob3RCZXR3ZWVuU2VsZWN0ZWRUaW1lEAQSDgoKYWxsVGhlVGltZRAFEgkKBW5ldmVyEAYSCwoHb25jZU5vdxAHEhYKEm9uY2VJblNlbGVjdGVkVGltZRAIEigKJG9ubHlJZkVudGl0eUxpc3RBcmVJbkFjdGlvbkxpc3RTdGF0ZRAJEgoKBmF0SG9tZRAKEg0KCW91dE9mSG9tZRALEhMKD2F0QVNwZWNpZmljVGltZRAM'); -@$core.Deprecated('Use areaPurposesTypesDescriptor instead') -const AreaPurposesTypes$json = const { - '1': 'AreaPurposesTypes', - '2': const [ - const {'1': 'bedroom', '2': 0}, - const {'1': 'studyRoom', '2': 1}, - const {'1': 'workRoom', '2': 2}, - const {'1': 'tvRoom', '2': 3}, - const {'1': 'videoGames', '2': 4}, - const {'1': 'livingRoom', '2': 5}, - const {'1': 'diningRoom', '2': 6}, - const {'1': 'kitchen', '2': 7}, - const {'1': 'outside', '2': 8}, - const {'1': 'outsidePrimary', '2': 9}, - const {'1': 'outsideNotPrimary', '2': 10}, - const {'1': 'toiletRoom', '2': 11}, - const {'1': 'shower', '2': 12}, - const {'1': 'trainingRoom', '2': 13}, - const {'1': 'meditation', '2': 14}, - const {'1': 'romantic', '2': 15}, - const {'1': 'stairsInside', '2': 16}, - const {'1': 'stairsOutside', '2': 17}, - const {'1': 'childrenRoom', '2': 18}, - const {'1': 'cinemaRoom', '2': 19}, - const {'1': 'boardGames', '2': 20}, - const {'1': 'bathtub', '2': 21}, - const {'1': 'laundryRoom', '2': 22}, - const {'1': 'protectedSpace', '2': 23}, - const {'1': 'safeRoom', '2': 24}, - const {'1': 'attic', '2': 25}, - const {'1': 'holidayCabin', '2': 26}, - ], -}; - -/// Descriptor for `AreaPurposesTypes`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List areaPurposesTypesDescriptor = $convert.base64Decode('ChFBcmVhUHVycG9zZXNUeXBlcxILCgdiZWRyb29tEAASDQoJc3R1ZHlSb29tEAESDAoId29ya1Jvb20QAhIKCgZ0dlJvb20QAxIOCgp2aWRlb0dhbWVzEAQSDgoKbGl2aW5nUm9vbRAFEg4KCmRpbmluZ1Jvb20QBhILCgdraXRjaGVuEAcSCwoHb3V0c2lkZRAIEhIKDm91dHNpZGVQcmltYXJ5EAkSFQoRb3V0c2lkZU5vdFByaW1hcnkQChIOCgp0b2lsZXRSb29tEAsSCgoGc2hvd2VyEAwSEAoMdHJhaW5pbmdSb29tEA0SDgoKbWVkaXRhdGlvbhAOEgwKCHJvbWFudGljEA8SEAoMc3RhaXJzSW5zaWRlEBASEQoNc3RhaXJzT3V0c2lkZRAREhAKDGNoaWxkcmVuUm9vbRASEg4KCmNpbmVtYVJvb20QExIOCgpib2FyZEdhbWVzEBQSCwoHYmF0aHR1YhAVEg8KC2xhdW5kcnlSb29tEBYSEgoOcHJvdGVjdGVkU3BhY2UQFxIMCghzYWZlUm9vbRAYEgkKBWF0dGljEBkSEAoMaG9saWRheUNhYmluEBo='); -@$core.Deprecated('Use clientStatusRequestsDescriptor instead') -const ClientStatusRequests$json = const { - '1': 'ClientStatusRequests', - '2': const [ - const {'1': 'sendingType', '3': 41, '4': 1, '5': 14, '6': '.CbjHub.SendingType', '10': 'sendingType'}, - const {'1': 'allRemoteCommands', '3': 42, '4': 1, '5': 9, '10': 'allRemoteCommands'}, - ], -}; - -/// Descriptor for `ClientStatusRequests`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List clientStatusRequestsDescriptor = $convert.base64Decode('ChRDbGllbnRTdGF0dXNSZXF1ZXN0cxI1CgtzZW5kaW5nVHlwZRgpIAEoDjITLkNiakh1Yi5TZW5kaW5nVHlwZVILc2VuZGluZ1R5cGUSLAoRYWxsUmVtb3RlQ29tbWFuZHMYKiABKAlSEWFsbFJlbW90ZUNvbW1hbmRz'); -@$core.Deprecated('Use requestsAndStatusFromHubDescriptor instead') -const RequestsAndStatusFromHub$json = const { - '1': 'RequestsAndStatusFromHub', - '2': const [ - const {'1': 'sendingType', '3': 43, '4': 1, '5': 14, '6': '.CbjHub.SendingType', '10': 'sendingType'}, - const {'1': 'allRemoteCommands', '3': 44, '4': 1, '5': 9, '10': 'allRemoteCommands'}, - ], -}; - -/// Descriptor for `RequestsAndStatusFromHub`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List requestsAndStatusFromHubDescriptor = $convert.base64Decode('ChhSZXF1ZXN0c0FuZFN0YXR1c0Zyb21IdWISNQoLc2VuZGluZ1R5cGUYKyABKA4yEy5DYmpIdWIuU2VuZGluZ1R5cGVSC3NlbmRpbmdUeXBlEiwKEWFsbFJlbW90ZUNvbW1hbmRzGCwgASgJUhFhbGxSZW1vdGVDb21tYW5kcw=='); -@$core.Deprecated('Use allRemoteCommandsDescriptor instead') -const AllRemoteCommands$json = const { - '1': 'AllRemoteCommands', - '2': const [ - const {'1': 'smartEntityInfo', '3': 40, '4': 1, '5': 11, '6': '.CbjHub.SmartEntityInfo', '10': 'smartEntityInfo'}, - ], -}; - -/// Descriptor for `AllRemoteCommands`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List allRemoteCommandsDescriptor = $convert.base64Decode('ChFBbGxSZW1vdGVDb21tYW5kcxJBCg9zbWFydEVudGl0eUluZm8YKCABKAsyFy5DYmpIdWIuU21hcnRFbnRpdHlJbmZvUg9zbWFydEVudGl0eUluZm8='); -@$core.Deprecated('Use firstSetupMessageDescriptor instead') -const FirstSetupMessage$json = const { - '1': 'FirstSetupMessage', - '2': const [ - const {'1': 'compInfo', '3': 38, '4': 1, '5': 11, '6': '.CbjHub.CompHubInfo', '10': 'compInfo'}, - const {'1': 'cloudAccountInformation', '3': 39, '4': 1, '5': 11, '6': '.CbjHub.CloudAccountInformation', '10': 'cloudAccountInformation'}, - ], -}; - -/// Descriptor for `FirstSetupMessage`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List firstSetupMessageDescriptor = $convert.base64Decode('ChFGaXJzdFNldHVwTWVzc2FnZRIvCghjb21wSW5mbxgmIAEoCzITLkNiakh1Yi5Db21wSHViSW5mb1IIY29tcEluZm8SWQoXY2xvdWRBY2NvdW50SW5mb3JtYXRpb24YJyABKAsyHy5DYmpIdWIuQ2xvdWRBY2NvdW50SW5mb3JtYXRpb25SF2Nsb3VkQWNjb3VudEluZm9ybWF0aW9u'); -@$core.Deprecated('Use compHubInfoDescriptor instead') -const CompHubInfo$json = const { - '1': 'CompHubInfo', - '2': const [ - const {'1': 'cbjInfo', '3': 47, '4': 1, '5': 11, '6': '.CbjHub.CbjHubIno', '10': 'cbjInfo'}, - const {'1': 'compSpecs', '3': 21, '4': 1, '5': 11, '6': '.CbjHub.CompHubSpecs', '10': 'compSpecs'}, - ], -}; - -/// Descriptor for `CompHubInfo`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List compHubInfoDescriptor = $convert.base64Decode('CgtDb21wSHViSW5mbxIrCgdjYmpJbmZvGC8gASgLMhEuQ2JqSHViLkNiakh1Yklub1IHY2JqSW5mbxIyCgljb21wU3BlY3MYFSABKAsyFC5DYmpIdWIuQ29tcEh1YlNwZWNzUgljb21wU3BlY3M='); -@$core.Deprecated('Use cbjHubInoDescriptor instead') -const CbjHubIno$json = const { - '1': 'CbjHubIno', - '2': const [ - const {'1': 'entityName', '3': 48, '4': 1, '5': 9, '10': 'entityName'}, - const {'1': 'pubspecYamlVersion', '3': 27, '4': 1, '5': 9, '10': 'pubspecYamlVersion'}, - const {'1': 'pubspecYamlBuildNumber', '3': 51, '4': 1, '5': 9, '10': 'pubspecYamlBuildNumber'}, - const {'1': 'protoLastGenDate', '3': 49, '4': 1, '5': 9, '10': 'protoLastGenDate'}, - const {'1': 'dartSdkVersion', '3': 52, '4': 1, '5': 9, '10': 'dartSdkVersion'}, - ], -}; - -/// Descriptor for `CbjHubIno`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List cbjHubInoDescriptor = $convert.base64Decode('CglDYmpIdWJJbm8SHgoKZW50aXR5TmFtZRgwIAEoCVIKZW50aXR5TmFtZRIuChJwdWJzcGVjWWFtbFZlcnNpb24YGyABKAlSEnB1YnNwZWNZYW1sVmVyc2lvbhI2ChZwdWJzcGVjWWFtbEJ1aWxkTnVtYmVyGDMgASgJUhZwdWJzcGVjWWFtbEJ1aWxkTnVtYmVyEioKEHByb3RvTGFzdEdlbkRhdGUYMSABKAlSEHByb3RvTGFzdEdlbkRhdGUSJgoOZGFydFNka1ZlcnNpb24YNCABKAlSDmRhcnRTZGtWZXJzaW9u'); -@$core.Deprecated('Use compHubSpecsDescriptor instead') -const CompHubSpecs$json = const { - '1': 'CompHubSpecs', - '2': const [ - const {'1': 'compId', '3': 22, '4': 1, '5': 9, '10': 'compId'}, - const {'1': 'compUuid', '3': 23, '4': 1, '5': 9, '10': 'compUuid'}, - const {'1': 'compOs', '3': 24, '4': 1, '5': 9, '10': 'compOs'}, - const {'1': 'compModel', '3': 25, '4': 1, '5': 9, '10': 'compModel'}, - const {'1': 'compType', '3': 26, '4': 1, '5': 9, '10': 'compType'}, - const {'1': 'compIp', '3': 50, '4': 1, '5': 9, '10': 'compIp'}, - ], -}; - -/// Descriptor for `CompHubSpecs`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List compHubSpecsDescriptor = $convert.base64Decode('CgxDb21wSHViU3BlY3MSFgoGY29tcElkGBYgASgJUgZjb21wSWQSGgoIY29tcFV1aWQYFyABKAlSCGNvbXBVdWlkEhYKBmNvbXBPcxgYIAEoCVIGY29tcE9zEhwKCWNvbXBNb2RlbBgZIAEoCVIJY29tcE1vZGVsEhoKCGNvbXBUeXBlGBogASgJUghjb21wVHlwZRIWCgZjb21wSXAYMiABKAlSBmNvbXBJcA=='); -@$core.Deprecated('Use microcontrollerSpecsDescriptor instead') -const MicrocontrollerSpecs$json = const { - '1': 'MicrocontrollerSpecs', - '2': const [ - const {'1': 'microcontrollerModel', '3': 31, '4': 1, '5': 9, '10': 'microcontrollerModel'}, - const {'1': 'microcontrollerType', '3': 32, '4': 1, '5': 9, '10': 'microcontrollerType'}, - const {'1': 'softwareVersion', '3': 33, '4': 1, '5': 9, '10': 'softwareVersion'}, - ], -}; - -/// Descriptor for `MicrocontrollerSpecs`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List microcontrollerSpecsDescriptor = $convert.base64Decode('ChRNaWNyb2NvbnRyb2xsZXJTcGVjcxIyChRtaWNyb2NvbnRyb2xsZXJNb2RlbBgfIAEoCVIUbWljcm9jb250cm9sbGVyTW9kZWwSMAoTbWljcm9jb250cm9sbGVyVHlwZRggIAEoCVITbWljcm9jb250cm9sbGVyVHlwZRIoCg9zb2Z0d2FyZVZlcnNpb24YISABKAlSD3NvZnR3YXJlVmVyc2lvbg=='); -@$core.Deprecated('Use smartEntityInfoDescriptor instead') -const SmartEntityInfo$json = const { - '1': 'SmartEntityInfo', - '2': const [ - const {'1': 'id', '3': 1, '4': 1, '5': 9, '10': 'id'}, - const {'1': 'state', '3': 3, '4': 1, '5': 9, '10': 'state'}, - const {'1': 'defaultName', '3': 14, '4': 1, '5': 9, '10': 'defaultName'}, - const {'1': 'roomId', '3': 15, '4': 1, '5': 9, '10': 'roomId'}, - const {'1': 'senderDeviceModel', '3': 16, '4': 1, '5': 9, '10': 'senderDeviceModel'}, - const {'1': 'senderDeviceOs', '3': 17, '4': 1, '5': 9, '10': 'senderDeviceOs'}, - const {'1': 'senderId', '3': 18, '4': 1, '5': 9, '10': 'senderId'}, - const {'1': 'serverTimeStamp', '3': 19, '4': 1, '5': 9, '10': 'serverTimeStamp'}, - const {'1': 'stateMassage', '3': 20, '4': 1, '5': 9, '10': 'stateMassage'}, - const {'1': 'mqttMassage', '3': 43, '4': 1, '5': 11, '6': '.CbjHub.MqttMassage', '10': 'mqttMassage'}, - const {'1': 'isComputer', '3': 29, '4': 1, '5': 8, '10': 'isComputer'}, - const {'1': 'compSpecs', '3': 30, '4': 1, '5': 11, '6': '.CbjHub.CompHubSpecs', '10': 'compSpecs'}, - const {'1': 'microcontrollerSpecsSpecs', '3': 31, '4': 1, '5': 11, '6': '.CbjHub.MicrocontrollerSpecs', '10': 'microcontrollerSpecsSpecs'}, - const {'1': 'entityTypesActions', '3': 34, '4': 1, '5': 11, '6': '.CbjHub.EntityTypesActions', '10': 'entityTypesActions'}, - ], -}; - -/// Descriptor for `SmartEntityInfo`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List smartEntityInfoDescriptor = $convert.base64Decode('Cg9TbWFydEVudGl0eUluZm8SDgoCaWQYASABKAlSAmlkEhQKBXN0YXRlGAMgASgJUgVzdGF0ZRIgCgtkZWZhdWx0TmFtZRgOIAEoCVILZGVmYXVsdE5hbWUSFgoGcm9vbUlkGA8gASgJUgZyb29tSWQSLAoRc2VuZGVyRGV2aWNlTW9kZWwYECABKAlSEXNlbmRlckRldmljZU1vZGVsEiYKDnNlbmRlckRldmljZU9zGBEgASgJUg5zZW5kZXJEZXZpY2VPcxIaCghzZW5kZXJJZBgSIAEoCVIIc2VuZGVySWQSKAoPc2VydmVyVGltZVN0YW1wGBMgASgJUg9zZXJ2ZXJUaW1lU3RhbXASIgoMc3RhdGVNYXNzYWdlGBQgASgJUgxzdGF0ZU1hc3NhZ2USNQoLbXF0dE1hc3NhZ2UYKyABKAsyEy5DYmpIdWIuTXF0dE1hc3NhZ2VSC21xdHRNYXNzYWdlEh4KCmlzQ29tcHV0ZXIYHSABKAhSCmlzQ29tcHV0ZXISMgoJY29tcFNwZWNzGB4gASgLMhQuQ2JqSHViLkNvbXBIdWJTcGVjc1IJY29tcFNwZWNzEloKGW1pY3JvY29udHJvbGxlclNwZWNzU3BlY3MYHyABKAsyHC5DYmpIdWIuTWljcm9jb250cm9sbGVyU3BlY3NSGW1pY3JvY29udHJvbGxlclNwZWNzU3BlY3MSSgoSZW50aXR5VHlwZXNBY3Rpb25zGCIgASgLMhouQ2JqSHViLkVudGl0eVR5cGVzQWN0aW9uc1ISZW50aXR5VHlwZXNBY3Rpb25z'); -@$core.Deprecated('Use smartEntityStatusDescriptor instead') -const SmartEntityStatus$json = const { - '1': 'SmartEntityStatus', - '2': const [ - const {'1': 'onOffState', '3': 4, '4': 1, '5': 8, '10': 'onOffState'}, - ], -}; - -/// Descriptor for `SmartEntityStatus`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List smartEntityStatusDescriptor = $convert.base64Decode('ChFTbWFydEVudGl0eVN0YXR1cxIeCgpvbk9mZlN0YXRlGAQgASgIUgpvbk9mZlN0YXRl'); -@$core.Deprecated('Use mqttMassageDescriptor instead') -const MqttMassage$json = const { - '1': 'MqttMassage', - '2': const [ - const {'1': 'mqttTopic', '3': 44, '4': 1, '5': 9, '10': 'mqttTopic'}, - const {'1': 'mqttMassage', '3': 45, '4': 1, '5': 9, '10': 'mqttMassage'}, - ], -}; - -/// Descriptor for `MqttMassage`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List mqttMassageDescriptor = $convert.base64Decode('CgtNcXR0TWFzc2FnZRIcCgltcXR0VG9waWMYLCABKAlSCW1xdHRUb3BpYxIgCgttcXR0TWFzc2FnZRgtIAEoCVILbXF0dE1hc3NhZ2U='); -@$core.Deprecated('Use commendStatusDescriptor instead') -const CommendStatus$json = const { - '1': 'CommendStatus', - '2': const [ - const {'1': 'success', '3': 5, '4': 1, '5': 8, '10': 'success'}, - ], -}; - -/// Descriptor for `CommendStatus`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List commendStatusDescriptor = $convert.base64Decode('Cg1Db21tZW5kU3RhdHVzEhgKB3N1Y2Nlc3MYBSABKAhSB3N1Y2Nlc3M='); -@$core.Deprecated('Use smartEntitiesUpdateDetailsDescriptor instead') -const SmartEntitiesUpdateDetails$json = const { - '1': 'SmartEntitiesUpdateDetails', - '2': const [ - const {'1': 'smartEntity', '3': 6, '4': 1, '5': 11, '6': '.CbjHub.SmartEntityInfo', '10': 'smartEntity'}, - const {'1': 'newName', '3': 7, '4': 1, '5': 9, '10': 'newName'}, - ], -}; - -/// Descriptor for `SmartEntitiesUpdateDetails`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List smartEntitiesUpdateDetailsDescriptor = $convert.base64Decode('ChpTbWFydEVudGl0aWVzVXBkYXRlRGV0YWlscxI5CgtzbWFydEVudGl0eRgGIAEoCzIXLkNiakh1Yi5TbWFydEVudGl0eUluZm9SC3NtYXJ0RW50aXR5EhgKB25ld05hbWUYByABKAlSB25ld05hbWU='); -@$core.Deprecated('Use cloudAccountInformationDescriptor instead') -const CloudAccountInformation$json = const { - '1': 'CloudAccountInformation', - '2': const [ - const {'1': 'cloudProjectId', '3': 8, '4': 1, '5': 9, '10': 'cloudProjectId'}, - const {'1': 'cloudApiKey', '3': 9, '4': 1, '5': 9, '10': 'cloudApiKey'}, - const {'1': 'userEmail', '3': 10, '4': 1, '5': 9, '10': 'userEmail'}, - const {'1': 'userPassword', '3': 11, '4': 1, '5': 9, '10': 'userPassword'}, - const {'1': 'homeId', '3': 12, '4': 1, '5': 9, '10': 'homeId'}, - ], -}; - -/// Descriptor for `CloudAccountInformation`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List cloudAccountInformationDescriptor = $convert.base64Decode('ChdDbG91ZEFjY291bnRJbmZvcm1hdGlvbhImCg5jbG91ZFByb2plY3RJZBgIIAEoCVIOY2xvdWRQcm9qZWN0SWQSIAoLY2xvdWRBcGlLZXkYCSABKAlSC2Nsb3VkQXBpS2V5EhwKCXVzZXJFbWFpbBgKIAEoCVIJdXNlckVtYWlsEiIKDHVzZXJQYXNzd29yZBgLIAEoCVIMdXNlclBhc3N3b3JkEhYKBmhvbWVJZBgMIAEoCVIGaG9tZUlk'); -@$core.Deprecated('Use entityTypesActionsDescriptor instead') -const EntityTypesActions$json = const { - '1': 'EntityTypesActions', - '2': const [ - const {'1': 'vendorsAndServices', '3': 46, '4': 1, '5': 14, '6': '.CbjHub.VendorsAndServices', '10': 'vendorsAndServices'}, - const {'1': 'entityType', '3': 35, '4': 1, '5': 14, '6': '.CbjHub.EntityTypes', '10': 'entityType'}, - const {'1': 'entityAction', '3': 36, '4': 1, '5': 14, '6': '.CbjHub.EntityActions', '10': 'entityAction'}, - const {'1': 'entityStateGRPC', '3': 37, '4': 1, '5': 14, '6': '.CbjHub.EntityStateGRPC', '10': 'entityStateGRPC'}, - ], -}; - -/// Descriptor for `EntityTypesActions`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List entityTypesActionsDescriptor = $convert.base64Decode('ChJFbnRpdHlUeXBlc0FjdGlvbnMSSgoSdmVuZG9yc0FuZFNlcnZpY2VzGC4gASgOMhouQ2JqSHViLlZlbmRvcnNBbmRTZXJ2aWNlc1ISdmVuZG9yc0FuZFNlcnZpY2VzEjMKCmVudGl0eVR5cGUYIyABKA4yEy5DYmpIdWIuRW50aXR5VHlwZXNSCmVudGl0eVR5cGUSOQoMZW50aXR5QWN0aW9uGCQgASgOMhUuQ2JqSHViLkVudGl0eUFjdGlvbnNSDGVudGl0eUFjdGlvbhJBCg9lbnRpdHlTdGF0ZUdSUEMYJSABKA4yFy5DYmpIdWIuRW50aXR5U3RhdGVHUlBDUg9lbnRpdHlTdGF0ZUdSUEM='); diff --git a/lib/infrastructure/gen/cbj_smart_device_server/proto_gen_date.dart b/lib/infrastructure/gen/cbj_smart_device_server/proto_gen_date.dart deleted file mode 100644 index b8f8395b..00000000 --- a/lib/infrastructure/gen/cbj_smart_device_server/proto_gen_date.dart +++ /dev/null @@ -1 +0,0 @@ -const cbjSmartDeviceServerProtocGenDate = '25/03/23'; diff --git a/lib/infrastructure/gen/cbj_smart_device_server/protoc_as_dart/cbj_smart_device_server.pb.dart b/lib/infrastructure/gen/cbj_smart_device_server/protoc_as_dart/cbj_smart_device_server.pb.dart deleted file mode 100644 index dabe74b0..00000000 --- a/lib/infrastructure/gen/cbj_smart_device_server/protoc_as_dart/cbj_smart_device_server.pb.dart +++ /dev/null @@ -1,1032 +0,0 @@ -/// -// Generated code. Do not modify. -// source: cbj_smart_device_server.proto -// -// @dart = 2.12 -// ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name - -import 'dart:core' as $core; - -import 'package:protobuf/protobuf.dart' as $pb; - -import 'cbj_smart_device_server.pbenum.dart'; - -export 'cbj_smart_device_server.pbenum.dart'; - -class CbjClientStatusRequests extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjClientStatusRequests', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjSmartDeviceConnections'), createEmptyInstance: create) - ..aOM(41, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'allRemoteCommands', protoName: 'allRemoteCommands', subBuilder: CbjAllRemoteCommands.create) - ..hasRequiredFields = false - ; - - CbjClientStatusRequests._() : super(); - factory CbjClientStatusRequests({ - CbjAllRemoteCommands? allRemoteCommands, - }) { - final _result = create(); - if (allRemoteCommands != null) { - _result.allRemoteCommands = allRemoteCommands; - } - return _result; - } - factory CbjClientStatusRequests.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory CbjClientStatusRequests.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - CbjClientStatusRequests clone() => CbjClientStatusRequests()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - CbjClientStatusRequests copyWith(void Function(CbjClientStatusRequests) updates) => super.copyWith((message) => updates(message as CbjClientStatusRequests)) as CbjClientStatusRequests; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static CbjClientStatusRequests create() => CbjClientStatusRequests._(); - CbjClientStatusRequests createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static CbjClientStatusRequests getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static CbjClientStatusRequests? _defaultInstance; - - @$pb.TagNumber(41) - CbjAllRemoteCommands get allRemoteCommands => $_getN(0); - @$pb.TagNumber(41) - set allRemoteCommands(CbjAllRemoteCommands v) { setField(41, v); } - @$pb.TagNumber(41) - $core.bool hasAllRemoteCommands() => $_has(0); - @$pb.TagNumber(41) - void clearAllRemoteCommands() => clearField(41); - @$pb.TagNumber(41) - CbjAllRemoteCommands ensureAllRemoteCommands() => $_ensure(0); -} - -class CbjRequestsAndStatusFromHub extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjRequestsAndStatusFromHub', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjSmartDeviceConnections'), createEmptyInstance: create) - ..aOM(42, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'allRemoteCommands', protoName: 'allRemoteCommands', subBuilder: CbjAllRemoteCommands.create) - ..hasRequiredFields = false - ; - - CbjRequestsAndStatusFromHub._() : super(); - factory CbjRequestsAndStatusFromHub({ - CbjAllRemoteCommands? allRemoteCommands, - }) { - final _result = create(); - if (allRemoteCommands != null) { - _result.allRemoteCommands = allRemoteCommands; - } - return _result; - } - factory CbjRequestsAndStatusFromHub.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory CbjRequestsAndStatusFromHub.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - CbjRequestsAndStatusFromHub clone() => CbjRequestsAndStatusFromHub()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - CbjRequestsAndStatusFromHub copyWith(void Function(CbjRequestsAndStatusFromHub) updates) => super.copyWith((message) => updates(message as CbjRequestsAndStatusFromHub)) as CbjRequestsAndStatusFromHub; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static CbjRequestsAndStatusFromHub create() => CbjRequestsAndStatusFromHub._(); - CbjRequestsAndStatusFromHub createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static CbjRequestsAndStatusFromHub getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static CbjRequestsAndStatusFromHub? _defaultInstance; - - @$pb.TagNumber(42) - CbjAllRemoteCommands get allRemoteCommands => $_getN(0); - @$pb.TagNumber(42) - set allRemoteCommands(CbjAllRemoteCommands v) { setField(42, v); } - @$pb.TagNumber(42) - $core.bool hasAllRemoteCommands() => $_has(0); - @$pb.TagNumber(42) - void clearAllRemoteCommands() => clearField(42); - @$pb.TagNumber(42) - CbjAllRemoteCommands ensureAllRemoteCommands() => $_ensure(0); -} - -class CbjAllRemoteCommands extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjAllRemoteCommands', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjSmartDeviceConnections'), createEmptyInstance: create) - ..aOM(40, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'smartDeviceInfo', protoName: 'smartDeviceInfo', subBuilder: CbjSmartDeviceInfo.create) - ..hasRequiredFields = false - ; - - CbjAllRemoteCommands._() : super(); - factory CbjAllRemoteCommands({ - CbjSmartDeviceInfo? smartDeviceInfo, - }) { - final _result = create(); - if (smartDeviceInfo != null) { - _result.smartDeviceInfo = smartDeviceInfo; - } - return _result; - } - factory CbjAllRemoteCommands.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory CbjAllRemoteCommands.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - CbjAllRemoteCommands clone() => CbjAllRemoteCommands()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - CbjAllRemoteCommands copyWith(void Function(CbjAllRemoteCommands) updates) => super.copyWith((message) => updates(message as CbjAllRemoteCommands)) as CbjAllRemoteCommands; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static CbjAllRemoteCommands create() => CbjAllRemoteCommands._(); - CbjAllRemoteCommands createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static CbjAllRemoteCommands getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static CbjAllRemoteCommands? _defaultInstance; - - @$pb.TagNumber(40) - CbjSmartDeviceInfo get smartDeviceInfo => $_getN(0); - @$pb.TagNumber(40) - set smartDeviceInfo(CbjSmartDeviceInfo v) { setField(40, v); } - @$pb.TagNumber(40) - $core.bool hasSmartDeviceInfo() => $_has(0); - @$pb.TagNumber(40) - void clearSmartDeviceInfo() => clearField(40); - @$pb.TagNumber(40) - CbjSmartDeviceInfo ensureSmartDeviceInfo() => $_ensure(0); -} - -class CbjFirstSetupMessage extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjFirstSetupMessage', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjSmartDeviceConnections'), createEmptyInstance: create) - ..aOM(38, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'compInfo', protoName: 'compInfo', subBuilder: CbjCompSmartDeviceInfo.create) - ..aOM(39, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'firebaseAccountInformation', protoName: 'firebaseAccountInformation', subBuilder: CbjFirebaseAccountInformation.create) - ..hasRequiredFields = false - ; - - CbjFirstSetupMessage._() : super(); - factory CbjFirstSetupMessage({ - CbjCompSmartDeviceInfo? compInfo, - CbjFirebaseAccountInformation? firebaseAccountInformation, - }) { - final _result = create(); - if (compInfo != null) { - _result.compInfo = compInfo; - } - if (firebaseAccountInformation != null) { - _result.firebaseAccountInformation = firebaseAccountInformation; - } - return _result; - } - factory CbjFirstSetupMessage.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory CbjFirstSetupMessage.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - CbjFirstSetupMessage clone() => CbjFirstSetupMessage()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - CbjFirstSetupMessage copyWith(void Function(CbjFirstSetupMessage) updates) => super.copyWith((message) => updates(message as CbjFirstSetupMessage)) as CbjFirstSetupMessage; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static CbjFirstSetupMessage create() => CbjFirstSetupMessage._(); - CbjFirstSetupMessage createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static CbjFirstSetupMessage getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static CbjFirstSetupMessage? _defaultInstance; - - @$pb.TagNumber(38) - CbjCompSmartDeviceInfo get compInfo => $_getN(0); - @$pb.TagNumber(38) - set compInfo(CbjCompSmartDeviceInfo v) { setField(38, v); } - @$pb.TagNumber(38) - $core.bool hasCompInfo() => $_has(0); - @$pb.TagNumber(38) - void clearCompInfo() => clearField(38); - @$pb.TagNumber(38) - CbjCompSmartDeviceInfo ensureCompInfo() => $_ensure(0); - - @$pb.TagNumber(39) - CbjFirebaseAccountInformation get firebaseAccountInformation => $_getN(1); - @$pb.TagNumber(39) - set firebaseAccountInformation(CbjFirebaseAccountInformation v) { setField(39, v); } - @$pb.TagNumber(39) - $core.bool hasFirebaseAccountInformation() => $_has(1); - @$pb.TagNumber(39) - void clearFirebaseAccountInformation() => clearField(39); - @$pb.TagNumber(39) - CbjFirebaseAccountInformation ensureFirebaseAccountInformation() => $_ensure(1); -} - -class CbjCompSmartDeviceInfo extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjCompSmartDeviceInfo', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjSmartDeviceConnections'), createEmptyInstance: create) - ..aOM(21, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'compSpecs', protoName: 'compSpecs', subBuilder: CbjCompSpecs.create) - ..pc(28, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'smartDevicesInComp', $pb.PbFieldType.PM, protoName: 'smartDevicesInComp', subBuilder: CbjSmartDeviceInfo.create) - ..hasRequiredFields = false - ; - - CbjCompSmartDeviceInfo._() : super(); - factory CbjCompSmartDeviceInfo({ - CbjCompSpecs? compSpecs, - $core.Iterable? smartDevicesInComp, - }) { - final _result = create(); - if (compSpecs != null) { - _result.compSpecs = compSpecs; - } - if (smartDevicesInComp != null) { - _result.smartDevicesInComp.addAll(smartDevicesInComp); - } - return _result; - } - factory CbjCompSmartDeviceInfo.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory CbjCompSmartDeviceInfo.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - CbjCompSmartDeviceInfo clone() => CbjCompSmartDeviceInfo()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - CbjCompSmartDeviceInfo copyWith(void Function(CbjCompSmartDeviceInfo) updates) => super.copyWith((message) => updates(message as CbjCompSmartDeviceInfo)) as CbjCompSmartDeviceInfo; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static CbjCompSmartDeviceInfo create() => CbjCompSmartDeviceInfo._(); - CbjCompSmartDeviceInfo createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static CbjCompSmartDeviceInfo getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static CbjCompSmartDeviceInfo? _defaultInstance; - - @$pb.TagNumber(21) - CbjCompSpecs get compSpecs => $_getN(0); - @$pb.TagNumber(21) - set compSpecs(CbjCompSpecs v) { setField(21, v); } - @$pb.TagNumber(21) - $core.bool hasCompSpecs() => $_has(0); - @$pb.TagNumber(21) - void clearCompSpecs() => clearField(21); - @$pb.TagNumber(21) - CbjCompSpecs ensureCompSpecs() => $_ensure(0); - - @$pb.TagNumber(28) - $core.List get smartDevicesInComp => $_getList(1); -} - -class CbjCompSpecs extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjCompSpecs', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjSmartDeviceConnections'), createEmptyInstance: create) - ..aOS(22, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'compId', protoName: 'compId') - ..aOS(23, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'compUuid', protoName: 'compUuid') - ..aOS(24, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'compOs', protoName: 'compOs') - ..aOS(25, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'compModel', protoName: 'compModel') - ..aOS(26, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'compType', protoName: 'compType') - ..aOS(27, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'pubspecYamlVersion', protoName: 'pubspecYamlVersion') - ..hasRequiredFields = false - ; - - CbjCompSpecs._() : super(); - factory CbjCompSpecs({ - $core.String? compId, - $core.String? compUuid, - $core.String? compOs, - $core.String? compModel, - $core.String? compType, - $core.String? pubspecYamlVersion, - }) { - final _result = create(); - if (compId != null) { - _result.compId = compId; - } - if (compUuid != null) { - _result.compUuid = compUuid; - } - if (compOs != null) { - _result.compOs = compOs; - } - if (compModel != null) { - _result.compModel = compModel; - } - if (compType != null) { - _result.compType = compType; - } - if (pubspecYamlVersion != null) { - _result.pubspecYamlVersion = pubspecYamlVersion; - } - return _result; - } - factory CbjCompSpecs.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory CbjCompSpecs.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - CbjCompSpecs clone() => CbjCompSpecs()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - CbjCompSpecs copyWith(void Function(CbjCompSpecs) updates) => super.copyWith((message) => updates(message as CbjCompSpecs)) as CbjCompSpecs; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static CbjCompSpecs create() => CbjCompSpecs._(); - CbjCompSpecs createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static CbjCompSpecs getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static CbjCompSpecs? _defaultInstance; - - @$pb.TagNumber(22) - $core.String get compId => $_getSZ(0); - @$pb.TagNumber(22) - set compId($core.String v) { $_setString(0, v); } - @$pb.TagNumber(22) - $core.bool hasCompId() => $_has(0); - @$pb.TagNumber(22) - void clearCompId() => clearField(22); - - @$pb.TagNumber(23) - $core.String get compUuid => $_getSZ(1); - @$pb.TagNumber(23) - set compUuid($core.String v) { $_setString(1, v); } - @$pb.TagNumber(23) - $core.bool hasCompUuid() => $_has(1); - @$pb.TagNumber(23) - void clearCompUuid() => clearField(23); - - @$pb.TagNumber(24) - $core.String get compOs => $_getSZ(2); - @$pb.TagNumber(24) - set compOs($core.String v) { $_setString(2, v); } - @$pb.TagNumber(24) - $core.bool hasCompOs() => $_has(2); - @$pb.TagNumber(24) - void clearCompOs() => clearField(24); - - @$pb.TagNumber(25) - $core.String get compModel => $_getSZ(3); - @$pb.TagNumber(25) - set compModel($core.String v) { $_setString(3, v); } - @$pb.TagNumber(25) - $core.bool hasCompModel() => $_has(3); - @$pb.TagNumber(25) - void clearCompModel() => clearField(25); - - @$pb.TagNumber(26) - $core.String get compType => $_getSZ(4); - @$pb.TagNumber(26) - set compType($core.String v) { $_setString(4, v); } - @$pb.TagNumber(26) - $core.bool hasCompType() => $_has(4); - @$pb.TagNumber(26) - void clearCompType() => clearField(26); - - @$pb.TagNumber(27) - $core.String get pubspecYamlVersion => $_getSZ(5); - @$pb.TagNumber(27) - set pubspecYamlVersion($core.String v) { $_setString(5, v); } - @$pb.TagNumber(27) - $core.bool hasPubspecYamlVersion() => $_has(5); - @$pb.TagNumber(27) - void clearPubspecYamlVersion() => clearField(27); -} - -class CbjMicrocontrollerSpecs extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjMicrocontrollerSpecs', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjSmartDeviceConnections'), createEmptyInstance: create) - ..aOS(31, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'microcontrollerModel', protoName: 'microcontrollerModel') - ..aOS(32, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'microcontrollerType', protoName: 'microcontrollerType') - ..aOS(33, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'softwareVersion', protoName: 'softwareVersion') - ..hasRequiredFields = false - ; - - CbjMicrocontrollerSpecs._() : super(); - factory CbjMicrocontrollerSpecs({ - $core.String? microcontrollerModel, - $core.String? microcontrollerType, - $core.String? softwareVersion, - }) { - final _result = create(); - if (microcontrollerModel != null) { - _result.microcontrollerModel = microcontrollerModel; - } - if (microcontrollerType != null) { - _result.microcontrollerType = microcontrollerType; - } - if (softwareVersion != null) { - _result.softwareVersion = softwareVersion; - } - return _result; - } - factory CbjMicrocontrollerSpecs.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory CbjMicrocontrollerSpecs.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - CbjMicrocontrollerSpecs clone() => CbjMicrocontrollerSpecs()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - CbjMicrocontrollerSpecs copyWith(void Function(CbjMicrocontrollerSpecs) updates) => super.copyWith((message) => updates(message as CbjMicrocontrollerSpecs)) as CbjMicrocontrollerSpecs; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static CbjMicrocontrollerSpecs create() => CbjMicrocontrollerSpecs._(); - CbjMicrocontrollerSpecs createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static CbjMicrocontrollerSpecs getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static CbjMicrocontrollerSpecs? _defaultInstance; - - @$pb.TagNumber(31) - $core.String get microcontrollerModel => $_getSZ(0); - @$pb.TagNumber(31) - set microcontrollerModel($core.String v) { $_setString(0, v); } - @$pb.TagNumber(31) - $core.bool hasMicrocontrollerModel() => $_has(0); - @$pb.TagNumber(31) - void clearMicrocontrollerModel() => clearField(31); - - @$pb.TagNumber(32) - $core.String get microcontrollerType => $_getSZ(1); - @$pb.TagNumber(32) - set microcontrollerType($core.String v) { $_setString(1, v); } - @$pb.TagNumber(32) - $core.bool hasMicrocontrollerType() => $_has(1); - @$pb.TagNumber(32) - void clearMicrocontrollerType() => clearField(32); - - @$pb.TagNumber(33) - $core.String get softwareVersion => $_getSZ(2); - @$pb.TagNumber(33) - set softwareVersion($core.String v) { $_setString(2, v); } - @$pb.TagNumber(33) - $core.bool hasSoftwareVersion() => $_has(2); - @$pb.TagNumber(33) - void clearSoftwareVersion() => clearField(33); -} - -class CbjSmartDeviceInfo extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjSmartDeviceInfo', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjSmartDeviceConnections'), createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'id') - ..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'state') - ..aOS(14, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'defaultName', protoName: 'defaultName') - ..aOS(15, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'roomId', protoName: 'roomId') - ..aOS(16, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'senderDeviceModel', protoName: 'senderDeviceModel') - ..aOS(17, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'senderDeviceOs', protoName: 'senderDeviceOs') - ..aOS(18, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'senderId', protoName: 'senderId') - ..aOS(19, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'serverTimeStamp', protoName: 'serverTimeStamp') - ..aOS(20, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'stateMassage', protoName: 'stateMassage') - ..aOB(29, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'isComputer', protoName: 'isComputer') - ..aOM(30, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'compSpecs', protoName: 'compSpecs', subBuilder: CbjCompSpecs.create) - ..aOM(31, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'microcontrollerSpecsSpecs', protoName: 'microcontrollerSpecsSpecs', subBuilder: CbjMicrocontrollerSpecs.create) - ..aOM(34, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'deviceTypesActions', protoName: 'deviceTypesActions', subBuilder: CbjDeviceTypesActions.create) - ..hasRequiredFields = false - ; - - CbjSmartDeviceInfo._() : super(); - factory CbjSmartDeviceInfo({ - $core.String? id, - $core.String? state, - $core.String? defaultName, - $core.String? roomId, - $core.String? senderDeviceModel, - $core.String? senderDeviceOs, - $core.String? senderId, - $core.String? serverTimeStamp, - $core.String? stateMassage, - $core.bool? isComputer, - CbjCompSpecs? compSpecs, - CbjMicrocontrollerSpecs? microcontrollerSpecsSpecs, - CbjDeviceTypesActions? deviceTypesActions, - }) { - final _result = create(); - if (id != null) { - _result.id = id; - } - if (state != null) { - _result.state = state; - } - if (defaultName != null) { - _result.defaultName = defaultName; - } - if (roomId != null) { - _result.roomId = roomId; - } - if (senderDeviceModel != null) { - _result.senderDeviceModel = senderDeviceModel; - } - if (senderDeviceOs != null) { - _result.senderDeviceOs = senderDeviceOs; - } - if (senderId != null) { - _result.senderId = senderId; - } - if (serverTimeStamp != null) { - _result.serverTimeStamp = serverTimeStamp; - } - if (stateMassage != null) { - _result.stateMassage = stateMassage; - } - if (isComputer != null) { - _result.isComputer = isComputer; - } - if (compSpecs != null) { - _result.compSpecs = compSpecs; - } - if (microcontrollerSpecsSpecs != null) { - _result.microcontrollerSpecsSpecs = microcontrollerSpecsSpecs; - } - if (deviceTypesActions != null) { - _result.deviceTypesActions = deviceTypesActions; - } - return _result; - } - factory CbjSmartDeviceInfo.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory CbjSmartDeviceInfo.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - CbjSmartDeviceInfo clone() => CbjSmartDeviceInfo()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - CbjSmartDeviceInfo copyWith(void Function(CbjSmartDeviceInfo) updates) => super.copyWith((message) => updates(message as CbjSmartDeviceInfo)) as CbjSmartDeviceInfo; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static CbjSmartDeviceInfo create() => CbjSmartDeviceInfo._(); - CbjSmartDeviceInfo createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static CbjSmartDeviceInfo getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static CbjSmartDeviceInfo? _defaultInstance; - - @$pb.TagNumber(1) - $core.String get id => $_getSZ(0); - @$pb.TagNumber(1) - set id($core.String v) { $_setString(0, v); } - @$pb.TagNumber(1) - $core.bool hasId() => $_has(0); - @$pb.TagNumber(1) - void clearId() => clearField(1); - - @$pb.TagNumber(3) - $core.String get state => $_getSZ(1); - @$pb.TagNumber(3) - set state($core.String v) { $_setString(1, v); } - @$pb.TagNumber(3) - $core.bool hasState() => $_has(1); - @$pb.TagNumber(3) - void clearState() => clearField(3); - - @$pb.TagNumber(14) - $core.String get defaultName => $_getSZ(2); - @$pb.TagNumber(14) - set defaultName($core.String v) { $_setString(2, v); } - @$pb.TagNumber(14) - $core.bool hasDefaultName() => $_has(2); - @$pb.TagNumber(14) - void clearDefaultName() => clearField(14); - - @$pb.TagNumber(15) - $core.String get roomId => $_getSZ(3); - @$pb.TagNumber(15) - set roomId($core.String v) { $_setString(3, v); } - @$pb.TagNumber(15) - $core.bool hasRoomId() => $_has(3); - @$pb.TagNumber(15) - void clearRoomId() => clearField(15); - - @$pb.TagNumber(16) - $core.String get senderDeviceModel => $_getSZ(4); - @$pb.TagNumber(16) - set senderDeviceModel($core.String v) { $_setString(4, v); } - @$pb.TagNumber(16) - $core.bool hasSenderDeviceModel() => $_has(4); - @$pb.TagNumber(16) - void clearSenderDeviceModel() => clearField(16); - - @$pb.TagNumber(17) - $core.String get senderDeviceOs => $_getSZ(5); - @$pb.TagNumber(17) - set senderDeviceOs($core.String v) { $_setString(5, v); } - @$pb.TagNumber(17) - $core.bool hasSenderDeviceOs() => $_has(5); - @$pb.TagNumber(17) - void clearSenderDeviceOs() => clearField(17); - - @$pb.TagNumber(18) - $core.String get senderId => $_getSZ(6); - @$pb.TagNumber(18) - set senderId($core.String v) { $_setString(6, v); } - @$pb.TagNumber(18) - $core.bool hasSenderId() => $_has(6); - @$pb.TagNumber(18) - void clearSenderId() => clearField(18); - - @$pb.TagNumber(19) - $core.String get serverTimeStamp => $_getSZ(7); - @$pb.TagNumber(19) - set serverTimeStamp($core.String v) { $_setString(7, v); } - @$pb.TagNumber(19) - $core.bool hasServerTimeStamp() => $_has(7); - @$pb.TagNumber(19) - void clearServerTimeStamp() => clearField(19); - - @$pb.TagNumber(20) - $core.String get stateMassage => $_getSZ(8); - @$pb.TagNumber(20) - set stateMassage($core.String v) { $_setString(8, v); } - @$pb.TagNumber(20) - $core.bool hasStateMassage() => $_has(8); - @$pb.TagNumber(20) - void clearStateMassage() => clearField(20); - - @$pb.TagNumber(29) - $core.bool get isComputer => $_getBF(9); - @$pb.TagNumber(29) - set isComputer($core.bool v) { $_setBool(9, v); } - @$pb.TagNumber(29) - $core.bool hasIsComputer() => $_has(9); - @$pb.TagNumber(29) - void clearIsComputer() => clearField(29); - - @$pb.TagNumber(30) - CbjCompSpecs get compSpecs => $_getN(10); - @$pb.TagNumber(30) - set compSpecs(CbjCompSpecs v) { setField(30, v); } - @$pb.TagNumber(30) - $core.bool hasCompSpecs() => $_has(10); - @$pb.TagNumber(30) - void clearCompSpecs() => clearField(30); - @$pb.TagNumber(30) - CbjCompSpecs ensureCompSpecs() => $_ensure(10); - - @$pb.TagNumber(31) - CbjMicrocontrollerSpecs get microcontrollerSpecsSpecs => $_getN(11); - @$pb.TagNumber(31) - set microcontrollerSpecsSpecs(CbjMicrocontrollerSpecs v) { setField(31, v); } - @$pb.TagNumber(31) - $core.bool hasMicrocontrollerSpecsSpecs() => $_has(11); - @$pb.TagNumber(31) - void clearMicrocontrollerSpecsSpecs() => clearField(31); - @$pb.TagNumber(31) - CbjMicrocontrollerSpecs ensureMicrocontrollerSpecsSpecs() => $_ensure(11); - - @$pb.TagNumber(34) - CbjDeviceTypesActions get deviceTypesActions => $_getN(12); - @$pb.TagNumber(34) - set deviceTypesActions(CbjDeviceTypesActions v) { setField(34, v); } - @$pb.TagNumber(34) - $core.bool hasDeviceTypesActions() => $_has(12); - @$pb.TagNumber(34) - void clearDeviceTypesActions() => clearField(34); - @$pb.TagNumber(34) - CbjDeviceTypesActions ensureDeviceTypesActions() => $_ensure(12); -} - -class CbjSmartDeviceStatus extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjSmartDeviceStatus', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjSmartDeviceConnections'), createEmptyInstance: create) - ..aOB(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'onOffState', protoName: 'onOffState') - ..hasRequiredFields = false - ; - - CbjSmartDeviceStatus._() : super(); - factory CbjSmartDeviceStatus({ - $core.bool? onOffState, - }) { - final _result = create(); - if (onOffState != null) { - _result.onOffState = onOffState; - } - return _result; - } - factory CbjSmartDeviceStatus.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory CbjSmartDeviceStatus.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - CbjSmartDeviceStatus clone() => CbjSmartDeviceStatus()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - CbjSmartDeviceStatus copyWith(void Function(CbjSmartDeviceStatus) updates) => super.copyWith((message) => updates(message as CbjSmartDeviceStatus)) as CbjSmartDeviceStatus; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static CbjSmartDeviceStatus create() => CbjSmartDeviceStatus._(); - CbjSmartDeviceStatus createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static CbjSmartDeviceStatus getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static CbjSmartDeviceStatus? _defaultInstance; - - @$pb.TagNumber(4) - $core.bool get onOffState => $_getBF(0); - @$pb.TagNumber(4) - set onOffState($core.bool v) { $_setBool(0, v); } - @$pb.TagNumber(4) - $core.bool hasOnOffState() => $_has(0); - @$pb.TagNumber(4) - void clearOnOffState() => clearField(4); -} - -class CbjCommendStatus extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjCommendStatus', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjSmartDeviceConnections'), createEmptyInstance: create) - ..aOB(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'success') - ..hasRequiredFields = false - ; - - CbjCommendStatus._() : super(); - factory CbjCommendStatus({ - $core.bool? success, - }) { - final _result = create(); - if (success != null) { - _result.success = success; - } - return _result; - } - factory CbjCommendStatus.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory CbjCommendStatus.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - CbjCommendStatus clone() => CbjCommendStatus()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - CbjCommendStatus copyWith(void Function(CbjCommendStatus) updates) => super.copyWith((message) => updates(message as CbjCommendStatus)) as CbjCommendStatus; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static CbjCommendStatus create() => CbjCommendStatus._(); - CbjCommendStatus createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static CbjCommendStatus getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static CbjCommendStatus? _defaultInstance; - - @$pb.TagNumber(5) - $core.bool get success => $_getBF(0); - @$pb.TagNumber(5) - set success($core.bool v) { $_setBool(0, v); } - @$pb.TagNumber(5) - $core.bool hasSuccess() => $_has(0); - @$pb.TagNumber(5) - void clearSuccess() => clearField(5); -} - -class CbjSmartDeviceUpdateDetails extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjSmartDeviceUpdateDetails', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjSmartDeviceConnections'), createEmptyInstance: create) - ..aOM(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'smartDevice', protoName: 'smartDevice', subBuilder: CbjSmartDeviceInfo.create) - ..aOS(7, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'newName', protoName: 'newName') - ..hasRequiredFields = false - ; - - CbjSmartDeviceUpdateDetails._() : super(); - factory CbjSmartDeviceUpdateDetails({ - CbjSmartDeviceInfo? smartDevice, - $core.String? newName, - }) { - final _result = create(); - if (smartDevice != null) { - _result.smartDevice = smartDevice; - } - if (newName != null) { - _result.newName = newName; - } - return _result; - } - factory CbjSmartDeviceUpdateDetails.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory CbjSmartDeviceUpdateDetails.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - CbjSmartDeviceUpdateDetails clone() => CbjSmartDeviceUpdateDetails()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - CbjSmartDeviceUpdateDetails copyWith(void Function(CbjSmartDeviceUpdateDetails) updates) => super.copyWith((message) => updates(message as CbjSmartDeviceUpdateDetails)) as CbjSmartDeviceUpdateDetails; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static CbjSmartDeviceUpdateDetails create() => CbjSmartDeviceUpdateDetails._(); - CbjSmartDeviceUpdateDetails createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static CbjSmartDeviceUpdateDetails getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static CbjSmartDeviceUpdateDetails? _defaultInstance; - - @$pb.TagNumber(6) - CbjSmartDeviceInfo get smartDevice => $_getN(0); - @$pb.TagNumber(6) - set smartDevice(CbjSmartDeviceInfo v) { setField(6, v); } - @$pb.TagNumber(6) - $core.bool hasSmartDevice() => $_has(0); - @$pb.TagNumber(6) - void clearSmartDevice() => clearField(6); - @$pb.TagNumber(6) - CbjSmartDeviceInfo ensureSmartDevice() => $_ensure(0); - - @$pb.TagNumber(7) - $core.String get newName => $_getSZ(1); - @$pb.TagNumber(7) - set newName($core.String v) { $_setString(1, v); } - @$pb.TagNumber(7) - $core.bool hasNewName() => $_has(1); - @$pb.TagNumber(7) - void clearNewName() => clearField(7); -} - -class CbjFirebaseAccountInformation extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjFirebaseAccountInformation', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjSmartDeviceConnections'), createEmptyInstance: create) - ..aOS(8, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'fireBaseProjectId', protoName: 'fireBaseProjectId') - ..aOS(9, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'fireBaseApiKey', protoName: 'fireBaseApiKey') - ..aOS(10, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'userEmail', protoName: 'userEmail') - ..aOS(11, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'userPassword', protoName: 'userPassword') - ..aOS(12, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'homeId', protoName: 'homeId') - ..hasRequiredFields = false - ; - - CbjFirebaseAccountInformation._() : super(); - factory CbjFirebaseAccountInformation({ - $core.String? fireBaseProjectId, - $core.String? fireBaseApiKey, - $core.String? userEmail, - $core.String? userPassword, - $core.String? homeId, - }) { - final _result = create(); - if (fireBaseProjectId != null) { - _result.fireBaseProjectId = fireBaseProjectId; - } - if (fireBaseApiKey != null) { - _result.fireBaseApiKey = fireBaseApiKey; - } - if (userEmail != null) { - _result.userEmail = userEmail; - } - if (userPassword != null) { - _result.userPassword = userPassword; - } - if (homeId != null) { - _result.homeId = homeId; - } - return _result; - } - factory CbjFirebaseAccountInformation.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory CbjFirebaseAccountInformation.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - CbjFirebaseAccountInformation clone() => CbjFirebaseAccountInformation()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - CbjFirebaseAccountInformation copyWith(void Function(CbjFirebaseAccountInformation) updates) => super.copyWith((message) => updates(message as CbjFirebaseAccountInformation)) as CbjFirebaseAccountInformation; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static CbjFirebaseAccountInformation create() => CbjFirebaseAccountInformation._(); - CbjFirebaseAccountInformation createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static CbjFirebaseAccountInformation getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static CbjFirebaseAccountInformation? _defaultInstance; - - @$pb.TagNumber(8) - $core.String get fireBaseProjectId => $_getSZ(0); - @$pb.TagNumber(8) - set fireBaseProjectId($core.String v) { $_setString(0, v); } - @$pb.TagNumber(8) - $core.bool hasFireBaseProjectId() => $_has(0); - @$pb.TagNumber(8) - void clearFireBaseProjectId() => clearField(8); - - @$pb.TagNumber(9) - $core.String get fireBaseApiKey => $_getSZ(1); - @$pb.TagNumber(9) - set fireBaseApiKey($core.String v) { $_setString(1, v); } - @$pb.TagNumber(9) - $core.bool hasFireBaseApiKey() => $_has(1); - @$pb.TagNumber(9) - void clearFireBaseApiKey() => clearField(9); - - @$pb.TagNumber(10) - $core.String get userEmail => $_getSZ(2); - @$pb.TagNumber(10) - set userEmail($core.String v) { $_setString(2, v); } - @$pb.TagNumber(10) - $core.bool hasUserEmail() => $_has(2); - @$pb.TagNumber(10) - void clearUserEmail() => clearField(10); - - @$pb.TagNumber(11) - $core.String get userPassword => $_getSZ(3); - @$pb.TagNumber(11) - set userPassword($core.String v) { $_setString(3, v); } - @$pb.TagNumber(11) - $core.bool hasUserPassword() => $_has(3); - @$pb.TagNumber(11) - void clearUserPassword() => clearField(11); - - @$pb.TagNumber(12) - $core.String get homeId => $_getSZ(4); - @$pb.TagNumber(12) - set homeId($core.String v) { $_setString(4, v); } - @$pb.TagNumber(12) - $core.bool hasHomeId() => $_has(4); - @$pb.TagNumber(12) - void clearHomeId() => clearField(12); -} - -class CbjDeviceTypesActions extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjDeviceTypesActions', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CbjSmartDeviceConnections'), createEmptyInstance: create) - ..e(35, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'deviceType', $pb.PbFieldType.OE, protoName: 'deviceType', defaultOrMaker: CbjDeviceTypes.typeNotSupported, valueOf: CbjDeviceTypes.valueOf, enumValues: CbjDeviceTypes.values) - ..e(36, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'deviceAction', $pb.PbFieldType.OE, protoName: 'deviceAction', defaultOrMaker: CbjDeviceActions.actionNotSupported, valueOf: CbjDeviceActions.valueOf, enumValues: CbjDeviceActions.values) - ..e(37, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'deviceStateGRPC', $pb.PbFieldType.OE, protoName: 'deviceStateGRPC', defaultOrMaker: CbjDeviceStateGRPC.stateNotSupported, valueOf: CbjDeviceStateGRPC.valueOf, enumValues: CbjDeviceStateGRPC.values) - ..hasRequiredFields = false - ; - - CbjDeviceTypesActions._() : super(); - factory CbjDeviceTypesActions({ - CbjDeviceTypes? deviceType, - CbjDeviceActions? deviceAction, - CbjDeviceStateGRPC? deviceStateGRPC, - }) { - final _result = create(); - if (deviceType != null) { - _result.deviceType = deviceType; - } - if (deviceAction != null) { - _result.deviceAction = deviceAction; - } - if (deviceStateGRPC != null) { - _result.deviceStateGRPC = deviceStateGRPC; - } - return _result; - } - factory CbjDeviceTypesActions.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory CbjDeviceTypesActions.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - CbjDeviceTypesActions clone() => CbjDeviceTypesActions()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - CbjDeviceTypesActions copyWith(void Function(CbjDeviceTypesActions) updates) => super.copyWith((message) => updates(message as CbjDeviceTypesActions)) as CbjDeviceTypesActions; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static CbjDeviceTypesActions create() => CbjDeviceTypesActions._(); - CbjDeviceTypesActions createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static CbjDeviceTypesActions getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static CbjDeviceTypesActions? _defaultInstance; - - @$pb.TagNumber(35) - CbjDeviceTypes get deviceType => $_getN(0); - @$pb.TagNumber(35) - set deviceType(CbjDeviceTypes v) { setField(35, v); } - @$pb.TagNumber(35) - $core.bool hasDeviceType() => $_has(0); - @$pb.TagNumber(35) - void clearDeviceType() => clearField(35); - - @$pb.TagNumber(36) - CbjDeviceActions get deviceAction => $_getN(1); - @$pb.TagNumber(36) - set deviceAction(CbjDeviceActions v) { setField(36, v); } - @$pb.TagNumber(36) - $core.bool hasDeviceAction() => $_has(1); - @$pb.TagNumber(36) - void clearDeviceAction() => clearField(36); - - @$pb.TagNumber(37) - CbjDeviceStateGRPC get deviceStateGRPC => $_getN(2); - @$pb.TagNumber(37) - set deviceStateGRPC(CbjDeviceStateGRPC v) { setField(37, v); } - @$pb.TagNumber(37) - $core.bool hasDeviceStateGRPC() => $_has(2); - @$pb.TagNumber(37) - void clearDeviceStateGRPC() => clearField(37); -} - diff --git a/lib/infrastructure/gen/cbj_smart_device_server/protoc_as_dart/cbj_smart_device_server.pbenum.dart b/lib/infrastructure/gen/cbj_smart_device_server/protoc_as_dart/cbj_smart_device_server.pbenum.dart deleted file mode 100644 index b86e5278..00000000 --- a/lib/infrastructure/gen/cbj_smart_device_server/protoc_as_dart/cbj_smart_device_server.pbenum.dart +++ /dev/null @@ -1,139 +0,0 @@ -/// -// Generated code. Do not modify. -// source: cbj_smart_device_server.proto -// -// @dart = 2.12 -// ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name - -// ignore_for_file: UNDEFINED_SHOWN_NAME -import 'dart:core' as $core; -import 'package:protobuf/protobuf.dart' as $pb; - -class CbjDeviceTypes extends $pb.ProtobufEnum { - static const CbjDeviceTypes typeNotSupported = CbjDeviceTypes._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'typeNotSupported'); - static const CbjDeviceTypes light = CbjDeviceTypes._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'light'); - static const CbjDeviceTypes blinds = CbjDeviceTypes._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'blinds'); - static const CbjDeviceTypes boiler = CbjDeviceTypes._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'boiler'); - static const CbjDeviceTypes button = CbjDeviceTypes._(4, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'button'); - static const CbjDeviceTypes buttonWithLight = CbjDeviceTypes._(5, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'buttonWithLight'); - static const CbjDeviceTypes hub = CbjDeviceTypes._(7, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'hub'); - static const CbjDeviceTypes phoneApp = CbjDeviceTypes._(8, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'phoneApp'); - static const CbjDeviceTypes computerApp = CbjDeviceTypes._(9, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'computerApp'); - static const CbjDeviceTypes browserApp = CbjDeviceTypes._(10, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'browserApp'); - static const CbjDeviceTypes smartComputer = CbjDeviceTypes._(11, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'smartComputer'); - - static const $core.List values = [ - typeNotSupported, - light, - blinds, - boiler, - button, - buttonWithLight, - hub, - phoneApp, - computerApp, - browserApp, - smartComputer, - ]; - - static final $core.Map<$core.int, CbjDeviceTypes> _byValue = $pb.ProtobufEnum.initByValue(values); - static CbjDeviceTypes? valueOf($core.int value) => _byValue[value]; - - const CbjDeviceTypes._($core.int v, $core.String n) : super(v, n); -} - -class CbjDeviceActions extends $pb.ProtobufEnum { - static const CbjDeviceActions actionNotSupported = CbjDeviceActions._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'actionNotSupported'); - static const CbjDeviceActions on = CbjDeviceActions._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'on'); - static const CbjDeviceActions off = CbjDeviceActions._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'off'); - static const CbjDeviceActions moveUp = CbjDeviceActions._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'moveUp'); - static const CbjDeviceActions stop = CbjDeviceActions._(4, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'stop'); - static const CbjDeviceActions moveDown = CbjDeviceActions._(5, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'moveDown'); - static const CbjDeviceActions pressed = CbjDeviceActions._(6, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'pressed'); - static const CbjDeviceActions longPress = CbjDeviceActions._(7, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'longPress'); - static const CbjDeviceActions doubleTap = CbjDeviceActions._(8, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'doubleTap'); - static const CbjDeviceActions position = CbjDeviceActions._(9, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'position'); - static const CbjDeviceActions suspend = CbjDeviceActions._(10, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'suspend'); - static const CbjDeviceActions shutdown = CbjDeviceActions._(11, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'shutdown'); - static const CbjDeviceActions itIsFalse = CbjDeviceActions._(12, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'itIsFalse'); - static const CbjDeviceActions itIsTrue = CbjDeviceActions._(13, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'itIsTrue'); - - static const $core.List values = [ - actionNotSupported, - on, - off, - moveUp, - stop, - moveDown, - pressed, - longPress, - doubleTap, - position, - suspend, - shutdown, - itIsFalse, - itIsTrue, - ]; - - static final $core.Map<$core.int, CbjDeviceActions> _byValue = $pb.ProtobufEnum.initByValue(values); - static CbjDeviceActions? valueOf($core.int value) => _byValue[value]; - - const CbjDeviceActions._($core.int v, $core.String n) : super(v, n); -} - -class CbjWhenToExecute extends $pb.ProtobufEnum { - static const CbjWhenToExecute undefined = CbjWhenToExecute._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'undefined'); - static const CbjWhenToExecute onOddNumberPress = CbjWhenToExecute._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'onOddNumberPress'); - static const CbjWhenToExecute evenNumberPress = CbjWhenToExecute._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'evenNumberPress'); - static const CbjWhenToExecute betweenSelectedTime = CbjWhenToExecute._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'betweenSelectedTime'); - static const CbjWhenToExecute doNotBetweenSelectedTime = CbjWhenToExecute._(4, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'doNotBetweenSelectedTime'); - static const CbjWhenToExecute allTheTime = CbjWhenToExecute._(5, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'allTheTime'); - static const CbjWhenToExecute never = CbjWhenToExecute._(6, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'never'); - static const CbjWhenToExecute onceNow = CbjWhenToExecute._(7, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'onceNow'); - static const CbjWhenToExecute onceInSelectedTime = CbjWhenToExecute._(8, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'onceInSelectedTime'); - static const CbjWhenToExecute onlyIfDeviceListIsAreInActionListState = CbjWhenToExecute._(9, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'onlyIfDeviceListIsAreInActionListState'); - static const CbjWhenToExecute atHome = CbjWhenToExecute._(10, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'atHome'); - static const CbjWhenToExecute outOfHome = CbjWhenToExecute._(11, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'outOfHome'); - - static const $core.List values = [ - undefined, - onOddNumberPress, - evenNumberPress, - betweenSelectedTime, - doNotBetweenSelectedTime, - allTheTime, - never, - onceNow, - onceInSelectedTime, - onlyIfDeviceListIsAreInActionListState, - atHome, - outOfHome, - ]; - - static final $core.Map<$core.int, CbjWhenToExecute> _byValue = $pb.ProtobufEnum.initByValue(values); - static CbjWhenToExecute? valueOf($core.int value) => _byValue[value]; - - const CbjWhenToExecute._($core.int v, $core.String n) : super(v, n); -} - -class CbjDeviceStateGRPC extends $pb.ProtobufEnum { - static const CbjDeviceStateGRPC stateNotSupported = CbjDeviceStateGRPC._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'stateNotSupported'); - static const CbjDeviceStateGRPC cancelStateInProcess = CbjDeviceStateGRPC._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'cancelStateInProcess'); - static const CbjDeviceStateGRPC ack = CbjDeviceStateGRPC._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ack'); - static const CbjDeviceStateGRPC newStateFailed = CbjDeviceStateGRPC._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'newStateFailed'); - static const CbjDeviceStateGRPC waitingInComp = CbjDeviceStateGRPC._(4, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'waitingInComp'); - - static const $core.List values = [ - stateNotSupported, - cancelStateInProcess, - ack, - newStateFailed, - waitingInComp, - ]; - - static final $core.Map<$core.int, CbjDeviceStateGRPC> _byValue = $pb.ProtobufEnum.initByValue(values); - static CbjDeviceStateGRPC? valueOf($core.int value) => _byValue[value]; - - const CbjDeviceStateGRPC._($core.int v, $core.String n) : super(v, n); -} - diff --git a/lib/infrastructure/gen/cbj_smart_device_server/protoc_as_dart/cbj_smart_device_server.pbgrpc.dart b/lib/infrastructure/gen/cbj_smart_device_server/protoc_as_dart/cbj_smart_device_server.pbgrpc.dart deleted file mode 100644 index 7e7b75fe..00000000 --- a/lib/infrastructure/gen/cbj_smart_device_server/protoc_as_dart/cbj_smart_device_server.pbgrpc.dart +++ /dev/null @@ -1,436 +0,0 @@ -/// -// Generated code. Do not modify. -// source: cbj_smart_device_server.proto -// -// @dart = 2.12 -// ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name - -import 'dart:async' as $async; - -import 'dart:core' as $core; - -import 'package:grpc/service_api.dart' as $grpc; -import 'cbj_smart_device_server.pb.dart' as $0; -export 'cbj_smart_device_server.pb.dart'; - -class CbjSmartDeviceConnectionsClient extends $grpc.Client { - static final _$firstSetup = - $grpc.ClientMethod<$0.CbjFirstSetupMessage, $0.CbjCommendStatus>( - '/CbjSmartDeviceConnections.CbjSmartDeviceConnections/FirstSetup', - ($0.CbjFirstSetupMessage value) => value.writeToBuffer(), - ($core.List<$core.int> value) => - $0.CbjCommendStatus.fromBuffer(value)); - static final _$getCompInfo = - $grpc.ClientMethod<$0.CbjCommendStatus, $0.CbjCompSmartDeviceInfo>( - '/CbjSmartDeviceConnections.CbjSmartDeviceConnections/GetCompInfo', - ($0.CbjCommendStatus value) => value.writeToBuffer(), - ($core.List<$core.int> value) => - $0.CbjCompSmartDeviceInfo.fromBuffer(value)); - static final _$setCompInfo = - $grpc.ClientMethod<$0.CbjCompSmartDeviceInfo, $0.CbjCommendStatus>( - '/CbjSmartDeviceConnections.CbjSmartDeviceConnections/SetCompInfo', - ($0.CbjCompSmartDeviceInfo value) => value.writeToBuffer(), - ($core.List<$core.int> value) => - $0.CbjCommendStatus.fromBuffer(value)); - static final _$setFirebaseAccountInformation = $grpc.ClientMethod< - $0.CbjFirebaseAccountInformation, $0.CbjCommendStatus>( - '/CbjSmartDeviceConnections.CbjSmartDeviceConnections/SetFirebaseAccountInformation', - ($0.CbjFirebaseAccountInformation value) => value.writeToBuffer(), - ($core.List<$core.int> value) => $0.CbjCommendStatus.fromBuffer(value)); - static final _$getStatus = - $grpc.ClientMethod<$0.CbjSmartDeviceInfo, $0.CbjSmartDeviceStatus>( - '/CbjSmartDeviceConnections.CbjSmartDeviceConnections/GetStatus', - ($0.CbjSmartDeviceInfo value) => value.writeToBuffer(), - ($core.List<$core.int> value) => - $0.CbjSmartDeviceStatus.fromBuffer(value)); - static final _$updateDeviceName = $grpc.ClientMethod< - $0.CbjSmartDeviceUpdateDetails, $0.CbjCommendStatus>( - '/CbjSmartDeviceConnections.CbjSmartDeviceConnections/UpdateDeviceName', - ($0.CbjSmartDeviceUpdateDetails value) => value.writeToBuffer(), - ($core.List<$core.int> value) => $0.CbjCommendStatus.fromBuffer(value)); - static final _$setOnDevice = - $grpc.ClientMethod<$0.CbjSmartDeviceInfo, $0.CbjCommendStatus>( - '/CbjSmartDeviceConnections.CbjSmartDeviceConnections/SetOnDevice', - ($0.CbjSmartDeviceInfo value) => value.writeToBuffer(), - ($core.List<$core.int> value) => - $0.CbjCommendStatus.fromBuffer(value)); - static final _$setOffDevice = - $grpc.ClientMethod<$0.CbjSmartDeviceInfo, $0.CbjCommendStatus>( - '/CbjSmartDeviceConnections.CbjSmartDeviceConnections/SetOffDevice', - ($0.CbjSmartDeviceInfo value) => value.writeToBuffer(), - ($core.List<$core.int> value) => - $0.CbjCommendStatus.fromBuffer(value)); - static final _$setBlindsUp = - $grpc.ClientMethod<$0.CbjSmartDeviceInfo, $0.CbjCommendStatus>( - '/CbjSmartDeviceConnections.CbjSmartDeviceConnections/setBlindsUp', - ($0.CbjSmartDeviceInfo value) => value.writeToBuffer(), - ($core.List<$core.int> value) => - $0.CbjCommendStatus.fromBuffer(value)); - static final _$setBlindsDown = - $grpc.ClientMethod<$0.CbjSmartDeviceInfo, $0.CbjCommendStatus>( - '/CbjSmartDeviceConnections.CbjSmartDeviceConnections/setBlindsDown', - ($0.CbjSmartDeviceInfo value) => value.writeToBuffer(), - ($core.List<$core.int> value) => - $0.CbjCommendStatus.fromBuffer(value)); - static final _$setBlindsStop = - $grpc.ClientMethod<$0.CbjSmartDeviceInfo, $0.CbjCommendStatus>( - '/CbjSmartDeviceConnections.CbjSmartDeviceConnections/setBlindsStop', - ($0.CbjSmartDeviceInfo value) => value.writeToBuffer(), - ($core.List<$core.int> value) => - $0.CbjCommendStatus.fromBuffer(value)); - static final _$registerClient = $grpc.ClientMethod<$0.CbjClientStatusRequests, - $0.CbjRequestsAndStatusFromHub>( - '/CbjSmartDeviceConnections.CbjSmartDeviceConnections/RegisterClient', - ($0.CbjClientStatusRequests value) => value.writeToBuffer(), - ($core.List<$core.int> value) => - $0.CbjRequestsAndStatusFromHub.fromBuffer(value)); - static final _$registerHub = $grpc.ClientMethod< - $0.CbjRequestsAndStatusFromHub, $0.CbjClientStatusRequests>( - '/CbjSmartDeviceConnections.CbjSmartDeviceConnections/RegisterHub', - ($0.CbjRequestsAndStatusFromHub value) => value.writeToBuffer(), - ($core.List<$core.int> value) => - $0.CbjClientStatusRequests.fromBuffer(value)); - static final _$suspendComputer = $grpc.ClientMethod<$0.CbjSmartDeviceInfo, - $0.CbjCommendStatus>( - '/CbjSmartDeviceConnections.CbjSmartDeviceConnections/suspendComputer', - ($0.CbjSmartDeviceInfo value) => value.writeToBuffer(), - ($core.List<$core.int> value) => $0.CbjCommendStatus.fromBuffer(value)); - static final _$shutdownComputer = $grpc.ClientMethod<$0.CbjSmartDeviceInfo, - $0.CbjCommendStatus>( - '/CbjSmartDeviceConnections.CbjSmartDeviceConnections/shutdownComputer', - ($0.CbjSmartDeviceInfo value) => value.writeToBuffer(), - ($core.List<$core.int> value) => $0.CbjCommendStatus.fromBuffer(value)); - - CbjSmartDeviceConnectionsClient($grpc.ClientChannel channel, - {$grpc.CallOptions? options, - $core.Iterable<$grpc.ClientInterceptor>? interceptors}) - : super(channel, options: options, interceptors: interceptors); - - $grpc.ResponseFuture<$0.CbjCommendStatus> firstSetup( - $0.CbjFirstSetupMessage request, - {$grpc.CallOptions? options}) { - return $createUnaryCall(_$firstSetup, request, options: options); - } - - $grpc.ResponseFuture<$0.CbjCompSmartDeviceInfo> getCompInfo( - $0.CbjCommendStatus request, - {$grpc.CallOptions? options}) { - return $createUnaryCall(_$getCompInfo, request, options: options); - } - - $grpc.ResponseFuture<$0.CbjCommendStatus> setCompInfo( - $0.CbjCompSmartDeviceInfo request, - {$grpc.CallOptions? options}) { - return $createUnaryCall(_$setCompInfo, request, options: options); - } - - $grpc.ResponseFuture<$0.CbjCommendStatus> setFirebaseAccountInformation( - $0.CbjFirebaseAccountInformation request, - {$grpc.CallOptions? options}) { - return $createUnaryCall(_$setFirebaseAccountInformation, request, - options: options); - } - - $grpc.ResponseFuture<$0.CbjSmartDeviceStatus> getStatus( - $0.CbjSmartDeviceInfo request, - {$grpc.CallOptions? options}) { - return $createUnaryCall(_$getStatus, request, options: options); - } - - $grpc.ResponseFuture<$0.CbjCommendStatus> updateDeviceName( - $0.CbjSmartDeviceUpdateDetails request, - {$grpc.CallOptions? options}) { - return $createUnaryCall(_$updateDeviceName, request, options: options); - } - - $grpc.ResponseFuture<$0.CbjCommendStatus> setOnDevice( - $0.CbjSmartDeviceInfo request, - {$grpc.CallOptions? options}) { - return $createUnaryCall(_$setOnDevice, request, options: options); - } - - $grpc.ResponseFuture<$0.CbjCommendStatus> setOffDevice( - $0.CbjSmartDeviceInfo request, - {$grpc.CallOptions? options}) { - return $createUnaryCall(_$setOffDevice, request, options: options); - } - - $grpc.ResponseFuture<$0.CbjCommendStatus> setBlindsUp( - $0.CbjSmartDeviceInfo request, - {$grpc.CallOptions? options}) { - return $createUnaryCall(_$setBlindsUp, request, options: options); - } - - $grpc.ResponseFuture<$0.CbjCommendStatus> setBlindsDown( - $0.CbjSmartDeviceInfo request, - {$grpc.CallOptions? options}) { - return $createUnaryCall(_$setBlindsDown, request, options: options); - } - - $grpc.ResponseFuture<$0.CbjCommendStatus> setBlindsStop( - $0.CbjSmartDeviceInfo request, - {$grpc.CallOptions? options}) { - return $createUnaryCall(_$setBlindsStop, request, options: options); - } - - $grpc.ResponseStream<$0.CbjRequestsAndStatusFromHub> registerClient( - $async.Stream<$0.CbjClientStatusRequests> request, - {$grpc.CallOptions? options}) { - return $createStreamingCall(_$registerClient, request, options: options); - } - - $grpc.ResponseStream<$0.CbjClientStatusRequests> registerHub( - $async.Stream<$0.CbjRequestsAndStatusFromHub> request, - {$grpc.CallOptions? options}) { - return $createStreamingCall(_$registerHub, request, options: options); - } - - $grpc.ResponseFuture<$0.CbjCommendStatus> suspendComputer( - $0.CbjSmartDeviceInfo request, - {$grpc.CallOptions? options}) { - return $createUnaryCall(_$suspendComputer, request, options: options); - } - - $grpc.ResponseFuture<$0.CbjCommendStatus> shutdownComputer( - $0.CbjSmartDeviceInfo request, - {$grpc.CallOptions? options}) { - return $createUnaryCall(_$shutdownComputer, request, options: options); - } -} - -abstract class CbjSmartDeviceConnectionsServiceBase extends $grpc.Service { - $core.String get $name => - 'CbjSmartDeviceConnections.CbjSmartDeviceConnections'; - - CbjSmartDeviceConnectionsServiceBase() { - $addMethod( - $grpc.ServiceMethod<$0.CbjFirstSetupMessage, $0.CbjCommendStatus>( - 'FirstSetup', - firstSetup_Pre, - false, - false, - ($core.List<$core.int> value) => - $0.CbjFirstSetupMessage.fromBuffer(value), - ($0.CbjCommendStatus value) => value.writeToBuffer())); - $addMethod( - $grpc.ServiceMethod<$0.CbjCommendStatus, $0.CbjCompSmartDeviceInfo>( - 'GetCompInfo', - getCompInfo_Pre, - false, - false, - ($core.List<$core.int> value) => - $0.CbjCommendStatus.fromBuffer(value), - ($0.CbjCompSmartDeviceInfo value) => value.writeToBuffer())); - $addMethod( - $grpc.ServiceMethod<$0.CbjCompSmartDeviceInfo, $0.CbjCommendStatus>( - 'SetCompInfo', - setCompInfo_Pre, - false, - false, - ($core.List<$core.int> value) => - $0.CbjCompSmartDeviceInfo.fromBuffer(value), - ($0.CbjCommendStatus value) => value.writeToBuffer())); - $addMethod($grpc.ServiceMethod<$0.CbjFirebaseAccountInformation, - $0.CbjCommendStatus>( - 'SetFirebaseAccountInformation', - setFirebaseAccountInformation_Pre, - false, - false, - ($core.List<$core.int> value) => - $0.CbjFirebaseAccountInformation.fromBuffer(value), - ($0.CbjCommendStatus value) => value.writeToBuffer())); - $addMethod( - $grpc.ServiceMethod<$0.CbjSmartDeviceInfo, $0.CbjSmartDeviceStatus>( - 'GetStatus', - getStatus_Pre, - false, - false, - ($core.List<$core.int> value) => - $0.CbjSmartDeviceInfo.fromBuffer(value), - ($0.CbjSmartDeviceStatus value) => value.writeToBuffer())); - $addMethod($grpc.ServiceMethod<$0.CbjSmartDeviceUpdateDetails, - $0.CbjCommendStatus>( - 'UpdateDeviceName', - updateDeviceName_Pre, - false, - false, - ($core.List<$core.int> value) => - $0.CbjSmartDeviceUpdateDetails.fromBuffer(value), - ($0.CbjCommendStatus value) => value.writeToBuffer())); - $addMethod($grpc.ServiceMethod<$0.CbjSmartDeviceInfo, $0.CbjCommendStatus>( - 'SetOnDevice', - setOnDevice_Pre, - false, - false, - ($core.List<$core.int> value) => - $0.CbjSmartDeviceInfo.fromBuffer(value), - ($0.CbjCommendStatus value) => value.writeToBuffer())); - $addMethod($grpc.ServiceMethod<$0.CbjSmartDeviceInfo, $0.CbjCommendStatus>( - 'SetOffDevice', - setOffDevice_Pre, - false, - false, - ($core.List<$core.int> value) => - $0.CbjSmartDeviceInfo.fromBuffer(value), - ($0.CbjCommendStatus value) => value.writeToBuffer())); - $addMethod($grpc.ServiceMethod<$0.CbjSmartDeviceInfo, $0.CbjCommendStatus>( - 'setBlindsUp', - setBlindsUp_Pre, - false, - false, - ($core.List<$core.int> value) => - $0.CbjSmartDeviceInfo.fromBuffer(value), - ($0.CbjCommendStatus value) => value.writeToBuffer())); - $addMethod($grpc.ServiceMethod<$0.CbjSmartDeviceInfo, $0.CbjCommendStatus>( - 'setBlindsDown', - setBlindsDown_Pre, - false, - false, - ($core.List<$core.int> value) => - $0.CbjSmartDeviceInfo.fromBuffer(value), - ($0.CbjCommendStatus value) => value.writeToBuffer())); - $addMethod($grpc.ServiceMethod<$0.CbjSmartDeviceInfo, $0.CbjCommendStatus>( - 'setBlindsStop', - setBlindsStop_Pre, - false, - false, - ($core.List<$core.int> value) => - $0.CbjSmartDeviceInfo.fromBuffer(value), - ($0.CbjCommendStatus value) => value.writeToBuffer())); - $addMethod($grpc.ServiceMethod<$0.CbjClientStatusRequests, - $0.CbjRequestsAndStatusFromHub>( - 'RegisterClient', - registerClient, - true, - true, - ($core.List<$core.int> value) => - $0.CbjClientStatusRequests.fromBuffer(value), - ($0.CbjRequestsAndStatusFromHub value) => value.writeToBuffer())); - $addMethod($grpc.ServiceMethod<$0.CbjRequestsAndStatusFromHub, - $0.CbjClientStatusRequests>( - 'RegisterHub', - registerHub, - true, - true, - ($core.List<$core.int> value) => - $0.CbjRequestsAndStatusFromHub.fromBuffer(value), - ($0.CbjClientStatusRequests value) => value.writeToBuffer())); - $addMethod($grpc.ServiceMethod<$0.CbjSmartDeviceInfo, $0.CbjCommendStatus>( - 'suspendComputer', - suspendComputer_Pre, - false, - false, - ($core.List<$core.int> value) => - $0.CbjSmartDeviceInfo.fromBuffer(value), - ($0.CbjCommendStatus value) => value.writeToBuffer())); - $addMethod($grpc.ServiceMethod<$0.CbjSmartDeviceInfo, $0.CbjCommendStatus>( - 'shutdownComputer', - shutdownComputer_Pre, - false, - false, - ($core.List<$core.int> value) => - $0.CbjSmartDeviceInfo.fromBuffer(value), - ($0.CbjCommendStatus value) => value.writeToBuffer())); - } - - $async.Future<$0.CbjCommendStatus> firstSetup_Pre($grpc.ServiceCall call, - $async.Future<$0.CbjFirstSetupMessage> request) async { - return firstSetup(call, await request); - } - - $async.Future<$0.CbjCompSmartDeviceInfo> getCompInfo_Pre( - $grpc.ServiceCall call, - $async.Future<$0.CbjCommendStatus> request) async { - return getCompInfo(call, await request); - } - - $async.Future<$0.CbjCommendStatus> setCompInfo_Pre($grpc.ServiceCall call, - $async.Future<$0.CbjCompSmartDeviceInfo> request) async { - return setCompInfo(call, await request); - } - - $async.Future<$0.CbjCommendStatus> setFirebaseAccountInformation_Pre( - $grpc.ServiceCall call, - $async.Future<$0.CbjFirebaseAccountInformation> request) async { - return setFirebaseAccountInformation(call, await request); - } - - $async.Future<$0.CbjSmartDeviceStatus> getStatus_Pre($grpc.ServiceCall call, - $async.Future<$0.CbjSmartDeviceInfo> request) async { - return getStatus(call, await request); - } - - $async.Future<$0.CbjCommendStatus> updateDeviceName_Pre( - $grpc.ServiceCall call, - $async.Future<$0.CbjSmartDeviceUpdateDetails> request) async { - return updateDeviceName(call, await request); - } - - $async.Future<$0.CbjCommendStatus> setOnDevice_Pre($grpc.ServiceCall call, - $async.Future<$0.CbjSmartDeviceInfo> request) async { - return setOnDevice(call, await request); - } - - $async.Future<$0.CbjCommendStatus> setOffDevice_Pre($grpc.ServiceCall call, - $async.Future<$0.CbjSmartDeviceInfo> request) async { - return setOffDevice(call, await request); - } - - $async.Future<$0.CbjCommendStatus> setBlindsUp_Pre($grpc.ServiceCall call, - $async.Future<$0.CbjSmartDeviceInfo> request) async { - return setBlindsUp(call, await request); - } - - $async.Future<$0.CbjCommendStatus> setBlindsDown_Pre($grpc.ServiceCall call, - $async.Future<$0.CbjSmartDeviceInfo> request) async { - return setBlindsDown(call, await request); - } - - $async.Future<$0.CbjCommendStatus> setBlindsStop_Pre($grpc.ServiceCall call, - $async.Future<$0.CbjSmartDeviceInfo> request) async { - return setBlindsStop(call, await request); - } - - $async.Future<$0.CbjCommendStatus> suspendComputer_Pre($grpc.ServiceCall call, - $async.Future<$0.CbjSmartDeviceInfo> request) async { - return suspendComputer(call, await request); - } - - $async.Future<$0.CbjCommendStatus> shutdownComputer_Pre( - $grpc.ServiceCall call, - $async.Future<$0.CbjSmartDeviceInfo> request) async { - return shutdownComputer(call, await request); - } - - $async.Future<$0.CbjCommendStatus> firstSetup( - $grpc.ServiceCall call, $0.CbjFirstSetupMessage request); - $async.Future<$0.CbjCompSmartDeviceInfo> getCompInfo( - $grpc.ServiceCall call, $0.CbjCommendStatus request); - $async.Future<$0.CbjCommendStatus> setCompInfo( - $grpc.ServiceCall call, $0.CbjCompSmartDeviceInfo request); - $async.Future<$0.CbjCommendStatus> setFirebaseAccountInformation( - $grpc.ServiceCall call, $0.CbjFirebaseAccountInformation request); - $async.Future<$0.CbjSmartDeviceStatus> getStatus( - $grpc.ServiceCall call, $0.CbjSmartDeviceInfo request); - $async.Future<$0.CbjCommendStatus> updateDeviceName( - $grpc.ServiceCall call, $0.CbjSmartDeviceUpdateDetails request); - $async.Future<$0.CbjCommendStatus> setOnDevice( - $grpc.ServiceCall call, $0.CbjSmartDeviceInfo request); - $async.Future<$0.CbjCommendStatus> setOffDevice( - $grpc.ServiceCall call, $0.CbjSmartDeviceInfo request); - $async.Future<$0.CbjCommendStatus> setBlindsUp( - $grpc.ServiceCall call, $0.CbjSmartDeviceInfo request); - $async.Future<$0.CbjCommendStatus> setBlindsDown( - $grpc.ServiceCall call, $0.CbjSmartDeviceInfo request); - $async.Future<$0.CbjCommendStatus> setBlindsStop( - $grpc.ServiceCall call, $0.CbjSmartDeviceInfo request); - $async.Stream<$0.CbjRequestsAndStatusFromHub> registerClient( - $grpc.ServiceCall call, - $async.Stream<$0.CbjClientStatusRequests> request); - $async.Stream<$0.CbjClientStatusRequests> registerHub($grpc.ServiceCall call, - $async.Stream<$0.CbjRequestsAndStatusFromHub> request); - $async.Future<$0.CbjCommendStatus> suspendComputer( - $grpc.ServiceCall call, $0.CbjSmartDeviceInfo request); - $async.Future<$0.CbjCommendStatus> shutdownComputer( - $grpc.ServiceCall call, $0.CbjSmartDeviceInfo request); -} diff --git a/lib/infrastructure/gen/cbj_smart_device_server/protoc_as_dart/cbj_smart_device_server.pbjson.dart b/lib/infrastructure/gen/cbj_smart_device_server/protoc_as_dart/cbj_smart_device_server.pbjson.dart deleted file mode 100644 index 27050f6e..00000000 --- a/lib/infrastructure/gen/cbj_smart_device_server/protoc_as_dart/cbj_smart_device_server.pbjson.dart +++ /dev/null @@ -1,246 +0,0 @@ -/// -// Generated code. Do not modify. -// source: cbj_smart_device_server.proto -// -// @dart = 2.12 -// ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,deprecated_member_use_from_same_package,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name - -import 'dart:core' as $core; -import 'dart:convert' as $convert; -import 'dart:typed_data' as $typed_data; -@$core.Deprecated('Use cbjDeviceTypesDescriptor instead') -const CbjDeviceTypes$json = const { - '1': 'CbjDeviceTypes', - '2': const [ - const {'1': 'typeNotSupported', '2': 0}, - const {'1': 'light', '2': 1}, - const {'1': 'blinds', '2': 2}, - const {'1': 'boiler', '2': 3}, - const {'1': 'button', '2': 4}, - const {'1': 'buttonWithLight', '2': 5}, - const {'1': 'hub', '2': 7}, - const {'1': 'phoneApp', '2': 8}, - const {'1': 'computerApp', '2': 9}, - const {'1': 'browserApp', '2': 10}, - const {'1': 'smartComputer', '2': 11}, - ], -}; - -/// Descriptor for `CbjDeviceTypes`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List cbjDeviceTypesDescriptor = $convert.base64Decode('Cg5DYmpEZXZpY2VUeXBlcxIUChB0eXBlTm90U3VwcG9ydGVkEAASCQoFbGlnaHQQARIKCgZibGluZHMQAhIKCgZib2lsZXIQAxIKCgZidXR0b24QBBITCg9idXR0b25XaXRoTGlnaHQQBRIHCgNodWIQBxIMCghwaG9uZUFwcBAIEg8KC2NvbXB1dGVyQXBwEAkSDgoKYnJvd3NlckFwcBAKEhEKDXNtYXJ0Q29tcHV0ZXIQCw=='); -@$core.Deprecated('Use cbjDeviceActionsDescriptor instead') -const CbjDeviceActions$json = const { - '1': 'CbjDeviceActions', - '2': const [ - const {'1': 'actionNotSupported', '2': 0}, - const {'1': 'on', '2': 1}, - const {'1': 'off', '2': 2}, - const {'1': 'moveUp', '2': 3}, - const {'1': 'stop', '2': 4}, - const {'1': 'moveDown', '2': 5}, - const {'1': 'pressed', '2': 6}, - const {'1': 'longPress', '2': 7}, - const {'1': 'doubleTap', '2': 8}, - const {'1': 'position', '2': 9}, - const {'1': 'suspend', '2': 10}, - const {'1': 'shutdown', '2': 11}, - const {'1': 'itIsFalse', '2': 12}, - const {'1': 'itIsTrue', '2': 13}, - ], -}; - -/// Descriptor for `CbjDeviceActions`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List cbjDeviceActionsDescriptor = $convert.base64Decode('ChBDYmpEZXZpY2VBY3Rpb25zEhYKEmFjdGlvbk5vdFN1cHBvcnRlZBAAEgYKAm9uEAESBwoDb2ZmEAISCgoGbW92ZVVwEAMSCAoEc3RvcBAEEgwKCG1vdmVEb3duEAUSCwoHcHJlc3NlZBAGEg0KCWxvbmdQcmVzcxAHEg0KCWRvdWJsZVRhcBAIEgwKCHBvc2l0aW9uEAkSCwoHc3VzcGVuZBAKEgwKCHNodXRkb3duEAsSDQoJaXRJc0ZhbHNlEAwSDAoIaXRJc1RydWUQDQ=='); -@$core.Deprecated('Use cbjWhenToExecuteDescriptor instead') -const CbjWhenToExecute$json = const { - '1': 'CbjWhenToExecute', - '2': const [ - const {'1': 'undefined', '2': 0}, - const {'1': 'onOddNumberPress', '2': 1}, - const {'1': 'evenNumberPress', '2': 2}, - const {'1': 'betweenSelectedTime', '2': 3}, - const {'1': 'doNotBetweenSelectedTime', '2': 4}, - const {'1': 'allTheTime', '2': 5}, - const {'1': 'never', '2': 6}, - const {'1': 'onceNow', '2': 7}, - const {'1': 'onceInSelectedTime', '2': 8}, - const {'1': 'onlyIfDeviceListIsAreInActionListState', '2': 9}, - const {'1': 'atHome', '2': 10}, - const {'1': 'outOfHome', '2': 11}, - ], -}; - -/// Descriptor for `CbjWhenToExecute`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List cbjWhenToExecuteDescriptor = $convert.base64Decode('ChBDYmpXaGVuVG9FeGVjdXRlEg0KCXVuZGVmaW5lZBAAEhQKEG9uT2RkTnVtYmVyUHJlc3MQARITCg9ldmVuTnVtYmVyUHJlc3MQAhIXChNiZXR3ZWVuU2VsZWN0ZWRUaW1lEAMSHAoYZG9Ob3RCZXR3ZWVuU2VsZWN0ZWRUaW1lEAQSDgoKYWxsVGhlVGltZRAFEgkKBW5ldmVyEAYSCwoHb25jZU5vdxAHEhYKEm9uY2VJblNlbGVjdGVkVGltZRAIEioKJm9ubHlJZkRldmljZUxpc3RJc0FyZUluQWN0aW9uTGlzdFN0YXRlEAkSCgoGYXRIb21lEAoSDQoJb3V0T2ZIb21lEAs='); -@$core.Deprecated('Use cbjDeviceStateGRPCDescriptor instead') -const CbjDeviceStateGRPC$json = const { - '1': 'CbjDeviceStateGRPC', - '2': const [ - const {'1': 'stateNotSupported', '2': 0}, - const {'1': 'cancelStateInProcess', '2': 1}, - const {'1': 'ack', '2': 2}, - const {'1': 'newStateFailed', '2': 3}, - const {'1': 'waitingInComp', '2': 4}, - ], -}; - -/// Descriptor for `CbjDeviceStateGRPC`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List cbjDeviceStateGRPCDescriptor = $convert.base64Decode('ChJDYmpEZXZpY2VTdGF0ZUdSUEMSFQoRc3RhdGVOb3RTdXBwb3J0ZWQQABIYChRjYW5jZWxTdGF0ZUluUHJvY2VzcxABEgcKA2FjaxACEhIKDm5ld1N0YXRlRmFpbGVkEAMSEQoNd2FpdGluZ0luQ29tcBAE'); -@$core.Deprecated('Use cbjClientStatusRequestsDescriptor instead') -const CbjClientStatusRequests$json = const { - '1': 'CbjClientStatusRequests', - '2': const [ - const {'1': 'allRemoteCommands', '3': 41, '4': 1, '5': 11, '6': '.CbjSmartDeviceConnections.CbjAllRemoteCommands', '10': 'allRemoteCommands'}, - ], -}; - -/// Descriptor for `CbjClientStatusRequests`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List cbjClientStatusRequestsDescriptor = $convert.base64Decode('ChdDYmpDbGllbnRTdGF0dXNSZXF1ZXN0cxJdChFhbGxSZW1vdGVDb21tYW5kcxgpIAEoCzIvLkNialNtYXJ0RGV2aWNlQ29ubmVjdGlvbnMuQ2JqQWxsUmVtb3RlQ29tbWFuZHNSEWFsbFJlbW90ZUNvbW1hbmRz'); -@$core.Deprecated('Use cbjRequestsAndStatusFromHubDescriptor instead') -const CbjRequestsAndStatusFromHub$json = const { - '1': 'CbjRequestsAndStatusFromHub', - '2': const [ - const {'1': 'allRemoteCommands', '3': 42, '4': 1, '5': 11, '6': '.CbjSmartDeviceConnections.CbjAllRemoteCommands', '10': 'allRemoteCommands'}, - ], -}; - -/// Descriptor for `CbjRequestsAndStatusFromHub`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List cbjRequestsAndStatusFromHubDescriptor = $convert.base64Decode('ChtDYmpSZXF1ZXN0c0FuZFN0YXR1c0Zyb21IdWISXQoRYWxsUmVtb3RlQ29tbWFuZHMYKiABKAsyLy5DYmpTbWFydERldmljZUNvbm5lY3Rpb25zLkNiakFsbFJlbW90ZUNvbW1hbmRzUhFhbGxSZW1vdGVDb21tYW5kcw=='); -@$core.Deprecated('Use cbjAllRemoteCommandsDescriptor instead') -const CbjAllRemoteCommands$json = const { - '1': 'CbjAllRemoteCommands', - '2': const [ - const {'1': 'smartDeviceInfo', '3': 40, '4': 1, '5': 11, '6': '.CbjSmartDeviceConnections.CbjSmartDeviceInfo', '10': 'smartDeviceInfo'}, - ], -}; - -/// Descriptor for `CbjAllRemoteCommands`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List cbjAllRemoteCommandsDescriptor = $convert.base64Decode('ChRDYmpBbGxSZW1vdGVDb21tYW5kcxJXCg9zbWFydERldmljZUluZm8YKCABKAsyLS5DYmpTbWFydERldmljZUNvbm5lY3Rpb25zLkNialNtYXJ0RGV2aWNlSW5mb1IPc21hcnREZXZpY2VJbmZv'); -@$core.Deprecated('Use cbjFirstSetupMessageDescriptor instead') -const CbjFirstSetupMessage$json = const { - '1': 'CbjFirstSetupMessage', - '2': const [ - const {'1': 'compInfo', '3': 38, '4': 1, '5': 11, '6': '.CbjSmartDeviceConnections.CbjCompSmartDeviceInfo', '10': 'compInfo'}, - const {'1': 'firebaseAccountInformation', '3': 39, '4': 1, '5': 11, '6': '.CbjSmartDeviceConnections.CbjFirebaseAccountInformation', '10': 'firebaseAccountInformation'}, - ], -}; - -/// Descriptor for `CbjFirstSetupMessage`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List cbjFirstSetupMessageDescriptor = $convert.base64Decode('ChRDYmpGaXJzdFNldHVwTWVzc2FnZRJNCghjb21wSW5mbxgmIAEoCzIxLkNialNtYXJ0RGV2aWNlQ29ubmVjdGlvbnMuQ2JqQ29tcFNtYXJ0RGV2aWNlSW5mb1IIY29tcEluZm8SeAoaZmlyZWJhc2VBY2NvdW50SW5mb3JtYXRpb24YJyABKAsyOC5DYmpTbWFydERldmljZUNvbm5lY3Rpb25zLkNiakZpcmViYXNlQWNjb3VudEluZm9ybWF0aW9uUhpmaXJlYmFzZUFjY291bnRJbmZvcm1hdGlvbg=='); -@$core.Deprecated('Use cbjCompSmartDeviceInfoDescriptor instead') -const CbjCompSmartDeviceInfo$json = const { - '1': 'CbjCompSmartDeviceInfo', - '2': const [ - const {'1': 'compSpecs', '3': 21, '4': 1, '5': 11, '6': '.CbjSmartDeviceConnections.CbjCompSpecs', '10': 'compSpecs'}, - const {'1': 'smartDevicesInComp', '3': 28, '4': 3, '5': 11, '6': '.CbjSmartDeviceConnections.CbjSmartDeviceInfo', '10': 'smartDevicesInComp'}, - ], -}; - -/// Descriptor for `CbjCompSmartDeviceInfo`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List cbjCompSmartDeviceInfoDescriptor = $convert.base64Decode('ChZDYmpDb21wU21hcnREZXZpY2VJbmZvEkUKCWNvbXBTcGVjcxgVIAEoCzInLkNialNtYXJ0RGV2aWNlQ29ubmVjdGlvbnMuQ2JqQ29tcFNwZWNzUgljb21wU3BlY3MSXQoSc21hcnREZXZpY2VzSW5Db21wGBwgAygLMi0uQ2JqU21hcnREZXZpY2VDb25uZWN0aW9ucy5DYmpTbWFydERldmljZUluZm9SEnNtYXJ0RGV2aWNlc0luQ29tcA=='); -@$core.Deprecated('Use cbjCompSpecsDescriptor instead') -const CbjCompSpecs$json = const { - '1': 'CbjCompSpecs', - '2': const [ - const {'1': 'compId', '3': 22, '4': 1, '5': 9, '10': 'compId'}, - const {'1': 'compUuid', '3': 23, '4': 1, '5': 9, '10': 'compUuid'}, - const {'1': 'compOs', '3': 24, '4': 1, '5': 9, '10': 'compOs'}, - const {'1': 'compModel', '3': 25, '4': 1, '5': 9, '10': 'compModel'}, - const {'1': 'compType', '3': 26, '4': 1, '5': 9, '10': 'compType'}, - const {'1': 'pubspecYamlVersion', '3': 27, '4': 1, '5': 9, '10': 'pubspecYamlVersion'}, - ], -}; - -/// Descriptor for `CbjCompSpecs`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List cbjCompSpecsDescriptor = $convert.base64Decode('CgxDYmpDb21wU3BlY3MSFgoGY29tcElkGBYgASgJUgZjb21wSWQSGgoIY29tcFV1aWQYFyABKAlSCGNvbXBVdWlkEhYKBmNvbXBPcxgYIAEoCVIGY29tcE9zEhwKCWNvbXBNb2RlbBgZIAEoCVIJY29tcE1vZGVsEhoKCGNvbXBUeXBlGBogASgJUghjb21wVHlwZRIuChJwdWJzcGVjWWFtbFZlcnNpb24YGyABKAlSEnB1YnNwZWNZYW1sVmVyc2lvbg=='); -@$core.Deprecated('Use cbjMicrocontrollerSpecsDescriptor instead') -const CbjMicrocontrollerSpecs$json = const { - '1': 'CbjMicrocontrollerSpecs', - '2': const [ - const {'1': 'microcontrollerModel', '3': 31, '4': 1, '5': 9, '10': 'microcontrollerModel'}, - const {'1': 'microcontrollerType', '3': 32, '4': 1, '5': 9, '10': 'microcontrollerType'}, - const {'1': 'softwareVersion', '3': 33, '4': 1, '5': 9, '10': 'softwareVersion'}, - ], -}; - -/// Descriptor for `CbjMicrocontrollerSpecs`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List cbjMicrocontrollerSpecsDescriptor = $convert.base64Decode('ChdDYmpNaWNyb2NvbnRyb2xsZXJTcGVjcxIyChRtaWNyb2NvbnRyb2xsZXJNb2RlbBgfIAEoCVIUbWljcm9jb250cm9sbGVyTW9kZWwSMAoTbWljcm9jb250cm9sbGVyVHlwZRggIAEoCVITbWljcm9jb250cm9sbGVyVHlwZRIoCg9zb2Z0d2FyZVZlcnNpb24YISABKAlSD3NvZnR3YXJlVmVyc2lvbg=='); -@$core.Deprecated('Use cbjSmartDeviceInfoDescriptor instead') -const CbjSmartDeviceInfo$json = const { - '1': 'CbjSmartDeviceInfo', - '2': const [ - const {'1': 'id', '3': 1, '4': 1, '5': 9, '10': 'id'}, - const {'1': 'state', '3': 3, '4': 1, '5': 9, '10': 'state'}, - const {'1': 'defaultName', '3': 14, '4': 1, '5': 9, '10': 'defaultName'}, - const {'1': 'roomId', '3': 15, '4': 1, '5': 9, '10': 'roomId'}, - const {'1': 'senderDeviceModel', '3': 16, '4': 1, '5': 9, '10': 'senderDeviceModel'}, - const {'1': 'senderDeviceOs', '3': 17, '4': 1, '5': 9, '10': 'senderDeviceOs'}, - const {'1': 'senderId', '3': 18, '4': 1, '5': 9, '10': 'senderId'}, - const {'1': 'serverTimeStamp', '3': 19, '4': 1, '5': 9, '10': 'serverTimeStamp'}, - const {'1': 'stateMassage', '3': 20, '4': 1, '5': 9, '10': 'stateMassage'}, - const {'1': 'isComputer', '3': 29, '4': 1, '5': 8, '10': 'isComputer'}, - const {'1': 'compSpecs', '3': 30, '4': 1, '5': 11, '6': '.CbjSmartDeviceConnections.CbjCompSpecs', '10': 'compSpecs'}, - const {'1': 'microcontrollerSpecsSpecs', '3': 31, '4': 1, '5': 11, '6': '.CbjSmartDeviceConnections.CbjMicrocontrollerSpecs', '10': 'microcontrollerSpecsSpecs'}, - const {'1': 'deviceTypesActions', '3': 34, '4': 1, '5': 11, '6': '.CbjSmartDeviceConnections.CbjDeviceTypesActions', '10': 'deviceTypesActions'}, - ], -}; - -/// Descriptor for `CbjSmartDeviceInfo`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List cbjSmartDeviceInfoDescriptor = $convert.base64Decode('ChJDYmpTbWFydERldmljZUluZm8SDgoCaWQYASABKAlSAmlkEhQKBXN0YXRlGAMgASgJUgVzdGF0ZRIgCgtkZWZhdWx0TmFtZRgOIAEoCVILZGVmYXVsdE5hbWUSFgoGcm9vbUlkGA8gASgJUgZyb29tSWQSLAoRc2VuZGVyRGV2aWNlTW9kZWwYECABKAlSEXNlbmRlckRldmljZU1vZGVsEiYKDnNlbmRlckRldmljZU9zGBEgASgJUg5zZW5kZXJEZXZpY2VPcxIaCghzZW5kZXJJZBgSIAEoCVIIc2VuZGVySWQSKAoPc2VydmVyVGltZVN0YW1wGBMgASgJUg9zZXJ2ZXJUaW1lU3RhbXASIgoMc3RhdGVNYXNzYWdlGBQgASgJUgxzdGF0ZU1hc3NhZ2USHgoKaXNDb21wdXRlchgdIAEoCFIKaXNDb21wdXRlchJFCgljb21wU3BlY3MYHiABKAsyJy5DYmpTbWFydERldmljZUNvbm5lY3Rpb25zLkNiakNvbXBTcGVjc1IJY29tcFNwZWNzEnAKGW1pY3JvY29udHJvbGxlclNwZWNzU3BlY3MYHyABKAsyMi5DYmpTbWFydERldmljZUNvbm5lY3Rpb25zLkNiak1pY3JvY29udHJvbGxlclNwZWNzUhltaWNyb2NvbnRyb2xsZXJTcGVjc1NwZWNzEmAKEmRldmljZVR5cGVzQWN0aW9ucxgiIAEoCzIwLkNialNtYXJ0RGV2aWNlQ29ubmVjdGlvbnMuQ2JqRGV2aWNlVHlwZXNBY3Rpb25zUhJkZXZpY2VUeXBlc0FjdGlvbnM='); -@$core.Deprecated('Use cbjSmartDeviceStatusDescriptor instead') -const CbjSmartDeviceStatus$json = const { - '1': 'CbjSmartDeviceStatus', - '2': const [ - const {'1': 'onOffState', '3': 4, '4': 1, '5': 8, '10': 'onOffState'}, - ], -}; - -/// Descriptor for `CbjSmartDeviceStatus`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List cbjSmartDeviceStatusDescriptor = $convert.base64Decode('ChRDYmpTbWFydERldmljZVN0YXR1cxIeCgpvbk9mZlN0YXRlGAQgASgIUgpvbk9mZlN0YXRl'); -@$core.Deprecated('Use cbjCommendStatusDescriptor instead') -const CbjCommendStatus$json = const { - '1': 'CbjCommendStatus', - '2': const [ - const {'1': 'success', '3': 5, '4': 1, '5': 8, '10': 'success'}, - ], -}; - -/// Descriptor for `CbjCommendStatus`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List cbjCommendStatusDescriptor = $convert.base64Decode('ChBDYmpDb21tZW5kU3RhdHVzEhgKB3N1Y2Nlc3MYBSABKAhSB3N1Y2Nlc3M='); -@$core.Deprecated('Use cbjSmartDeviceUpdateDetailsDescriptor instead') -const CbjSmartDeviceUpdateDetails$json = const { - '1': 'CbjSmartDeviceUpdateDetails', - '2': const [ - const {'1': 'smartDevice', '3': 6, '4': 1, '5': 11, '6': '.CbjSmartDeviceConnections.CbjSmartDeviceInfo', '10': 'smartDevice'}, - const {'1': 'newName', '3': 7, '4': 1, '5': 9, '10': 'newName'}, - ], -}; - -/// Descriptor for `CbjSmartDeviceUpdateDetails`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List cbjSmartDeviceUpdateDetailsDescriptor = $convert.base64Decode('ChtDYmpTbWFydERldmljZVVwZGF0ZURldGFpbHMSTwoLc21hcnREZXZpY2UYBiABKAsyLS5DYmpTbWFydERldmljZUNvbm5lY3Rpb25zLkNialNtYXJ0RGV2aWNlSW5mb1ILc21hcnREZXZpY2USGAoHbmV3TmFtZRgHIAEoCVIHbmV3TmFtZQ=='); -@$core.Deprecated('Use cbjFirebaseAccountInformationDescriptor instead') -const CbjFirebaseAccountInformation$json = const { - '1': 'CbjFirebaseAccountInformation', - '2': const [ - const {'1': 'fireBaseProjectId', '3': 8, '4': 1, '5': 9, '10': 'fireBaseProjectId'}, - const {'1': 'fireBaseApiKey', '3': 9, '4': 1, '5': 9, '10': 'fireBaseApiKey'}, - const {'1': 'userEmail', '3': 10, '4': 1, '5': 9, '10': 'userEmail'}, - const {'1': 'userPassword', '3': 11, '4': 1, '5': 9, '10': 'userPassword'}, - const {'1': 'homeId', '3': 12, '4': 1, '5': 9, '10': 'homeId'}, - ], -}; - -/// Descriptor for `CbjFirebaseAccountInformation`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List cbjFirebaseAccountInformationDescriptor = $convert.base64Decode('Ch1DYmpGaXJlYmFzZUFjY291bnRJbmZvcm1hdGlvbhIsChFmaXJlQmFzZVByb2plY3RJZBgIIAEoCVIRZmlyZUJhc2VQcm9qZWN0SWQSJgoOZmlyZUJhc2VBcGlLZXkYCSABKAlSDmZpcmVCYXNlQXBpS2V5EhwKCXVzZXJFbWFpbBgKIAEoCVIJdXNlckVtYWlsEiIKDHVzZXJQYXNzd29yZBgLIAEoCVIMdXNlclBhc3N3b3JkEhYKBmhvbWVJZBgMIAEoCVIGaG9tZUlk'); -@$core.Deprecated('Use cbjDeviceTypesActionsDescriptor instead') -const CbjDeviceTypesActions$json = const { - '1': 'CbjDeviceTypesActions', - '2': const [ - const {'1': 'deviceType', '3': 35, '4': 1, '5': 14, '6': '.CbjSmartDeviceConnections.CbjDeviceTypes', '10': 'deviceType'}, - const {'1': 'deviceAction', '3': 36, '4': 1, '5': 14, '6': '.CbjSmartDeviceConnections.CbjDeviceActions', '10': 'deviceAction'}, - const {'1': 'deviceStateGRPC', '3': 37, '4': 1, '5': 14, '6': '.CbjSmartDeviceConnections.CbjDeviceStateGRPC', '10': 'deviceStateGRPC'}, - ], -}; - -/// Descriptor for `CbjDeviceTypesActions`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List cbjDeviceTypesActionsDescriptor = $convert.base64Decode('ChVDYmpEZXZpY2VUeXBlc0FjdGlvbnMSSQoKZGV2aWNlVHlwZRgjIAEoDjIpLkNialNtYXJ0RGV2aWNlQ29ubmVjdGlvbnMuQ2JqRGV2aWNlVHlwZXNSCmRldmljZVR5cGUSTwoMZGV2aWNlQWN0aW9uGCQgASgOMisuQ2JqU21hcnREZXZpY2VDb25uZWN0aW9ucy5DYmpEZXZpY2VBY3Rpb25zUgxkZXZpY2VBY3Rpb24SVwoPZGV2aWNlU3RhdGVHUlBDGCUgASgOMi0uQ2JqU21hcnREZXZpY2VDb25uZWN0aW9ucy5DYmpEZXZpY2VTdGF0ZUdSUENSD2RldmljZVN0YXRlR1JQQw=='); diff --git a/lib/infrastructure/generic_devices/abstract_device/abstract_company_connector_conjector.dart b/lib/infrastructure/generic_devices/abstract_device/abstract_company_connector_conjector.dart deleted file mode 100644 index 1dfd23a2..00000000 --- a/lib/infrastructure/generic_devices/abstract_device/abstract_company_connector_conjector.dart +++ /dev/null @@ -1,17 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; - -abstract class AbstractCompanyConnectorConjector { - /// Stores all devices for the each vendor, devices will be stored as the - /// vendor implementation and not as generic devices - /// - /// key is entityUniqueId so that it can both use it quickly to not add the - /// same device twice and to manage requests of actions from the app since - /// the action already arrives with entityUniqueId value - Map companyDevices = {}; - - /// Will set up device for this vendor into the connector conjecture, - /// will be called for each saved device of this vendor - Future setUpDeviceFromDb(DeviceEntityAbstract deviceEntity); - - Future manageHubRequestsForDevice(DeviceEntityAbstract entity); -} diff --git a/lib/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart b/lib/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart deleted file mode 100644 index d3eb3ddb..00000000 --- a/lib/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart +++ /dev/null @@ -1,90 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/generic_blinds_device/generic_blinds_device_dtos.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/generic_boiler_device/generic_boiler_device_dtos.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/generic_dimmable_light_device/generic_dimmable_light_device_dtos.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/generic_empty_device/generic_empty_device_dtos.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/generic_light_device/generic_light_device_dtos.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/generic_ping_device/generic_ping_device_dtos.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/generic_printer_device/generic_printer_device_dtos.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/generic_rgbw_light_device/generic_rgbw_light_device_dtos.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/generic_smart_computer_device/generic_smart_computer_device_dtos.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/generic_smart_plug_device/generic_smart_plug_device_dtos.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/generic_smart_tv_device/generic_smart_tv_device_dtos.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/generic_smart_type_type_not_supported_device/generic_smart_type_not_supported_device_dtos.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/generic_switch_device/generic_switch_device_dtos.dart'; -import 'package:cbj_hub/utils.dart'; - -class DeviceEntityDtoAbstract { - DeviceEntityDtoAbstract(); - - factory DeviceEntityDtoAbstract.fromDomain() { - logger.t('DeviceEntityDtoAbstract.fromDomain'); - return DeviceEntityDtoAbstract(); - } - - factory DeviceEntityDtoAbstract.fromJson(Map json) { - DeviceEntityDtoAbstract deviceEntityDtoAbstract = DeviceEntityDtoAbstract(); - final String jsonDeviceDtoClass = json['deviceDtoClass'].toString(); - - if (jsonDeviceDtoClass == (GenericLightDeviceDtos).toString() || - json['entityTypes'] == EntityTypes.light.toString()) { - deviceEntityDtoAbstract = GenericLightDeviceDtos.fromJson(json); - } else if (jsonDeviceDtoClass == - (GenericDimmableLightDeviceDtos).toString() || - json['entityTypes'] == EntityTypes.dimmableLight.toString()) { - deviceEntityDtoAbstract = GenericDimmableLightDeviceDtos.fromJson(json); - } else if (jsonDeviceDtoClass == (GenericRgbwLightDeviceDtos).toString() || - json['entityTypes'] == EntityTypes.rgbwLights.toString()) { - deviceEntityDtoAbstract = GenericRgbwLightDeviceDtos.fromJson(json); - } else if (jsonDeviceDtoClass == (GenericBlindsDeviceDtos).toString() || - json['entityTypes'] == EntityTypes.blinds.toString()) { - deviceEntityDtoAbstract = GenericBlindsDeviceDtos.fromJson(json); - } else if (jsonDeviceDtoClass == (GenericBoilerDeviceDtos).toString() || - json['entityTypes'] == EntityTypes.boiler.toString()) { - deviceEntityDtoAbstract = GenericBoilerDeviceDtos.fromJson(json); - } else if (jsonDeviceDtoClass == (GenericSmartTvDeviceDtos).toString() || - json['entityTypes'] == EntityTypes.smartTV.toString()) { - deviceEntityDtoAbstract = GenericSmartTvDeviceDtos.fromJson(json); - } else if (jsonDeviceDtoClass == (GenericSwitchDeviceDtos).toString() || - json['entityTypes'] == EntityTypes.switch_.toString()) { - deviceEntityDtoAbstract = GenericSwitchDeviceDtos.fromJson(json); - } else if (jsonDeviceDtoClass == (GenericSmartPlugDeviceDtos).toString() || - json['entityTypes'] == EntityTypes.smartPlug.toString()) { - deviceEntityDtoAbstract = GenericSmartPlugDeviceDtos.fromJson(json); - } else if (jsonDeviceDtoClass == - (GenericSmartComputerDeviceDtos).toString() || - json['entityTypes'] == EntityTypes.smartComputer.toString()) { - deviceEntityDtoAbstract = GenericSmartComputerDeviceDtos.fromJson(json); - } else if (jsonDeviceDtoClass == (GenericPrinterDeviceDtos).toString() || - json['entityTypes'] == EntityTypes.printer.toString()) { - deviceEntityDtoAbstract = GenericPrinterDeviceDtos.fromJson(json); - } else if (jsonDeviceDtoClass == (GenericEmptyDeviceDtos).toString() || - json['entityTypes'] == EntityTypes.emptyEntity.toString()) { - deviceEntityDtoAbstract = GenericEmptyDeviceDtos.fromJson(json); - } else if (jsonDeviceDtoClass == (GenericPingDeviceDtos).toString() || - json['entityTypes'] == EntityTypes.pingEntity.toString()) { - deviceEntityDtoAbstract = GenericPingDeviceDtos.fromJson(json); - } else if (jsonDeviceDtoClass == - (GenericSmartTypeNotSupportedDeviceDtos).toString() || - json['entityTypes'] == EntityTypes.smartTypeNotSupported.toString()) { - deviceEntityDtoAbstract = - GenericSmartTypeNotSupportedDeviceDtos.fromJson(json); - } else { - throw 'DtoClassTypeDoesNotExist, please add here support for ${json['entityTypes']}'; - } - return deviceEntityDtoAbstract; - } - - final String deviceDtoClassInstance = (DeviceEntityDtoAbstract).toString(); - - Map toJson() { - logger.t('DeviceEntityDtoAbstract to Json'); - return {}; - } - - DeviceEntityAbstract toDomain() { - logger.t('ToDomain'); - return DeviceEntityNotAbstract(); - } -} diff --git a/lib/infrastructure/generic_devices/generic_blinds_device/generic_blinds_device_dtos.dart b/lib/infrastructure/generic_devices/generic_blinds_device/generic_blinds_device_dtos.dart deleted file mode 100644 index 433426cf..00000000 --- a/lib/infrastructure/generic_devices/generic_blinds_device/generic_blinds_device_dtos.dart +++ /dev/null @@ -1,116 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_blinds_device/generic_blinds_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_blinds_device/generic_blinds_value_objects.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'generic_blinds_device_dtos.freezed.dart'; -part 'generic_blinds_device_dtos.g.dart'; - -@freezed -abstract class GenericBlindsDeviceDtos - implements _$GenericBlindsDeviceDtos, DeviceEntityDtoAbstract { - factory GenericBlindsDeviceDtos({ - // @JsonKey(ignore: true) - required String id, - required String entityUniqueId, - required String? cbjEntityName, - required String? entityOriginalName, - required String? deviceOriginalName, - required String? entityStateGRPC, - required String? senderDeviceOs, - required String? senderDeviceModel, - required String? senderId, - required String? blindsSwitchState, - required String? entityTypes, - required String? compUuid, - required String? deviceVendor, - required String? powerConsumption, - required String? deviceUniqueId, - required String? devicePort, - required String? deviceLastKnownIp, - required String? deviceHostName, - required String? deviceMdns, - required String? devicesMacAddress, - required String? entityKey, - required String? requestTimeStamp, - required String? lastResponseFromDeviceTimeStamp, - required String? deviceCbjUniqueId, - String? deviceDtoClass, - String? stateMassage, - - // required ServerTimestampConverter() FieldValue serverTimeStamp, - }) = _GenericBlindsDeviceDtos; - - GenericBlindsDeviceDtos._(); - - factory GenericBlindsDeviceDtos.fromDomain(GenericBlindsDE deviceDe) { - return GenericBlindsDeviceDtos( - deviceDtoClass: (GenericBlindsDeviceDtos).toString(), - id: deviceDe.uniqueId.getOrCrash(), - entityUniqueId: deviceDe.entityUniqueId.getOrCrash(), - cbjEntityName: deviceDe.cbjEntityName.getOrCrash(), - entityOriginalName: deviceDe.entityOriginalName.getOrCrash(), - deviceOriginalName: deviceDe.deviceOriginalName.getOrCrash(), - entityStateGRPC: deviceDe.entityStateGRPC.getOrCrash(), - stateMassage: deviceDe.stateMassage.getOrCrash(), - senderDeviceOs: deviceDe.senderDeviceOs.getOrCrash(), - senderDeviceModel: deviceDe.senderDeviceModel.getOrCrash(), - senderId: deviceDe.senderId.getOrCrash(), - blindsSwitchState: deviceDe.blindsSwitchState!.getOrCrash(), - entityTypes: deviceDe.entityTypes.getOrCrash(), - compUuid: deviceDe.compUuid.getOrCrash(), - deviceVendor: deviceDe.deviceVendor.getOrCrash(), - powerConsumption: deviceDe.powerConsumption.getOrCrash(), - deviceUniqueId: deviceDe.deviceUniqueId.getOrCrash(), - devicePort: deviceDe.devicePort.getOrCrash(), - deviceLastKnownIp: deviceDe.deviceLastKnownIp.getOrCrash(), - deviceHostName: deviceDe.deviceHostName.getOrCrash(), - deviceMdns: deviceDe.deviceMdns.getOrCrash(), - devicesMacAddress: deviceDe.devicesMacAddress.getOrCrash(), - entityKey: deviceDe.entityKey.getOrCrash(), - requestTimeStamp: deviceDe.requestTimeStamp.getOrCrash(), - lastResponseFromDeviceTimeStamp: - deviceDe.lastResponseFromDeviceTimeStamp.getOrCrash(), - deviceCbjUniqueId: deviceDe.deviceCbjUniqueId.getOrCrash(), - ); - } - - factory GenericBlindsDeviceDtos.fromJson(Map json) => - _$GenericBlindsDeviceDtosFromJson(json); - - @override - final String deviceDtoClassInstance = (GenericBlindsDeviceDtos).toString(); - - @override - DeviceEntityAbstract toDomain() { - return GenericBlindsDE( - uniqueId: CoreUniqueId.fromUniqueString(id), - entityUniqueId: EntityUniqueId(entityUniqueId), - cbjEntityName: CbjEntityName(cbjEntityName), - entityOriginalName: EntityOriginalName(cbjEntityName), - deviceOriginalName: DeviceOriginalName(cbjEntityName), - entityStateGRPC: EntityState(entityStateGRPC), - stateMassage: DeviceStateMassage(stateMassage), - senderDeviceOs: DeviceSenderDeviceOs(senderDeviceOs), - senderDeviceModel: DeviceSenderDeviceModel(senderDeviceModel), - senderId: DeviceSenderId.fromUniqueString(senderId), - deviceVendor: DeviceVendor(deviceVendor), - compUuid: DeviceCompUuid(compUuid), - blindsSwitchState: GenericBlindsSwitchState(blindsSwitchState), - powerConsumption: DevicePowerConsumption(powerConsumption), - deviceUniqueId: DeviceUniqueId(deviceUniqueId), - devicePort: DevicePort(devicePort), - deviceLastKnownIp: DeviceLastKnownIp(deviceLastKnownIp), - deviceHostName: DeviceHostName(deviceHostName), - deviceMdns: DeviceMdns(deviceMdns), - devicesMacAddress: DevicesMacAddress(devicesMacAddress), - entityKey: EntityKey(entityKey), - requestTimeStamp: RequestTimeStamp(requestTimeStamp), - lastResponseFromDeviceTimeStamp: - LastResponseFromDeviceTimeStamp(lastResponseFromDeviceTimeStamp), - deviceCbjUniqueId: CoreUniqueId.fromUniqueString(deviceCbjUniqueId!), - ); - } -} diff --git a/lib/infrastructure/generic_devices/generic_boiler_device/generic_boiler_device_dtos.dart b/lib/infrastructure/generic_devices/generic_boiler_device/generic_boiler_device_dtos.dart deleted file mode 100644 index 23e01bda..00000000 --- a/lib/infrastructure/generic_devices/generic_boiler_device/generic_boiler_device_dtos.dart +++ /dev/null @@ -1,116 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_boiler_device/generic_boiler_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_boiler_device/generic_boiler_value_objects.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'generic_boiler_device_dtos.freezed.dart'; -part 'generic_boiler_device_dtos.g.dart'; - -@freezed -abstract class GenericBoilerDeviceDtos - implements _$GenericBoilerDeviceDtos, DeviceEntityDtoAbstract { - factory GenericBoilerDeviceDtos({ - // @JsonKey(ignore: true) - required String id, - required String entityUniqueId, - required String? cbjEntityName, - required String? entityOriginalName, - required String? deviceOriginalName, - required String? entityStateGRPC, - required String? senderDeviceOs, - required String? senderDeviceModel, - required String? senderId, - required String? boilerSwitchState, - required String? entityTypes, - required String? compUuid, - required String? deviceVendor, - required String? powerConsumption, - required String? deviceUniqueId, - required String? devicePort, - required String? deviceLastKnownIp, - required String? deviceHostName, - required String? deviceMdns, - required String? devicesMacAddress, - required String? entityKey, - required String? requestTimeStamp, - required String? lastResponseFromDeviceTimeStamp, - required String? deviceCbjUniqueId, - String? deviceDtoClass, - String? stateMassage, - - // required ServerTimestampConverter() FieldValue serverTimeStamp, - }) = _GenericBoilerDeviceDtos; - - GenericBoilerDeviceDtos._(); - - factory GenericBoilerDeviceDtos.fromDomain(GenericBoilerDE deviceDe) { - return GenericBoilerDeviceDtos( - deviceDtoClass: (GenericBoilerDeviceDtos).toString(), - id: deviceDe.uniqueId.getOrCrash(), - entityUniqueId: deviceDe.entityUniqueId.getOrCrash(), - cbjEntityName: deviceDe.cbjEntityName.getOrCrash(), - entityOriginalName: deviceDe.entityOriginalName.getOrCrash(), - deviceOriginalName: deviceDe.deviceOriginalName.getOrCrash(), - entityStateGRPC: deviceDe.entityStateGRPC.getOrCrash(), - stateMassage: deviceDe.stateMassage.getOrCrash(), - senderDeviceOs: deviceDe.senderDeviceOs.getOrCrash(), - senderDeviceModel: deviceDe.senderDeviceModel.getOrCrash(), - senderId: deviceDe.senderId.getOrCrash(), - boilerSwitchState: deviceDe.boilerSwitchState!.getOrCrash(), - entityTypes: deviceDe.entityTypes.getOrCrash(), - compUuid: deviceDe.compUuid.getOrCrash(), - deviceVendor: deviceDe.deviceVendor.getOrCrash(), - powerConsumption: deviceDe.powerConsumption.getOrCrash(), - deviceUniqueId: deviceDe.deviceUniqueId.getOrCrash(), - devicePort: deviceDe.devicePort.getOrCrash(), - deviceLastKnownIp: deviceDe.deviceLastKnownIp.getOrCrash(), - deviceHostName: deviceDe.deviceHostName.getOrCrash(), - deviceMdns: deviceDe.deviceMdns.getOrCrash(), - devicesMacAddress: deviceDe.devicesMacAddress.getOrCrash(), - entityKey: deviceDe.entityKey.getOrCrash(), - requestTimeStamp: deviceDe.requestTimeStamp.getOrCrash(), - lastResponseFromDeviceTimeStamp: - deviceDe.lastResponseFromDeviceTimeStamp.getOrCrash(), - deviceCbjUniqueId: deviceDe.deviceCbjUniqueId.getOrCrash(), - ); - } - - factory GenericBoilerDeviceDtos.fromJson(Map json) => - _$GenericBoilerDeviceDtosFromJson(json); - - @override - final String deviceDtoClassInstance = (GenericBoilerDeviceDtos).toString(); - - @override - DeviceEntityAbstract toDomain() { - return GenericBoilerDE( - uniqueId: CoreUniqueId.fromUniqueString(id), - entityUniqueId: EntityUniqueId(entityUniqueId), - cbjEntityName: CbjEntityName(cbjEntityName), - entityOriginalName: EntityOriginalName(cbjEntityName), - deviceOriginalName: DeviceOriginalName(cbjEntityName), - entityStateGRPC: EntityState(entityStateGRPC), - stateMassage: DeviceStateMassage(stateMassage), - senderDeviceOs: DeviceSenderDeviceOs(senderDeviceOs), - senderDeviceModel: DeviceSenderDeviceModel(senderDeviceModel), - senderId: DeviceSenderId.fromUniqueString(senderId), - deviceVendor: DeviceVendor(deviceVendor), - compUuid: DeviceCompUuid(compUuid), - boilerSwitchState: GenericBoilerSwitchState(boilerSwitchState), - powerConsumption: DevicePowerConsumption(powerConsumption), - deviceUniqueId: DeviceUniqueId(deviceUniqueId), - devicePort: DevicePort(devicePort), - deviceLastKnownIp: DeviceLastKnownIp(deviceLastKnownIp), - deviceHostName: DeviceHostName(deviceHostName), - deviceMdns: DeviceMdns(deviceMdns), - devicesMacAddress: DevicesMacAddress(devicesMacAddress), - entityKey: EntityKey(entityKey), - requestTimeStamp: RequestTimeStamp(requestTimeStamp), - lastResponseFromDeviceTimeStamp: - LastResponseFromDeviceTimeStamp(lastResponseFromDeviceTimeStamp), - deviceCbjUniqueId: CoreUniqueId.fromUniqueString(deviceCbjUniqueId!), - ); - } -} diff --git a/lib/infrastructure/generic_devices/generic_dimmable_light_device/generic_dimmable_light_device_dtos.dart b/lib/infrastructure/generic_devices/generic_dimmable_light_device/generic_dimmable_light_device_dtos.dart deleted file mode 100644 index 1e1e9f5e..00000000 --- a/lib/infrastructure/generic_devices/generic_dimmable_light_device/generic_dimmable_light_device_dtos.dart +++ /dev/null @@ -1,122 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_dimmable_light_device/generic_dimmable_light_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_dimmable_light_device/generic_dimmable_light_value_objects.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'generic_dimmable_light_device_dtos.freezed.dart'; -part 'generic_dimmable_light_device_dtos.g.dart'; - -@freezed -abstract class GenericDimmableLightDeviceDtos - implements _$GenericDimmableLightDeviceDtos, DeviceEntityDtoAbstract { - factory GenericDimmableLightDeviceDtos({ - // @JsonKey(ignore: true) - required String id, - required String entityUniqueId, - required String? cbjEntityName, - required String? entityOriginalName, - required String? deviceOriginalName, - required String? entityStateGRPC, - required String? senderDeviceOs, - required String? senderDeviceModel, - required String? senderId, - required String? lightSwitchState, - required String? entityTypes, - required String? compUuid, - required String? deviceVendor, - required String? powerConsumption, - required String? lightBrightness, - required String? deviceUniqueId, - required String? devicePort, - required String? deviceLastKnownIp, - required String? deviceHostName, - required String? deviceMdns, - required String? devicesMacAddress, - required String? entityKey, - required String? requestTimeStamp, - required String? lastResponseFromDeviceTimeStamp, - required String? deviceCbjUniqueId, - String? deviceDtoClass, - String? stateMassage, - - // required ServerTimestampConverter() FieldValue serverTimeStamp, - }) = _GenericDimmableLightDeviceDtos; - - GenericDimmableLightDeviceDtos._(); - - factory GenericDimmableLightDeviceDtos.fromDomain( - GenericDimmableLightDE deviceDe, - ) { - return GenericDimmableLightDeviceDtos( - deviceDtoClass: (GenericDimmableLightDeviceDtos).toString(), - id: deviceDe.uniqueId.getOrCrash(), - entityUniqueId: deviceDe.entityUniqueId.getOrCrash(), - cbjEntityName: deviceDe.cbjEntityName.getOrCrash(), - entityOriginalName: deviceDe.entityOriginalName.getOrCrash(), - deviceOriginalName: deviceDe.deviceOriginalName.getOrCrash(), - entityStateGRPC: deviceDe.entityStateGRPC.getOrCrash(), - stateMassage: deviceDe.stateMassage.getOrCrash(), - senderDeviceOs: deviceDe.senderDeviceOs.getOrCrash(), - senderDeviceModel: deviceDe.senderDeviceModel.getOrCrash(), - senderId: deviceDe.senderId.getOrCrash(), - lightSwitchState: deviceDe.lightSwitchState!.getOrCrash(), - entityTypes: deviceDe.entityTypes.getOrCrash(), - compUuid: deviceDe.compUuid.getOrCrash(), - deviceVendor: deviceDe.deviceVendor.getOrCrash(), - lightBrightness: deviceDe.lightBrightness.getOrCrash(), - powerConsumption: deviceDe.powerConsumption.getOrCrash(), - deviceUniqueId: deviceDe.deviceUniqueId.getOrCrash(), - devicePort: deviceDe.devicePort.getOrCrash(), - deviceLastKnownIp: deviceDe.deviceLastKnownIp.getOrCrash(), - deviceHostName: deviceDe.deviceHostName.getOrCrash(), - deviceMdns: deviceDe.deviceMdns.getOrCrash(), - devicesMacAddress: deviceDe.devicesMacAddress.getOrCrash(), - entityKey: deviceDe.entityKey.getOrCrash(), - requestTimeStamp: deviceDe.requestTimeStamp.getOrCrash(), - lastResponseFromDeviceTimeStamp: - deviceDe.lastResponseFromDeviceTimeStamp.getOrCrash(), - deviceCbjUniqueId: deviceDe.deviceCbjUniqueId.getOrCrash(), - ); - } - - factory GenericDimmableLightDeviceDtos.fromJson(Map json) => - _$GenericDimmableLightDeviceDtosFromJson(json); - - @override - final String deviceDtoClassInstance = - (GenericDimmableLightDeviceDtos).toString(); - - @override - DeviceEntityAbstract toDomain() { - return GenericDimmableLightDE( - uniqueId: CoreUniqueId.fromUniqueString(id), - entityUniqueId: EntityUniqueId(entityUniqueId), - cbjEntityName: CbjEntityName(cbjEntityName), - entityOriginalName: EntityOriginalName(cbjEntityName), - deviceOriginalName: DeviceOriginalName(cbjEntityName), - entityStateGRPC: EntityState(entityStateGRPC), - stateMassage: DeviceStateMassage(stateMassage), - senderDeviceOs: DeviceSenderDeviceOs(senderDeviceOs), - senderDeviceModel: DeviceSenderDeviceModel(senderDeviceModel), - senderId: DeviceSenderId.fromUniqueString(senderId), - deviceVendor: DeviceVendor(deviceVendor), - compUuid: DeviceCompUuid(compUuid), - lightSwitchState: GenericDimmableLightSwitchState(lightSwitchState), - lightBrightness: GenericDimmableLightBrightness(lightBrightness), - powerConsumption: DevicePowerConsumption(powerConsumption), - deviceUniqueId: DeviceUniqueId(deviceUniqueId), - devicePort: DevicePort(devicePort), - deviceLastKnownIp: DeviceLastKnownIp(deviceLastKnownIp), - deviceHostName: DeviceHostName(deviceHostName), - deviceMdns: DeviceMdns(deviceMdns), - devicesMacAddress: DevicesMacAddress(devicesMacAddress), - entityKey: EntityKey(entityKey), - requestTimeStamp: RequestTimeStamp(requestTimeStamp), - lastResponseFromDeviceTimeStamp: - LastResponseFromDeviceTimeStamp(lastResponseFromDeviceTimeStamp), - deviceCbjUniqueId: CoreUniqueId.fromUniqueString(deviceCbjUniqueId!), - ); - } -} diff --git a/lib/infrastructure/generic_devices/generic_empty_device/generic_empty_device_dtos.dart b/lib/infrastructure/generic_devices/generic_empty_device/generic_empty_device_dtos.dart deleted file mode 100644 index d347c4cc..00000000 --- a/lib/infrastructure/generic_devices/generic_empty_device/generic_empty_device_dtos.dart +++ /dev/null @@ -1,116 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_empty_device/generic_empty_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_empty_device/generic_empty_value_objects.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'generic_empty_device_dtos.freezed.dart'; -part 'generic_empty_device_dtos.g.dart'; - -@freezed -abstract class GenericEmptyDeviceDtos - implements _$GenericEmptyDeviceDtos, DeviceEntityDtoAbstract { - factory GenericEmptyDeviceDtos({ - // @JsonKey(ignore: true) - required String id, - required String entityUniqueId, - required String? cbjEntityName, - required String? entityOriginalName, - required String? deviceOriginalName, - required String? entityStateGRPC, - required String? senderDeviceOs, - required String? senderDeviceModel, - required String? senderId, - required String? emptySwitchState, - required String? entityTypes, - required String? compUuid, - required String? deviceVendor, - required String? powerConsumption, - required String? deviceUniqueId, - required String? devicePort, - required String? deviceLastKnownIp, - required String? deviceHostName, - required String? deviceMdns, - required String? devicesMacAddress, - required String? entityKey, - required String? requestTimeStamp, - required String? lastResponseFromDeviceTimeStamp, - required String? deviceCbjUniqueId, - String? deviceDtoClass, - String? stateMassage, - - // required ServerTimestampConverter() FieldValue serverTimeStamp, - }) = _GenericEmptyDeviceDtos; - - GenericEmptyDeviceDtos._(); - - factory GenericEmptyDeviceDtos.fromDomain(GenericEmptyDE deviceDe) { - return GenericEmptyDeviceDtos( - deviceDtoClass: (GenericEmptyDeviceDtos).toString(), - id: deviceDe.uniqueId.getOrCrash(), - entityUniqueId: deviceDe.entityUniqueId.getOrCrash(), - cbjEntityName: deviceDe.cbjEntityName.getOrCrash(), - entityOriginalName: deviceDe.entityOriginalName.getOrCrash(), - deviceOriginalName: deviceDe.deviceOriginalName.getOrCrash(), - entityStateGRPC: deviceDe.entityStateGRPC.getOrCrash(), - stateMassage: deviceDe.stateMassage.getOrCrash(), - senderDeviceOs: deviceDe.senderDeviceOs.getOrCrash(), - senderDeviceModel: deviceDe.senderDeviceModel.getOrCrash(), - senderId: deviceDe.senderId.getOrCrash(), - emptySwitchState: deviceDe.emptySwitchState!.getOrCrash(), - entityTypes: deviceDe.entityTypes.getOrCrash(), - compUuid: deviceDe.compUuid.getOrCrash(), - deviceVendor: deviceDe.deviceVendor.getOrCrash(), - powerConsumption: deviceDe.powerConsumption.getOrCrash(), - deviceUniqueId: deviceDe.deviceUniqueId.getOrCrash(), - devicePort: deviceDe.devicePort.getOrCrash(), - deviceLastKnownIp: deviceDe.deviceLastKnownIp.getOrCrash(), - deviceHostName: deviceDe.deviceHostName.getOrCrash(), - deviceMdns: deviceDe.deviceMdns.getOrCrash(), - devicesMacAddress: deviceDe.devicesMacAddress.getOrCrash(), - entityKey: deviceDe.entityKey.getOrCrash(), - requestTimeStamp: deviceDe.requestTimeStamp.getOrCrash(), - lastResponseFromDeviceTimeStamp: - deviceDe.lastResponseFromDeviceTimeStamp.getOrCrash(), - deviceCbjUniqueId: deviceDe.deviceCbjUniqueId.getOrCrash(), - ); - } - - factory GenericEmptyDeviceDtos.fromJson(Map json) => - _$GenericEmptyDeviceDtosFromJson(json); - - @override - final String deviceDtoClassInstance = (GenericEmptyDeviceDtos).toString(); - - @override - DeviceEntityAbstract toDomain() { - return GenericEmptyDE( - uniqueId: CoreUniqueId.fromUniqueString(id), - entityUniqueId: EntityUniqueId(entityUniqueId), - cbjEntityName: CbjEntityName(cbjEntityName), - entityOriginalName: EntityOriginalName(cbjEntityName), - deviceOriginalName: DeviceOriginalName(cbjEntityName), - entityStateGRPC: EntityState(entityStateGRPC), - stateMassage: DeviceStateMassage(stateMassage), - senderDeviceOs: DeviceSenderDeviceOs(senderDeviceOs), - senderDeviceModel: DeviceSenderDeviceModel(senderDeviceModel), - senderId: DeviceSenderId.fromUniqueString(senderId), - deviceVendor: DeviceVendor(deviceVendor), - compUuid: DeviceCompUuid(compUuid), - emptySwitchState: GenericEmptySwitchState(emptySwitchState), - powerConsumption: DevicePowerConsumption(powerConsumption), - deviceUniqueId: DeviceUniqueId(deviceUniqueId), - devicePort: DevicePort(devicePort), - deviceLastKnownIp: DeviceLastKnownIp(deviceLastKnownIp), - deviceHostName: DeviceHostName(deviceHostName), - deviceMdns: DeviceMdns(deviceMdns), - devicesMacAddress: DevicesMacAddress(devicesMacAddress), - entityKey: EntityKey(entityKey), - requestTimeStamp: RequestTimeStamp(requestTimeStamp), - lastResponseFromDeviceTimeStamp: - LastResponseFromDeviceTimeStamp(lastResponseFromDeviceTimeStamp), - deviceCbjUniqueId: CoreUniqueId.fromUniqueString(deviceCbjUniqueId!), - ); - } -} diff --git a/lib/infrastructure/generic_devices/generic_light_device/generic_light_device_dtos.dart b/lib/infrastructure/generic_devices/generic_light_device/generic_light_device_dtos.dart deleted file mode 100644 index 990e05d3..00000000 --- a/lib/infrastructure/generic_devices/generic_light_device/generic_light_device_dtos.dart +++ /dev/null @@ -1,116 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_light_device/generic_light_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_light_device/generic_light_value_objects.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'generic_light_device_dtos.freezed.dart'; -part 'generic_light_device_dtos.g.dart'; - -@freezed -abstract class GenericLightDeviceDtos - implements _$GenericLightDeviceDtos, DeviceEntityDtoAbstract { - factory GenericLightDeviceDtos({ - // @JsonKey(ignore: true) - required String id, - required String entityUniqueId, - required String? cbjEntityName, - required String? entityOriginalName, - required String? deviceOriginalName, - required String? entityStateGRPC, - required String? senderDeviceOs, - required String? senderDeviceModel, - required String? senderId, - required String? lightSwitchState, - required String? entityTypes, - required String? compUuid, - required String? deviceVendor, - required String? powerConsumption, - required String? deviceUniqueId, - required String? devicePort, - required String? deviceLastKnownIp, - required String? deviceHostName, - required String? deviceMdns, - required String? devicesMacAddress, - required String? entityKey, - required String? requestTimeStamp, - required String? lastResponseFromDeviceTimeStamp, - required String? deviceCbjUniqueId, - String? deviceDtoClass, - String? stateMassage, - - // required ServerTimestampConverter() FieldValue serverTimeStamp, - }) = _GenericLightDeviceDtos; - - GenericLightDeviceDtos._(); - - factory GenericLightDeviceDtos.fromDomain(GenericLightDE deviceDe) { - return GenericLightDeviceDtos( - deviceDtoClass: (GenericLightDeviceDtos).toString(), - id: deviceDe.uniqueId.getOrCrash(), - entityUniqueId: deviceDe.entityUniqueId.getOrCrash(), - cbjEntityName: deviceDe.cbjEntityName.getOrCrash(), - entityOriginalName: deviceDe.entityOriginalName.getOrCrash(), - deviceOriginalName: deviceDe.deviceOriginalName.getOrCrash(), - entityStateGRPC: deviceDe.entityStateGRPC.getOrCrash(), - stateMassage: deviceDe.stateMassage.getOrCrash(), - senderDeviceOs: deviceDe.senderDeviceOs.getOrCrash(), - senderDeviceModel: deviceDe.senderDeviceModel.getOrCrash(), - senderId: deviceDe.senderId.getOrCrash(), - lightSwitchState: deviceDe.lightSwitchState!.getOrCrash(), - entityTypes: deviceDe.entityTypes.getOrCrash(), - compUuid: deviceDe.compUuid.getOrCrash(), - deviceVendor: deviceDe.deviceVendor.getOrCrash(), - powerConsumption: deviceDe.powerConsumption.getOrCrash(), - deviceUniqueId: deviceDe.deviceUniqueId.getOrCrash(), - devicePort: deviceDe.devicePort.getOrCrash(), - deviceLastKnownIp: deviceDe.deviceLastKnownIp.getOrCrash(), - deviceHostName: deviceDe.deviceHostName.getOrCrash(), - deviceMdns: deviceDe.deviceMdns.getOrCrash(), - devicesMacAddress: deviceDe.devicesMacAddress.getOrCrash(), - entityKey: deviceDe.entityKey.getOrCrash(), - requestTimeStamp: deviceDe.requestTimeStamp.getOrCrash(), - lastResponseFromDeviceTimeStamp: - deviceDe.lastResponseFromDeviceTimeStamp.getOrCrash(), - deviceCbjUniqueId: deviceDe.deviceCbjUniqueId.getOrCrash(), - ); - } - - factory GenericLightDeviceDtos.fromJson(Map json) => - _$GenericLightDeviceDtosFromJson(json); - - @override - final String deviceDtoClassInstance = (GenericLightDeviceDtos).toString(); - - @override - DeviceEntityAbstract toDomain() { - return GenericLightDE( - uniqueId: CoreUniqueId.fromUniqueString(id), - entityUniqueId: EntityUniqueId(entityUniqueId), - cbjEntityName: CbjEntityName(cbjEntityName), - entityOriginalName: EntityOriginalName(cbjEntityName), - deviceOriginalName: DeviceOriginalName(cbjEntityName), - entityStateGRPC: EntityState(entityStateGRPC), - stateMassage: DeviceStateMassage(stateMassage), - senderDeviceOs: DeviceSenderDeviceOs(senderDeviceOs), - senderDeviceModel: DeviceSenderDeviceModel(senderDeviceModel), - senderId: DeviceSenderId.fromUniqueString(senderId), - deviceVendor: DeviceVendor(deviceVendor), - compUuid: DeviceCompUuid(compUuid), - lightSwitchState: GenericLightSwitchState(lightSwitchState), - powerConsumption: DevicePowerConsumption(powerConsumption), - deviceUniqueId: DeviceUniqueId(deviceUniqueId), - devicePort: DevicePort(devicePort), - deviceLastKnownIp: DeviceLastKnownIp(deviceLastKnownIp), - deviceHostName: DeviceHostName(deviceHostName), - deviceMdns: DeviceMdns(deviceMdns), - devicesMacAddress: DevicesMacAddress(devicesMacAddress), - entityKey: EntityKey(entityKey), - requestTimeStamp: RequestTimeStamp(requestTimeStamp), - lastResponseFromDeviceTimeStamp: - LastResponseFromDeviceTimeStamp(lastResponseFromDeviceTimeStamp), - deviceCbjUniqueId: CoreUniqueId.fromUniqueString(deviceCbjUniqueId!), - ); - } -} diff --git a/lib/infrastructure/generic_devices/generic_ping_device/generic_ping_device_dtos.dart b/lib/infrastructure/generic_devices/generic_ping_device/generic_ping_device_dtos.dart deleted file mode 100644 index b60e9e6f..00000000 --- a/lib/infrastructure/generic_devices/generic_ping_device/generic_ping_device_dtos.dart +++ /dev/null @@ -1,116 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_ping_device/generic_ping_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_ping_device/generic_ping_value_objects.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'generic_ping_device_dtos.freezed.dart'; -part 'generic_ping_device_dtos.g.dart'; - -@freezed -abstract class GenericPingDeviceDtos - implements _$GenericPingDeviceDtos, DeviceEntityDtoAbstract { - factory GenericPingDeviceDtos({ - // @JsonKey(ignore: true) - required String id, - required String entityUniqueId, - required String? cbjEntityName, - required String? entityOriginalName, - required String? deviceOriginalName, - required String? entityStateGRPC, - required String? senderDeviceOs, - required String? senderDeviceModel, - required String? senderId, - required String? pingSwitchState, - required String? entityTypes, - required String? compUuid, - required String? deviceVendor, - required String? powerConsumption, - required String? deviceUniqueId, - required String? devicePort, - required String? deviceLastKnownIp, - required String? deviceHostName, - required String? deviceMdns, - required String? devicesMacAddress, - required String? entityKey, - required String? requestTimeStamp, - required String? lastResponseFromDeviceTimeStamp, - required String? deviceCbjUniqueId, - String? deviceDtoClass, - String? stateMassage, - - // required ServerTimestampConverter() FieldValue serverTimeStamp, - }) = _GenericPingDeviceDtos; - - GenericPingDeviceDtos._(); - - factory GenericPingDeviceDtos.fromDomain(GenericPingDE deviceDe) { - return GenericPingDeviceDtos( - deviceDtoClass: (GenericPingDeviceDtos).toString(), - id: deviceDe.uniqueId.getOrCrash(), - entityUniqueId: deviceDe.entityUniqueId.getOrCrash(), - cbjEntityName: deviceDe.cbjEntityName.getOrCrash(), - entityOriginalName: deviceDe.entityOriginalName.getOrCrash(), - deviceOriginalName: deviceDe.deviceOriginalName.getOrCrash(), - entityStateGRPC: deviceDe.entityStateGRPC.getOrCrash(), - stateMassage: deviceDe.stateMassage.getOrCrash(), - senderDeviceOs: deviceDe.senderDeviceOs.getOrCrash(), - senderDeviceModel: deviceDe.senderDeviceModel.getOrCrash(), - senderId: deviceDe.senderId.getOrCrash(), - pingSwitchState: deviceDe.pingSwitchState!.getOrCrash(), - entityTypes: deviceDe.entityTypes.getOrCrash(), - compUuid: deviceDe.compUuid.getOrCrash(), - deviceVendor: deviceDe.deviceVendor.getOrCrash(), - powerConsumption: deviceDe.powerConsumption.getOrCrash(), - deviceUniqueId: deviceDe.deviceUniqueId.getOrCrash(), - devicePort: deviceDe.devicePort.getOrCrash(), - deviceLastKnownIp: deviceDe.deviceLastKnownIp.getOrCrash(), - deviceHostName: deviceDe.deviceHostName.getOrCrash(), - deviceMdns: deviceDe.deviceMdns.getOrCrash(), - devicesMacAddress: deviceDe.devicesMacAddress.getOrCrash(), - entityKey: deviceDe.entityKey.getOrCrash(), - requestTimeStamp: deviceDe.requestTimeStamp.getOrCrash(), - lastResponseFromDeviceTimeStamp: - deviceDe.lastResponseFromDeviceTimeStamp.getOrCrash(), - deviceCbjUniqueId: deviceDe.deviceCbjUniqueId.getOrCrash(), - ); - } - - factory GenericPingDeviceDtos.fromJson(Map json) => - _$GenericPingDeviceDtosFromJson(json); - - @override - final String deviceDtoClassInstance = (GenericPingDeviceDtos).toString(); - - @override - DeviceEntityAbstract toDomain() { - return GenericPingDE( - uniqueId: CoreUniqueId.fromUniqueString(id), - entityUniqueId: EntityUniqueId(entityUniqueId), - cbjEntityName: CbjEntityName(cbjEntityName), - entityOriginalName: EntityOriginalName(cbjEntityName), - deviceOriginalName: DeviceOriginalName(cbjEntityName), - entityStateGRPC: EntityState(entityStateGRPC), - stateMassage: DeviceStateMassage(stateMassage), - senderDeviceOs: DeviceSenderDeviceOs(senderDeviceOs), - senderDeviceModel: DeviceSenderDeviceModel(senderDeviceModel), - senderId: DeviceSenderId.fromUniqueString(senderId), - deviceVendor: DeviceVendor(deviceVendor), - compUuid: DeviceCompUuid(compUuid), - pingSwitchState: GenericPingSwitchState(pingSwitchState), - powerConsumption: DevicePowerConsumption(powerConsumption), - deviceUniqueId: DeviceUniqueId(deviceUniqueId), - devicePort: DevicePort(devicePort), - deviceLastKnownIp: DeviceLastKnownIp(deviceLastKnownIp), - deviceHostName: DeviceHostName(deviceHostName), - deviceMdns: DeviceMdns(deviceMdns), - devicesMacAddress: DevicesMacAddress(devicesMacAddress), - entityKey: EntityKey(entityKey), - requestTimeStamp: RequestTimeStamp(requestTimeStamp), - lastResponseFromDeviceTimeStamp: - LastResponseFromDeviceTimeStamp(lastResponseFromDeviceTimeStamp), - deviceCbjUniqueId: CoreUniqueId.fromUniqueString(deviceCbjUniqueId!), - ); - } -} diff --git a/lib/infrastructure/generic_devices/generic_printer_device/generic_printer_device_dtos.dart b/lib/infrastructure/generic_devices/generic_printer_device/generic_printer_device_dtos.dart deleted file mode 100644 index b9165996..00000000 --- a/lib/infrastructure/generic_devices/generic_printer_device/generic_printer_device_dtos.dart +++ /dev/null @@ -1,120 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_printer_device/generic_printer_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_printer_device/generic_printer_value_objects.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'generic_printer_device_dtos.freezed.dart'; -part 'generic_printer_device_dtos.g.dart'; - -@freezed -abstract class GenericPrinterDeviceDtos - implements _$GenericPrinterDeviceDtos, DeviceEntityDtoAbstract { - factory GenericPrinterDeviceDtos({ - // @JsonKey(ignore: true) - required String id, - required String entityUniqueId, - required String? cbjEntityName, - required String? entityOriginalName, - required String? deviceOriginalName, - required String? entityStateGRPC, - required String? senderDeviceOs, - required String? senderDeviceModel, - required String? senderId, - required String? printerSwitchState, - required String? lastKnownIp, - required String? entityTypes, - required String? compUuid, - required String? deviceVendor, - required String? powerConsumption, - required String? deviceUniqueId, - required String? devicePort, - required String? deviceLastKnownIp, - required String? deviceHostName, - required String? deviceMdns, - required String? devicesMacAddress, - required String? entityKey, - required String? requestTimeStamp, - required String? lastResponseFromDeviceTimeStamp, - required String? deviceCbjUniqueId, - String? deviceDtoClass, - String? stateMassage, - - // required ServerTimestampConverter() FieldValue serverTimeStamp, - }) = _GenericPrinterDeviceDtos; - - GenericPrinterDeviceDtos._(); - - factory GenericPrinterDeviceDtos.fromDomain( - GenericPrinterDE deviceDe, - ) { - return GenericPrinterDeviceDtos( - deviceDtoClass: (GenericPrinterDeviceDtos).toString(), - id: deviceDe.uniqueId.getOrCrash(), - entityUniqueId: deviceDe.entityUniqueId.getOrCrash(), - cbjEntityName: deviceDe.cbjEntityName.getOrCrash(), - entityOriginalName: deviceDe.entityOriginalName.getOrCrash(), - deviceOriginalName: deviceDe.deviceOriginalName.getOrCrash(), - entityStateGRPC: deviceDe.entityStateGRPC.getOrCrash(), - stateMassage: deviceDe.stateMassage.getOrCrash(), - senderDeviceOs: deviceDe.senderDeviceOs.getOrCrash(), - senderDeviceModel: deviceDe.senderDeviceModel.getOrCrash(), - senderId: deviceDe.senderId.getOrCrash(), - printerSwitchState: deviceDe.printerSwitchState!.getOrCrash(), - lastKnownIp: deviceDe.deviceLastKnownIp.getOrCrash(), - entityTypes: deviceDe.entityTypes.getOrCrash(), - compUuid: deviceDe.compUuid.getOrCrash(), - deviceVendor: deviceDe.deviceVendor.getOrCrash(), - powerConsumption: deviceDe.powerConsumption.getOrCrash(), - deviceUniqueId: deviceDe.deviceUniqueId.getOrCrash(), - devicePort: deviceDe.devicePort.getOrCrash(), - deviceLastKnownIp: deviceDe.deviceLastKnownIp.getOrCrash(), - deviceHostName: deviceDe.deviceHostName.getOrCrash(), - deviceMdns: deviceDe.deviceMdns.getOrCrash(), - devicesMacAddress: deviceDe.devicesMacAddress.getOrCrash(), - entityKey: deviceDe.entityKey.getOrCrash(), - requestTimeStamp: deviceDe.requestTimeStamp.getOrCrash(), - lastResponseFromDeviceTimeStamp: - deviceDe.lastResponseFromDeviceTimeStamp.getOrCrash(), - deviceCbjUniqueId: deviceDe.deviceCbjUniqueId.getOrCrash(), - ); - } - - factory GenericPrinterDeviceDtos.fromJson(Map json) => - _$GenericPrinterDeviceDtosFromJson(json); - - @override - final String deviceDtoClassInstance = (GenericPrinterDeviceDtos).toString(); - - @override - DeviceEntityAbstract toDomain() { - return GenericPrinterDE( - uniqueId: CoreUniqueId.fromUniqueString(id), - entityUniqueId: EntityUniqueId(entityUniqueId), - cbjEntityName: CbjEntityName(cbjEntityName), - entityOriginalName: EntityOriginalName(cbjEntityName), - deviceOriginalName: DeviceOriginalName(cbjEntityName), - entityStateGRPC: EntityState(entityStateGRPC), - stateMassage: DeviceStateMassage(stateMassage), - senderDeviceOs: DeviceSenderDeviceOs(senderDeviceOs), - senderDeviceModel: DeviceSenderDeviceModel(senderDeviceModel), - senderId: DeviceSenderId.fromUniqueString(senderId), - deviceVendor: DeviceVendor(deviceVendor), - compUuid: DeviceCompUuid(compUuid), - printerSwitchState: GenericPrinterSwitchState(printerSwitchState), - powerConsumption: DevicePowerConsumption(powerConsumption), - deviceUniqueId: DeviceUniqueId(deviceUniqueId), - devicePort: DevicePort(devicePort), - deviceLastKnownIp: DeviceLastKnownIp(deviceLastKnownIp), - deviceHostName: DeviceHostName(deviceHostName), - deviceMdns: DeviceMdns(deviceMdns), - devicesMacAddress: DevicesMacAddress(devicesMacAddress), - entityKey: EntityKey(entityKey), - requestTimeStamp: RequestTimeStamp(requestTimeStamp), - lastResponseFromDeviceTimeStamp: - LastResponseFromDeviceTimeStamp(lastResponseFromDeviceTimeStamp), - deviceCbjUniqueId: CoreUniqueId.fromUniqueString(deviceCbjUniqueId!), - ); - } -} diff --git a/lib/infrastructure/generic_devices/generic_rgbw_light_device/generic_rgbw_light_device_dtos.dart b/lib/infrastructure/generic_devices/generic_rgbw_light_device/generic_rgbw_light_device_dtos.dart deleted file mode 100644 index 71b2bb0e..00000000 --- a/lib/infrastructure/generic_devices/generic_rgbw_light_device/generic_rgbw_light_device_dtos.dart +++ /dev/null @@ -1,138 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_value_objects.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'generic_rgbw_light_device_dtos.freezed.dart'; -part 'generic_rgbw_light_device_dtos.g.dart'; - -@freezed -abstract class GenericRgbwLightDeviceDtos - implements _$GenericRgbwLightDeviceDtos, DeviceEntityDtoAbstract { - factory GenericRgbwLightDeviceDtos({ - // @JsonKey(ignore: true) - required String id, - required String entityUniqueId, - required String? cbjEntityName, - required String? entityOriginalName, - required String? deviceOriginalName, - required String? entityStateGRPC, - required String? senderDeviceOs, - required String? senderDeviceModel, - required String? senderId, - required String? entityTypes, - required String? compUuid, - required String? deviceVendor, - required String? powerConsumption, - required String? deviceUniqueId, - required String? devicePort, - required String? deviceLastKnownIp, - required String? deviceHostName, - required String? deviceMdns, - required String? devicesMacAddress, - required String? entityKey, - required String? requestTimeStamp, - required String? lastResponseFromDeviceTimeStamp, - required String? deviceCbjUniqueId, - required String? lightSwitchState, - required String? lightColorTemperature, - required String? lightBrightness, - required String? lightColorAlpha, - required String? lightColorHue, - required String? lightColorSaturation, - required String? lightColorValue, - String? deviceDtoClass, - String? stateMassage, - - // required ServerTimestampConverter() FieldValue serverTimeStamp, - }) = _GenericRgbwLightDeviceDtos; - - GenericRgbwLightDeviceDtos._(); - - factory GenericRgbwLightDeviceDtos.fromDomain( - GenericRgbwLightDE deviceDe, - ) { - return GenericRgbwLightDeviceDtos( - deviceDtoClass: (GenericRgbwLightDeviceDtos).toString(), - id: deviceDe.uniqueId.getOrCrash(), - entityUniqueId: deviceDe.entityUniqueId.getOrCrash(), - cbjEntityName: deviceDe.cbjEntityName.getOrCrash(), - entityOriginalName: deviceDe.entityOriginalName.getOrCrash(), - deviceOriginalName: deviceDe.deviceOriginalName.getOrCrash(), - entityStateGRPC: deviceDe.entityStateGRPC.getOrCrash(), - stateMassage: deviceDe.stateMassage.getOrCrash(), - senderDeviceOs: deviceDe.senderDeviceOs.getOrCrash(), - senderDeviceModel: deviceDe.senderDeviceModel.getOrCrash(), - senderId: deviceDe.senderId.getOrCrash(), - lightSwitchState: deviceDe.lightSwitchState!.getOrCrash(), - entityTypes: deviceDe.entityTypes.getOrCrash(), - compUuid: deviceDe.compUuid.getOrCrash(), - deviceVendor: deviceDe.deviceVendor.getOrCrash(), - powerConsumption: deviceDe.powerConsumption.getOrCrash(), - deviceUniqueId: deviceDe.deviceUniqueId.getOrCrash(), - devicePort: deviceDe.devicePort.getOrCrash(), - deviceLastKnownIp: deviceDe.deviceLastKnownIp.getOrCrash(), - deviceHostName: deviceDe.deviceHostName.getOrCrash(), - deviceMdns: deviceDe.deviceMdns.getOrCrash(), - devicesMacAddress: deviceDe.devicesMacAddress.getOrCrash(), - entityKey: deviceDe.entityKey.getOrCrash(), - requestTimeStamp: deviceDe.requestTimeStamp.getOrCrash(), - lastResponseFromDeviceTimeStamp: - deviceDe.lastResponseFromDeviceTimeStamp.getOrCrash(), - lightColorTemperature: deviceDe.lightColorTemperature.getOrCrash(), - lightBrightness: deviceDe.lightBrightness.getOrCrash(), - lightColorAlpha: deviceDe.lightColorAlpha.getOrCrash(), - lightColorHue: deviceDe.lightColorHue.getOrCrash(), - lightColorSaturation: deviceDe.lightColorSaturation.getOrCrash(), - lightColorValue: deviceDe.lightColorValue.getOrCrash(), - deviceCbjUniqueId: deviceDe.deviceCbjUniqueId.getOrCrash(), - ); - } - - factory GenericRgbwLightDeviceDtos.fromJson(Map json) => - _$GenericRgbwLightDeviceDtosFromJson(json); - - @override - final String deviceDtoClassInstance = (GenericRgbwLightDeviceDtos).toString(); - - @override - DeviceEntityAbstract toDomain() { - return GenericRgbwLightDE( - uniqueId: CoreUniqueId.fromUniqueString(id), - entityUniqueId: EntityUniqueId(entityUniqueId), - cbjEntityName: CbjEntityName(cbjEntityName), - entityOriginalName: EntityOriginalName(cbjEntityName), - deviceOriginalName: DeviceOriginalName(cbjEntityName), - entityStateGRPC: EntityState(entityStateGRPC), - stateMassage: DeviceStateMassage(stateMassage), - senderDeviceOs: DeviceSenderDeviceOs(senderDeviceOs), - senderDeviceModel: DeviceSenderDeviceModel(senderDeviceModel), - senderId: DeviceSenderId.fromUniqueString(senderId), - deviceVendor: DeviceVendor(deviceVendor), - compUuid: DeviceCompUuid(compUuid), - lightSwitchState: GenericRgbwLightSwitchState(lightSwitchState), - lightColorTemperature: - GenericRgbwLightColorTemperature(lightColorTemperature), - lightBrightness: GenericRgbwLightBrightness(lightBrightness), - lightColorAlpha: GenericRgbwLightColorAlpha(lightColorAlpha), - lightColorHue: GenericRgbwLightColorHue(lightColorHue), - lightColorSaturation: - GenericRgbwLightColorSaturation(lightColorSaturation), - lightColorValue: GenericRgbwLightColorValue(lightColorValue), - powerConsumption: DevicePowerConsumption(powerConsumption), - deviceUniqueId: DeviceUniqueId(deviceUniqueId), - devicePort: DevicePort(devicePort), - deviceLastKnownIp: DeviceLastKnownIp(deviceLastKnownIp), - deviceHostName: DeviceHostName(deviceHostName), - deviceMdns: DeviceMdns(deviceMdns), - devicesMacAddress: DevicesMacAddress(devicesMacAddress), - entityKey: EntityKey(entityKey), - requestTimeStamp: RequestTimeStamp(requestTimeStamp), - lastResponseFromDeviceTimeStamp: - LastResponseFromDeviceTimeStamp(lastResponseFromDeviceTimeStamp), - deviceCbjUniqueId: CoreUniqueId.fromUniqueString(deviceCbjUniqueId!), - ); - } -} diff --git a/lib/infrastructure/generic_devices/generic_smart_computer_device/generic_smart_computer_device_dtos.dart b/lib/infrastructure/generic_devices/generic_smart_computer_device/generic_smart_computer_device_dtos.dart deleted file mode 100644 index 8bb10152..00000000 --- a/lib/infrastructure/generic_devices/generic_smart_computer_device/generic_smart_computer_device_dtos.dart +++ /dev/null @@ -1,126 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_computer_device/generic_smart_computer_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_computer_device/generic_smart_computer_value_objects.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'generic_smart_computer_device_dtos.freezed.dart'; -part 'generic_smart_computer_device_dtos.g.dart'; - -@freezed -abstract class GenericSmartComputerDeviceDtos - implements _$GenericSmartComputerDeviceDtos, DeviceEntityDtoAbstract { - factory GenericSmartComputerDeviceDtos({ - // @JsonKey(ignore: true) - required String id, - required String entityUniqueId, - required String? cbjEntityName, - required String? entityOriginalName, - required String? deviceOriginalName, - required String? entityStateGRPC, - required String? senderDeviceOs, - required String? senderDeviceModel, - required String? senderId, - required String? entityTypes, - required String? compUuid, - required String? deviceVendor, - required String? powerConsumption, - required String? deviceUniqueId, - required String? devicePort, - required String? deviceLastKnownIp, - required String? deviceHostName, - required String? deviceMdns, - required String? devicesMacAddress, - required String? entityKey, - required String? requestTimeStamp, - required String? lastResponseFromDeviceTimeStamp, - required String? deviceCbjUniqueId, - required String? smartComputerSuspendState, - required String? smartComputerShutDownState, - String? deviceDtoClass, - String? stateMassage, - - // required ServerTimestampConverter() FieldValue serverTimeStamp, - }) = _GenericSmartComputerDeviceDtos; - - GenericSmartComputerDeviceDtos._(); - - factory GenericSmartComputerDeviceDtos.fromDomain( - GenericSmartComputerDE deviceDe, - ) { - return GenericSmartComputerDeviceDtos( - deviceDtoClass: (GenericSmartComputerDeviceDtos).toString(), - id: deviceDe.uniqueId.getOrCrash(), - entityUniqueId: deviceDe.entityUniqueId.getOrCrash(), - cbjEntityName: deviceDe.cbjEntityName.getOrCrash(), - entityOriginalName: deviceDe.entityOriginalName.getOrCrash(), - deviceOriginalName: deviceDe.deviceOriginalName.getOrCrash(), - entityStateGRPC: deviceDe.entityStateGRPC.getOrCrash(), - stateMassage: deviceDe.stateMassage.getOrCrash(), - senderDeviceOs: deviceDe.senderDeviceOs.getOrCrash(), - senderDeviceModel: deviceDe.senderDeviceModel.getOrCrash(), - senderId: deviceDe.senderId.getOrCrash(), - smartComputerSuspendState: - deviceDe.smartComputerSuspendState!.getOrCrash(), - smartComputerShutDownState: - deviceDe.smartComputerShutDownState!.getOrCrash(), - entityTypes: deviceDe.entityTypes.getOrCrash(), - compUuid: deviceDe.compUuid.getOrCrash(), - deviceVendor: deviceDe.deviceVendor.getOrCrash(), - powerConsumption: deviceDe.powerConsumption.getOrCrash(), - deviceUniqueId: deviceDe.deviceUniqueId.getOrCrash(), - devicePort: deviceDe.devicePort.getOrCrash(), - deviceLastKnownIp: deviceDe.deviceLastKnownIp.getOrCrash(), - deviceHostName: deviceDe.deviceHostName.getOrCrash(), - deviceMdns: deviceDe.deviceMdns.getOrCrash(), - devicesMacAddress: deviceDe.devicesMacAddress.getOrCrash(), - entityKey: deviceDe.entityKey.getOrCrash(), - requestTimeStamp: deviceDe.requestTimeStamp.getOrCrash(), - lastResponseFromDeviceTimeStamp: - deviceDe.lastResponseFromDeviceTimeStamp.getOrCrash(), - deviceCbjUniqueId: deviceDe.deviceCbjUniqueId.getOrCrash(), - ); - } - - factory GenericSmartComputerDeviceDtos.fromJson(Map json) => - _$GenericSmartComputerDeviceDtosFromJson(json); - - @override - final String deviceDtoClassInstance = - (GenericSmartComputerDeviceDtos).toString(); - - @override - DeviceEntityAbstract toDomain() { - return GenericSmartComputerDE( - uniqueId: CoreUniqueId.fromUniqueString(id), - entityUniqueId: EntityUniqueId(entityUniqueId), - cbjEntityName: CbjEntityName(cbjEntityName), - entityOriginalName: EntityOriginalName(cbjEntityName), - deviceOriginalName: DeviceOriginalName(cbjEntityName), - entityStateGRPC: EntityState(entityStateGRPC), - stateMassage: DeviceStateMassage(stateMassage), - senderDeviceOs: DeviceSenderDeviceOs(senderDeviceOs), - senderDeviceModel: DeviceSenderDeviceModel(senderDeviceModel), - senderId: DeviceSenderId.fromUniqueString(senderId), - deviceVendor: DeviceVendor(deviceVendor), - compUuid: DeviceCompUuid(compUuid), - smartComputerSuspendState: - GenericSmartComputerSuspendState(smartComputerSuspendState), - smartComputerShutDownState: - GenericSmartComputerShutdownState(smartComputerShutDownState), - powerConsumption: DevicePowerConsumption(powerConsumption), - deviceUniqueId: DeviceUniqueId(deviceUniqueId), - devicePort: DevicePort(devicePort), - deviceLastKnownIp: DeviceLastKnownIp(deviceLastKnownIp), - deviceHostName: DeviceHostName(deviceHostName), - deviceMdns: DeviceMdns(deviceMdns), - devicesMacAddress: DevicesMacAddress(devicesMacAddress), - entityKey: EntityKey(entityKey), - requestTimeStamp: RequestTimeStamp(requestTimeStamp), - lastResponseFromDeviceTimeStamp: - LastResponseFromDeviceTimeStamp(lastResponseFromDeviceTimeStamp), - deviceCbjUniqueId: CoreUniqueId.fromUniqueString(deviceCbjUniqueId!), - ); - } -} diff --git a/lib/infrastructure/generic_devices/generic_smart_plug_device/generic_smart_plug_device_dtos.dart b/lib/infrastructure/generic_devices/generic_smart_plug_device/generic_smart_plug_device_dtos.dart deleted file mode 100644 index cee0f647..00000000 --- a/lib/infrastructure/generic_devices/generic_smart_plug_device/generic_smart_plug_device_dtos.dart +++ /dev/null @@ -1,118 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_plug_device/generic_smart_plug_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_plug_device/generic_smart_plug_value_objects.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'generic_smart_plug_device_dtos.freezed.dart'; -part 'generic_smart_plug_device_dtos.g.dart'; - -@freezed -abstract class GenericSmartPlugDeviceDtos - implements _$GenericSmartPlugDeviceDtos, DeviceEntityDtoAbstract { - factory GenericSmartPlugDeviceDtos({ - // @JsonKey(ignore: true) - required String id, - required String entityUniqueId, - required String? cbjEntityName, - required String? entityOriginalName, - required String? deviceOriginalName, - required String? entityStateGRPC, - required String? senderDeviceOs, - required String? senderDeviceModel, - required String? senderId, - required String? smartPlugState, - required String? entityTypes, - required String? compUuid, - required String? deviceVendor, - required String? powerConsumption, - required String? deviceUniqueId, - required String? devicePort, - required String? deviceLastKnownIp, - required String? deviceHostName, - required String? deviceMdns, - required String? devicesMacAddress, - required String? entityKey, - required String? requestTimeStamp, - required String? lastResponseFromDeviceTimeStamp, - required String? deviceCbjUniqueId, - String? deviceDtoClass, - String? stateMassage - // required ServerTimestampConverter() FieldValue serverTimeStamp, - , - }) = _GenericSmartPlugDeviceDtos; - - GenericSmartPlugDeviceDtos._(); - - factory GenericSmartPlugDeviceDtos.fromDomain( - GenericSmartPlugDE deviceDe, - ) { - return GenericSmartPlugDeviceDtos( - deviceDtoClass: (GenericSmartPlugDeviceDtos).toString(), - id: deviceDe.uniqueId.getOrCrash(), - entityUniqueId: deviceDe.entityUniqueId.getOrCrash(), - cbjEntityName: deviceDe.cbjEntityName.getOrCrash(), - entityOriginalName: deviceDe.entityOriginalName.getOrCrash(), - deviceOriginalName: deviceDe.deviceOriginalName.getOrCrash(), - entityStateGRPC: deviceDe.entityStateGRPC.getOrCrash(), - stateMassage: deviceDe.stateMassage.getOrCrash(), - senderDeviceOs: deviceDe.senderDeviceOs.getOrCrash(), - senderDeviceModel: deviceDe.senderDeviceModel.getOrCrash(), - senderId: deviceDe.senderId.getOrCrash(), - smartPlugState: deviceDe.smartPlugState!.getOrCrash(), - entityTypes: deviceDe.entityTypes.getOrCrash(), - compUuid: deviceDe.compUuid.getOrCrash(), - deviceVendor: deviceDe.deviceVendor.getOrCrash(), - powerConsumption: deviceDe.powerConsumption.getOrCrash(), - deviceUniqueId: deviceDe.deviceUniqueId.getOrCrash(), - devicePort: deviceDe.devicePort.getOrCrash(), - deviceLastKnownIp: deviceDe.deviceLastKnownIp.getOrCrash(), - deviceHostName: deviceDe.deviceHostName.getOrCrash(), - deviceMdns: deviceDe.deviceMdns.getOrCrash(), - devicesMacAddress: deviceDe.devicesMacAddress.getOrCrash(), - entityKey: deviceDe.entityKey.getOrCrash(), - requestTimeStamp: deviceDe.requestTimeStamp.getOrCrash(), - lastResponseFromDeviceTimeStamp: - deviceDe.lastResponseFromDeviceTimeStamp.getOrCrash(), - deviceCbjUniqueId: deviceDe.deviceCbjUniqueId.getOrCrash(), - ); - } - - factory GenericSmartPlugDeviceDtos.fromJson(Map json) => - _$GenericSmartPlugDeviceDtosFromJson(json); - - @override - final String deviceDtoClassInstance = (GenericSmartPlugDeviceDtos).toString(); - - @override - DeviceEntityAbstract toDomain() { - return GenericSmartPlugDE( - uniqueId: CoreUniqueId.fromUniqueString(id), - entityUniqueId: EntityUniqueId(entityUniqueId), - cbjEntityName: CbjEntityName(cbjEntityName), - entityOriginalName: EntityOriginalName(cbjEntityName), - deviceOriginalName: DeviceOriginalName(cbjEntityName), - entityStateGRPC: EntityState(entityStateGRPC), - stateMassage: DeviceStateMassage(stateMassage), - senderDeviceOs: DeviceSenderDeviceOs(senderDeviceOs), - senderDeviceModel: DeviceSenderDeviceModel(senderDeviceModel), - senderId: DeviceSenderId.fromUniqueString(senderId), - deviceVendor: DeviceVendor(deviceVendor), - compUuid: DeviceCompUuid(compUuid), - smartPlugState: GenericSmartPlugState(smartPlugState), - powerConsumption: DevicePowerConsumption(powerConsumption), - deviceUniqueId: DeviceUniqueId(deviceUniqueId), - devicePort: DevicePort(devicePort), - deviceLastKnownIp: DeviceLastKnownIp(deviceLastKnownIp), - deviceHostName: DeviceHostName(deviceHostName), - deviceMdns: DeviceMdns(deviceMdns), - devicesMacAddress: DevicesMacAddress(devicesMacAddress), - entityKey: EntityKey(entityKey), - requestTimeStamp: RequestTimeStamp(requestTimeStamp), - lastResponseFromDeviceTimeStamp: - LastResponseFromDeviceTimeStamp(lastResponseFromDeviceTimeStamp), - deviceCbjUniqueId: CoreUniqueId.fromUniqueString(deviceCbjUniqueId!), - ); - } -} diff --git a/lib/infrastructure/generic_devices/generic_smart_tv_device/generic_smart_tv_device_dtos.dart b/lib/infrastructure/generic_devices/generic_smart_tv_device/generic_smart_tv_device_dtos.dart deleted file mode 100644 index a8eb9c1d..00000000 --- a/lib/infrastructure/generic_devices/generic_smart_tv_device/generic_smart_tv_device_dtos.dart +++ /dev/null @@ -1,132 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_tv/generic_smart_tv_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_tv/generic_smart_tv_value_objects.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'generic_smart_tv_device_dtos.freezed.dart'; -part 'generic_smart_tv_device_dtos.g.dart'; - -@freezed -abstract class GenericSmartTvDeviceDtos - implements _$GenericSmartTvDeviceDtos, DeviceEntityDtoAbstract { - factory GenericSmartTvDeviceDtos({ - // @JsonKey(ignore: true) - required String id, - required String entityUniqueId, - required String? cbjEntityName, - required String? entityOriginalName, - required String? deviceOriginalName, - required String? entityStateGRPC, - required String? senderDeviceOs, - required String? senderDeviceModel, - required String? senderId, - required String? smartTvSwitchState, - required String? entityTypes, - required String? compUuid, - required String? deviceVendor, - required String? powerConsumption, - required String? deviceUniqueId, - required String? devicePort, - required String? deviceLastKnownIp, - required String? deviceHostName, - required String? deviceMdns, - required String? devicesMacAddress, - required String? entityKey, - required String? requestTimeStamp, - required String? lastResponseFromDeviceTimeStamp, - required String? deviceCbjUniqueId, - required String? openUrl, - required String? pausePlayState, - required String? skip, - required String? volume, - String? deviceDtoClass, - String? stateMassage - // required ServerTimestampConverter() FieldValue serverTimeStamp, - , - }) = _GenericSmartTvDeviceDtos; - - GenericSmartTvDeviceDtos._(); - - factory GenericSmartTvDeviceDtos.fromDomain( - GenericSmartTvDE deviceDe, - ) { - return GenericSmartTvDeviceDtos( - deviceDtoClass: (GenericSmartTvDeviceDtos).toString(), - id: deviceDe.uniqueId.getOrCrash(), - entityUniqueId: deviceDe.entityUniqueId.getOrCrash(), - cbjEntityName: deviceDe.cbjEntityName.getOrCrash(), - entityOriginalName: deviceDe.entityOriginalName.getOrCrash(), - deviceOriginalName: deviceDe.deviceOriginalName.getOrCrash(), - entityStateGRPC: deviceDe.entityStateGRPC.getOrCrash(), - stateMassage: deviceDe.stateMassage.getOrCrash(), - senderDeviceOs: deviceDe.senderDeviceOs.getOrCrash(), - senderDeviceModel: deviceDe.senderDeviceModel.getOrCrash(), - senderId: deviceDe.senderId.getOrCrash(), - smartTvSwitchState: deviceDe.smartTvSwitchState!.getOrCrash(), - entityTypes: deviceDe.entityTypes.getOrCrash(), - compUuid: deviceDe.compUuid.getOrCrash(), - deviceVendor: deviceDe.deviceVendor.getOrCrash(), - powerConsumption: deviceDe.powerConsumption.getOrCrash(), - deviceUniqueId: deviceDe.deviceUniqueId.getOrCrash(), - devicePort: deviceDe.devicePort.getOrCrash(), - deviceLastKnownIp: deviceDe.deviceLastKnownIp.getOrCrash(), - deviceHostName: deviceDe.deviceHostName.getOrCrash(), - deviceMdns: deviceDe.deviceMdns.getOrCrash(), - devicesMacAddress: deviceDe.devicesMacAddress.getOrCrash(), - entityKey: deviceDe.entityKey.getOrCrash(), - requestTimeStamp: deviceDe.requestTimeStamp.getOrCrash(), - lastResponseFromDeviceTimeStamp: - deviceDe.lastResponseFromDeviceTimeStamp.getOrCrash(), - openUrl: deviceDe.openUrl?.getOrCrash(), - pausePlayState: deviceDe.pausePlayState?.getOrCrash(), - skip: deviceDe.skip?.getOrCrash(), - volume: deviceDe.volume?.getOrCrash(), - deviceCbjUniqueId: deviceDe.deviceCbjUniqueId.getOrCrash(), - ); - } - - factory GenericSmartTvDeviceDtos.fromJson(Map json) => - _$GenericSmartTvDeviceDtosFromJson(json); - - @override - final String deviceDtoClassInstance = (GenericSmartTvDeviceDtos).toString(); - - @override - DeviceEntityAbstract toDomain() { - return GenericSmartTvDE( - uniqueId: CoreUniqueId.fromUniqueString(id), - entityUniqueId: EntityUniqueId(entityUniqueId), - cbjEntityName: CbjEntityName(cbjEntityName), - entityOriginalName: EntityOriginalName(cbjEntityName), - deviceOriginalName: DeviceOriginalName(cbjEntityName), - entityStateGRPC: EntityState(entityStateGRPC), - stateMassage: DeviceStateMassage(stateMassage), - senderDeviceOs: DeviceSenderDeviceOs(senderDeviceOs), - senderDeviceModel: DeviceSenderDeviceModel(senderDeviceModel), - senderId: DeviceSenderId.fromUniqueString(senderId), - deviceVendor: DeviceVendor(deviceVendor), - compUuid: DeviceCompUuid(compUuid), - smartTvSwitchState: GenericSmartTvSwitchState(smartTvSwitchState), - openUrl: openUrl == null ? null : GenericSmartTvOpenUrl(openUrl), - pausePlayState: pausePlayState == null - ? null - : GenericSmartTvPausePlayState(pausePlayState), - skip: skip == null ? null : GenericSmartTvSkipBackOrForward(skip), - volume: volume == null ? null : GenericSmartTvVolume(volume), - powerConsumption: DevicePowerConsumption(powerConsumption), - deviceUniqueId: DeviceUniqueId(deviceUniqueId), - devicePort: DevicePort(devicePort), - deviceLastKnownIp: DeviceLastKnownIp(deviceLastKnownIp), - deviceHostName: DeviceHostName(deviceHostName), - deviceMdns: DeviceMdns(deviceMdns), - devicesMacAddress: DevicesMacAddress(devicesMacAddress), - entityKey: EntityKey(entityKey), - requestTimeStamp: RequestTimeStamp(requestTimeStamp), - lastResponseFromDeviceTimeStamp: - LastResponseFromDeviceTimeStamp(lastResponseFromDeviceTimeStamp), - deviceCbjUniqueId: CoreUniqueId.fromUniqueString(deviceCbjUniqueId!), - ); - } -} diff --git a/lib/infrastructure/generic_devices/generic_smart_type_type_not_supported_device/generic_smart_type_not_supported_device_dtos.dart b/lib/infrastructure/generic_devices/generic_smart_type_type_not_supported_device/generic_smart_type_not_supported_device_dtos.dart deleted file mode 100644 index a64cfd9e..00000000 --- a/lib/infrastructure/generic_devices/generic_smart_type_type_not_supported_device/generic_smart_type_not_supported_device_dtos.dart +++ /dev/null @@ -1,119 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_type_not_supported_device/generic_smart_type_not_supported_entity.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'generic_smart_type_not_supported_device_dtos.freezed.dart'; -part 'generic_smart_type_not_supported_device_dtos.g.dart'; - -@freezed -abstract class GenericSmartTypeNotSupportedDeviceDtos - implements - _$GenericSmartTypeNotSupportedDeviceDtos, - DeviceEntityDtoAbstract { - factory GenericSmartTypeNotSupportedDeviceDtos({ - // @JsonKey(ignore: true) - required String id, - required String entityUniqueId, - required String? cbjEntityName, - required String? entityOriginalName, - required String? deviceOriginalName, - required String? entityStateGRPC, - required String? senderDeviceOs, - required String? senderDeviceModel, - required String? senderId, - required String? entityTypes, - required String? compUuid, - required String? deviceVendor, - required String? powerConsumption, - required String? deviceUniqueId, - required String? devicePort, - required String? deviceLastKnownIp, - required String? deviceHostName, - required String? deviceMdns, - required String? devicesMacAddress, - required String? entityKey, - required String? requestTimeStamp, - required String? lastResponseFromDeviceTimeStamp, - required String? deviceCbjUniqueId, - String? deviceDtoClass, - String? stateMassage, - - // required ServerTimestampConverter() FieldValue serverTimeStamp, - }) = _GenericSmartTypeNotSupportedDeviceDtos; - - GenericSmartTypeNotSupportedDeviceDtos._(); - - factory GenericSmartTypeNotSupportedDeviceDtos.fromDomain( - GenericSmartTypeNotSupportedDE deviceDe, - ) { - return GenericSmartTypeNotSupportedDeviceDtos( - deviceDtoClass: (GenericSmartTypeNotSupportedDeviceDtos).toString(), - id: deviceDe.uniqueId.getOrCrash(), - entityUniqueId: deviceDe.entityUniqueId.getOrCrash(), - cbjEntityName: deviceDe.cbjEntityName.getOrCrash(), - entityOriginalName: deviceDe.entityOriginalName.getOrCrash(), - deviceOriginalName: deviceDe.deviceOriginalName.getOrCrash(), - entityStateGRPC: deviceDe.entityStateGRPC.getOrCrash(), - stateMassage: deviceDe.stateMassage.getOrCrash(), - senderDeviceOs: deviceDe.senderDeviceOs.getOrCrash(), - senderDeviceModel: deviceDe.senderDeviceModel.getOrCrash(), - senderId: deviceDe.senderId.getOrCrash(), - entityTypes: deviceDe.entityTypes.getOrCrash(), - compUuid: deviceDe.compUuid.getOrCrash(), - deviceVendor: deviceDe.deviceVendor.getOrCrash(), - powerConsumption: deviceDe.powerConsumption.getOrCrash(), - deviceUniqueId: deviceDe.deviceUniqueId.getOrCrash(), - devicePort: deviceDe.devicePort.getOrCrash(), - deviceLastKnownIp: deviceDe.deviceLastKnownIp.getOrCrash(), - deviceHostName: deviceDe.deviceHostName.getOrCrash(), - deviceMdns: deviceDe.deviceMdns.getOrCrash(), - devicesMacAddress: deviceDe.devicesMacAddress.getOrCrash(), - entityKey: deviceDe.entityKey.getOrCrash(), - requestTimeStamp: deviceDe.requestTimeStamp.getOrCrash(), - lastResponseFromDeviceTimeStamp: - deviceDe.lastResponseFromDeviceTimeStamp.getOrCrash(), - deviceCbjUniqueId: deviceDe.deviceCbjUniqueId.getOrCrash(), - ); - } - - factory GenericSmartTypeNotSupportedDeviceDtos.fromJson( - Map json, - ) => - _$GenericSmartTypeNotSupportedDeviceDtosFromJson(json); - - @override - final String deviceDtoClassInstance = - (GenericSmartTypeNotSupportedDeviceDtos).toString(); - - @override - DeviceEntityAbstract toDomain() { - return GenericSmartTypeNotSupportedDE( - uniqueId: CoreUniqueId.fromUniqueString(id), - entityUniqueId: EntityUniqueId(entityUniqueId), - cbjEntityName: CbjEntityName(cbjEntityName), - entityOriginalName: EntityOriginalName(cbjEntityName), - deviceOriginalName: DeviceOriginalName(cbjEntityName), - entityStateGRPC: EntityState(entityStateGRPC), - stateMassage: DeviceStateMassage(stateMassage), - senderDeviceOs: DeviceSenderDeviceOs(senderDeviceOs), - senderDeviceModel: DeviceSenderDeviceModel(senderDeviceModel), - senderId: DeviceSenderId.fromUniqueString(senderId), - deviceVendor: DeviceVendor(deviceVendor), - compUuid: DeviceCompUuid(compUuid), - powerConsumption: DevicePowerConsumption(powerConsumption), - deviceUniqueId: DeviceUniqueId(deviceUniqueId), - devicePort: DevicePort(devicePort), - deviceLastKnownIp: DeviceLastKnownIp(deviceLastKnownIp), - deviceHostName: DeviceHostName(deviceHostName), - deviceMdns: DeviceMdns(deviceMdns), - devicesMacAddress: DevicesMacAddress(devicesMacAddress), - entityKey: EntityKey(entityKey), - requestTimeStamp: RequestTimeStamp(requestTimeStamp), - lastResponseFromDeviceTimeStamp: - LastResponseFromDeviceTimeStamp(lastResponseFromDeviceTimeStamp), - deviceCbjUniqueId: CoreUniqueId.fromUniqueString(deviceCbjUniqueId!), - ); - } -} diff --git a/lib/infrastructure/generic_devices/generic_switch_device/generic_switch_device_dtos.dart b/lib/infrastructure/generic_devices/generic_switch_device/generic_switch_device_dtos.dart deleted file mode 100644 index 7830187a..00000000 --- a/lib/infrastructure/generic_devices/generic_switch_device/generic_switch_device_dtos.dart +++ /dev/null @@ -1,116 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_value_objects.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'generic_switch_device_dtos.freezed.dart'; -part 'generic_switch_device_dtos.g.dart'; - -@freezed -abstract class GenericSwitchDeviceDtos - implements _$GenericSwitchDeviceDtos, DeviceEntityDtoAbstract { - factory GenericSwitchDeviceDtos({ - // @JsonKey(ignore: true) - required String id, - required String entityUniqueId, - required String? cbjEntityName, - required String? entityOriginalName, - required String? deviceOriginalName, - required String? entityStateGRPC, - required String? senderDeviceOs, - required String? senderDeviceModel, - required String? senderId, - required String? switchState, - required String? entityTypes, - required String? compUuid, - required String? deviceVendor, - required String? powerConsumption, - required String? deviceUniqueId, - required String? devicePort, - required String? deviceLastKnownIp, - required String? deviceHostName, - required String? deviceMdns, - required String? devicesMacAddress, - required String? entityKey, - required String? requestTimeStamp, - required String? lastResponseFromDeviceTimeStamp, - required String? deviceCbjUniqueId, - String? deviceDtoClass, - String? stateMassage, - - // required ServerTimestampConverter() FieldValue serverTimeStamp, - }) = _GenericSwitchDeviceDtos; - - GenericSwitchDeviceDtos._(); - - factory GenericSwitchDeviceDtos.fromDomain(GenericSwitchDE deviceDe) { - return GenericSwitchDeviceDtos( - deviceDtoClass: (GenericSwitchDeviceDtos).toString(), - id: deviceDe.uniqueId.getOrCrash(), - entityUniqueId: deviceDe.entityUniqueId.getOrCrash(), - cbjEntityName: deviceDe.cbjEntityName.getOrCrash(), - entityOriginalName: deviceDe.entityOriginalName.getOrCrash(), - deviceOriginalName: deviceDe.deviceOriginalName.getOrCrash(), - entityStateGRPC: deviceDe.entityStateGRPC.getOrCrash(), - stateMassage: deviceDe.stateMassage.getOrCrash(), - senderDeviceOs: deviceDe.senderDeviceOs.getOrCrash(), - senderDeviceModel: deviceDe.senderDeviceModel.getOrCrash(), - senderId: deviceDe.senderId.getOrCrash(), - switchState: deviceDe.switchState!.getOrCrash(), - entityTypes: deviceDe.entityTypes.getOrCrash(), - compUuid: deviceDe.compUuid.getOrCrash(), - deviceVendor: deviceDe.deviceVendor.getOrCrash(), - powerConsumption: deviceDe.powerConsumption.getOrCrash(), - deviceUniqueId: deviceDe.deviceUniqueId.getOrCrash(), - devicePort: deviceDe.devicePort.getOrCrash(), - deviceLastKnownIp: deviceDe.deviceLastKnownIp.getOrCrash(), - deviceHostName: deviceDe.deviceHostName.getOrCrash(), - deviceMdns: deviceDe.deviceMdns.getOrCrash(), - devicesMacAddress: deviceDe.devicesMacAddress.getOrCrash(), - entityKey: deviceDe.entityKey.getOrCrash(), - requestTimeStamp: deviceDe.requestTimeStamp.getOrCrash(), - lastResponseFromDeviceTimeStamp: - deviceDe.lastResponseFromDeviceTimeStamp.getOrCrash(), - deviceCbjUniqueId: deviceDe.deviceCbjUniqueId.getOrCrash(), - ); - } - - factory GenericSwitchDeviceDtos.fromJson(Map json) => - _$GenericSwitchDeviceDtosFromJson(json); - - @override - final String deviceDtoClassInstance = (GenericSwitchDeviceDtos).toString(); - - @override - DeviceEntityAbstract toDomain() { - return GenericSwitchDE( - uniqueId: CoreUniqueId.fromUniqueString(id), - entityUniqueId: EntityUniqueId(entityUniqueId), - cbjEntityName: CbjEntityName(cbjEntityName), - entityOriginalName: EntityOriginalName(cbjEntityName), - deviceOriginalName: DeviceOriginalName(cbjEntityName), - entityStateGRPC: EntityState(entityStateGRPC), - stateMassage: DeviceStateMassage(stateMassage), - senderDeviceOs: DeviceSenderDeviceOs(senderDeviceOs), - senderDeviceModel: DeviceSenderDeviceModel(senderDeviceModel), - senderId: DeviceSenderId.fromUniqueString(senderId), - deviceVendor: DeviceVendor(deviceVendor), - compUuid: DeviceCompUuid(compUuid), - switchState: GenericSwitchSwitchState(switchState), - powerConsumption: DevicePowerConsumption(powerConsumption), - deviceUniqueId: DeviceUniqueId(deviceUniqueId), - devicePort: DevicePort(devicePort), - deviceLastKnownIp: DeviceLastKnownIp(deviceLastKnownIp), - deviceHostName: DeviceHostName(deviceHostName), - deviceMdns: DeviceMdns(deviceMdns), - devicesMacAddress: DevicesMacAddress(devicesMacAddress), - entityKey: EntityKey(entityKey), - requestTimeStamp: RequestTimeStamp(requestTimeStamp), - lastResponseFromDeviceTimeStamp: - LastResponseFromDeviceTimeStamp(lastResponseFromDeviceTimeStamp), - deviceCbjUniqueId: CoreUniqueId.fromUniqueString(deviceCbjUniqueId!), - ); - } -} diff --git a/lib/infrastructure/generic_vendors_login/generic_esphome_login/generic_esphome_login_dtos.dart b/lib/infrastructure/generic_vendors_login/generic_esphome_login/generic_esphome_login_dtos.dart deleted file mode 100644 index 7deb571f..00000000 --- a/lib/infrastructure/generic_vendors_login/generic_esphome_login/generic_esphome_login_dtos.dart +++ /dev/null @@ -1,59 +0,0 @@ -import 'package:cbj_hub/domain/vendors/esphome_login/generic_esphome_login_entity.dart'; -import 'package:cbj_hub/domain/vendors/esphome_login/generic_esphome_login_value_objects.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/login_entity_abstract.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/value_login_objects_core.dart'; -import 'package:cbj_hub/infrastructure/generic_vendors_login/generic_login_abstract/login_entity_dto_abstract.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'generic_esphome_login_dtos.freezed.dart'; -part 'generic_esphome_login_dtos.g.dart'; - -@freezed -abstract class GenericEspHomeLoginDtos - implements _$GenericEspHomeLoginDtos, LoginEntityDtoAbstract { - factory GenericEspHomeLoginDtos({ - // @JsonKey(ignore: true) - required String? senderUniqueId, - required String? loginVendor, - required String? esphomeDevicePass, - // required ServerTimestampConverter() FieldValue serverTimeStamp, - }) = _GenericEspHomeLoginDtos; - - GenericEspHomeLoginDtos._(); - - factory GenericEspHomeLoginDtos.fromDomain( - GenericEspHomeLoginDE genericEspHomeDE, - ) { - return GenericEspHomeLoginDtos( - senderUniqueId: genericEspHomeDE.senderUniqueId.getOrCrash(), - loginVendor: genericEspHomeDE.loginVendor.getOrCrash(), - esphomeDevicePass: genericEspHomeDE.espHomeDevicePass.getOrCrash(), - ); - } - - factory GenericEspHomeLoginDtos.fromJson(Map json) => - _$GenericEspHomeLoginDtosFromJson(json); - - @override - final String loginDtoClassInstance = (GenericEspHomeLoginDtos).toString(); - - @override - LoginEntityAbstract toDomain() { - return GenericEspHomeLoginDE( - senderUniqueId: CoreLoginSenderId.fromUniqueString(senderUniqueId), - espHomeDevicePass: GenericEspHomeDeviceLoginApiPass(esphomeDevicePass), - ); - } -} - -// class ServerTimestampConverter implements JsonConverter { -// const ServerTimestampConverter(); -// -// @override -// FieldValue fromJson(Object json) { -// return FieldValue.serverTimestamp(); -// } -// -// @override -// Object toJson(FieldValue fieldValue) => fieldValue; -// } diff --git a/lib/infrastructure/generic_vendors_login/generic_ewelink_login/generic_ewelink_login_dtos.dart b/lib/infrastructure/generic_vendors_login/generic_ewelink_login/generic_ewelink_login_dtos.dart deleted file mode 100644 index 77d31523..00000000 --- a/lib/infrastructure/generic_vendors_login/generic_ewelink_login/generic_ewelink_login_dtos.dart +++ /dev/null @@ -1,63 +0,0 @@ -import 'package:cbj_hub/domain/vendors/ewelink_login/generic_ewelink_login_entity.dart'; -import 'package:cbj_hub/domain/vendors/ewelink_login/generic_ewelink_login_value_objects.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/login_entity_abstract.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/value_login_objects_core.dart'; -import 'package:cbj_hub/infrastructure/generic_vendors_login/generic_login_abstract/login_entity_dto_abstract.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'generic_ewelink_login_dtos.freezed.dart'; -part 'generic_ewelink_login_dtos.g.dart'; - -@freezed -abstract class GenericEwelinkLoginDtos - implements _$GenericEwelinkLoginDtos, LoginEntityDtoAbstract { - factory GenericEwelinkLoginDtos({ - // @JsonKey(ignore: true) - required String? senderUniqueId, - required String? loginVendor, - required String? ewelinkAccountEmail, - required String? ewelinkAccountPass, - - // required ServerTimestampConverter() FieldValue serverTimeStamp, - }) = _GenericEwelinkLoginDtos; - - GenericEwelinkLoginDtos._(); - - factory GenericEwelinkLoginDtos.fromDomain( - GenericEwelinkLoginDE genericEwelinkDE, - ) { - return GenericEwelinkLoginDtos( - senderUniqueId: genericEwelinkDE.senderUniqueId.getOrCrash(), - loginVendor: genericEwelinkDE.loginVendor.getOrCrash(), - ewelinkAccountEmail: genericEwelinkDE.ewelinkAccountEmail.getOrCrash(), - ewelinkAccountPass: genericEwelinkDE.ewelinkAccountPass.getOrCrash(), - ); - } - - factory GenericEwelinkLoginDtos.fromJson(Map json) => - _$GenericEwelinkLoginDtosFromJson(json); - - @override - final String loginDtoClassInstance = (GenericEwelinkLoginDtos).toString(); - - @override - LoginEntityAbstract toDomain() { - return GenericEwelinkLoginDE( - senderUniqueId: CoreLoginSenderId.fromUniqueString(senderUniqueId), - ewelinkAccountEmail: GenericEwelinkAccountEmail(ewelinkAccountEmail), - ewelinkAccountPass: GenericEwelinkAccountPass(ewelinkAccountPass), - ); - } -} - -// class ServerTimestampConverter implements JsonConverter { -// const ServerTimestampConverter(); -// -// @override -// FieldValue fromJson(Object json) { -// return FieldValue.serverTimestamp(); -// } -// -// @override -// Object toJson(FieldValue fieldValue) => fieldValue; -// } diff --git a/lib/infrastructure/generic_vendors_login/generic_lifx_login/generic_lifx_login_dtos.dart b/lib/infrastructure/generic_vendors_login/generic_lifx_login/generic_lifx_login_dtos.dart deleted file mode 100644 index 2afccc2a..00000000 --- a/lib/infrastructure/generic_vendors_login/generic_lifx_login/generic_lifx_login_dtos.dart +++ /dev/null @@ -1,57 +0,0 @@ -import 'package:cbj_hub/domain/vendors/lifx_login/generic_lifx_login_entity.dart'; -import 'package:cbj_hub/domain/vendors/lifx_login/generic_lifx_login_value_objects.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/login_entity_abstract.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/value_login_objects_core.dart'; -import 'package:cbj_hub/infrastructure/generic_vendors_login/generic_login_abstract/login_entity_dto_abstract.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'generic_lifx_login_dtos.freezed.dart'; -part 'generic_lifx_login_dtos.g.dart'; - -@freezed -abstract class GenericLifxLoginDtos - implements _$GenericLifxLoginDtos, LoginEntityDtoAbstract { - factory GenericLifxLoginDtos({ - // @JsonKey(ignore: true) - required String? senderUniqueId, - required String? loginVendor, - required String? lifxApiKey, - // required ServerTimestampConverter() FieldValue serverTimeStamp, - }) = _GenericLifxLoginDtos; - - GenericLifxLoginDtos._(); - - factory GenericLifxLoginDtos.fromDomain(GenericLifxLoginDE genericLifxDE) { - return GenericLifxLoginDtos( - senderUniqueId: genericLifxDE.senderUniqueId.getOrCrash(), - loginVendor: genericLifxDE.loginVendor.getOrCrash(), - lifxApiKey: genericLifxDE.lifxApiKey.getOrCrash(), - ); - } - - factory GenericLifxLoginDtos.fromJson(Map json) => - _$GenericLifxLoginDtosFromJson(json); - - @override - final String loginDtoClassInstance = (GenericLifxLoginDtos).toString(); - - @override - LoginEntityAbstract toDomain() { - return GenericLifxLoginDE( - senderUniqueId: CoreLoginSenderId.fromUniqueString(senderUniqueId), - lifxApiKey: GenericLifxLoginApiKey(lifxApiKey), - ); - } -} - -// class ServerTimestampConverter implements JsonConverter { -// const ServerTimestampConverter(); -// -// @override -// FieldValue fromJson(Object json) { -// return FieldValue.serverTimestamp(); -// } -// -// @override -// Object toJson(FieldValue fieldValue) => fieldValue; -// } diff --git a/lib/infrastructure/generic_vendors_login/generic_login_abstract/login_entity_dto_abstract.dart b/lib/infrastructure/generic_vendors_login/generic_login_abstract/login_entity_dto_abstract.dart deleted file mode 100644 index c3c8ca56..00000000 --- a/lib/infrastructure/generic_vendors_login/generic_login_abstract/login_entity_dto_abstract.dart +++ /dev/null @@ -1,52 +0,0 @@ -import 'package:cbj_hub/domain/vendors/login_abstract/login_entity_abstract.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/generic_vendors_login/generic_esphome_login/generic_esphome_login_dtos.dart'; -import 'package:cbj_hub/infrastructure/generic_vendors_login/generic_ewelink_login/generic_ewelink_login_dtos.dart'; -import 'package:cbj_hub/infrastructure/generic_vendors_login/generic_lifx_login/generic_lifx_login_dtos.dart'; -import 'package:cbj_hub/infrastructure/generic_vendors_login/generic_tuya_login/generic_tuya_login_dtos.dart'; -import 'package:cbj_hub/infrastructure/generic_vendors_login/generic_xiaomi_mi_login/generic_xiaomi_mi_login_dtos.dart'; -import 'package:cbj_hub/utils.dart'; - -class LoginEntityDtoAbstract { - LoginEntityDtoAbstract(); - - factory LoginEntityDtoAbstract.fromDomain() { - logger.t('LoginEntityDtoAbstract.fromDomain'); - return LoginEntityDtoAbstract(); - } - - factory LoginEntityDtoAbstract.fromJson(Map json) { - LoginEntityDtoAbstract loginEntityDtoAbstract = LoginEntityDtoAbstract(); - final String jsonLoginDtoClass = json['loginVendor'].toString(); - - if (jsonLoginDtoClass == VendorsAndServices.lifx.toString()) { - loginEntityDtoAbstract = GenericLifxLoginDtos.fromJson(json); - } else if (jsonLoginDtoClass == VendorsAndServices.espHome.toString()) { - loginEntityDtoAbstract = GenericEspHomeLoginDtos.fromJson(json); - } else if (jsonLoginDtoClass == VendorsAndServices.tuyaSmart.toString() || - jsonLoginDtoClass == VendorsAndServices.smartLife.toString() || - jsonLoginDtoClass == VendorsAndServices.jinvooSmart.toString()) { - loginEntityDtoAbstract = GenericTuyaLoginDtos.fromJson(json); - } else if (jsonLoginDtoClass == VendorsAndServices.xiaomiMi.toString()) { - loginEntityDtoAbstract = GenericXiaomiMiLoginDtos.fromJson(json); - } else if (jsonLoginDtoClass == - VendorsAndServices.sonoffEweLink.toString()) { - loginEntityDtoAbstract = GenericEwelinkLoginDtos.fromJson(json); - } else { - throw 'DtoClassTypeDoesNotExist'; - } - return loginEntityDtoAbstract; - } - - final String loginDtoClassInstance = (LoginEntityDtoAbstract).toString(); - - Map toJson() { - logger.t('LoginEntityDtoAbstract to Json'); - return {}; - } - - LoginEntityAbstract toDomain() { - logger.t('ToDomain'); - return LoginEntityEmpty(); - } -} diff --git a/lib/infrastructure/generic_vendors_login/generic_tuya_login/generic_tuya_login_dtos.dart b/lib/infrastructure/generic_vendors_login/generic_tuya_login/generic_tuya_login_dtos.dart deleted file mode 100644 index 4cd9ebe0..00000000 --- a/lib/infrastructure/generic_vendors_login/generic_tuya_login/generic_tuya_login_dtos.dart +++ /dev/null @@ -1,70 +0,0 @@ -import 'package:cbj_hub/domain/vendors/login_abstract/login_entity_abstract.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/value_login_objects_core.dart'; -import 'package:cbj_hub/domain/vendors/tuya_login/generic_tuya_login_entity.dart'; -import 'package:cbj_hub/domain/vendors/tuya_login/generic_tuya_login_value_objects.dart'; -import 'package:cbj_hub/infrastructure/generic_vendors_login/generic_login_abstract/login_entity_dto_abstract.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'generic_tuya_login_dtos.freezed.dart'; -part 'generic_tuya_login_dtos.g.dart'; - -@freezed -abstract class GenericTuyaLoginDtos - implements _$GenericTuyaLoginDtos, LoginEntityDtoAbstract { - factory GenericTuyaLoginDtos({ - // @JsonKey(ignore: true) - required String? senderUniqueId, - required String? loginVendor, - required String? userName, - required String? userPassword, - required String? countryCode, - required String? bizType, - required String? region, - // required ServerTimestampConverter() FieldValue serverTimeStamp, - }) = _GenericTuyaLoginDtos; - - GenericTuyaLoginDtos._(); - - factory GenericTuyaLoginDtos.fromDomain(GenericTuyaLoginDE genericTuyaDE) { - return GenericTuyaLoginDtos( - senderUniqueId: genericTuyaDE.senderUniqueId.getOrCrash(), - loginVendor: genericTuyaDE.loginVendor.getOrCrash(), - userName: genericTuyaDE.tuyaUserName.getOrCrash(), - userPassword: genericTuyaDE.tuyaUserPassword.getOrCrash(), - countryCode: genericTuyaDE.tuyaCountryCode.getOrCrash(), - bizType: genericTuyaDE.tuyaBizType.getOrCrash(), - region: genericTuyaDE.tuyaRegion.getOrCrash(), - ); - } - - factory GenericTuyaLoginDtos.fromJson(Map json) => - _$GenericTuyaLoginDtosFromJson(json); - - @override - final String loginDtoClassInstance = (GenericTuyaLoginDtos).toString(); - - @override - LoginEntityAbstract toDomain() { - return GenericTuyaLoginDE( - senderUniqueId: CoreLoginSenderId.fromUniqueString(senderUniqueId), - loginVendor: CoreLoginVendor(loginVendor), - tuyaUserName: GenericTuyaLoginUserName(userName), - tuyaUserPassword: GenericTuyaLoginUserPassword(userPassword), - tuyaCountryCode: GenericTuyaLoginCountryCode(countryCode), - tuyaBizType: GenericTuyaLoginBizType(bizType), - tuyaRegion: GenericTuyaLoginRegion(region), - ); - } -} - -// class ServerTimestampConverter implements JsonConverter { -// const ServerTimestampConverter(); -// -// @override -// FieldValue fromJson(Object json) { -// return FieldValue.serverTimestamp(); -// } -// -// @override -// Object toJson(FieldValue fieldValue) => fieldValue; -// } diff --git a/lib/infrastructure/generic_vendors_login/generic_wiz_login/generic_wiz_login_dtos.dart b/lib/infrastructure/generic_vendors_login/generic_wiz_login/generic_wiz_login_dtos.dart deleted file mode 100644 index 545b0a97..00000000 --- a/lib/infrastructure/generic_vendors_login/generic_wiz_login/generic_wiz_login_dtos.dart +++ /dev/null @@ -1,57 +0,0 @@ -import 'package:cbj_hub/domain/vendors/login_abstract/login_entity_abstract.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/value_login_objects_core.dart'; -import 'package:cbj_hub/domain/vendors/wiz_login/generic_wiz_login_entity.dart'; -import 'package:cbj_hub/domain/vendors/wiz_login/generic_wiz_login_value_objects.dart'; -import 'package:cbj_hub/infrastructure/generic_vendors_login/generic_login_abstract/login_entity_dto_abstract.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'generic_wiz_login_dtos.freezed.dart'; -part 'generic_wiz_login_dtos.g.dart'; - -@freezed -abstract class GenericWizLoginDtos - implements _$GenericWizLoginDtos, LoginEntityDtoAbstract { - factory GenericWizLoginDtos({ - // @JsonKey(ignore: true) - required String? senderUniqueId, - required String? loginVendor, - required String? wizApiKey, - // required ServerTimestampConverter() FieldValue serverTimeStamp, - }) = _GenericWizLoginDtos; - - GenericWizLoginDtos._(); - - factory GenericWizLoginDtos.fromDomain(GenericWizLoginDE genericWizDE) { - return GenericWizLoginDtos( - senderUniqueId: genericWizDE.senderUniqueId.getOrCrash(), - loginVendor: genericWizDE.loginVendor.getOrCrash(), - wizApiKey: genericWizDE.wizApiKey.getOrCrash(), - ); - } - - factory GenericWizLoginDtos.fromJson(Map json) => - _$GenericWizLoginDtosFromJson(json); - - @override - final String loginDtoClassInstance = (GenericWizLoginDtos).toString(); - - @override - LoginEntityAbstract toDomain() { - return GenericWizLoginDE( - senderUniqueId: CoreLoginSenderId.fromUniqueString(senderUniqueId), - wizApiKey: GenericWizLoginApiKey(wizApiKey), - ); - } -} - -// class ServerTimestampConverter implements JsonConverter { -// const ServerTimestampConverter(); -// -// @override -// FieldValue fromJson(Object json) { -// return FieldValue.serverTimestamp(); -// } -// -// @override -// Object toJson(FieldValue fieldValue) => fieldValue; -// } diff --git a/lib/infrastructure/generic_vendors_login/generic_xiaomi_mi_login/generic_xiaomi_mi_login_dtos.dart b/lib/infrastructure/generic_vendors_login/generic_xiaomi_mi_login/generic_xiaomi_mi_login_dtos.dart deleted file mode 100644 index da731ef5..00000000 --- a/lib/infrastructure/generic_vendors_login/generic_xiaomi_mi_login/generic_xiaomi_mi_login_dtos.dart +++ /dev/null @@ -1,63 +0,0 @@ -import 'package:cbj_hub/domain/vendors/login_abstract/login_entity_abstract.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/value_login_objects_core.dart'; -import 'package:cbj_hub/domain/vendors/xiaomi_mi_login/generic_xiaomi_mi_login_entity.dart'; -import 'package:cbj_hub/domain/vendors/xiaomi_mi_login/generic_xiaomi_mi_login_value_objects.dart'; -import 'package:cbj_hub/infrastructure/generic_vendors_login/generic_login_abstract/login_entity_dto_abstract.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'generic_xiaomi_mi_login_dtos.freezed.dart'; -part 'generic_xiaomi_mi_login_dtos.g.dart'; - -@freezed -abstract class GenericXiaomiMiLoginDtos - implements _$GenericXiaomiMiLoginDtos, LoginEntityDtoAbstract { - factory GenericXiaomiMiLoginDtos({ - // @JsonKey(ignore: true) - required String? senderUniqueId, - required String? loginVendor, - required String? xiaomiMiAccountEmail, - required String? xiaomiMiAccountPass, - - // required ServerTimestampConverter() FieldValue serverTimeStamp, - }) = _GenericXiaomiMiLoginDtos; - - GenericXiaomiMiLoginDtos._(); - - factory GenericXiaomiMiLoginDtos.fromDomain( - GenericXiaomiMiLoginDE genericXiaomiMiDE, - ) { - return GenericXiaomiMiLoginDtos( - senderUniqueId: genericXiaomiMiDE.senderUniqueId.getOrCrash(), - loginVendor: genericXiaomiMiDE.loginVendor.getOrCrash(), - xiaomiMiAccountEmail: genericXiaomiMiDE.xiaomiMiAccountEmail.getOrCrash(), - xiaomiMiAccountPass: genericXiaomiMiDE.xiaomiMiAccountPass.getOrCrash(), - ); - } - - factory GenericXiaomiMiLoginDtos.fromJson(Map json) => - _$GenericXiaomiMiLoginDtosFromJson(json); - - @override - final String loginDtoClassInstance = (GenericXiaomiMiLoginDtos).toString(); - - @override - LoginEntityAbstract toDomain() { - return GenericXiaomiMiLoginDE( - senderUniqueId: CoreLoginSenderId.fromUniqueString(senderUniqueId), - xiaomiMiAccountEmail: GenericXiaomiMiAccountEmail(xiaomiMiAccountEmail), - xiaomiMiAccountPass: GenericXiaomiMiAccountPass(xiaomiMiAccountPass), - ); - } -} - -// class ServerTimestampConverter implements JsonConverter { -// const ServerTimestampConverter(); -// -// @override -// FieldValue fromJson(Object json) { -// return FieldValue.serverTimestamp(); -// } -// -// @override -// Object toJson(FieldValue fieldValue) => fieldValue; -// } diff --git a/lib/infrastructure/generic_vendors_login/vendor_helper.dart b/lib/infrastructure/generic_vendors_login/vendor_helper.dart deleted file mode 100644 index baf097b5..00000000 --- a/lib/infrastructure/generic_vendors_login/vendor_helper.dart +++ /dev/null @@ -1,62 +0,0 @@ -import 'dart:convert'; - -import 'package:cbj_hub/domain/vendors/login_abstract/login_entity_abstract.dart'; -import 'package:cbj_hub/infrastructure/generic_vendors_login/generic_login_abstract/login_entity_dto_abstract.dart'; - -class VendorHelper { - /// Dto to json - static Map convertDtoToJson( - LoginEntityDtoAbstract loginEntityDto, - ) { - return loginEntityDto.toJson(); - } - - /// json to Dto - static LoginEntityDtoAbstract convertJsonToDto(Map json) { - return LoginEntityDtoAbstract.fromJson(json); - } - - /// json to json string - static String convertJsonToJsonString(Map json) { - return jsonEncode(json); - } - - /// string json to json - static Map convertJsonStringToJson(String jsonString) { - return jsonDecode(jsonString) as Map; - } - - /// Device entity to dto - static LoginEntityDtoAbstract convertDomainToDto( - LoginEntityAbstract loginEntity, - ) { - return loginEntity.toInfrastructure(); - } - - /// Dto to login entity - static LoginEntityAbstract convertDtoToDomain( - LoginEntityDtoAbstract loginEntityDto, - ) { - return loginEntityDto.toDomain(); - } - - // Extras methods - - static String convertDtoToJsonString( - LoginEntityDtoAbstract loginEntityDto, - ) { - return convertJsonToJsonString(convertDtoToJson(loginEntityDto)); - } - - static LoginEntityAbstract convertJsonStringToDomain(String jsonString) { - return convertDtoToDomain( - convertJsonToDto(convertJsonStringToJson(jsonString)), - ); - } - - static String convertDomainToJsonString(LoginEntityAbstract loginEntity) { - return convertJsonToJsonString( - convertDtoToJson(convertDomainToDto(loginEntity)), - ); - } -} diff --git a/lib/infrastructure/local_db/hive_objects/bindings_hive_model.dart b/lib/infrastructure/local_db/hive_objects/bindings_hive_model.dart deleted file mode 100644 index c4b310f1..00000000 --- a/lib/infrastructure/local_db/hive_objects/bindings_hive_model.dart +++ /dev/null @@ -1,9 +0,0 @@ -import 'package:hive/hive.dart'; - -part 'bindings_hive_model.g.dart'; - -@HiveType(typeId: 7) -class BindingsHiveModel extends HiveObject { - @HiveField(0) - late String bindingsStringJson; -} diff --git a/lib/infrastructure/local_db/hive_objects/devices_hive_model.dart b/lib/infrastructure/local_db/hive_objects/devices_hive_model.dart deleted file mode 100644 index ac64b414..00000000 --- a/lib/infrastructure/local_db/hive_objects/devices_hive_model.dart +++ /dev/null @@ -1,9 +0,0 @@ -import 'package:hive/hive.dart'; - -part 'devices_hive_model.g.dart'; - -@HiveType(typeId: 4) -class DevicesHiveModel extends HiveObject { - @HiveField(0) - late String deviceStringJson; -} diff --git a/lib/infrastructure/local_db/hive_objects/esphome_vendor_credentials_hive_model.dart b/lib/infrastructure/local_db/hive_objects/esphome_vendor_credentials_hive_model.dart deleted file mode 100644 index b95860ff..00000000 --- a/lib/infrastructure/local_db/hive_objects/esphome_vendor_credentials_hive_model.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:hive/hive.dart'; - -part 'esphome_vendor_credentials_hive_model.g.dart'; - -@HiveType(typeId: 9) -class EspHomeVendorCredentialsHiveModel extends HiveObject { - @HiveField(0) - late String? senderUniqueId; - @HiveField(1) - late String espHomeDevicePass; -} diff --git a/lib/infrastructure/local_db/hive_objects/ewelink_vendor_credentials_hive_model.dart b/lib/infrastructure/local_db/hive_objects/ewelink_vendor_credentials_hive_model.dart deleted file mode 100644 index 26ae6eb3..00000000 --- a/lib/infrastructure/local_db/hive_objects/ewelink_vendor_credentials_hive_model.dart +++ /dev/null @@ -1,13 +0,0 @@ -import 'package:hive/hive.dart'; - -part 'ewelink_vendor_credentials_hive_model.g.dart'; - -@HiveType(typeId: 11) -class EwelinkVendorCredentialsHiveModel extends HiveObject { - @HiveField(0) - late String? senderUniqueId; - @HiveField(1) - late String ewelinkAccountEmail; - @HiveField(2) - late String ewelinkAccountPass; -} diff --git a/lib/infrastructure/local_db/hive_objects/hub_entity_hive_model.dart b/lib/infrastructure/local_db/hive_objects/hub_entity_hive_model.dart deleted file mode 100644 index abab88c2..00000000 --- a/lib/infrastructure/local_db/hive_objects/hub_entity_hive_model.dart +++ /dev/null @@ -1,15 +0,0 @@ -import 'package:hive/hive.dart'; - -part 'hub_entity_hive_model.g.dart'; - -@HiveType(typeId: 1) -class HubEntityHiveModel extends HiveObject { - @HiveField(0) - late String hubNetworkBssid; - - @HiveField(1) - late String networkName; - - @HiveField(2) - late String lastKnownIp; -} diff --git a/lib/infrastructure/local_db/hive_objects/lifx_vendor_credentials_hive_model.dart b/lib/infrastructure/local_db/hive_objects/lifx_vendor_credentials_hive_model.dart deleted file mode 100644 index e346b3c3..00000000 --- a/lib/infrastructure/local_db/hive_objects/lifx_vendor_credentials_hive_model.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:hive/hive.dart'; - -part 'lifx_vendor_credentials_hive_model.g.dart'; - -@HiveType(typeId: 8) -class LifxVendorCredentialsHiveModel extends HiveObject { - @HiveField(0) - late String? senderUniqueId; - @HiveField(1) - late String lifxApiKey; -} diff --git a/lib/infrastructure/local_db/hive_objects/remote_pipes_hive_model.dart b/lib/infrastructure/local_db/hive_objects/remote_pipes_hive_model.dart deleted file mode 100644 index 43b13573..00000000 --- a/lib/infrastructure/local_db/hive_objects/remote_pipes_hive_model.dart +++ /dev/null @@ -1,9 +0,0 @@ -import 'package:hive/hive.dart'; - -part 'remote_pipes_hive_model.g.dart'; - -@HiveType(typeId: 0) -class RemotePipesHiveModel extends HiveObject { - @HiveField(0) - late String domainName; -} diff --git a/lib/infrastructure/local_db/hive_objects/rooms_hive_model.dart b/lib/infrastructure/local_db/hive_objects/rooms_hive_model.dart deleted file mode 100644 index d040f5f1..00000000 --- a/lib/infrastructure/local_db/hive_objects/rooms_hive_model.dart +++ /dev/null @@ -1,27 +0,0 @@ -import 'package:hive/hive.dart'; - -part 'rooms_hive_model.g.dart'; - -@HiveType(typeId: 3) -class RoomsHiveModel extends HiveObject { - @HiveField(0) - late String roomUniqueId; - @HiveField(1) - late String roomDefaultName; - @HiveField(2) - late List roomDevicesId; - @HiveField(3) - late List roomScenesId; - @HiveField(4) - late List roomRoutinesId; - @HiveField(5) - late List roomBindingsId; - @HiveField(6) - late List roomMostUsedBy; - @HiveField(7) - late List roomPermissions; - @HiveField(8) - late List roomTypes; - @HiveField(9) - late String roomBackground; -} diff --git a/lib/infrastructure/local_db/hive_objects/routines_hive_model.dart b/lib/infrastructure/local_db/hive_objects/routines_hive_model.dart deleted file mode 100644 index 5b12f633..00000000 --- a/lib/infrastructure/local_db/hive_objects/routines_hive_model.dart +++ /dev/null @@ -1,9 +0,0 @@ -import 'package:hive/hive.dart'; - -part 'routines_hive_model.g.dart'; - -@HiveType(typeId: 6) -class RoutinesHiveModel extends HiveObject { - @HiveField(0) - late String routinesStringJson; -} diff --git a/lib/infrastructure/local_db/hive_objects/scenes_hive_model.dart b/lib/infrastructure/local_db/hive_objects/scenes_hive_model.dart deleted file mode 100644 index 49d6e7f0..00000000 --- a/lib/infrastructure/local_db/hive_objects/scenes_hive_model.dart +++ /dev/null @@ -1,9 +0,0 @@ -import 'package:hive/hive.dart'; - -part 'scenes_hive_model.g.dart'; - -@HiveType(typeId: 5) -class ScenesHiveModel extends HiveObject { - @HiveField(0) - late String scenesStringJson; -} diff --git a/lib/infrastructure/local_db/hive_objects/tuya_vendor_credentials_hive_model.dart b/lib/infrastructure/local_db/hive_objects/tuya_vendor_credentials_hive_model.dart deleted file mode 100644 index 6db4ff23..00000000 --- a/lib/infrastructure/local_db/hive_objects/tuya_vendor_credentials_hive_model.dart +++ /dev/null @@ -1,21 +0,0 @@ -import 'package:hive/hive.dart'; - -part 'tuya_vendor_credentials_hive_model.g.dart'; - -@HiveType(typeId: 2) -class TuyaVendorCredentialsHiveModel extends HiveObject { - @HiveField(0) - late String? senderUniqueId; - @HiveField(1) - late String tuyaUserName; - @HiveField(2) - late String tuyaUserPassword; - @HiveField(3) - late String tuyaCountryCode; - @HiveField(4) - late String tuyaBizType; - @HiveField(5) - late String tuyaRegion; - @HiveField(6) - late String loginVendor; -} diff --git a/lib/infrastructure/local_db/hive_objects/xiaomi_mi_vendor_credentials_hive_model.dart b/lib/infrastructure/local_db/hive_objects/xiaomi_mi_vendor_credentials_hive_model.dart deleted file mode 100644 index 4873472d..00000000 --- a/lib/infrastructure/local_db/hive_objects/xiaomi_mi_vendor_credentials_hive_model.dart +++ /dev/null @@ -1,13 +0,0 @@ -import 'package:hive/hive.dart'; - -part 'xiaomi_mi_vendor_credentials_hive_model.g.dart'; - -@HiveType(typeId: 10) -class XiaomiMiVendorCredentialsHiveModel extends HiveObject { - @HiveField(0) - late String? senderUniqueId; - @HiveField(1) - late String xiaomiMiAccountEmail; - @HiveField(2) - late String xiaomiMiAccountPass; -} diff --git a/lib/infrastructure/local_db/isar_old_objects/bindings_isar_model.dart b/lib/infrastructure/local_db/isar_old_objects/bindings_isar_model.dart deleted file mode 100644 index 25439500..00000000 --- a/lib/infrastructure/local_db/isar_old_objects/bindings_isar_model.dart +++ /dev/null @@ -1,9 +0,0 @@ -// import 'package:isar/isar.dart'; -// -// part 'bindings_isar_model.g.dart'; -// -// @collection -// class BindingsIsarModel { -// Id id = Isar.autoIncrement; -// late String bindingsStringJson; -// } diff --git a/lib/infrastructure/local_db/isar_old_objects/devices_isar_model.dart b/lib/infrastructure/local_db/isar_old_objects/devices_isar_model.dart deleted file mode 100644 index 6d0264c7..00000000 --- a/lib/infrastructure/local_db/isar_old_objects/devices_isar_model.dart +++ /dev/null @@ -1,9 +0,0 @@ -// import 'package:isar/isar.dart'; -// -// part 'devices_isar_model.g.dart'; -// -// @collection -// class DevicesIsarModel { -// Id? id = Isar.autoIncrement; -// late String deviceStringJson; -// } diff --git a/lib/infrastructure/local_db/isar_old_objects/hub_entity_isar_model.dart b/lib/infrastructure/local_db/isar_old_objects/hub_entity_isar_model.dart deleted file mode 100644 index 3373100c..00000000 --- a/lib/infrastructure/local_db/isar_old_objects/hub_entity_isar_model.dart +++ /dev/null @@ -1,12 +0,0 @@ -// import 'package:isar/isar.dart'; -// -// part 'hub_entity_isar_model.g.dart'; -// -// @collection -// class HubEntityIsarModel { -// Id id = Isar.autoIncrement; -// -// late String hubNetworkBssid; -// late String networkName; -// late String lastKnownIp; -// } diff --git a/lib/infrastructure/local_db/isar_old_objects/lifx_vendor_credentials_isar_model.dart b/lib/infrastructure/local_db/isar_old_objects/lifx_vendor_credentials_isar_model.dart deleted file mode 100644 index 37a98e8a..00000000 --- a/lib/infrastructure/local_db/isar_old_objects/lifx_vendor_credentials_isar_model.dart +++ /dev/null @@ -1,16 +0,0 @@ -// import 'package:isar/isar.dart'; -// -// part 'lifx_vendor_credentials_isar_model.g.dart'; -// -// @collection -// class LifxVendorCredentialsIsarModel { -// Id id = Isar.autoIncrement; -// -// late String? senderUniqueId; -// late String lifxApiKey; -// late String tuyaUserPassword; -// late String tuyaCountryCode; -// late String tuyaBizType; -// late String tuyaRegion; -// late String loginVendor; -// } diff --git a/lib/infrastructure/local_db/isar_old_objects/remote_pipes_isar_model.dart b/lib/infrastructure/local_db/isar_old_objects/remote_pipes_isar_model.dart deleted file mode 100644 index bb571e68..00000000 --- a/lib/infrastructure/local_db/isar_old_objects/remote_pipes_isar_model.dart +++ /dev/null @@ -1,10 +0,0 @@ -// import 'package:isar/isar.dart'; -// -// part 'remote_pipes_isar_model.g.dart'; -// -// @collection -// class RemotePipesIsarModel { -// Id id = Isar.autoIncrement; -// -// late String domainName; -// } diff --git a/lib/infrastructure/local_db/isar_old_objects/rooms_isar_model.dart b/lib/infrastructure/local_db/isar_old_objects/rooms_isar_model.dart deleted file mode 100644 index 9284ea8f..00000000 --- a/lib/infrastructure/local_db/isar_old_objects/rooms_isar_model.dart +++ /dev/null @@ -1,19 +0,0 @@ -// import 'package:isar/isar.dart'; -// -// part 'rooms_isar_model.g.dart'; -// -// @collection -// class RoomsIsarModel { -// Id id = Isar.autoIncrement; -// -// late String roomUniqueId; -// late String roomDefaultName; -// late List roomDevicesId; -// late List roomScenesId; -// late List roomRoutinesId; -// late List roomBindingsId; -// late List roomMostUsedBy; -// late List roomPermissions; -// late List roomTypes; -// late String roomBackground; -// } diff --git a/lib/infrastructure/local_db/isar_old_objects/routines_isar_model.dart b/lib/infrastructure/local_db/isar_old_objects/routines_isar_model.dart deleted file mode 100644 index 8993b81e..00000000 --- a/lib/infrastructure/local_db/isar_old_objects/routines_isar_model.dart +++ /dev/null @@ -1,9 +0,0 @@ -// import 'package:isar/isar.dart'; -// -// part 'routines_isar_model.g.dart'; -// -// @collection -// class RoutinesIsarModel { -// Id id = Isar.autoIncrement; -// late String routinesStringJson; -// } diff --git a/lib/infrastructure/local_db/isar_old_objects/scenes_isar_model.dart b/lib/infrastructure/local_db/isar_old_objects/scenes_isar_model.dart deleted file mode 100644 index 51d70b6b..00000000 --- a/lib/infrastructure/local_db/isar_old_objects/scenes_isar_model.dart +++ /dev/null @@ -1,9 +0,0 @@ -// import 'package:isar/isar.dart'; -// -// part 'scenes_isar_model.g.dart'; -// -// @collection -// class ScenesIsarModel { -// Id id = Isar.autoIncrement; -// late String scenesStringJson; -// } diff --git a/lib/infrastructure/local_db/isar_old_objects/tuya_vendor_credentials_isar_model.dart b/lib/infrastructure/local_db/isar_old_objects/tuya_vendor_credentials_isar_model.dart deleted file mode 100644 index 6da7a078..00000000 --- a/lib/infrastructure/local_db/isar_old_objects/tuya_vendor_credentials_isar_model.dart +++ /dev/null @@ -1,16 +0,0 @@ -// import 'package:isar/isar.dart'; -// -// part 'tuya_vendor_credentials_isar_model.g.dart'; -// -// @collection -// class TuyaVendorCredentialsIsarModel { -// Id id = Isar.autoIncrement; -// -// late String? senderUniqueId; -// late String tuyaUserName; -// late String tuyaUserPassword; -// late String tuyaCountryCode; -// late String tuyaBizType; -// late String tuyaRegion; -// late String loginVendor; -// } diff --git a/lib/infrastructure/local_db/local_db_hive_repository.dart b/lib/infrastructure/local_db/local_db_hive_repository.dart deleted file mode 100644 index 5e232f05..00000000 --- a/lib/infrastructure/local_db/local_db_hive_repository.dart +++ /dev/null @@ -1,1183 +0,0 @@ -import 'dart:convert'; - -import 'package:cbj_hub/domain/app_communication/i_app_communication_repository.dart'; -import 'package:cbj_hub/domain/binding/binding_cbj_entity.dart'; -import 'package:cbj_hub/domain/binding/i_binding_cbj_repository.dart'; -import 'package:cbj_hub/domain/binding/value_objects_routine_cbj.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/local_db/i_local_db_repository.dart'; -import 'package:cbj_hub/domain/local_db/local_db_failures.dart'; -import 'package:cbj_hub/domain/room/room_entity.dart'; -import 'package:cbj_hub/domain/room/value_objects_room.dart'; -import 'package:cbj_hub/domain/rooms/i_saved_rooms_repo.dart'; -import 'package:cbj_hub/domain/routine/i_routine_cbj_repository.dart'; -import 'package:cbj_hub/domain/routine/routine_cbj_entity.dart'; -import 'package:cbj_hub/domain/routine/value_objects_routine_cbj.dart'; -import 'package:cbj_hub/domain/saved_devices/i_saved_devices_repo.dart'; -import 'package:cbj_hub/domain/scene/i_scene_cbj_repository.dart'; -import 'package:cbj_hub/domain/scene/scene_cbj_entity.dart'; -import 'package:cbj_hub/domain/scene/value_objects_scene_cbj.dart'; -import 'package:cbj_hub/domain/vendors/esphome_login/generic_esphome_login_entity.dart'; -import 'package:cbj_hub/domain/vendors/esphome_login/generic_esphome_login_value_objects.dart'; -import 'package:cbj_hub/domain/vendors/ewelink_login/generic_ewelink_login_entity.dart'; -import 'package:cbj_hub/domain/vendors/ewelink_login/generic_ewelink_login_value_objects.dart'; -import 'package:cbj_hub/domain/vendors/lifx_login/generic_lifx_login_entity.dart'; -import 'package:cbj_hub/domain/vendors/lifx_login/generic_lifx_login_value_objects.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/login_entity_abstract.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/value_login_objects_core.dart'; -import 'package:cbj_hub/domain/vendors/tuya_login/generic_tuya_login_entity.dart'; -import 'package:cbj_hub/domain/vendors/tuya_login/generic_tuya_login_value_objects.dart'; -import 'package:cbj_hub/domain/vendors/xiaomi_mi_login/generic_xiaomi_mi_login_entity.dart'; -import 'package:cbj_hub/domain/vendors/xiaomi_mi_login/generic_xiaomi_mi_login_value_objects.dart'; -import 'package:cbj_hub/infrastructure/bindings/binding_cbj_dtos.dart'; -import 'package:cbj_hub/infrastructure/devices/companies_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/devices/device_helper/device_helper.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/local_db/hive_objects/bindings_hive_model.dart'; -import 'package:cbj_hub/infrastructure/local_db/hive_objects/devices_hive_model.dart'; -import 'package:cbj_hub/infrastructure/local_db/hive_objects/esphome_vendor_credentials_hive_model.dart'; -import 'package:cbj_hub/infrastructure/local_db/hive_objects/ewelink_vendor_credentials_hive_model.dart'; -import 'package:cbj_hub/infrastructure/local_db/hive_objects/hub_entity_hive_model.dart'; -import 'package:cbj_hub/infrastructure/local_db/hive_objects/lifx_vendor_credentials_hive_model.dart'; -import 'package:cbj_hub/infrastructure/local_db/hive_objects/remote_pipes_hive_model.dart'; -import 'package:cbj_hub/infrastructure/local_db/hive_objects/rooms_hive_model.dart'; -import 'package:cbj_hub/infrastructure/local_db/hive_objects/routines_hive_model.dart'; -import 'package:cbj_hub/infrastructure/local_db/hive_objects/scenes_hive_model.dart'; -import 'package:cbj_hub/infrastructure/local_db/hive_objects/tuya_vendor_credentials_hive_model.dart'; -import 'package:cbj_hub/infrastructure/local_db/hive_objects/xiaomi_mi_vendor_credentials_hive_model.dart'; -import 'package:cbj_hub/infrastructure/room/room_entity_dtos.dart'; -import 'package:cbj_hub/infrastructure/routines/routine_cbj_dtos.dart'; -import 'package:cbj_hub/infrastructure/scenes/scene_cbj_dtos.dart'; -import 'package:cbj_hub/infrastructure/system_commands/system_commands_manager_d.dart'; -import 'package:cbj_hub/injection.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; -import 'package:hive/hive.dart'; -import 'package:injectable/injectable.dart'; - -/// Only ISavedDevicesRepo need to call functions here -@LazySingleton(as: ILocalDbRepository) -class HiveRepository extends ILocalDbRepository { - @override - Future initializeDb() async { - String? localDbPath = await getIt().getLocalDbPath(); - - if (localDbPath[localDbPath.length - 1] == '/') { - localDbPath = localDbPath.substring(0, localDbPath.length - 1); - } - localDbPath += '/hive'; - - logger.i('Hive db location\n$localDbPath'); - - Hive.init(localDbPath); - await Future.delayed(const Duration(milliseconds: 500)); - Hive.registerAdapter(RemotePipesHiveModelAdapter()); - Hive.registerAdapter(RoomsHiveModelAdapter()); - Hive.registerAdapter(DevicesHiveModelAdapter()); - Hive.registerAdapter(ScenesHiveModelAdapter()); - Hive.registerAdapter(RoutinesHiveModelAdapter()); - Hive.registerAdapter(BindingsHiveModelAdapter()); - Hive.registerAdapter(HubEntityHiveModelAdapter()); - Hive.registerAdapter(TuyaVendorCredentialsHiveModelAdapter()); - Hive.registerAdapter(LifxVendorCredentialsHiveModelAdapter()); - Hive.registerAdapter(EspHomeVendorCredentialsHiveModelAdapter()); - Hive.registerAdapter(XiaomiMiVendorCredentialsHiveModelAdapter()); - Hive.registerAdapter(EwelinkVendorCredentialsHiveModelAdapter()); - - /// Delay inorder for the Hive boxes to initialize - /// In case you got the following error: - /// "HiveError: You need to initialize Hive or provide a path to store - /// the box." - /// Please increase the duration - await Future.delayed(const Duration(milliseconds: 100)); - - await loadFromDb(); - } - - Box? roomsBox; - Box? devicesBox; - Box? remotePipesBox; - Box? scenesBox; - Box? routinesBox; - Box? bindingsBox; - Box? tuyaVendorCredentialsBox; - Box? smartLifeVendorCredentialsBox; - Box? jinvooSmartVendorCredentialsBox; - Box? lifxVendorCredentialsBox; - Box? espHomeVendorCredentialsBox; - Box? xiaomiMiVendorCredentialsBox; - Box? ewelinkVendorCredentialsBox; - - @override - Future loadFromDb() async { - (await getRemotePipesDnsName()).fold( - (l) => - logger.w('No Remote Pipes Dns name was found in the local storage'), - (r) { - getIt().startRemotePipesConnection(r); - - logger.i('Remote Pipes DNS name was "$r" found'); - }); - - { - await tuyaVendorCredentialsBox?.close(); - - tuyaVendorCredentialsBox = - await Hive.openBox( - tuyaVendorCredentialsBoxName, - ); - - final List - tuyaVendorCredentialsModelFromDb = tuyaVendorCredentialsBox!.values - .toList() - .cast(); - await tuyaVendorCredentialsBox?.close(); - - (await getTuyaVendorLoginCredentials( - tuyaVendorCredentialsModelFromDb: tuyaVendorCredentialsModelFromDb, - vendorBoxName: tuyaVendorCredentialsBoxName, - )) - .fold((l) {}, (r) { - CompaniesConnectorConjector.setVendorLoginCredentials(r); - - logger.i( - 'Tuya login credentials user name ${r.tuyaUserName.getOrCrash()} found', - ); - }); - } - - { - await smartLifeVendorCredentialsBox?.close(); - - smartLifeVendorCredentialsBox = - await Hive.openBox( - smartLifeVendorCredentialsBoxName, - ); - - final List - tuyaVendorCredentialsModelFromDb = smartLifeVendorCredentialsBox! - .values - .toList() - .cast(); - await smartLifeVendorCredentialsBox?.close(); - (await getTuyaVendorLoginCredentials( - tuyaVendorCredentialsModelFromDb: tuyaVendorCredentialsModelFromDb, - vendorBoxName: smartLifeVendorCredentialsBoxName, - )) - .fold((l) {}, (r) { - CompaniesConnectorConjector.setVendorLoginCredentials(r); - - logger.i( - 'Smart Life login credentials user name ${r.tuyaUserName.getOrCrash()} found', - ); - }); - } - - { - await jinvooSmartVendorCredentialsBox?.close(); - - jinvooSmartVendorCredentialsBox = - await Hive.openBox( - jinvooSmartVendorCredentialsBoxName, - ); - - final List - tuyaVendorCredentialsModelFromDb = jinvooSmartVendorCredentialsBox! - .values - .toList() - .cast(); - await jinvooSmartVendorCredentialsBox?.close(); - - (await getTuyaVendorLoginCredentials( - tuyaVendorCredentialsModelFromDb: tuyaVendorCredentialsModelFromDb, - vendorBoxName: jinvooSmartVendorCredentialsBoxName, - )) - .fold((l) {}, (r) { - CompaniesConnectorConjector.setVendorLoginCredentials(r); - - logger.i( - 'Jinvoo Smart login credentials user name ${r.tuyaUserName.getOrCrash()} found', - ); - }); - } - - { - await lifxVendorCredentialsBox?.close(); - - lifxVendorCredentialsBox = - await Hive.openBox( - lifxVendorCredentialsBoxName, - ); - - final List - lifxVendorCredentialsModelFromDb = lifxVendorCredentialsBox!.values - .toList() - .cast(); - await lifxVendorCredentialsBox?.close(); - - (await getLifxVendorLoginCredentials( - lifxVendorCredentialsModelFromDb: lifxVendorCredentialsModelFromDb, - )) - .fold((l) {}, (r) { - CompaniesConnectorConjector.setVendorLoginCredentials(r); - - logger.i( - 'Lifx login credentials got found in DB', - ); - }); - } - - { - await espHomeVendorCredentialsBox?.close(); - - espHomeVendorCredentialsBox = - await Hive.openBox( - espHomeVendorCredentialsBoxName, - ); - - final List - espHomeVendorCredentialsModelFromDb = espHomeVendorCredentialsBox! - .values - .toList() - .cast(); - await espHomeVendorCredentialsBox?.close(); - - (await getEspHomeVendorLoginCredentials( - espHomeVendorCredentialsModelFromDb: - espHomeVendorCredentialsModelFromDb, - )) - .fold((l) {}, (r) { - CompaniesConnectorConjector.setVendorLoginCredentials(r); - - logger.i( - 'ESPHome device password got found in DB', - ); - }); - } - - /// Xiaomi Mi - { - await xiaomiMiVendorCredentialsBox?.close(); - - xiaomiMiVendorCredentialsBox = - await Hive.openBox( - xiaomiMiVendorCredentialsBoxName, - ); - - final List - xiaomiMiVendorCredentialsModelFromDb = xiaomiMiVendorCredentialsBox! - .values - .toList() - .cast(); - await xiaomiMiVendorCredentialsBox?.close(); - - (await getXiaomiMiVendorLoginCredentials( - xiaomiMiVendorCredentialsModelFromDb: - xiaomiMiVendorCredentialsModelFromDb, - )) - .fold((l) {}, (r) { - CompaniesConnectorConjector.setVendorLoginCredentials(r); - - logger.i( - 'Xiaomi Mi device password got found in DB', - ); - }); - } - - /// eWeLink - { - await ewelinkVendorCredentialsBox?.close(); - - ewelinkVendorCredentialsBox = - await Hive.openBox( - ewelinkVendorCredentialsBoxName, - ); - - final List - ewelinkVendorCredentialsModelFromDb = ewelinkVendorCredentialsBox! - .values - .toList() - .cast(); - await ewelinkVendorCredentialsBox?.close(); - - (await getEwelinkVendorLoginCredentials( - ewelinkVendorCredentialsModelFromDb: - ewelinkVendorCredentialsModelFromDb, - )) - .fold((l) {}, (r) { - CompaniesConnectorConjector.setVendorLoginCredentials(r); - - logger.i( - 'EweLink account email and password got found in DB', - ); - }); - } - - // Rooms need to stay first one - await getIt().setUpAllFromDb(); - await getIt().setUpAllFromDb(); - await getIt().setUpAllFromDb(); - await getIt().setUpAllFromDb(); - await getIt().setUpAllFromDb(); - } - - @override - Future>> getRoomsFromDb() async { - final List rooms = []; - - try { - await roomsBox?.close(); - roomsBox = await Hive.openBox(roomsBoxName); - final List roomsHiveModelFromDb = - roomsBox!.values.toList().cast(); - - await roomsBox?.close(); - for (final RoomsHiveModel roomHive in roomsHiveModelFromDb) { - final RoomEntity roomEntity = RoomEntity( - uniqueId: RoomUniqueId.fromUniqueString(roomHive.roomUniqueId), - cbjEntityName: RoomDefaultName(roomHive.roomDefaultName), - background: RoomBackground(roomHive.roomBackground), - roomTypes: RoomTypes(roomHive.roomTypes), - roomDevicesId: RoomDevicesId(roomHive.roomDevicesId), - roomScenesId: RoomScenesId(roomHive.roomScenesId), - roomRoutinesId: RoomRoutinesId(roomHive.roomRoutinesId), - roomBindingsId: RoomBindingsId(roomHive.roomBindingsId), - roomMostUsedBy: RoomMostUsedBy(roomHive.roomMostUsedBy), - roomPermissions: RoomPermissions(roomHive.roomPermissions), - ); - rooms.add(roomEntity); - } - } catch (e) { - logger.e('Local DB hive error while getting rooms: $e'); - // TODO: Check why hive crash stop this from working - await deleteAllSavedRooms(); - } - - return right(rooms); - } - - @override - Future>> - getSmartDevicesFromDb() async { - final List devices = []; - - try { - await devicesBox?.close(); - devicesBox = await Hive.openBox(devicesBoxName); - - final List devicesHiveModelFromDb = - devicesBox!.values.toList().cast(); - - await devicesBox?.close(); - - for (final DevicesHiveModel deviceHive in devicesHiveModelFromDb) { - final DeviceEntityAbstract deviceEntity = - DeviceHelper.convertJsonStringToDomain(deviceHive.deviceStringJson); - - devices.add( - deviceEntity - ..entityStateGRPC = - EntityState(EntityStateGRPC.waitingInComp.toString()), - ); - } - return right(devices); - } catch (e) { - logger.e('Local DB hive error while getting devices: $e'); - } - return left(const LocalDbFailures.unexpected()); - } - - @override - Future> getHubEntityLastKnownIp() async { - // TODO: implement getHubEntityLastKnownIp - throw UnimplementedError(); - } - - @override - Future> getHubEntityNetworkBssid() async { - // TODO: implement getHubEntityNetworkBssid - throw UnimplementedError(); - } - - @override - Future> getHubEntityNetworkName() async { - // TODO: implement getHubEntityNetworkName - throw UnimplementedError(); - } - - @override - Future> - getTuyaVendorLoginCredentials({ - required List - tuyaVendorCredentialsModelFromDb, - required String vendorBoxName, - }) async { - try { - if (tuyaVendorCredentialsModelFromDb.isNotEmpty) { - final TuyaVendorCredentialsHiveModel firstTuyaVendorFromDB = - tuyaVendorCredentialsModelFromDb[0]; - - final String? senderUniqueId = firstTuyaVendorFromDB.senderUniqueId; - final String tuyaUserName = firstTuyaVendorFromDB.tuyaUserName; - final String tuyaUserPassword = firstTuyaVendorFromDB.tuyaUserPassword; - final String tuyaCountryCode = firstTuyaVendorFromDB.tuyaCountryCode; - final String tuyaBizType = firstTuyaVendorFromDB.tuyaBizType; - final String tuyaRegion = firstTuyaVendorFromDB.tuyaRegion; - final String loginVendor = firstTuyaVendorFromDB.loginVendor; - - final GenericTuyaLoginDE genericTuyaLoginDE = GenericTuyaLoginDE( - senderUniqueId: CoreLoginSenderId.fromUniqueString(senderUniqueId), - loginVendor: CoreLoginVendor(loginVendor), - tuyaUserName: GenericTuyaLoginUserName(tuyaUserName), - tuyaUserPassword: GenericTuyaLoginUserPassword(tuyaUserPassword), - tuyaCountryCode: GenericTuyaLoginCountryCode(tuyaCountryCode), - tuyaBizType: GenericTuyaLoginBizType(tuyaBizType), - tuyaRegion: GenericTuyaLoginRegion(tuyaRegion), - ); - - logger.i( - 'Tuya user name is: ' - '$tuyaUserName', - ); - return right(genericTuyaLoginDE); - } - // logger.i( - // "Didn't find any Tuya in the local DB", - // ); - } catch (e) { - logger.e('Local DB hive error while getting Tuya vendor: $e'); - } - return left(const LocalDbFailures.unexpected()); - } - - @override - Future> - getLifxVendorLoginCredentials({ - required List - lifxVendorCredentialsModelFromDb, - }) async { - try { - if (lifxVendorCredentialsModelFromDb.isNotEmpty) { - final LifxVendorCredentialsHiveModel firstLifxVendorFromDB = - lifxVendorCredentialsModelFromDb[0]; - - final String? senderUniqueId = firstLifxVendorFromDB.senderUniqueId; - final String lifxApiKey = firstLifxVendorFromDB.lifxApiKey; - - final GenericLifxLoginDE genericLifxLoginDE = GenericLifxLoginDE( - senderUniqueId: CoreLoginSenderId.fromUniqueString(senderUniqueId), - lifxApiKey: GenericLifxLoginApiKey(lifxApiKey), - ); - - logger.i( - 'Lifx got returned from local storage', - ); - return right(genericLifxLoginDE); - } - // logger.i( - // "Didn't find any Lifx in the local DB", - // ); - } catch (e) { - logger.e('Local DB hive error while getting Lifx vendor: $e'); - } - return left(const LocalDbFailures.unexpected()); - } - - @override - Future> - getEspHomeVendorLoginCredentials({ - required List - espHomeVendorCredentialsModelFromDb, - }) async { - try { - if (espHomeVendorCredentialsModelFromDb.isNotEmpty) { - final EspHomeVendorCredentialsHiveModel firstEspHomeVendorFromDB = - espHomeVendorCredentialsModelFromDb[0]; - - final String? senderUniqueId = firstEspHomeVendorFromDB.senderUniqueId; - final String espHomeDevicePass = - firstEspHomeVendorFromDB.espHomeDevicePass; - - final GenericEspHomeLoginDE genericEspHomeLoginDE = - GenericEspHomeLoginDE( - senderUniqueId: CoreLoginSenderId.fromUniqueString(senderUniqueId), - espHomeDevicePass: - GenericEspHomeDeviceLoginApiPass(espHomeDevicePass), - ); - - logger.i( - 'ESPHome got returned from local storage', - ); - return right(genericEspHomeLoginDE); - } - // logger.i( - // "Didn't find any ESPHome in the local DB", - // ); - } catch (e) { - logger.e('Local DB hive error while getting ESPHome vendor: $e'); - } - return left(const LocalDbFailures.unexpected()); - } - - @override - Future> - getXiaomiMiVendorLoginCredentials({ - required List - xiaomiMiVendorCredentialsModelFromDb, - }) async { - try { - if (xiaomiMiVendorCredentialsModelFromDb.isNotEmpty) { - final XiaomiMiVendorCredentialsHiveModel firstXiaomiMiVendorFromDB = - xiaomiMiVendorCredentialsModelFromDb[0]; - - final String? senderUniqueId = firstXiaomiMiVendorFromDB.senderUniqueId; - final String xiaomiMiAccountEmail = - firstXiaomiMiVendorFromDB.xiaomiMiAccountEmail; - final String xiaomiMiAccountPass = - firstXiaomiMiVendorFromDB.xiaomiMiAccountPass; - - final GenericXiaomiMiLoginDE genericXiaomiMiLoginDE = - GenericXiaomiMiLoginDE( - senderUniqueId: CoreLoginSenderId.fromUniqueString(senderUniqueId), - xiaomiMiAccountEmail: - GenericXiaomiMiAccountEmail(xiaomiMiAccountEmail), - xiaomiMiAccountPass: GenericXiaomiMiAccountPass(xiaomiMiAccountPass), - ); - - logger.i( - 'Xiaomi Mi got returned from local storage', - ); - return right(genericXiaomiMiLoginDE); - } - // logger.i( - // "Didn't find any Xiaomi Mi in the local DB", - // ); - } catch (e) { - logger.e('Local DB hive error while getting Xiaomi Mi vendor: $e'); - } - return left(const LocalDbFailures.unexpected()); - } - - @override - Future> - getEwelinkVendorLoginCredentials({ - required List - ewelinkVendorCredentialsModelFromDb, - }) async { - try { - if (ewelinkVendorCredentialsModelFromDb.isNotEmpty) { - final EwelinkVendorCredentialsHiveModel firstEwelinkVendorFromDB = - ewelinkVendorCredentialsModelFromDb[0]; - - final String? senderUniqueId = firstEwelinkVendorFromDB.senderUniqueId; - final String ewelinkAccountEmail = - firstEwelinkVendorFromDB.ewelinkAccountEmail; - final String ewelinkAccountPass = - firstEwelinkVendorFromDB.ewelinkAccountPass; - - final GenericEwelinkLoginDE genericEwelinkLoginDE = - GenericEwelinkLoginDE( - senderUniqueId: CoreLoginSenderId.fromUniqueString(senderUniqueId), - ewelinkAccountEmail: GenericEwelinkAccountEmail(ewelinkAccountEmail), - ewelinkAccountPass: GenericEwelinkAccountPass(ewelinkAccountPass), - ); - - logger.i( - 'EweLink got returned from local storage', - ); - return right(genericEwelinkLoginDE); - } - // logger.i( - // "Didn't find any Xiaomi Mi in the local DB", - // ); - } catch (e) { - logger.e('Local DB hive error while getting Xiaomi Mi vendor: $e'); - } - return left(const LocalDbFailures.unexpected()); - } - - @override - Future> getRemotePipesDnsName() async { - try { - await remotePipesBox?.close(); - remotePipesBox = - await Hive.openBox(remotePipesBoxName); - final List remotePipesHiveModelFromDb = - remotePipesBox!.values.toList().cast(); - await remotePipesBox?.close(); - - if (remotePipesHiveModelFromDb.isNotEmpty) { - final String remotePipesDnsName = - remotePipesHiveModelFromDb[0].domainName; - - logger.i( - 'Remote pipes domain name is: ' - '$remotePipesDnsName', - ); - return right(remotePipesDnsName); - } - logger.i("Didn't find any remote pipes in the local DB"); - } catch (e) { - logger.e('Local DB hive error while getting Remote Pipes: $e'); - } - return left(const LocalDbFailures.unexpected()); - } - - @override - Future> saveSmartDevices({ - required List deviceList, - }) async { - try { - final List devicesHiveList = []; - - final List devicesListStringJson = List.from( - deviceList.map((e) => DeviceHelper.convertDomainToJsonString(e)), - ); - - for (final String devicesEntityDtosJsonString in devicesListStringJson) { - final DevicesHiveModel devicesHiveModel = DevicesHiveModel() - ..deviceStringJson = devicesEntityDtosJsonString; - devicesHiveList.add(devicesHiveModel); - } - - await devicesBox?.close(); - devicesBox = await Hive.openBox(devicesBoxName); - await devicesBox?.clear(); - await devicesBox?.addAll(devicesHiveList); - - await devicesBox?.close(); - logger.i('Devices got saved to local storage'); - } catch (e) { - logger.e('Error saving Devices to local storage\n$e'); - return left(const LocalDbFailures.unexpected()); - } - - return right(unit); - } - - @override - Future> saveRoomsToDb({ - required List roomsList, - }) async { - try { - final List rommsHiveList = []; - - final List roomsListDto = - List.from(roomsList.map((e) => e.toInfrastructure())); - - for (final RoomEntityDtos roomEntityDtos in roomsListDto) { - final RoomsHiveModel roomsHiveModel = RoomsHiveModel() - ..roomUniqueId = roomEntityDtos.uniqueId - ..roomDefaultName = roomEntityDtos.cbjEntityName - ..roomBackground = roomEntityDtos.background - ..roomDevicesId = roomEntityDtos.roomDevicesId - ..roomScenesId = roomEntityDtos.roomScenesId - ..roomRoutinesId = roomEntityDtos.roomRoutinesId - ..roomBindingsId = roomEntityDtos.roomBindingsId - ..roomMostUsedBy = roomEntityDtos.roomMostUsedBy - ..roomPermissions = roomEntityDtos.roomPermissions - ..roomTypes = roomEntityDtos.roomTypes; - rommsHiveList.add(roomsHiveModel); - } - - await roomsBox?.close(); - roomsBox = await Hive.openBox(roomsBoxName); - - await roomsBox?.clear(); - await roomsBox?.addAll(rommsHiveList); - - await roomsBox?.close(); - logger.i('Rooms got saved to local storage'); - } catch (e) { - logger.e('Error saving Rooms to local storage\n$e'); - return left(const LocalDbFailures.unexpected()); - } - - return right(unit); - } - - @override - Future> saveHubEntity({ - required String hubNetworkBssid, - required String networkName, - required String lastKnownIp, - }) async { - // TODO: implement saveHubEntity - throw UnimplementedError(); - } - - @override - Future> saveVendorLoginCredentials({ - required LoginEntityAbstract loginEntityAbstract, - }) async { - if (loginEntityAbstract is GenericTuyaLoginDE) { - if (loginEntityAbstract.loginVendor.getOrCrash() == - VendorsAndServices.smartLife.name) { - saveTuyaVendorCredentials( - tuyaLoginDE: loginEntityAbstract, - vendorCredentialsBoxName: smartLifeVendorCredentialsBoxName, - ); - } else if (loginEntityAbstract.loginVendor.getOrCrash() == - VendorsAndServices.jinvooSmart.name) { - saveTuyaVendorCredentials( - tuyaLoginDE: loginEntityAbstract, - vendorCredentialsBoxName: jinvooSmartVendorCredentialsBoxName, - ); - } else { - saveTuyaVendorCredentials( - tuyaLoginDE: loginEntityAbstract, - vendorCredentialsBoxName: tuyaVendorCredentialsBoxName, - ); - } - } else if (loginEntityAbstract is GenericLifxLoginDE) { - saveLifxVendorCredentials( - lifxLoginDE: loginEntityAbstract, - vendorCredentialsBoxName: lifxVendorCredentialsBoxName, - ); - } else if (loginEntityAbstract is GenericEspHomeLoginDE) { - saveEspHomeVendorCredentials( - espHomeLoginDE: loginEntityAbstract, - vendorCredentialsBoxName: espHomeVendorCredentialsBoxName, - ); - } else if (loginEntityAbstract is GenericXiaomiMiLoginDE) { - saveXiaomiMiVendorCredentials( - xiaomiMiLoginDE: loginEntityAbstract, - vendorCredentialsBoxName: xiaomiMiVendorCredentialsBoxName, - ); - } else if (loginEntityAbstract is GenericEwelinkLoginDE) { - saveEwelinkVendorCredentials( - ewelinkLoginDE: loginEntityAbstract, - vendorCredentialsBoxName: ewelinkVendorCredentialsBoxName, - ); - } else { - logger.e( - 'Please implement save function for this login type ' - '${loginEntityAbstract.runtimeType}', - ); - } - - return right(unit); - } - - @override - Future> saveRemotePipes({ - required String remotePipesDomainName, - }) async { - try { - await remotePipesBox?.close(); - remotePipesBox = - await Hive.openBox(remotePipesBoxName); - final RemotePipesHiveModel remotePipesHiveModel = RemotePipesHiveModel() - ..domainName = remotePipesDomainName; - - if (remotePipesBox!.isNotEmpty) { - await remotePipesBox!.putAt(0, remotePipesHiveModel); - } else { - remotePipesBox!.add(remotePipesHiveModel); - } - - await remotePipesBox?.close(); - logger.i( - 'Remote Pipes got saved to local storage with domain name is: ' - '$remotePipesDomainName', - ); - } catch (e) { - logger.e('Error saving Remote Pipes to local storage'); - return left(const LocalDbFailures.unexpected()); - } - - return right(unit); - } - - Future> saveTuyaVendorCredentials({ - required GenericTuyaLoginDE tuyaLoginDE, - required String vendorCredentialsBoxName, - }) async { - try { - final Box tuyaVendorCredentialsBox = - await Hive.openBox( - vendorCredentialsBoxName, - ); - - final TuyaVendorCredentialsHiveModel tuyaVendorCredentialsModel = - TuyaVendorCredentialsHiveModel() - ..senderUniqueId = tuyaLoginDE.senderUniqueId.getOrCrash() - ..tuyaUserName = tuyaLoginDE.tuyaUserName.getOrCrash() - ..tuyaUserPassword = tuyaLoginDE.tuyaUserPassword.getOrCrash() - ..tuyaCountryCode = tuyaLoginDE.tuyaCountryCode.getOrCrash() - ..tuyaBizType = tuyaLoginDE.tuyaBizType.getOrCrash() - ..tuyaRegion = tuyaLoginDE.tuyaRegion.getOrCrash() - ..loginVendor = tuyaLoginDE.loginVendor.getOrCrash(); - - if (tuyaVendorCredentialsBox.isNotEmpty) { - await tuyaVendorCredentialsBox.putAt(0, tuyaVendorCredentialsModel); - } else { - tuyaVendorCredentialsBox.add(tuyaVendorCredentialsModel); - } - - await tuyaVendorCredentialsBox.close(); - logger.i( - 'Tuya vendor credentials saved to local storage with the user name: ' - '${tuyaLoginDE.tuyaUserName.getOrCrash()}', - ); - } catch (e) { - logger.e('Error saving Tuya vendor credentials to local storage'); - return left(const LocalDbFailures.unexpected()); - } - return right(unit); - } - - Future> saveLifxVendorCredentials({ - required GenericLifxLoginDE lifxLoginDE, - required String vendorCredentialsBoxName, - }) async { - try { - final Box lifxVendorCredentialsBox = - await Hive.openBox( - vendorCredentialsBoxName, - ); - - final LifxVendorCredentialsHiveModel lifxVendorCredentialsModel = - LifxVendorCredentialsHiveModel() - ..senderUniqueId = lifxLoginDE.senderUniqueId.getOrCrash() - ..lifxApiKey = lifxLoginDE.lifxApiKey.getOrCrash(); - - if (lifxVendorCredentialsBox.isNotEmpty) { - await lifxVendorCredentialsBox.putAt(0, lifxVendorCredentialsModel); - } else { - lifxVendorCredentialsBox.add(lifxVendorCredentialsModel); - } - - await lifxVendorCredentialsBox.close(); - logger.i( - 'Lifx vendor credentials saved to local storage', - ); - } catch (e) { - logger.e('Error saving Lifx vendor credentials to local storage'); - return left(const LocalDbFailures.unexpected()); - } - return right(unit); - } - - Future> saveEspHomeVendorCredentials({ - required GenericEspHomeLoginDE espHomeLoginDE, - required String vendorCredentialsBoxName, - }) async { - try { - final Box espHomeVendorCredentialsBox = - await Hive.openBox( - vendorCredentialsBoxName, - ); - - final EspHomeVendorCredentialsHiveModel espHomeVendorCredentialsModel = - EspHomeVendorCredentialsHiveModel() - ..senderUniqueId = espHomeLoginDE.senderUniqueId.getOrCrash() - ..espHomeDevicePass = espHomeLoginDE.espHomeDevicePass.getOrCrash(); - - if (espHomeVendorCredentialsBox.isNotEmpty) { - await espHomeVendorCredentialsBox.putAt( - 0, - espHomeVendorCredentialsModel, - ); - } else { - espHomeVendorCredentialsBox.add(espHomeVendorCredentialsModel); - } - - await espHomeVendorCredentialsBox.close(); - logger.i( - 'ESPHome vendor credentials saved to local storage', - ); - } catch (e) { - logger.e('Error saving ESPHome vendor credentials to local storage'); - return left(const LocalDbFailures.unexpected()); - } - return right(unit); - } - - Future> saveXiaomiMiVendorCredentials({ - required GenericXiaomiMiLoginDE xiaomiMiLoginDE, - required String vendorCredentialsBoxName, - }) async { - try { - final Box - xiaomiMiVendorCredentialsBox = - await Hive.openBox( - vendorCredentialsBoxName, - ); - - final XiaomiMiVendorCredentialsHiveModel xiaomiMiVendorCredentialsModel = - XiaomiMiVendorCredentialsHiveModel() - ..senderUniqueId = xiaomiMiLoginDE.senderUniqueId.getOrCrash() - ..xiaomiMiAccountEmail = - xiaomiMiLoginDE.xiaomiMiAccountEmail.getOrCrash() - ..xiaomiMiAccountPass = - xiaomiMiLoginDE.xiaomiMiAccountPass.getOrCrash(); - - if (xiaomiMiVendorCredentialsBox.isNotEmpty) { - await xiaomiMiVendorCredentialsBox.putAt( - 0, - xiaomiMiVendorCredentialsModel, - ); - } else { - xiaomiMiVendorCredentialsBox.add(xiaomiMiVendorCredentialsModel); - } - - await xiaomiMiVendorCredentialsBox.close(); - logger.i( - 'Xiaomi Mi vendor credentials saved to local storage', - ); - } catch (e) { - logger.e('Error saving Xiaomi Mi vendor credentials to local storage'); - return left(const LocalDbFailures.unexpected()); - } - return right(unit); - } - - Future> saveEwelinkVendorCredentials({ - required GenericEwelinkLoginDE ewelinkLoginDE, - required String vendorCredentialsBoxName, - }) async { - try { - final Box ewelinkVendorCredentialsBox = - await Hive.openBox( - vendorCredentialsBoxName, - ); - - final EwelinkVendorCredentialsHiveModel ewelinkVendorCredentialsModel = - EwelinkVendorCredentialsHiveModel() - ..senderUniqueId = ewelinkLoginDE.senderUniqueId.getOrCrash() - ..ewelinkAccountEmail = - ewelinkLoginDE.ewelinkAccountEmail.getOrCrash() - ..ewelinkAccountPass = - ewelinkLoginDE.ewelinkAccountPass.getOrCrash(); - - if (ewelinkVendorCredentialsBox.isNotEmpty) { - await ewelinkVendorCredentialsBox.putAt( - 0, - ewelinkVendorCredentialsModel, - ); - } else { - ewelinkVendorCredentialsBox.add(ewelinkVendorCredentialsModel); - } - - await ewelinkVendorCredentialsBox.close(); - logger.i( - 'EweLink vendor credentials saved to local storage', - ); - } catch (e) { - logger.e('Error saving EweLink vendor credentials to local storage'); - return left(const LocalDbFailures.unexpected()); - } - return right(unit); - } - - Future deleteAllSavedRooms() async { - await saveRoomsToDb(roomsList: []); - } - - @override - Future>> - getScenesFromDb() async { - final List scenes = []; - - try { - await scenesBox?.close(); - - scenesBox = await Hive.openBox(scenesBoxName); - - final List scenesHiveModelFromDb = - scenesBox!.values.toList().cast(); - - await scenesBox?.close(); - - for (final ScenesHiveModel sceneHive in scenesHiveModelFromDb) { - final SceneCbjEntity sceneEntity = SceneCbjDtos.fromJson( - jsonDecode(sceneHive.scenesStringJson) as Map, - ).toDomain(); - - scenes.add( - sceneEntity.copyWith( - entityStateGRPC: SceneCbjDeviceStateGRPC( - EntityStateGRPC.waitingInComp.toString(), - ), - ), - ); - } - return right(scenes); - } catch (e) { - logger.e('Local DB hive error while getting scenes: $e'); - } - return left(const LocalDbFailures.unexpected()); - } - - @override - Future>> - getRoutinesFromDb() async { - final List routines = []; - - try { - await routinesBox?.close(); - routinesBox = await Hive.openBox(routinesBoxName); - - final List routinesHiveModelFromDb = - routinesBox!.values.toList().cast(); - - await routinesBox?.close(); - - for (final RoutinesHiveModel routineHive in routinesHiveModelFromDb) { - final RoutineCbjEntity routineEntity = RoutineCbjDtos.fromJson( - jsonDecode(routineHive.routinesStringJson) as Map, - ).toDomain(); - - routines.add( - routineEntity.copyWith( - entityStateGRPC: RoutineCbjDeviceStateGRPC( - EntityStateGRPC.waitingInComp.toString(), - ), - ), - ); - } - return right(routines); - } catch (e) { - logger.e('Local DB hive error while getting routines: $e'); - } - return left(const LocalDbFailures.unexpected()); - } - - @override - Future>> - getBindingsFromDb() async { - final List bindings = []; - - try { - await bindingsBox?.close(); - bindingsBox = await Hive.openBox(bindingsBoxName); - - final List bindingsHiveModelFromDb = - bindingsBox!.values.toList().cast(); - - await bindingsBox?.close(); - - for (final BindingsHiveModel bindingHive in bindingsHiveModelFromDb) { - final BindingCbjEntity bindingEntity = BindingCbjDtos.fromJson( - jsonDecode(bindingHive.bindingsStringJson) as Map, - ).toDomain(); - - bindings.add( - bindingEntity.copyWith( - entityStateGRPC: BindingCbjDeviceStateGRPC( - EntityStateGRPC.waitingInComp.toString(), - ), - ), - ); - } - return right(bindings); - } catch (e) { - logger.e('Local DB hive error while getting bindings: $e'); - } - return left(const LocalDbFailures.unexpected()); - } - - @override - Future> saveScenes({ - required List sceneList, - }) async { - try { - final List scenesHiveList = []; - - final List scenesListStringJson = List.from( - sceneList.map((e) => jsonEncode(e.toInfrastructure().toJson())), - ); - - for (final String scenesEntityDtosJsonString in scenesListStringJson) { - final ScenesHiveModel scenesHiveModel = ScenesHiveModel() - ..scenesStringJson = scenesEntityDtosJsonString; - scenesHiveList.add(scenesHiveModel); - } - - await scenesBox?.close(); - scenesBox = await Hive.openBox(scenesBoxName); - - await scenesBox?.clear(); - await scenesBox?.addAll(scenesHiveList); - - await scenesBox?.close(); - logger.i('Scenes got saved to local storage'); - } catch (e) { - logger.e('Error saving Scenes to local storage\n$e'); - return left(const LocalDbFailures.unexpected()); - } - - return right(unit); - } - - @override - Future> saveRoutines({ - required List routineList, - }) async { - try { - final List routinesHiveList = []; - - final List routinesListStringJson = List.from( - routineList.map((e) => jsonEncode(e.toInfrastructure().toJson())), - ); - - for (final String routinesEntityDtosJsonString - in routinesListStringJson) { - final RoutinesHiveModel routinesHiveModel = RoutinesHiveModel() - ..routinesStringJson = routinesEntityDtosJsonString; - routinesHiveList.add(routinesHiveModel); - } - - await routinesBox?.close(); - routinesBox = await Hive.openBox(routinesBoxName); - - await routinesBox?.clear(); - await routinesBox?.addAll(routinesHiveList); - - await routinesBox?.close(); - logger.i('Routines got saved to local storage'); - } catch (e) { - logger.e('Error saving Routines to local storage\n$e'); - return left(const LocalDbFailures.unexpected()); - } - - return right(unit); - } - - @override - Future> saveBindings({ - required List bindingList, - }) async { - try { - final List bindingsHiveList = []; - - final List bindingsListStringJson = List.from( - bindingList.map((e) => jsonEncode(e.toInfrastructure().toJson())), - ); - - for (final String bindingsEntityDtosJsonString - in bindingsListStringJson) { - final BindingsHiveModel bindingsHiveModel = BindingsHiveModel() - ..bindingsStringJson = bindingsEntityDtosJsonString; - bindingsHiveList.add(bindingsHiveModel); - } - - await bindingsBox?.close(); - - bindingsBox = await Hive.openBox(bindingsBoxName); - - await bindingsBox?.clear(); - await bindingsBox?.addAll(bindingsHiveList); - - await bindingsBox?.close(); - logger.i('Bindings got saved to local storage'); - } catch (e) { - logger.e('Error saving Bindings to local storage\n$e'); - return left(const LocalDbFailures.unexpected()); - } - - return right(unit); - } -} diff --git a/lib/infrastructure/local_db/local_db_isar_repository_old.dart b/lib/infrastructure/local_db/local_db_isar_repository_old.dart deleted file mode 100644 index ba9d9bc4..00000000 --- a/lib/infrastructure/local_db/local_db_isar_repository_old.dart +++ /dev/null @@ -1,812 +0,0 @@ -// import 'dart:convert'; -// -// import 'package:cbj_hub/domain/app_communication/i_app_communication_repository.dart'; -// import 'package:cbj_hub/domain/binding/binding_cbj_entity.dart'; -// import 'package:cbj_hub/domain/binding/i_binding_cbj_repository.dart'; -// import 'package:cbj_hub/domain/binding/value_objects_routine_cbj.dart'; -// import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -// import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -// import 'package:cbj_hub/domain/local_db/i_local_db_repository.dart'; -// import 'package:cbj_hub/domain/local_db/local_db_failures.dart'; -// import 'package:cbj_hub/domain/room/room_entity.dart'; -// import 'package:cbj_hub/domain/room/value_objects_room.dart'; -// import 'package:cbj_hub/domain/rooms/i_saved_rooms_repo.dart'; -// import 'package:cbj_hub/domain/routine/i_routine_cbj_repository.dart'; -// import 'package:cbj_hub/domain/routine/routine_cbj_entity.dart'; -// import 'package:cbj_hub/domain/routine/value_objects_routine_cbj.dart'; -// import 'package:cbj_hub/domain/saved_devices/i_saved_devices_repo.dart'; -// import 'package:cbj_hub/domain/scene/i_scene_cbj_repository.dart'; -// import 'package:cbj_hub/domain/scene/scene_cbj_entity.dart'; -// import 'package:cbj_hub/domain/scene/value_objects_scene_cbj.dart'; -// import 'package:cbj_hub/domain/vendors/esphome_login/generic_esphome_login_entity.dart'; -// import 'package:cbj_hub/domain/vendors/esphome_login/generic_esphome_login_value_objects.dart'; -// import 'package:cbj_hub/domain/vendors/ewelink_login/generic_ewelink_login_entity.dart'; -// import 'package:cbj_hub/domain/vendors/lifx_login/generic_lifx_login_entity.dart'; -// import 'package:cbj_hub/domain/vendors/lifx_login/generic_lifx_login_value_objects.dart'; -// import 'package:cbj_hub/domain/vendors/login_abstract/login_entity_abstract.dart'; -// import 'package:cbj_hub/domain/vendors/login_abstract/value_login_objects_core.dart'; -// import 'package:cbj_hub/domain/vendors/tuya_login/generic_tuya_login_entity.dart'; -// import 'package:cbj_hub/domain/vendors/tuya_login/generic_tuya_login_value_objects.dart'; -// import 'package:cbj_hub/domain/vendors/xiaomi_mi_login/generic_xiaomi_mi_login_entity.dart'; -// import 'package:cbj_hub/domain/vendors/xiaomi_mi_login/generic_xiaomi_mi_login_value_objects.dart'; -// import 'package:cbj_hub/infrastructure/bindings/binding_cbj_dtos.dart'; -// import 'package:cbj_hub/infrastructure/devices/companies_connector_conjector.dart'; -// import 'package:cbj_hub/infrastructure/devices/device_helper/device_helper.dart'; -// import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -// import 'package:cbj_hub/infrastructure/local_db/hive_objects/esphome_vendor_credentials_hive_model.dart'; -// import 'package:cbj_hub/infrastructure/local_db/hive_objects/ewelink_vendor_credentials_hive_model.dart'; -// import 'package:cbj_hub/infrastructure/local_db/hive_objects/lifx_vendor_credentials_hive_model.dart'; -// import 'package:cbj_hub/infrastructure/local_db/hive_objects/tuya_vendor_credentials_hive_model.dart'; -// import 'package:cbj_hub/infrastructure/local_db/hive_objects/xiaomi_mi_vendor_credentials_hive_model.dart'; -// import 'package:cbj_hub/infrastructure/local_db/isar_old_objects/bindings_isar_model.dart'; -// import 'package:cbj_hub/infrastructure/local_db/isar_old_objects/devices_isar_model.dart'; -// import 'package:cbj_hub/infrastructure/local_db/isar_old_objects/remote_pipes_isar_model.dart'; -// import 'package:cbj_hub/infrastructure/local_db/isar_old_objects/rooms_isar_model.dart'; -// import 'package:cbj_hub/infrastructure/local_db/isar_old_objects/routines_isar_model.dart'; -// import 'package:cbj_hub/infrastructure/local_db/isar_old_objects/scenes_isar_model.dart'; -// import 'package:cbj_hub/infrastructure/local_db/isar_old_objects/tuya_vendor_credentials_isar_model.dart'; -// import 'package:cbj_hub/infrastructure/room/room_entity_dtos.dart'; -// import 'package:cbj_hub/infrastructure/routines/routine_cbj_dtos.dart'; -// import 'package:cbj_hub/infrastructure/scenes/scene_cbj_dtos.dart'; -// import 'package:cbj_hub/infrastructure/system_commands/system_commands_manager_d.dart'; -// import 'package:cbj_hub/injection.dart'; -// import 'package:cbj_hub/utils.dart'; -// import 'package:dartz/dartz.dart'; -// import 'package:isar/isar.dart'; -// -// // We are going back to hive and leving all this part as isar does not -// // currently support linux arm/arm64 architecture -// // https://github.com/isar/isar/issues/848 -// -// /// Only ISavedDevicesRepo need to call functions here -// // @LazySingleton(as: ILocalDbRepository) -// class IsarRepository extends ILocalDbRepository { -// late Isar isar; -// Future? didDbInitialzed; -// -// @override -// Future initializeDb() async { -// if (didDbInitialzed == null) { -// didDbInitialzed = asyncConstractorHelper(); -// await loadFromDb(); -// } else { -// await didDbInitialzed; -// } -// } -// -// Future asyncConstractorHelper() async { -// await getIt().getLocalDbPath(); -// -// logger.i('Isar db location\n${isar.path}'); -// -// await Isar.initializeIsarCore(download: true); -// isar = await Isar.open([ -// BindingsIsarModelSchema, -// RoomsIsarModelSchema, -// DevicesIsarModelSchema, -// TuyaVendorCredentialsIsarModelSchema, -// RemotePipesIsarModelSchema, -// ScenesIsarModelSchema, -// RoutinesIsarModelSchema, -// ]); -// -// return true; -// } -// -// @override -// Future loadFromDb() async { -// (await getRemotePipesDnsName()).fold( -// (l) => -// logger.w('No Remote Pipes Dns name was found in the local storage'), -// (r) { -// getIt().startRemotePipesConnection(r); -// -// logger.i('Remote Pipes DNS name was "$r" found'); -// }); -// (await getTuyaVendorLoginCredentials( -// vendorBoxName: tuyaVendorCredentialsBoxName, -// tuyaVendorCredentialsModelFromDb: [], -// )) -// .fold((l) {}, (r) { -// CompaniesConnectorConjector.setVendorLoginCredentials(r); -// -// logger.i( -// 'Tuya login credentials user name ${r.tuyaUserName.getOrCrash()} found', -// ); -// }); -// (await getTuyaVendorLoginCredentials( -// vendorBoxName: smartLifeVendorCredentialsBoxName, -// tuyaVendorCredentialsModelFromDb: [], -// )) -// .fold((l) {}, (r) { -// CompaniesConnectorConjector.setVendorLoginCredentials(r); -// -// logger.i( -// 'Smart Life login credentials user name ${r.tuyaUserName.getOrCrash()} found', -// ); -// }); -// (await getTuyaVendorLoginCredentials( -// vendorBoxName: jinvooSmartVendorCredentialsBoxName, -// tuyaVendorCredentialsModelFromDb: [], -// )) -// .fold((l) {}, (r) { -// CompaniesConnectorConjector.setVendorLoginCredentials(r); -// -// logger.i( -// 'Jinvoo Smart login credentials user name ${r.tuyaUserName.getOrCrash()} found', -// ); -// }); -// -// // Rooms need to stay first one -// await getIt().setUpAllFromDb(); -// await getIt().setUpAllFromDb(); -// await getIt().setUpAllFromDb(); -// await getIt().setUpAllFromDb(); -// await getIt().setUpAllFromDb(); -// } -// -// @override -// Future>> getRoomsFromDb() async { -// await initializeDb(); -// -// final List rooms = []; -// try { -// final List roomsIsarModelFromDb = -// await isar.roomsIsarModels.where().findAll(); -// -// for (final RoomsIsarModel roomIsar in roomsIsarModelFromDb) { -// final RoomEntity roomEntity = RoomEntity( -// uniqueId: RoomUniqueId.fromUniqueString(roomIsar.roomUniqueId), -// cbjEntityName: RoomDefaultName(roomIsar.roomDefaultName), -// background: RoomBackground(roomIsar.roomBackground), -// roomTypes: RoomTypes(roomIsar.roomTypes), -// roomDevicesId: RoomDevicesId(roomIsar.roomDevicesId), -// roomScenesId: RoomScenesId(roomIsar.roomScenesId), -// roomRoutinesId: RoomRoutinesId(roomIsar.roomRoutinesId), -// roomBindingsId: RoomBindingsId(roomIsar.roomBindingsId), -// roomMostUsedBy: RoomMostUsedBy(roomIsar.roomMostUsedBy), -// roomPermissions: RoomPermissions(roomIsar.roomPermissions), -// ); -// rooms.add(roomEntity); -// } -// } catch (e) { -// logger.e('Local DB isar error while getting rooms: $e'); -// await deleteAllSavedRooms(); -// } -// return right(rooms); -// } -// -// @override -// Future>> -// getSmartDevicesFromDb() async { -// await initializeDb(); -// -// final List devices = []; -// -// try { -// final List devicesIsarModelFromDb = -// await isar.devicesIsarModels.where().findAll(); -// -// for (final DevicesIsarModel deviceIsar in devicesIsarModelFromDb) { -// final DeviceEntityAbstract deviceEntity = -// DeviceHelper.convertJsonStringToDomain(deviceIsar.deviceStringJson); -// -// devices.add( -// deviceEntity -// ..entityStateGRPC = -// EntityState(EntityStateGRPC.waitingInComp.toString()), -// ); -// } -// return right(devices); -// } catch (e) { -// logger.e('Local DB isar error while getting devices: $e'); -// } -// return left(const LocalDbFailures.unexpected()); -// } -// -// @override -// Future> getHubEntityLastKnownIp() async { -// await initializeDb(); -// -// // TODO: implement getHubEntityLastKnownIp -// throw UnimplementedError(); -// } -// -// @override -// Future> getHubEntityNetworkBssid() async { -// await initializeDb(); -// -// // TODO: implement getHubEntityNetworkBssid -// throw UnimplementedError(); -// } -// -// @override -// Future> getHubEntityNetworkName() async { -// await initializeDb(); -// -// // TODO: implement getHubEntityNetworkName -// throw UnimplementedError(); -// } -// -// @override -// Future> -// getTuyaVendorLoginCredentials({ -// required List -// tuyaVendorCredentialsModelFromDb, -// required String vendorBoxName, -// }) async { -// await initializeDb(); -// -// try { -// final List -// tuyaVendorCredentialsModelFromDb = -// await isar.tuyaVendorCredentialsIsarModels.where().findAll(); -// -// if (tuyaVendorCredentialsModelFromDb.isNotEmpty) { -// final TuyaVendorCredentialsIsarModel firstTuyaVendorFromDB = -// tuyaVendorCredentialsModelFromDb[0]; -// -// final String? senderUniqueId = firstTuyaVendorFromDB.senderUniqueId; -// final String tuyaUserName = firstTuyaVendorFromDB.tuyaUserName; -// final String tuyaUserPassword = firstTuyaVendorFromDB.tuyaUserPassword; -// final String tuyaCountryCode = firstTuyaVendorFromDB.tuyaCountryCode; -// final String tuyaBizType = firstTuyaVendorFromDB.tuyaBizType; -// final String tuyaRegion = firstTuyaVendorFromDB.tuyaRegion; -// final String loginVendor = firstTuyaVendorFromDB.loginVendor; -// -// final GenericTuyaLoginDE genericTuyaLoginDE = GenericTuyaLoginDE( -// senderUniqueId: CoreLoginSenderId.fromUniqueString(senderUniqueId), -// loginVendor: CoreLoginVendor(loginVendor), -// tuyaUserName: GenericTuyaLoginUserName(tuyaUserName), -// tuyaUserPassword: GenericTuyaLoginUserPassword(tuyaUserPassword), -// tuyaCountryCode: GenericTuyaLoginCountryCode(tuyaCountryCode), -// tuyaBizType: GenericTuyaLoginBizType(tuyaBizType), -// tuyaRegion: GenericTuyaLoginRegion(tuyaRegion), -// ); -// -// logger.i( -// 'Tuya user name is: ' -// '$tuyaUserName', -// ); -// return right(genericTuyaLoginDE); -// } -// logger.i( -// "Didn't find any Tuya in the local DB for box name $vendorBoxName", -// ); -// } catch (e) { -// logger.e('Local DB isar error while getting Tuya vendor: $e'); -// } -// return left(const LocalDbFailures.unexpected()); -// } -// -// @override -// Future> getRemotePipesDnsName() async { -// await initializeDb(); -// -// try { -// final List remotePipesIsarModelFromDb = -// await isar.remotePipesIsarModels.where().findAll(); -// -// if (remotePipesIsarModelFromDb.isNotEmpty) { -// final String remotePipesDnsName = -// remotePipesIsarModelFromDb[0].domainName; -// -// logger.i( -// 'Remote pipes domain name is: ' -// '$remotePipesDnsName', -// ); -// return right(remotePipesDnsName); -// } -// logger.i("Didn't find any remote pipes in the local DB"); -// } catch (e) { -// logger.e('Local DB isar error while getting Remote Pipes: $e'); -// isar.close(); -// } -// return left(const LocalDbFailures.unexpected()); -// } -// -// @override -// Future> saveSmartDevices({ -// required List deviceList, -// }) async { -// await initializeDb(); -// -// try { -// final List devicesIsarList = []; -// -// final List devicesListStringJson = List.from( -// deviceList.map((e) => DeviceHelper.convertDomainToJsonString(e)), -// ); -// -// for (final String devicesEntityDtosJsonString in devicesListStringJson) { -// final DevicesIsarModel devicesIsarModel = DevicesIsarModel() -// ..deviceStringJson = devicesEntityDtosJsonString; -// devicesIsarList.add(devicesIsarModel); -// } -// -// await isar.writeTxn(() async { -// await isar.devicesIsarModels.clear(); -// await isar.devicesIsarModels.putAll(devicesIsarList); -// }); -// -// logger.i('Devices got saved to local storage'); -// } catch (e) { -// logger.e('Error saving Devices to local storage\n$e'); -// -// return left(const LocalDbFailures.unexpected()); -// } -// -// return right(unit); -// } -// -// @override -// Future> saveRoomsToDb({ -// required List roomsList, -// }) async { -// await initializeDb(); -// -// try { -// final List roomsIsarList = []; -// -// final List roomsListDto = -// List.from(roomsList.map((e) => e.toInfrastructure())); -// -// for (final RoomEntityDtos roomEntityDtos in roomsListDto) { -// final RoomsIsarModel roomsIsarModel = RoomsIsarModel() -// ..roomUniqueId = roomEntityDtos.uniqueId -// ..roomDefaultName = roomEntityDtos.cbjEntityName -// ..roomBackground = roomEntityDtos.background -// ..roomDevicesId = roomEntityDtos.roomDevicesId -// ..roomScenesId = roomEntityDtos.roomScenesId -// ..roomRoutinesId = roomEntityDtos.roomRoutinesId -// ..roomBindingsId = roomEntityDtos.roomBindingsId -// ..roomMostUsedBy = roomEntityDtos.roomMostUsedBy -// ..roomPermissions = roomEntityDtos.roomPermissions -// ..roomTypes = roomEntityDtos.roomTypes; -// roomsIsarList.add(roomsIsarModel); -// } -// -// await isar.writeTxn(() async { -// await isar.roomsIsarModels.clear(); -// await isar.roomsIsarModels.putAll(roomsIsarList); -// }); -// -// logger.i('Rooms got saved to local storage'); -// } catch (e) { -// logger.e('Error saving Rooms to local storage\n$e'); -// -// return left(const LocalDbFailures.unexpected()); -// } -// -// return right(unit); -// } -// -// @override -// Future> saveHubEntity({ -// required String hubNetworkBssid, -// required String networkName, -// required String lastKnownIp, -// }) async { -// await initializeDb(); -// -// // TODO: implement saveHubEntity -// throw UnimplementedError(); -// } -// -// @override -// Future> saveVendorLoginCredentials({ -// required LoginEntityAbstract loginEntityAbstract, -// }) async { -// await initializeDb(); -// -// if (loginEntityAbstract is GenericTuyaLoginDE) { -// if (loginEntityAbstract.loginVendor.getOrCrash() == -// VendorsAndServices.smartLife.name) { -// saveTuyaVendorCredentials( -// tuyaLoginDE: loginEntityAbstract, -// vendorCredentialsBoxName: smartLifeVendorCredentialsBoxName, -// ); -// } else if (loginEntityAbstract.loginVendor.getOrCrash() == -// VendorsAndServices.jinvooSmart.name) { -// saveTuyaVendorCredentials( -// tuyaLoginDE: loginEntityAbstract, -// vendorCredentialsBoxName: jinvooSmartVendorCredentialsBoxName, -// ); -// } else { -// saveTuyaVendorCredentials( -// tuyaLoginDE: loginEntityAbstract, -// vendorCredentialsBoxName: tuyaVendorCredentialsBoxName, -// ); -// } -// } else { -// logger.e( -// 'Please implement save function for this login type ' -// '${loginEntityAbstract.runtimeType}', -// ); -// } -// -// return right(unit); -// } -// -// @override -// Future> saveRemotePipes({ -// required String remotePipesDomainName, -// }) async { -// await initializeDb(); -// -// try { -// final RemotePipesIsarModel remotePipesIsarModel = RemotePipesIsarModel() -// ..domainName = remotePipesDomainName; -// -// await isar.writeTxn(() async { -// await isar.remotePipesIsarModels.clear(); -// await isar.remotePipesIsarModels.put(remotePipesIsarModel); -// }); -// -// logger.i( -// 'Remote Pipes got saved to local storage with domain name is: ' -// '$remotePipesDomainName', -// ); -// } catch (e) { -// logger.e('Error saving Remote Pipes to local storage'); -// -// return left(const LocalDbFailures.unexpected()); -// } -// -// return right(unit); -// } -// -// Future> saveTuyaVendorCredentials({ -// required GenericTuyaLoginDE tuyaLoginDE, -// required String vendorCredentialsBoxName, -// }) async { -// await initializeDb(); -// -// try { -// final TuyaVendorCredentialsIsarModel tuyaVendorCredentialsModel = -// TuyaVendorCredentialsIsarModel() -// ..senderUniqueId = tuyaLoginDE.senderUniqueId.getOrCrash() -// ..tuyaUserName = tuyaLoginDE.tuyaUserName.getOrCrash() -// ..tuyaUserPassword = tuyaLoginDE.tuyaUserPassword.getOrCrash() -// ..tuyaCountryCode = tuyaLoginDE.tuyaCountryCode.getOrCrash() -// ..tuyaBizType = tuyaLoginDE.tuyaBizType.getOrCrash() -// ..tuyaRegion = tuyaLoginDE.tuyaRegion.getOrCrash() -// ..loginVendor = tuyaLoginDE.loginVendor.getOrCrash(); -// -// await isar.writeTxn(() async { -// await isar.tuyaVendorCredentialsIsarModels.clear(); -// await isar.tuyaVendorCredentialsIsarModels -// .put(tuyaVendorCredentialsModel); -// }); -// -// logger.i( -// 'Tuya vendor credentials saved to local storage with the user name: ' -// '${tuyaLoginDE.tuyaUserName.getOrCrash()}', -// ); -// } catch (e) { -// logger.e('Error saving Remote Pipes to local storage'); -// -// return left(const LocalDbFailures.unexpected()); -// } -// return right(unit); -// } -// -// Future deleteAllSavedRooms() async { -// await saveRoomsToDb(roomsList: []); -// } -// -// @override -// Future>> -// getScenesFromDb() async { -// await initializeDb(); -// -// final List scenes = []; -// -// try { -// final List scenesIsarModelFromDb = -// await isar.scenesIsarModels.where().findAll(); -// -// for (final ScenesIsarModel sceneIsar in scenesIsarModelFromDb) { -// final SceneCbjEntity sceneEntity = SceneCbjDtos.fromJson( -// jsonDecode(sceneIsar.scenesStringJson) as Map, -// ).toDomain(); -// -// scenes.add( -// sceneEntity.copyWith( -// entityStateGRPC: SceneCbjDeviceStateGRPC( -// EntityStateGRPC.waitingInComp.toString(), -// ), -// ), -// ); -// } -// return right(scenes); -// } catch (e) { -// logger.e('Local DB isar error while getting scenes: $e'); -// } -// return left(const LocalDbFailures.unexpected()); -// } -// -// @override -// Future>> -// getRoutinesFromDb() async { -// await initializeDb(); -// -// final List routines = []; -// -// try { -// final List routinesIsarModelFromDb = -// await isar.routinesIsarModels.where().findAll(); -// -// for (final RoutinesIsarModel routineIsar in routinesIsarModelFromDb) { -// final RoutineCbjEntity routineEntity = RoutineCbjDtos.fromJson( -// jsonDecode(routineIsar.routinesStringJson) as Map, -// ).toDomain(); -// -// routines.add( -// routineEntity.copyWith( -// entityStateGRPC: RoutineCbjDeviceStateGRPC( -// EntityStateGRPC.waitingInComp.toString(), -// ), -// ), -// ); -// } -// return right(routines); -// } catch (e) { -// logger.e('Local DB isar error while getting routines: $e'); -// } -// return left(const LocalDbFailures.unexpected()); -// } -// -// @override -// Future>> -// getBindingsFromDb() async { -// await initializeDb(); -// -// final List bindings = []; -// -// try { -// final List bindingsIsarModelFromDb = -// await isar.bindingsIsarModels.where().findAll(); -// -// for (final BindingsIsarModel bindingIsar in bindingsIsarModelFromDb) { -// final BindingCbjEntity bindingEntity = BindingCbjDtos.fromJson( -// jsonDecode(bindingIsar.bindingsStringJson) as Map, -// ).toDomain(); -// -// bindings.add( -// bindingEntity.copyWith( -// entityStateGRPC: BindingCbjDeviceStateGRPC( -// EntityStateGRPC.waitingInComp.toString(), -// ), -// ), -// ); -// } -// return right(bindings); -// } catch (e) { -// logger.e('Local DB isar error while getting bindings: $e'); -// } -// return left(const LocalDbFailures.unexpected()); -// } -// -// @override -// Future> saveScenes({ -// required List sceneList, -// }) async { -// await initializeDb(); -// -// try { -// final List scenesIsarList = []; -// -// final List scenesListStringJson = List.from( -// sceneList.map((e) => jsonEncode(e.toInfrastructure().toJson())), -// ); -// -// for (final String scenesEntityDtosJsonString in scenesListStringJson) { -// final ScenesIsarModel scenesIsarModel = ScenesIsarModel() -// ..scenesStringJson = scenesEntityDtosJsonString; -// scenesIsarList.add(scenesIsarModel); -// } -// -// await isar.writeTxn(() async { -// await isar.scenesIsarModels.clear(); -// await isar.scenesIsarModels.putAll(scenesIsarList); -// }); -// -// logger.i('Scenes got saved to local storage'); -// } catch (e) { -// logger.e('Error saving Scenes to local storage\n$e'); -// -// return left(const LocalDbFailures.unexpected()); -// } -// -// return right(unit); -// } -// -// @override -// Future> saveRoutines({ -// required List routineList, -// }) async { -// await initializeDb(); -// -// try { -// final List routinesIsarList = []; -// -// final List routinesListStringJson = List.from( -// routineList.map((e) => jsonEncode(e.toInfrastructure().toJson())), -// ); -// -// for (final String routinesEntityDtosJsonString -// in routinesListStringJson) { -// final RoutinesIsarModel routinesIsarModel = RoutinesIsarModel() -// ..routinesStringJson = routinesEntityDtosJsonString; -// routinesIsarList.add(routinesIsarModel); -// } -// -// await isar.writeTxn(() async { -// await isar.routinesIsarModels.clear(); -// await isar.routinesIsarModels.putAll(routinesIsarList); -// }); -// -// logger.i('Routines got saved to local storage'); -// } catch (e) { -// logger.e('Error saving Routines to local storage\n$e'); -// -// return left(const LocalDbFailures.unexpected()); -// } -// -// return right(unit); -// } -// -// @override -// Future> saveBindings({ -// required List bindingList, -// }) async { -// await initializeDb(); -// -// try { -// final List bindingsIsarList = []; -// -// final List bindingsListStringJson = List.from( -// bindingList.map((e) => jsonEncode(e.toInfrastructure().toJson())), -// ); -// -// for (final String bindingsEntityDtosJsonString -// in bindingsListStringJson) { -// final BindingsIsarModel bindingsIsarModel = BindingsIsarModel() -// ..bindingsStringJson = bindingsEntityDtosJsonString; -// bindingsIsarList.add(bindingsIsarModel); -// } -// -// await isar.writeTxn(() async { -// await isar.bindingsIsarModels.clear(); -// await isar.bindingsIsarModels.putAll(bindingsIsarList); -// }); -// -// logger.i('Bindings got saved to local storage'); -// } catch (e) { -// logger.e('Error saving Bindings to local storage\n$e'); -// -// return left(const LocalDbFailures.unexpected()); -// } -// -// return right(unit); -// } -// -// @override -// Future> -// getLifxVendorLoginCredentials({ -// required List -// lifxVendorCredentialsModelFromDb, -// }) async { -// try { -// if (lifxVendorCredentialsModelFromDb.isNotEmpty) { -// final LifxVendorCredentialsHiveModel firstLifxVendorFromDB = -// lifxVendorCredentialsModelFromDb[0]; -// -// final String? senderUniqueId = firstLifxVendorFromDB.senderUniqueId; -// final String lifxApiKey = firstLifxVendorFromDB.lifxApiKey; -// -// final GenericLifxLoginDE genericLifxLoginDE = GenericLifxLoginDE( -// senderUniqueId: CoreLoginSenderId.fromUniqueString(senderUniqueId), -// lifxApiKey: GenericLifxLoginApiKey(lifxApiKey), -// ); -// -// logger.i( -// 'Lifx got returned from local storage', -// ); -// return right(genericLifxLoginDE); -// } -// logger.i( -// "Didn't find any Lifx in the local DB", -// ); -// } catch (e) { -// logger.e('Local DB hive error while getting Lifx vendor: $e'); -// } -// return left(const LocalDbFailures.unexpected()); -// } -// -// @override -// Future> -// getEspHomeVendorLoginCredentials({ -// required List -// espHomeVendorCredentialsModelFromDb, -// }) async { -// try { -// if (espHomeVendorCredentialsModelFromDb.isNotEmpty) { -// final EspHomeVendorCredentialsHiveModel firstEspHomeVendorFromDB = -// espHomeVendorCredentialsModelFromDb[0]; -// -// final String? senderUniqueId = firstEspHomeVendorFromDB.senderUniqueId; -// final String espHomeDevicePass = -// firstEspHomeVendorFromDB.espHomeDevicePass; -// -// final GenericEspHomeLoginDE genericEspHomeLoginDE = -// GenericEspHomeLoginDE( -// senderUniqueId: CoreLoginSenderId.fromUniqueString(senderUniqueId), -// espHomeDevicePass: -// GenericEspHomeDeviceLoginApiPass(espHomeDevicePass), -// ); -// -// logger.i( -// 'ESPHome got returned from local storage', -// ); -// return right(genericEspHomeLoginDE); -// } -// logger.i( -// "Didn't find any ESPHome in the local DB", -// ); -// } catch (e) { -// logger.e('Local DB hive error while getting ESPHome vendor: $e'); -// } -// return left(const LocalDbFailures.unexpected()); -// } -// -// @override -// Future> -// getXiaomiMiVendorLoginCredentials({ -// required List -// xiaomiMiVendorCredentialsModelFromDb, -// }) async { -// try { -// if (xiaomiMiVendorCredentialsModelFromDb.isNotEmpty) { -// final XiaomiMiVendorCredentialsHiveModel firstXiaomiMiVendorFromDB = -// xiaomiMiVendorCredentialsModelFromDb[0]; -// -// final String? senderUniqueId = firstXiaomiMiVendorFromDB.senderUniqueId; -// final String xiaomiMiAccountEmail = -// firstXiaomiMiVendorFromDB.xiaomiMiAccountEmail; -// final String xiaomiMiAccountPass = -// firstXiaomiMiVendorFromDB.xiaomiMiAccountPass; -// -// final GenericXiaomiMiLoginDE genericXiaomiMiLoginDE = -// GenericXiaomiMiLoginDE( -// senderUniqueId: CoreLoginSenderId.fromUniqueString(senderUniqueId), -// xiaomiMiAccountEmail: -// GenericXiaomiMiAccountEmail(xiaomiMiAccountEmail), -// xiaomiMiAccountPass: GenericXiaomiMiAccountPass(xiaomiMiAccountPass), -// ); -// -// logger.i( -// 'Xiaomi Mi got returned from local storage', -// ); -// return right(genericXiaomiMiLoginDE); -// } -// logger.i( -// "Didn't find any Xiaomi Mi in the local DB", -// ); -// } catch (e) { -// logger.e('Local DB hive error while getting Xiaomi Mi vendor: $e'); -// } -// return left(const LocalDbFailures.unexpected()); -// } -// -// @override -// Future> -// getEwelinkVendorLoginCredentials({ -// required List -// ewelinkVendorCredentialsModelFromDb, -// }) { -// // TODO: implement getEwelinkVendorLoginCredentials -// throw UnimplementedError(); -// } -// } diff --git a/lib/infrastructure/mqtt_server/mqtt_server_repository.dart b/lib/infrastructure/mqtt_server/mqtt_server_repository.dart index 36f8f69c..6379dfa1 100644 --- a/lib/infrastructure/mqtt_server/mqtt_server_repository.dart +++ b/lib/infrastructure/mqtt_server/mqtt_server_repository.dart @@ -1,31 +1,33 @@ import 'dart:convert'; import 'package:cbj_hub/application/connector/connector.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/value_objects_core.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_blinds_device/generic_blinds_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_boiler_device/generic_boiler_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_dimmable_light_device/generic_dimmable_light_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_light_device/generic_light_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_computer_device/generic_smart_computer_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_plug_device/generic_smart_plug_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_tv/generic_smart_tv_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_entity.dart'; -import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart'; -import 'package:cbj_hub/domain/saved_devices/i_saved_devices_repo.dart'; import 'package:cbj_hub/infrastructure/app_communication/app_communication_repository.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:cbj_hub/injection.dart'; import 'package:cbj_hub/utils.dart'; -import 'package:injectable/injectable.dart'; +import 'package:cbj_integrations_controller/domain/mqtt_server/i_mqtt_server_repository.dart'; +import 'package:cbj_integrations_controller/domain/saved_devices/i_saved_devices_repo.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/value_objects_core.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_blinds_device/generic_blinds_entity.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_boiler_device/generic_boiler_entity.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_dimmable_light_device/generic_dimmable_light_entity.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_light_device/generic_light_entity.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_rgbw_light_device/generic_rgbw_light_entity.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_smart_computer_device/generic_smart_computer_entity.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_smart_plug_device/generic_smart_plug_entity.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_smart_tv/generic_smart_tv_entity.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_switch_device/generic_switch_entity.dart'; +import 'package:cbj_integrations_controller/injection.dart'; import 'package:mqtt_client/mqtt_client.dart'; import 'package:mqtt_client/mqtt_server_client.dart'; // ignore: implementation_imports import 'package:mqtt_client/src/observable/src/records.dart'; -@LazySingleton(as: IMqttServerRepository) class MqttServerRepository extends IMqttServerRepository { + MqttServerRepository() { + IMqttServerRepository.instance = this; + } + /// Static instance of connection to mqtt broker static MqttServerClient client = MqttServerClient('127.0.0.1', 'CBJ_Hub'); @@ -218,7 +220,7 @@ class MqttServerRepository extends IMqttServerRepository { deviceDeviceTypeThatChanged: mqttPublishMessage[0].payload, }; - final ISavedDevicesRepo savedDevicesRepo = getIt(); + final ISavedDevicesRepo savedDevicesRepo = getItCbj(); final Map allDevices = await savedDevicesRepo.getAllDevices(); @@ -381,7 +383,7 @@ class MqttServerRepository extends IMqttServerRepository { /// Resend the device object throw mqtt Future findDeviceAndResendItToMqtt(String deviceId) async { - final ISavedDevicesRepo savedDevicesRepo = getIt(); + final ISavedDevicesRepo savedDevicesRepo = getItCbj(); final Map allDevices = await savedDevicesRepo.getAllDevices(); @@ -410,7 +412,7 @@ class MqttServerRepository extends IMqttServerRepository { bool? gotFromApp, }) async { if (entityFromTheApp is DeviceEntityAbstract) { - final ISavedDevicesRepo savedDevicesRepo = getIt(); + final ISavedDevicesRepo savedDevicesRepo = getItCbj(); final Map allDevices = await savedDevicesRepo.getAllDevices(); final DeviceEntityAbstract? savedDeviceEntity = diff --git a/lib/infrastructure/node_red/node_red_converter.dart b/lib/infrastructure/node_red/node_red_converter.dart index 83e72d0a..35fa51b8 100644 --- a/lib/infrastructure/node_red/node_red_converter.dart +++ b/lib/infrastructure/node_red/node_red_converter.dart @@ -1,12 +1,12 @@ import 'package:cbj_hub/domain/binding/binding_cbj_entity.dart'; import 'package:cbj_hub/domain/binding/value_objects_routine_cbj.dart'; -import 'package:cbj_hub/domain/core/value_objects.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; import 'package:cbj_hub/domain/routine/routine_cbj_entity.dart'; import 'package:cbj_hub/domain/routine/value_objects_routine_cbj.dart'; import 'package:cbj_hub/domain/scene/scene_cbj_entity.dart'; import 'package:cbj_hub/domain/scene/value_objects_scene_cbj.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbenum.dart'; +import 'package:cbj_integrations_controller/domain/core/value_objects.dart'; +import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_abstract.dart'; import 'package:nodered/nodered.dart'; import 'package:uuid/uuid.dart'; diff --git a/lib/infrastructure/remote_pipes/remote_pipes_client.dart b/lib/infrastructure/remote_pipes/remote_pipes_client.dart index 5e6d3a8c..aeeaa982 100644 --- a/lib/infrastructure/remote_pipes/remote_pipes_client.dart +++ b/lib/infrastructure/remote_pipes/remote_pipes_client.dart @@ -2,17 +2,16 @@ import 'dart:async'; import 'dart:convert'; import 'package:cbj_hub/domain/app_communication/i_app_communication_repository.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_ping_device/generic_ping_entity.dart'; import 'package:cbj_hub/infrastructure/app_communication/app_communication_repository.dart'; -import 'package:cbj_hub/infrastructure/devices/device_helper/device_helper.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:cbj_hub/infrastructure/generic_devices/generic_ping_device/generic_ping_device_dtos.dart'; import 'package:cbj_hub/infrastructure/room/room_entity_dtos.dart'; import 'package:cbj_hub/infrastructure/routines/routine_cbj_dtos.dart'; import 'package:cbj_hub/infrastructure/scenes/scene_cbj_dtos.dart'; -import 'package:cbj_hub/injection.dart'; import 'package:cbj_hub/utils.dart'; +import 'package:cbj_integrations_controller/infrastructure/devices/device_helper/device_helper.dart'; +import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_ping_device/generic_ping_device_dtos.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_ping_device/generic_ping_entity.dart'; import 'package:grpc/grpc.dart'; import 'package:rxdart/rxdart.dart'; @@ -74,7 +73,7 @@ class RemotePipesClient { ); /// All responses from the app->remote pipes going int the hub - getIt().getFromApp( + IAppCommunicationRepository.instance.getFromApp( request: response, requestUrl: addressToHub, isRemotePipes: true, diff --git a/lib/infrastructure/room/saved_rooms_repo.dart b/lib/infrastructure/room/saved_rooms_repo.dart index ada728b7..38d0f1e7 100644 --- a/lib/infrastructure/room/saved_rooms_repo.dart +++ b/lib/infrastructure/room/saved_rooms_repo.dart @@ -2,47 +2,48 @@ import 'dart:collection'; import 'dart:math'; import 'package:cbj_hub/domain/binding/binding_cbj_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/local_db/i_local_db_repository.dart'; -import 'package:cbj_hub/domain/local_db/local_db_failures.dart'; import 'package:cbj_hub/domain/room/room_entity.dart'; import 'package:cbj_hub/domain/room/value_objects_room.dart'; import 'package:cbj_hub/domain/rooms/i_saved_rooms_repo.dart'; import 'package:cbj_hub/domain/routine/routine_cbj_entity.dart'; -import 'package:cbj_hub/domain/saved_devices/i_saved_devices_repo.dart'; import 'package:cbj_hub/domain/scene/i_scene_cbj_repository.dart'; import 'package:cbj_hub/domain/scene/scene_cbj_entity.dart'; import 'package:cbj_hub/domain/scene/scene_cbj_failures.dart'; -import 'package:cbj_hub/infrastructure/app_communication/app_communication_repository.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/injection.dart'; import 'package:cbj_hub/utils.dart'; +import 'package:cbj_integrations_controller/domain/local_db/local_db_failures.dart'; +import 'package:cbj_integrations_controller/domain/saved_devices/i_saved_devices_repo.dart'; +import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/injection.dart'; import 'package:dartz/dartz.dart'; -import 'package:injectable/injectable.dart'; -@LazySingleton(as: ISavedRoomsRepo) class SavedRoomsRepo extends ISavedRoomsRepo { + SavedRoomsRepo() { + ISavedRoomsRepo.instance = this; + } + static final HashMap _allRooms = HashMap(); @override Future setUpAllFromDb() async { - await getIt().getRoomsFromDb().then((value) { - value.fold((l) => null, (rooms) { - /// Gets all rooms from db, if there are non it will create and return - /// only a discovered room - if (rooms.isEmpty) { - final RoomEntity discoveredRoom = RoomEntity.empty().copyWith( - uniqueId: RoomUniqueId.discoveredRoomId(), - cbjEntityName: RoomDefaultName.discoveredRoomName(), - ); - rooms.add(discoveredRoom); - } - for (final element in rooms) { - addOrUpdateRoom(element); - } - }); - }); + // TODO: Fix after new cbj_integrations_controller + // await getItCbj().getRoomsFromDb().then((value) { + // value.fold((l) => null, (rooms) { + // /// Gets all rooms from db, if there are non it will create and return + // /// only a discovered room + // if (rooms.isEmpty) { + // final RoomEntity discoveredRoom = RoomEntity.empty().copyWith( + // uniqueId: RoomUniqueId.discoveredRoomId(), + // cbjEntityName: RoomDefaultName.discoveredRoomName(), + // ); + // rooms.add(discoveredRoom); + // } + // for (final element in rooms) { + // addOrUpdateRoom(element); + // } + // }); + // }); } @override @@ -260,27 +261,28 @@ class SavedRoomsRepo extends ISavedRoomsRepo { _allRooms[roomId] = roomEntityCombinedDevices; } // TODO: check if this line is not redundant - await getIt().saveAndActivateSmartDevicesToDb(); + await getItCbj().saveAndActivateSmartDevicesToDb(); await createScenesForAllSelectedRoomTypes( roomEntity: roomEntityTemp, newRoom: newRoom, ); - await getIt() + await getItCbj() .addDevicesToMultipleScenesAreaTypeWithPreSetActions( devicesId: newDevicesList, scenesId: _allRooms[roomId]!.roomScenesId.getOrCrash(), areaTypes: _allRooms[roomId]!.roomTypes.getOrCrash(), ); - - final Future> saveRoomToDbResponse = - getIt().saveRoomsToDb( - roomsList: List.from(_allRooms.values), - ); - - AppCommunicationRepository.sendAllRoomsFromHubRequestsStream(); - return saveRoomToDbResponse; + // TODO: Fix after new cbj_integrations_controller + // final Future> saveRoomToDbResponse = + // getItCbj().saveRoomsToDb( + // roomsList: List.from(_allRooms.values), + // ); + // + // AppCommunicationRepository.sendAllRoomsFromHubRequestsStream(); + // return saveRoomToDbResponse; + return left(const LocalDbFailures.unableToUpdate()); } @override @@ -330,7 +332,7 @@ class SavedRoomsRepo extends ISavedRoomsRepo { final String areaNameEdited = areaNameCapsWithSpces(areaPurposeType); final Either sceneOrFailure = - await getIt() + await getItCbj() .addOrUpdateNewSceneInHubFromDevicesPropertyActionList( areaNameEdited, [], diff --git a/lib/infrastructure/routines/routine_cbj_dtos.dart b/lib/infrastructure/routines/routine_cbj_dtos.dart index 085a7d57..55130474 100644 --- a/lib/infrastructure/routines/routine_cbj_dtos.dart +++ b/lib/infrastructure/routines/routine_cbj_dtos.dart @@ -1,4 +1,4 @@ -import 'package:cbj_hub/domain/core/value_objects.dart'; +import 'package:cbj_integrations_controller/domain/core/value_objects.dart'; import 'package:cbj_hub/domain/routine/routine_cbj_entity.dart'; import 'package:cbj_hub/domain/routine/value_objects_routine_cbj.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; diff --git a/lib/infrastructure/routines/routine_repository.dart b/lib/infrastructure/routines/routine_repository.dart index d57454f4..6875b018 100644 --- a/lib/infrastructure/routines/routine_repository.dart +++ b/lib/infrastructure/routines/routine_repository.dart @@ -1,14 +1,11 @@ -import 'package:cbj_hub/domain/local_db/i_local_db_repository.dart'; -import 'package:cbj_hub/domain/local_db/local_db_failures.dart'; -import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart'; import 'package:cbj_hub/domain/rooms/i_saved_rooms_repo.dart'; import 'package:cbj_hub/domain/routine/i_routine_cbj_repository.dart'; import 'package:cbj_hub/domain/routine/routine_cbj_entity.dart'; import 'package:cbj_hub/domain/routine/routine_cbj_failures.dart'; -import 'package:cbj_hub/domain/routine/value_objects_routine_cbj.dart'; -import 'package:cbj_hub/domain/saved_devices/i_saved_devices_repo.dart'; -import 'package:cbj_hub/infrastructure/node_red/node_red_repository.dart'; -import 'package:cbj_hub/injection.dart'; +import 'package:cbj_integrations_controller/domain/local_db/local_db_failures.dart'; +import 'package:cbj_integrations_controller/domain/mqtt_server/i_mqtt_server_repository.dart'; +import 'package:cbj_integrations_controller/domain/saved_devices/i_saved_devices_repo.dart'; +import 'package:cbj_integrations_controller/injection.dart'; import 'package:dartz/dartz.dart'; import 'package:injectable/injectable.dart'; @@ -18,13 +15,14 @@ class RoutineCbjRepository implements IRoutineCbjRepository { @override Future setUpAllFromDb() async { - await getIt().getRoutinesFromDb().then((value) { - value.fold((l) => null, (r) async { - for (final element in r) { - await addNewRoutine(element); - } - }); - }); + // TODO: Fix after new cbj_integrations_controller + // await getItCbj().getRoutinesFromDb().then((value) { + // value.fold((l) => null, (r) async { + // for (final element in r) { + // await addNewRoutine(element); + // } + // }); + // }); } @override @@ -38,17 +36,20 @@ class RoutineCbjRepository implements IRoutineCbjRepository { } @override - Future> saveAndActivateRoutineToDb() { - return getIt().saveRoutines( - routineList: List.from(_allRoutines.values), - ); + Future> saveAndActivateRoutineToDb() async { + // TODO: Fix after new cbj_integrations_controller + // + // return getItCbj().saveRoutines( + // routineList: List.from(_allRoutines.values), + // ); + return left(const LocalDbFailures.unableToUpdate()); } @override Future> addNewRoutine( RoutineCbjEntity routineCbj, ) async { - RoutineCbjEntity tempRoutineCbj = routineCbj; + final RoutineCbjEntity tempRoutineCbj = routineCbj; /// Check if routine already exist if (findRoutineIfAlreadyBeenAdded(tempRoutineCbj) == null) { @@ -61,15 +62,17 @@ class RoutineCbjRepository implements IRoutineCbjRepository { /// If it is new routine _allRoutines[entityId] = tempRoutineCbj; - getIt() + ISavedRoomsRepo.instance .addRoutineToRoomDiscoveredIfNotExist(tempRoutineCbj); - final String routineNodeRedFlowId = await getIt() - .createNewNodeRedRoutine(tempRoutineCbj); - if (routineNodeRedFlowId.isNotEmpty) { - tempRoutineCbj = tempRoutineCbj.copyWith( - nodeRedFlowId: RoutineCbjNodeRedFlowId(routineNodeRedFlowId), - ); - } + // TODO: Fix after new cbj_integrations_controller + // final String routineNodeRedFlowId = await getItCbj() + // .createNewNodeRedRoutine(tempRoutineCbj); + // if (routineNodeRedFlowId.isNotEmpty) { + // tempRoutineCbj = tempRoutineCbj.copyWith( + // nodeRedFlowId: RoutineCbjNodeRedFlowId(routineNodeRedFlowId), + // ); + // } + return left(const RoutineCbjFailure.unableToUpdate()); } return right(unit); } @@ -79,7 +82,7 @@ class RoutineCbjRepository implements IRoutineCbjRepository { RoutineCbjEntity routineCbj, ) async { await addNewRoutine(routineCbj); - await getIt().saveAndActivateSmartDevicesToDb(); + await getItCbj().saveAndActivateSmartDevicesToDb(); await saveAndActivateRoutineToDb(); return right(unit); @@ -90,7 +93,7 @@ class RoutineCbjRepository implements IRoutineCbjRepository { RoutineCbjEntity routineCbj, ) async { final String fullPathOfRoutine = await getFullMqttPathOfRoutine(routineCbj); - getIt() + IMqttServerRepository.instance .publishMessage(fullPathOfRoutine, DateTime.now().toString()); return true; @@ -100,9 +103,9 @@ class RoutineCbjRepository implements IRoutineCbjRepository { @override Future getFullMqttPathOfRoutine(RoutineCbjEntity routineCbj) async { final String hubBaseTopic = - getIt().getHubBaseTopic(); + IMqttServerRepository.instance.getHubBaseTopic(); final String routinesTopicTypeName = - getIt().getRoutinesTopicTypeName(); + IMqttServerRepository.instance.getRoutinesTopicTypeName(); final String routineId = routineCbj.firstNodeId.getOrCrash()!; return '$hubBaseTopic/$routinesTopicTypeName/$routineId'; diff --git a/lib/infrastructure/saved_devices/saved_devices_repo.dart b/lib/infrastructure/saved_devices/saved_devices_repo.dart deleted file mode 100644 index 3a95fe29..00000000 --- a/lib/infrastructure/saved_devices/saved_devices_repo.dart +++ /dev/null @@ -1,149 +0,0 @@ -import 'dart:collection'; - -import 'package:cbj_hub/domain/app_communication/i_app_communication_repository.dart'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/local_db/i_local_db_repository.dart'; -import 'package:cbj_hub/domain/local_db/local_db_failures.dart'; -import 'package:cbj_hub/domain/remote_pipes/remote_pipes_entity.dart'; -import 'package:cbj_hub/domain/rooms/i_saved_rooms_repo.dart'; -import 'package:cbj_hub/domain/saved_devices/i_saved_devices_repo.dart'; -import 'package:cbj_hub/domain/vendors/login_abstract/login_entity_abstract.dart'; -import 'package:cbj_hub/infrastructure/devices/companies_connector_conjector.dart'; -import 'package:cbj_hub/infrastructure/remote_pipes/remote_pipes_dtos.dart'; -import 'package:cbj_hub/injection.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; -import 'package:injectable/injectable.dart'; - -@LazySingleton(as: ISavedDevicesRepo) -class SavedDevicesRepo extends ISavedDevicesRepo { - static final HashMap _allDevices = - HashMap(); - - static bool setUpAllFromDbAtLestOnce = false; - - @override - Future setUpAllFromDb() async { - await getIt().getSmartDevicesFromDb().then((value) { - value.fold((l) => null, (r) { - for (final element in r) { - addOrUpdateDevice(element); - } - }); - }); - setUpAllFromDbAtLestOnce = true; - } - - @override - Future> getAllDevices() async { - while (!setUpAllFromDbAtLestOnce) { - await Future.delayed(const Duration(milliseconds: 200)); - } - return _allDevices; - } - - @override - DeviceEntityAbstract? addOrUpdateFromMqtt(dynamic updateFromMqtt) { - if (updateFromMqtt is DeviceEntityAbstract) { - return addOrUpdateDevice(updateFromMqtt); - } else { - logger.w('Add or update type from MQTT not supported'); - } - return null; - } - - @override - DeviceEntityAbstract addOrUpdateDevice(DeviceEntityAbstract deviceEntity) { - final DeviceEntityAbstract? deviceExistByIdOfVendor = - findDeviceIfAlreadyBeenAdded(deviceEntity); - - /// Check if device already exist - if (deviceExistByIdOfVendor != null) { - deviceEntity.uniqueId = deviceExistByIdOfVendor.uniqueId; - _allDevices[deviceExistByIdOfVendor.uniqueId.getOrCrash()] = deviceEntity; - return deviceEntity; - } - - final String entityId = deviceEntity.getDeviceId(); - - /// If it is new device - _allDevices[entityId] = deviceEntity; - - getIt().addDeviceToRoomDiscoveredIfNotExist(deviceEntity); - - return deviceEntity; - - // - // ConnectorStreamToMqtt.toMqttController.sink.add( - // MapEntry( - // entityId, - // allDevices[entityId]!, - // ), - // ); - // ConnectorStreamToMqtt.toMqttController.sink.add( - // MapEntry( - // discoveredRoomId, - // allRooms[discoveredRoomId]!, - // ), - // ); - } - - @override - Future> saveAndActivateRemotePipesDomainToDb({ - required RemotePipesEntity remotePipes, - }) async { - final RemotePipesDtos remotePipesDtos = remotePipes.toInfrastructure(); - - final String rpDomainName = remotePipesDtos.domainName; - - getIt() - .startRemotePipesConnection(rpDomainName); - - return getIt() - .saveRemotePipes(remotePipesDomainName: rpDomainName); - } - - @override - Future> - saveAndActivateVendorLoginCredentialsDomainToDb({ - required LoginEntityAbstract loginEntity, - }) async { - CompaniesConnectorConjector.setVendorLoginCredentials(loginEntity); - - return getIt() - .saveVendorLoginCredentials(loginEntityAbstract: loginEntity); - } - - /// Check if allDevices does not contain the same device already - /// Will compare the unique id's that each company sent us - DeviceEntityAbstract? findDeviceIfAlreadyBeenAdded( - DeviceEntityAbstract deviceEntity, - ) { - for (final DeviceEntityAbstract deviceTemp in _allDevices.values) { - if (deviceEntity.entityUniqueId.getOrCrash() == - deviceTemp.entityUniqueId.getOrCrash()) { - return deviceTemp; - } - } - return null; - } - - @override - Future> - saveAndActivateSmartDevicesToDb() async { - return getIt().saveSmartDevices( - deviceList: List.from(_allDevices.values), - ); - } - - @override - Future> getDeviceById( - String entityUniqueId, - ) async { - final DeviceEntityAbstract? device = _allDevices[entityUniqueId]; - if (device != null) { - return right(device); - } - return left(const LocalDbFailures.unexpected()); - } -} diff --git a/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/bed_room_area_actions.dart b/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/bed_room_area_actions.dart index 977a6339..b37de67d 100644 --- a/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/bed_room_area_actions.dart +++ b/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/bed_room_area_actions.dart @@ -1,6 +1,6 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_abstract.dart'; import 'package:cbj_hub/domain/scene/scene_cbj_failures.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; +import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_hub/infrastructure/scenes/area_types_scientific_presets/common_devices_scenes_presets_for_devices.dart'; import 'package:dartz/dartz.dart'; diff --git a/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/outside_area_actions.dart b/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/outside_area_actions.dart index 17fc2c15..3348d664 100644 --- a/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/outside_area_actions.dart +++ b/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/outside_area_actions.dart @@ -1,6 +1,6 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_abstract.dart'; import 'package:cbj_hub/domain/scene/scene_cbj_failures.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; +import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_hub/infrastructure/scenes/area_types_scientific_presets/common_devices_scenes_presets_for_devices.dart'; import 'package:dartz/dartz.dart'; diff --git a/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/study_room_area_actions.dart b/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/study_room_area_actions.dart index 399fc679..abb9b9db 100644 --- a/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/study_room_area_actions.dart +++ b/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/study_room_area_actions.dart @@ -1,6 +1,6 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_abstract.dart'; import 'package:cbj_hub/domain/scene/scene_cbj_failures.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; +import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_hub/infrastructure/scenes/area_types_scientific_presets/common_devices_scenes_presets_for_devices.dart'; import 'package:dartz/dartz.dart'; diff --git a/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/video_games_area_actions.dart b/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/video_games_area_actions.dart index 0a4a4d52..419467ec 100644 --- a/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/video_games_area_actions.dart +++ b/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/video_games_area_actions.dart @@ -1,6 +1,6 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_abstract.dart'; import 'package:cbj_hub/domain/scene/scene_cbj_failures.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; +import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_hub/infrastructure/scenes/area_types_scientific_presets/common_devices_scenes_presets_for_devices.dart'; import 'package:dartz/dartz.dart'; diff --git a/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/work_room_area_actions.dart b/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/work_room_area_actions.dart index f5160ae7..d9dfca36 100644 --- a/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/work_room_area_actions.dart +++ b/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/work_room_area_actions.dart @@ -1,6 +1,6 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_abstract.dart'; import 'package:cbj_hub/domain/scene/scene_cbj_failures.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; +import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_hub/infrastructure/scenes/area_types_scientific_presets/common_devices_scenes_presets_for_devices.dart'; import 'package:dartz/dartz.dart'; diff --git a/lib/infrastructure/scenes/area_types_scientific_presets/area_type_with_device_type_preset.dart b/lib/infrastructure/scenes/area_types_scientific_presets/area_type_with_device_type_preset.dart index 509e7f88..772da4c5 100644 --- a/lib/infrastructure/scenes/area_types_scientific_presets/area_type_with_device_type_preset.dart +++ b/lib/infrastructure/scenes/area_types_scientific_presets/area_type_with_device_type_preset.dart @@ -1,15 +1,15 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/local_db/local_db_failures.dart'; -import 'package:cbj_hub/domain/matirial_colors/colors.dart'; -import 'package:cbj_hub/domain/saved_devices/i_saved_devices_repo.dart'; import 'package:cbj_hub/domain/scene/scene_cbj_failures.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_hub/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/bed_room_area_actions.dart'; import 'package:cbj_hub/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/outside_area_actions.dart'; import 'package:cbj_hub/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/study_room_area_actions.dart'; import 'package:cbj_hub/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/video_games_area_actions.dart'; import 'package:cbj_hub/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/work_room_area_actions.dart'; -import 'package:cbj_hub/injection.dart'; +import 'package:cbj_integrations_controller/domain/local_db/local_db_failures.dart'; +import 'package:cbj_integrations_controller/domain/matirial_colors/colors.dart'; +import 'package:cbj_integrations_controller/domain/saved_devices/i_saved_devices_repo.dart'; +import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/injection.dart'; import 'package:dartz/dartz.dart'; /// Pre define actions for each device in each area type @@ -21,7 +21,7 @@ class AreaTypeWithDeviceTypePreset { required String brokerNodeId, }) async { final Either dTemp = - await getIt().getDeviceById(deviceId); + await getItCbj().getDeviceById(deviceId); if (dTemp.isLeft()) { return left(const SceneCbjFailure.unexpected()); } diff --git a/lib/infrastructure/scenes/area_types_scientific_presets/common_devices_scenes_presets_for_devices.dart b/lib/infrastructure/scenes/area_types_scientific_presets/common_devices_scenes_presets_for_devices.dart index 9cf5a593..ab3471ef 100644 --- a/lib/infrastructure/scenes/area_types_scientific_presets/common_devices_scenes_presets_for_devices.dart +++ b/lib/infrastructure/scenes/area_types_scientific_presets/common_devices_scenes_presets_for_devices.dart @@ -1,14 +1,14 @@ -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_blinds_device/generic_blinds_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_boiler_device/generic_boiler_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_light_device/generic_light_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_rgbw_light_device/generic_rgbw_light_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_computer_device/generic_smart_computer_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_plug_device/generic_smart_plug_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_smart_tv/generic_smart_tv_entity.dart'; -import 'package:cbj_hub/domain/generic_devices/generic_switch_device/generic_switch_entity.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_hub/infrastructure/node_red/node_red_converter.dart'; +import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_blinds_device/generic_blinds_entity.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_boiler_device/generic_boiler_entity.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_light_device/generic_light_entity.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_rgbw_light_device/generic_rgbw_light_entity.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_smart_computer_device/generic_smart_computer_entity.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_smart_plug_device/generic_smart_plug_entity.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_smart_tv/generic_smart_tv_entity.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_switch_device/generic_switch_entity.dart'; class CommonDevicesScenesPresetsForDevices { /// TODO: add TypeNotSupported preset diff --git a/lib/infrastructure/scenes/scene_cbj_dtos.dart b/lib/infrastructure/scenes/scene_cbj_dtos.dart index 1c7eec96..cbc17859 100644 --- a/lib/infrastructure/scenes/scene_cbj_dtos.dart +++ b/lib/infrastructure/scenes/scene_cbj_dtos.dart @@ -1,4 +1,4 @@ -import 'package:cbj_hub/domain/core/value_objects.dart'; +import 'package:cbj_integrations_controller/domain/core/value_objects.dart'; import 'package:cbj_hub/domain/scene/scene_cbj_entity.dart'; import 'package:cbj_hub/domain/scene/value_objects_scene_cbj.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; diff --git a/lib/infrastructure/scenes/scene_repository.dart b/lib/infrastructure/scenes/scene_repository.dart index d8301c84..c1fca5fb 100644 --- a/lib/infrastructure/scenes/scene_repository.dart +++ b/lib/infrastructure/scenes/scene_repository.dart @@ -1,24 +1,22 @@ import 'dart:collection'; import 'dart:convert'; -import 'package:cbj_hub/domain/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/local_db/i_local_db_repository.dart'; -import 'package:cbj_hub/domain/local_db/local_db_failures.dart'; -import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart'; import 'package:cbj_hub/domain/rooms/i_saved_rooms_repo.dart'; -import 'package:cbj_hub/domain/saved_devices/i_saved_devices_repo.dart'; import 'package:cbj_hub/domain/scene/i_scene_cbj_repository.dart'; import 'package:cbj_hub/domain/scene/scene_cbj_entity.dart'; import 'package:cbj_hub/domain/scene/scene_cbj_failures.dart'; import 'package:cbj_hub/domain/scene/value_objects_scene_cbj.dart'; import 'package:cbj_hub/infrastructure/app_communication/app_communication_repository.dart'; -import 'package:cbj_hub/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_hub/infrastructure/node_red/node_red_converter.dart'; -import 'package:cbj_hub/infrastructure/node_red/node_red_repository.dart'; import 'package:cbj_hub/infrastructure/room/saved_rooms_repo.dart'; import 'package:cbj_hub/infrastructure/scenes/area_types_scientific_presets/area_type_with_device_type_preset.dart'; -import 'package:cbj_hub/injection.dart'; import 'package:cbj_hub/utils.dart'; +import 'package:cbj_integrations_controller/domain/local_db/local_db_failures.dart'; +import 'package:cbj_integrations_controller/domain/mqtt_server/i_mqtt_server_repository.dart'; +import 'package:cbj_integrations_controller/domain/saved_devices/i_saved_devices_repo.dart'; +import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_abstract.dart'; +import 'package:cbj_integrations_controller/injection.dart'; import 'package:dartz/dartz.dart'; import 'package:injectable/injectable.dart'; import 'package:kt_dart/kt.dart'; @@ -30,13 +28,14 @@ class SceneCbjRepository implements ISceneCbjRepository { @override Future setUpAllFromDb() async { - await getIt().getScenesFromDb().then((value) { - value.fold((l) => null, (r) { - for (final element in r) { - addNewScene(element); - } - }); - }); + // TODO: Fix after new cbj_integrations_controller + // await getItCbj().getScenesFromDb().then((value) { + // value.fold((l) => null, (r) { + // for (final element in r) { + // addNewScene(element); + // } + // }); + // }); } @override @@ -52,11 +51,13 @@ class SceneCbjRepository implements ISceneCbjRepository { @override Future> saveAndActivateScenesAndSmartDevicesToDb() async { - await getIt().saveAndActivateSmartDevicesToDb(); + await getItCbj().saveAndActivateSmartDevicesToDb(); - return getIt().saveScenes( - sceneList: List.from(_allScenes.values), - ); + // TODO: Fix after new cbj_integrations_controller + // return getItCbj().saveScenes( + // sceneList: List.from(_allScenes.values), + // ); + return left(const LocalDbFailures.unableToUpdate()); } @override @@ -87,8 +88,9 @@ class SceneCbjRepository implements ISceneCbjRepository { if (existingScene == null || tempSceneCbj.automationString.getOrCrash() != existingScene.automationString.getOrCrash()) { - sceneNodeRedFlowId = - await getIt().createNewNodeRedScene(tempSceneCbj); + // TODO: Fix after new cbj_integrations_controller + // sceneNodeRedFlowId = + // await getItCbj().createNewNodeRedScene(tempSceneCbj); } if (sceneNodeRedFlowId.isNotEmpty) { @@ -96,7 +98,7 @@ class SceneCbjRepository implements ISceneCbjRepository { nodeRedFlowId: SceneCbjNodeRedFlowId(sceneNodeRedFlowId), ); } - getIt().addSceneToRoomDiscoveredIfNotExist(tempSceneCbj); + ISavedRoomsRepo.instance.addSceneToRoomDiscoveredIfNotExist(tempSceneCbj); _allScenes[tempSceneCbj.uniqueId.getOrCrash()] = tempSceneCbj; return right(sceneNodeRedFlowId); } @@ -114,7 +116,7 @@ class SceneCbjRepository implements ISceneCbjRepository { @override Future activateScene(SceneCbjEntity sceneCbj) async { final String fullPathOfScene = await getFullMqttPathOfScene(sceneCbj); - getIt() + IMqttServerRepository.instance .publishMessage(fullPathOfScene, DateTime.now().toString()); return true; @@ -124,9 +126,9 @@ class SceneCbjRepository implements ISceneCbjRepository { @override Future getFullMqttPathOfScene(SceneCbjEntity sceneCbj) async { final String hubBaseTopic = - getIt().getHubBaseTopic(); + IMqttServerRepository.instance.getHubBaseTopic(); final String scenesTopicTypeName = - getIt().getScenesTopicTypeName(); + IMqttServerRepository.instance.getScenesTopicTypeName(); final String sceneId = sceneCbj.firstNodeId.getOrCrash()!; return '$hubBaseTopic/$scenesTopicTypeName/$sceneId'; @@ -162,9 +164,9 @@ class SceneCbjRepository implements ISceneCbjRepository { if (tempScene != null) { sceneCbjEntityTemp = sceneCbjEntityTemp.copyWith(nodeRedFlowId: tempScene.nodeRedFlowId); - - nodeRedFlowId = await getIt() - .createNewNodeRedScene(sceneCbjEntityTemp); + // TODO: Fix after new cbj_integrations_controller + // nodeRedFlowId = await getItCbj() + // .createNewNodeRedScene(sceneCbjEntityTemp); sceneCbjEntityTemp = sceneCbjEntityTemp.copyWith( nodeRedFlowId: SceneCbjNodeRedFlowId(nodeRedFlowId), @@ -395,8 +397,9 @@ class SceneCbjRepository implements ISceneCbjRepository { if (tempScene != null) { scene = scene.copyWith(nodeRedFlowId: tempScene.nodeRedFlowId); - nodeRedFlowId = - await getIt().createNewNodeRedScene(scene); + // TODO: Fix after new cbj_integrations_controller + // nodeRedFlowId = + // await getItCbj().createNewNodeRedScene(scene); scene = scene.copyWith(nodeRedFlowId: SceneCbjNodeRedFlowId(nodeRedFlowId)); diff --git a/lib/infrastructure/system_commands/bash_commands_d/bash_commands_for_raspberry_pi_d.dart b/lib/infrastructure/system_commands/bash_commands_d/bash_commands_for_raspberry_pi_d.dart deleted file mode 100644 index 44cff4bc..00000000 --- a/lib/infrastructure/system_commands/bash_commands_d/bash_commands_for_raspberry_pi_d.dart +++ /dev/null @@ -1,25 +0,0 @@ -import 'dart:io'; - -import 'package:cbj_hub/utils.dart'; - -class BashCommandsForRaspberryPi { - static Future getRaspberryPiDeviceVersion() async { - String piVersion = await Process.run('cat', ['/proc/cpuinfo']) - .then((ProcessResult result) { - return result.stdout.toString(); - }); - - if (!piVersion.contains('Model')) { - return null; - } - piVersion = piVersion.substring(piVersion.indexOf('Model')); - - logger.t('This is the Pi Version: $piVersion'); - - piVersion = piVersion.substring(piVersion.indexOf(':') + 2); - - piVersion = piVersion.trim().replaceAll(' ', '_').replaceAll('.', '_'); - - return piVersion; - } -} diff --git a/lib/infrastructure/system_commands/bash_commands_d/common_bash_commands_d.dart b/lib/infrastructure/system_commands/bash_commands_d/common_bash_commands_d.dart deleted file mode 100644 index 8b348066..00000000 --- a/lib/infrastructure/system_commands/bash_commands_d/common_bash_commands_d.dart +++ /dev/null @@ -1,165 +0,0 @@ -import 'dart:io'; - -import 'package:cbj_hub/infrastructure/shared_variables.dart'; -import 'package:cbj_hub/infrastructure/system_commands/system_commands_base_class_d.dart'; -import 'package:cbj_hub/infrastructure/system_commands/system_commands_manager_d.dart'; -import 'package:cbj_hub/injection.dart'; -import 'package:cbj_hub/utils.dart'; - -class CommonBashCommandsD implements SystemCommandsBaseClassD { - Future asyncConstractor() async { - getIt(); - } - - @override - Future getCurrentUserName() async { - final String whoami = - await Process.run('id', ['-nu']).then((ProcessResult result) { - // whoami is getting permission error inside the snap - // await Process.run('whoami', []).then((ProcessResult result) { - return result.stdout.toString(); - }); - return whoami.trim(); - } - - @override - Future getUuidOfCurrentDevice() async { - String df = await Process.run('df', ['-h', '/']) - .then((ProcessResult result) { - return result.stdout.toString(); - }); - - df = df.substring(df.indexOf('\n') + 1); - df = df.substring(0, df.indexOf(' ')); - - // The full bash command looks like this /sbin/blkid | grep "$(df -h / | sed -n 2p | cut -d" " -f1):" | grep -o "UUID=\"[^\"]*\" " | sed "s/UUID=\"//;s/\"//" - String blkid = - await Process.run('/sbin/blkid', []).then((ProcessResult result) { - return result.stdout.toString(); - }); - - if (doesExistAndStringContainUuid(blkid, df)) { - blkid = blkid.substring(blkid.indexOf(df)); - } else if (doesExistAndStringContainUuid(blkid, '/dev/mmcblk0p1')) { - blkid = blkid.substring(blkid.indexOf('/dev/mmcblk0p1')); - } else if (doesExistAndStringContainUuid(blkid, '/dev/mmcblk0p2')) { - blkid = blkid.substring(blkid.indexOf('/dev/mmcblk0p2')); - } else if (doesExistAndStringContainUuid(blkid, '/dev/zram0')) { - blkid = blkid.substring(blkid.indexOf('/dev/zram0')); - } else if (doesExistAndStringContainUuid(blkid, '/dev/zram1')) { - blkid = blkid.substring(blkid.indexOf('/dev/zram1')); - } else { - blkid = blkid.substring(blkid.indexOf('/dev/')); - } - - blkid = blkid.trim(); - - final String uuid = blkid.substring(blkid.indexOf('UUID="') + 6); - return uuid.substring(0, uuid.indexOf('"')); - } - - @override - Future getDeviceHostName() async { - final String hostName = await Process.run('hostname', ['-s']) - .then((ProcessResult result) { -// String hostName = result.stdout; -// hostName = hostName.substring( -// 0, hostName.length - 1); // Removes the invisible new line at the end -// logger.t('Host name: ' + hostName); - return result.stdout.toString(); - }); - return hostName.trim(); - } - - @override - Future getAllEtcReleaseFilesText() async { - /// TODO: need to be replaced with echo $(cat /proc/device-tree/model) for nanopi - String etcReleaseFiles = ''; - - try { - final List allContents = - await Directory('/etc/').list().toList(); - - final List etcReleaseFilesNames = []; - for (final FileSystemEntity f in allContents) { - if (f.toString().contains('release')) { - etcReleaseFilesNames.add(f.path); - } - } - for (final String releaseContent in etcReleaseFilesNames) { - etcReleaseFiles += File(releaseContent).readAsStringSync(); - } - } catch (error) { - logger.e( - 'Error getting all files from /etc/ that end with release\n$error', - ); - } - return etcReleaseFiles; - } - - @override - Future getFileContent(String fileFullPath) async { - final String fileContent = await Process.run('cat', [fileFullPath]) - .then((ProcessResult result) { - return result.stdout.toString(); - }); - - if (fileContent == '') { - return null; - } - return fileContent; - } - - @override - Future getDeviceConfiguration() { - return getFileContent('/etc/cbjinni/deviceConfigs.txt'); - } - - bool doesExistAndStringContainUuid(String blkid, String driveName) { - return blkid.contains(driveName) && - blkid.substring(blkid.indexOf(driveName)).contains('UUID="'); - } - - @override - Future getLocalDbPath( - Future currentUserName, - ) async { - String localDbFolderPath; - - final String? snapCommonEnvironmentVariable = - getIt().getSnapCommonEnvironmentVariable(); - if (snapCommonEnvironmentVariable == null) { - localDbFolderPath = '/home/${await currentUserName}/'; - } else { - // /var/snap/cbj-hub/common/isar - localDbFolderPath = snapCommonEnvironmentVariable; - } - return localDbFolderPath; - } - - @override - Future getProjectFilesLocation() async { - final String? snapLocation = - getIt().getSnapLocationEnvironmentVariable(); - if (snapLocation == null) { - return Directory.current.path; - } - - return snapLocation; - } - - @override - Future getIpFromMdnsName(String mdnsName) async { - try { - final String fileContent = - await Process.run('avahi-resolve-host-name', [mdnsName]) - .then((ProcessResult result) { - return result.stdout.toString(); - }); - return fileContent.substring(fileContent.indexOf('\t') + 1).trim(); - } catch (e) { - logger.w("Can't get device IP from mdns $mdnsName\n$e"); - } - return null; - } -} diff --git a/lib/infrastructure/system_commands/batch_commands_d/common_batch_commands_d.dart b/lib/infrastructure/system_commands/batch_commands_d/common_batch_commands_d.dart deleted file mode 100644 index b51221a7..00000000 --- a/lib/infrastructure/system_commands/batch_commands_d/common_batch_commands_d.dart +++ /dev/null @@ -1,141 +0,0 @@ -import 'dart:io'; - -import 'package:cbj_hub/infrastructure/system_commands/system_commands_base_class_d.dart'; -import 'package:cbj_hub/utils.dart'; - -class CommonBatchCommandsD implements SystemCommandsBaseClassD { - String? currentUserName; - String? currentDriveLetter; - - @override - Future getCurrentUserName() async { - if (currentUserName != null) { - return currentUserName!; - } - final String whoAmI = - await Process.run('cmd', ['/C', 'echo', '%username%']) - .then((ProcessResult result) { - return result.stdout.toString(); - }); - currentUserName = whoAmI.substring(0, whoAmI.indexOf('\r')); - return currentUserName!; - } - - @override - Future getUuidOfCurrentDevice() async { - final String uuid = await Process.run('cmd', [ - '/C', - 'wmic', - 'path', - 'win32_computersystemproduct', - 'get', - 'uuid', - ]).then((ProcessResult result) { - return result.stdout.toString(); - }); - return uuid - .substring(uuid.indexOf('\n') + 1) - .substring(0, uuid.indexOf('\r')) - .substring(0, uuid.indexOf(' ')); - } - - @override - Future getDeviceHostName() async { - final String hostName = - await Process.run('cmd', ['/C', 'echo', '%COMPUTERNAME%']) - .then((ProcessResult result) { - return result.stdout.toString(); - }); - return hostName.substring(0, hostName.indexOf('\r')); - } - - @override - Future getAllEtcReleaseFilesText() { - //TODO: add implementation, for now will return getDeviceHostName - return getDeviceHostName(); - } - - @override - Future getFileContent(String fileFullPath) async { - final String fileText = await Process.run( - 'cmd', - ['/C', 'more', fileFullPath], - ).then((ProcessResult result) { - return result.stdout.toString(); - }); - return fileText; - } - - @override - Future getDeviceConfiguration() async { - // String fileFullPath = (await getOsDriveLetter()) + r'\Users\' + (await getCurrentUserName()) + r'\Documents\cbjinni\deviceConfigs.txt'; // Needed to fix function getOsDriveLetter before - final String fileFullPath = (await getCurrentDriveLetter()) + - r'\Users\' + - (await getCurrentUserName()) + - r'\Documents\cbjinni\deviceConfigs.txt'; // Will only work if the program located in the os driver - - String fileContent = await getFileContent(fileFullPath); - if (fileContent.isEmpty) { - // Windows is weird and needs help - fileContent = await getFileContent('$fileFullPath.txt'); - } - if (fileContent.isEmpty) { - logger.w( - 'Config file does not exist or empty, path searching: $fileFullPath', - ); - return ''; - } - return fileContent.substring(0, fileContent.indexOf('\r')); - } - - Future getCurrentDriveLetter() async { - if (currentDriveLetter != null) { - return currentDriveLetter!; - } - - final String driveLetter; - driveLetter = await Process.run( - 'cmd', - ['/C', 'echo', '%cd:~0,2%'], - ).then((ProcessResult result) { - return result.stdout.toString(); - }); - - currentDriveLetter = driveLetter.substring(0, driveLetter.indexOf('\r')); - - return currentDriveLetter!; - } - - //TODO: Currently does not work as echo %~dp0 will not work at the command - // line, only in a batch file. - Future getOsDriveLetter() async { - final String driveLetter = - await Process.run('cmd', ['/C', 'echo', '%~d0']) - .then((ProcessResult result) { - return result.stdout.toString(); - }); - return driveLetter.substring(0, driveLetter.indexOf('\r')); - } - - @override - Future getLocalDbPath( - Future currentUserName, - ) async { - final String cbjFullPath = (await getCurrentDriveLetter()) + - r'\Users\' + - (await getCurrentUserName()) + - r'\Documents\cbjinni\'; // Will only work if the program located in the os driver - return cbjFullPath; - } - - @override - Future getProjectFilesLocation() async { - return Directory.current.path; - } - - @override - Future getIpFromMdnsName(String mdnsName) async { - // TODO: implement getIpFromMdnsName - throw UnimplementedError(); - } -} diff --git a/lib/infrastructure/system_commands/device_pin_manager.dart b/lib/infrastructure/system_commands/device_pin_manager.dart deleted file mode 100644 index de12b5d5..00000000 --- a/lib/infrastructure/system_commands/device_pin_manager.dart +++ /dev/null @@ -1,97 +0,0 @@ -import 'package:cbj_hub/domain/generic_devices/device_type_enums.dart'; -import 'package:cbj_hub/infrastructure/system_commands/system_commands_manager_d.dart'; -import 'package:cbj_hub/injection.dart'; -import 'package:cbj_hub/utils.dart'; - -/// This class save all the configuration of the pins per device, -/// every device have different pin for each task, -/// and these class will give the correct pin for the task. -/// Also these class will manage unused pins for new connections and -/// will return free pins number for the required task. - -/// Also these class manage the pins, -/// and check if this pin is in the type that the user needs (gpio and more), -/// If pin is not in use and in the correct type that user expect it return the -/// number of the pin, else return -1 - -abstract class DevicePinListManagerAbstract { - /// Will save the type of the current physical device - static PhysicalDeviceType? physicalDeviceType; - - /// Set recognize and set the physical device type in the singleton - Future setPhysicalDeviceType(); - - PhysicalDeviceType? convertPhysicalDeviceTypeStringToPhysicalDeviceTypeObject( - String physicalDeviceType, - ); -} - -class DevicePinListManager extends DevicePinListManagerAbstract { - /// Will save the type of the current physical device - static PhysicalDeviceType? physicalDeviceType; - - @override - Future setPhysicalDeviceType() async { - // TODO: check if this can be done using - // https://pub.dev/packages/flutter_gpiod or by using - // https://pub.dev/packages/linux_system_info - final SystemCommandsManager systemCommandsManager = - getIt(); - final String etcReleaseOutput = - await systemCommandsManager.getAllEtcReleaseFilesText(); - - final List etcReleaseFilesAsList = etcReleaseOutput.split('\n'); - try { - String deviceHostName = etcReleaseFilesAsList.firstWhere( - (etcReleaseSingleLine) => etcReleaseSingleLine.contains('BOARD'), - ); - deviceHostName = - deviceHostName.substring(deviceHostName.indexOf('=') + 1); - logger.t(deviceHostName); - deviceHostName = deviceHostName.replaceAll('-', '').replaceAll(' ', ''); - - physicalDeviceType = - convertPhysicalDeviceTypeStringToPhysicalDeviceTypeObject( - deviceHostName, - ); - - final String? raspberryPiVersion = - await systemCommandsManager.getRaspberryPiDeviceVersion(); - - if (physicalDeviceType == null && - raspberryPiVersion != null && - raspberryPiVersion - .toLowerCase() - .contains('Raspberry_Pi'.toLowerCase())) { - physicalDeviceType = PhysicalDeviceType.raspberryPi; - } - - logger.t('phys type is $physicalDeviceType'); - } catch (e) { - logger.w('Board type does not exist'); - } - logger.i( - 'This device is of type:' - ' ${EnumHelperCbj.physicalDeviceTypeToString(physicalDeviceType)}', - ); - } - - /// Return physicalDeviceType object if - /// string physicalDeviceType exist (in general) else return null - @override - PhysicalDeviceType? convertPhysicalDeviceTypeStringToPhysicalDeviceTypeObject( - String physicalDeviceType, - ) { - // Loop through all the physical devices types - for (final PhysicalDeviceType physicalDeviceTypeTemp - in PhysicalDeviceType.values) { - if (EnumHelperCbj.physicalDeviceTypeToString(physicalDeviceTypeTemp) - .toLowerCase() == - physicalDeviceType.toLowerCase()) { - return physicalDeviceTypeTemp; // If physicalDeviceType string exist - // return the physicalDeviceType enum object - } - } - return null; - } -} diff --git a/lib/infrastructure/system_commands/system_commands_base_class_d.dart b/lib/infrastructure/system_commands/system_commands_base_class_d.dart deleted file mode 100644 index 81e5904f..00000000 --- a/lib/infrastructure/system_commands/system_commands_base_class_d.dart +++ /dev/null @@ -1,29 +0,0 @@ -abstract class SystemCommandsBaseClassD { - Future getCurrentUserName(); - - Future getLocalDbPath(Future currentUserName); - - Future getUuidOfCurrentDevice(); - - Future getDeviceHostName(); - - Future getAllEtcReleaseFilesText(); - - Future getFileContent(String fileFullPath); - - Future getDeviceConfiguration(); - - Future getProjectFilesLocation(); - - Future getIpFromMdnsName(String mdnsName); - -// TODO: Need to find a way in dart to get os environment variable -// /// Get Snap location environment variable "SNAP" -// Future getSnapLocationEnvironmentVariable(); -// -// /// Get Snap common environment variable "SNAP_COMMON" can be modified by root -// Future getSnapCommonEnvironmentVariable(); -// -// /// Get Snap user common environment variable "SNAP_USER_COMMON" -// Future getSnapUserCommonEnvironmentVariable(); -} diff --git a/lib/infrastructure/system_commands/system_commands_manager_d.dart b/lib/infrastructure/system_commands/system_commands_manager_d.dart deleted file mode 100644 index f09304e2..00000000 --- a/lib/infrastructure/system_commands/system_commands_manager_d.dart +++ /dev/null @@ -1,73 +0,0 @@ -import 'dart:io'; - -import 'package:cbj_hub/infrastructure/system_commands/bash_commands_d/bash_commands_for_raspberry_pi_d.dart'; -import 'package:cbj_hub/infrastructure/system_commands/bash_commands_d/common_bash_commands_d.dart'; -import 'package:cbj_hub/infrastructure/system_commands/batch_commands_d/common_batch_commands_d.dart'; -import 'package:cbj_hub/infrastructure/system_commands/system_commands_base_class_d.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:injectable/injectable.dart'; - -@singleton -class SystemCommandsManager { - SystemCommandsManager() { - if (Platform.isLinux) { - logger.t('Linux platform detected in SystemCommandsManager'); - systemCommandsBaseClassD = CommonBashCommandsD(); - } else if (Platform.isWindows) { - logger.t('Windows platform detected in SystemCommandsManager'); - systemCommandsBaseClassD = CommonBatchCommandsD(); - } else if (Platform.isMacOS) { - logger.w('Mac os is currently not supported in SystemCommandsManager'); - throw 'Mac os is currently not supported'; - } else { - logger.e( - '${Platform.operatingSystem} os is not supported in SystemCommandsManager', - ); - throw '${Platform.operatingSystem} os is not supported'; - } - } - - SystemCommandsBaseClassD? systemCommandsBaseClassD; - - Future getCurrentUserName() { - return systemCommandsBaseClassD!.getCurrentUserName(); - } - - Future getLocalDbPath() { - return systemCommandsBaseClassD!.getLocalDbPath( - getCurrentUserName(), - ); - } - - Future getProjectFilesLocation() { - return systemCommandsBaseClassD!.getProjectFilesLocation(); - } - - Future getDeviceHostName() { - return systemCommandsBaseClassD!.getDeviceHostName(); - } - - Future getAllEtcReleaseFilesText() { - return systemCommandsBaseClassD!.getAllEtcReleaseFilesText(); - } - - Future getFileContent(String fileFullPath) { - return systemCommandsBaseClassD!.getFileContent(fileFullPath); - } - - Future getUuidOfCurrentDevice() { - return systemCommandsBaseClassD!.getUuidOfCurrentDevice(); - } - - Future getDeviceConfiguration() { - return systemCommandsBaseClassD!.getDeviceConfiguration(); - } - - Future getRaspberryPiDeviceVersion() { - return BashCommandsForRaspberryPi.getRaspberryPiDeviceVersion(); - } - - Future getIpFromMdnsName(String mdnsName) { - return systemCommandsBaseClassD!.getIpFromMdnsName(mdnsName); - } -} diff --git a/lib/injection.config.dart b/lib/injection.config.dart index ca28f191..01b5a25b 100644 --- a/lib/injection.config.dart +++ b/lib/injection.config.dart @@ -10,72 +10,33 @@ // ignore_for_file: no_leading_underscores_for_library_prefixes import 'package:cbj_hub/domain/app_communication/i_app_communication_repository.dart' - as _i8; -import 'package:cbj_hub/domain/binding/i_binding_cbj_repository.dart' as _i10; + as _i3; +import 'package:cbj_hub/domain/binding/i_binding_cbj_repository.dart' as _i5; import 'package:cbj_hub/domain/cbj_web_server/i_cbj_web_server_repository.dart' - as _i12; -import 'package:cbj_hub/domain/local_db/i_local_db_repository.dart' as _i14; -import 'package:cbj_hub/domain/mqtt_server/i_mqtt_server_repository.dart' - as _i16; -import 'package:cbj_hub/domain/rooms/i_saved_rooms_repo.dart' as _i22; -import 'package:cbj_hub/domain/routine/i_routine_cbj_repository.dart' as _i18; -import 'package:cbj_hub/domain/saved_devices/i_saved_devices_repo.dart' as _i20; -import 'package:cbj_hub/domain/scene/i_scene_cbj_repository.dart' as _i24; + as _i7; +import 'package:cbj_hub/domain/rooms/i_saved_rooms_repo.dart' as _i15; +import 'package:cbj_hub/domain/routine/i_routine_cbj_repository.dart' as _i11; +import 'package:cbj_hub/domain/scene/i_scene_cbj_repository.dart' as _i17; import 'package:cbj_hub/infrastructure/app_communication/app_communication_repository.dart' - as _i9; -import 'package:cbj_hub/infrastructure/bindings/binding_repository.dart' - as _i11; -import 'package:cbj_hub/infrastructure/cbj_web_server/cbj_web_server_repository.dart' - as _i13; -import 'package:cbj_hub/infrastructure/devices/cbj_devices/cbj_devices_connector_conjector.dart' - as _i3; -import 'package:cbj_hub/infrastructure/devices/esphome/esphome_connector_conjector.dart' as _i4; -import 'package:cbj_hub/infrastructure/devices/ewelink/ewelink_connector_conjector.dart' - as _i5; -import 'package:cbj_hub/infrastructure/devices/google/google_connector_conjector.dart' - as _i6; -import 'package:cbj_hub/infrastructure/devices/hp/hp_connector_conjector.dart' - as _i7; -import 'package:cbj_hub/infrastructure/devices/lg/lg_connector_conjector.dart' - as _i26; -import 'package:cbj_hub/infrastructure/devices/lifx/lifx_connector_conjector.dart' - as _i27; -import 'package:cbj_hub/infrastructure/devices/philips_hue/philips_hue_connector_conjector.dart' - as _i29; -import 'package:cbj_hub/infrastructure/devices/shelly/shelly_connector_conjector.dart' - as _i31; -import 'package:cbj_hub/infrastructure/devices/sonoff_diy/sonoff_diy_connector_conjector.dart' - as _i32; -import 'package:cbj_hub/infrastructure/devices/switcher/switcher_connector_conjector.dart' - as _i33; -import 'package:cbj_hub/infrastructure/devices/tasmota/tasmota_ip/tasmota_ip_connector_conjector.dart' - as _i35; -import 'package:cbj_hub/infrastructure/devices/tasmota/tasmota_mqtt/tasmota_mqtt_connector_conjector.dart' - as _i36; -import 'package:cbj_hub/infrastructure/devices/tuya_smart/tuya_smart_connector_conjector.dart' - as _i37; -import 'package:cbj_hub/infrastructure/devices/wiz/wiz_connector_conjector.dart' - as _i38; -import 'package:cbj_hub/infrastructure/devices/xiaomi_io/xiaomi_io_connector_conjector.dart' - as _i39; -import 'package:cbj_hub/infrastructure/devices/yeelight/yeelight_connector_conjector.dart' - as _i40; -import 'package:cbj_hub/infrastructure/local_db/local_db_hive_repository.dart' - as _i15; +import 'package:cbj_hub/infrastructure/bindings/binding_repository.dart' as _i6; +import 'package:cbj_hub/infrastructure/cbj_web_server/cbj_web_server_repository.dart' + as _i8; import 'package:cbj_hub/infrastructure/mqtt_server/mqtt_server_repository.dart' - as _i17; + as _i10; import 'package:cbj_hub/infrastructure/node_red/node_red_repository.dart' - as _i28; -import 'package:cbj_hub/infrastructure/room/saved_rooms_repo.dart' as _i23; -import 'package:cbj_hub/infrastructure/routines/routine_repository.dart' as _i19; +import 'package:cbj_hub/infrastructure/room/saved_rooms_repo.dart' as _i16; +import 'package:cbj_hub/infrastructure/routines/routine_repository.dart' + as _i12; import 'package:cbj_hub/infrastructure/saved_devices/saved_devices_repo.dart' - as _i21; -import 'package:cbj_hub/infrastructure/scenes/scene_repository.dart' as _i25; -import 'package:cbj_hub/infrastructure/shared_variables.dart' as _i30; -import 'package:cbj_hub/infrastructure/system_commands/system_commands_manager_d.dart' - as _i34; + as _i14; +import 'package:cbj_hub/infrastructure/scenes/scene_repository.dart' as _i18; +import 'package:cbj_hub/infrastructure/shared_variables.dart' as _i20; +import 'package:cbj_integrations_controller/domain/mqtt_server/i_mqtt_server_repository.dart' + as _i9; +import 'package:cbj_integrations_controller/domain/saved_devices/i_saved_devices_repo.dart' + as _i13; import 'package:get_it/get_it.dart' as _i1; import 'package:injectable/injectable.dart' as _i2; @@ -90,52 +51,21 @@ extension GetItInjectableX on _i1.GetIt { environment, environmentFilter, ); - gh.singleton<_i3.CbjDevicesConnectorConjector>( - _i3.CbjDevicesConnectorConjector()); - gh.singleton<_i4.EspHomeConnectorConjector>( - _i4.EspHomeConnectorConjector()); - gh.singleton<_i5.EwelinkConnectorConjector>( - _i5.EwelinkConnectorConjector()); - gh.singleton<_i6.GoogleConnectorConjector>(_i6.GoogleConnectorConjector()); - gh.singleton<_i7.HpConnectorConjector>(_i7.HpConnectorConjector()); - gh.lazySingleton<_i8.IAppCommunicationRepository>( - () => _i9.AppCommunicationRepository()); - gh.lazySingleton<_i10.IBindingCbjRepository>( - () => _i11.BindingCbjRepository()); - gh.lazySingleton<_i12.ICbjWebServerRepository>( - () => _i13.CbjWebServerRepository()); - gh.lazySingleton<_i14.ILocalDbRepository>(() => _i15.HiveRepository()); - gh.lazySingleton<_i16.IMqttServerRepository>( - () => _i17.MqttServerRepository()); - gh.lazySingleton<_i18.IRoutineCbjRepository>( - () => _i19.RoutineCbjRepository()); - gh.lazySingleton<_i20.ISavedDevicesRepo>(() => _i21.SavedDevicesRepo()); - gh.lazySingleton<_i22.ISavedRoomsRepo>(() => _i23.SavedRoomsRepo()); - gh.lazySingleton<_i24.ISceneCbjRepository>(() => _i25.SceneCbjRepository()); - gh.singleton<_i26.LgConnectorConjector>(_i26.LgConnectorConjector()); - gh.singleton<_i27.LifxConnectorConjector>(_i27.LifxConnectorConjector()); - gh.lazySingleton<_i28.NodeRedRepository>(() => _i28.NodeRedRepository()); - gh.singleton<_i29.PhilipsHueConnectorConjector>( - _i29.PhilipsHueConnectorConjector()); - gh.singleton<_i30.SharedVariables>(_i30.SharedVariables()); - gh.singleton<_i31.ShellyConnectorConjector>( - _i31.ShellyConnectorConjector()); - gh.singleton<_i32.SonoffDiyConnectorConjector>( - _i32.SonoffDiyConnectorConjector()); - gh.singleton<_i33.SwitcherConnectorConjector>( - _i33.SwitcherConnectorConjector()); - gh.singleton<_i34.SystemCommandsManager>(_i34.SystemCommandsManager()); - gh.singleton<_i35.TasmotaIpConnectorConjector>( - _i35.TasmotaIpConnectorConjector()); - gh.singleton<_i36.TasmotaMqttConnectorConjector>( - _i36.TasmotaMqttConnectorConjector()); - gh.singleton<_i37.TuyaSmartConnectorConjector>( - _i37.TuyaSmartConnectorConjector()); - gh.singleton<_i38.WizConnectorConjector>(_i38.WizConnectorConjector()); - gh.singleton<_i39.XiaomiIoConnectorConjector>( - _i39.XiaomiIoConnectorConjector()); - gh.singleton<_i40.YeelightConnectorConjector>( - _i40.YeelightConnectorConjector()); + gh.lazySingleton<_i3.IAppCommunicationRepository>( + () => _i4.AppCommunicationRepository()); + gh.lazySingleton<_i5.IBindingCbjRepository>( + () => _i6.BindingCbjRepository()); + gh.lazySingleton<_i7.ICbjWebServerRepository>( + () => _i8.CbjWebServerRepository()); + gh.lazySingleton<_i9.IMqttServerRepository>( + () => _i10.MqttServerRepository()); + gh.lazySingleton<_i11.IRoutineCbjRepository>( + () => _i12.RoutineCbjRepository()); + gh.lazySingleton<_i13.ISavedDevicesRepo>(() => _i14.SavedDevicesRepo()); + gh.lazySingleton<_i15.ISavedRoomsRepo>(() => _i16.SavedRoomsRepo()); + gh.lazySingleton<_i17.ISceneCbjRepository>(() => _i18.SceneCbjRepository()); + gh.lazySingleton<_i19.NodeRedRepository>(() => _i19.NodeRedRepository()); + gh.singleton<_i20.SharedVariables>(_i20.SharedVariables()); return this; } } diff --git a/lib/injection.dart b/lib/injection.dart index 69f1a98e..a10cd1cf 100644 --- a/lib/injection.dart +++ b/lib/injection.dart @@ -1,23 +1,23 @@ -import 'package:cbj_hub/injection.config.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:get_it/get_it.dart'; -import 'package:injectable/injectable.dart'; - -final getIt = GetIt.instance; - -/// Saves the current environment for manual use -late String currentEnv; - -@injectableInit -Future configureInjection(String environment) async { - currentEnv = environment; - logger.i('Current CyBear Jinni Hub environment name: $currentEnv'); - getIt.init(environment: environment); -} - -abstract class Env { - static const String test = 'test'; - static const String devPc = 'dev_pc'; - static const String devPi = 'dev_pi'; - static const String prod = 'prod'; -} +// import 'package:cbj_hub/injection.config.dart'; +// import 'package:cbj_hub/utils.dart'; +// import 'package:get_it/get_it.dart'; +// import 'package:injectable/injectable.dart'; +// +// final getIt = GetIt.instance; +// +// /// Saves the current environment for manual use +// late String currentEnv; +// +// @injectableInit +// Future configureInjection(String environment) async { +// currentEnv = environment; +// logger.i('Current CyBear Jinni Hub environment name: $currentEnv'); +// getIt.init(environment: environment); +// } +// +// abstract class Env { +// static const String test = 'test'; +// static const String devPc = 'dev_pc'; +// static const String devPi = 'dev_pi'; +// static const String prod = 'prod'; +// } diff --git a/pubspec.yaml b/pubspec.yaml index b53fe5c7..8a67b5d1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,6 +11,8 @@ environment: dependencies: # Contains utility classes in the style of dart:async to work with asynchronous computations. async: ^2.11.0 + cbj_integrations_controller: + path: ../cbj_integrations_controller # Package to create, convert, alter, and compare colors in a variety of colorspaces. color: ^3.0.0 # Compute function made available for all non-Flutter Dart programs @@ -82,16 +84,19 @@ dependencies: # Dart library for controlling Yeelight products over LAN. yeedart: ^0.3.2 +dependency_overrides: + # Defines the annotations used by json_serializable + get_it: ^7.6.0 + dev_dependencies: # A build system for Dart code generation and modular compilation. build_runner: - # A generator for injectable library # Code generator for unions/pattern-matching/copy. freezed: ^2.4.1 # Automatically generates Hive TypeAdapters to store any class hive_generator: ^2.0.1 - # Injectable is a convenient code generator for get_it. + # Injectable is a convenient code generator for get _it. injectable_generator: ^2.4.0 # Code generator for the Isar Database. Finds classes annotated with @Collection. # isar_generator: ^3.0.5 From d3adf26f1f646db8975ac090e5686df478215dd8 Mon Sep 17 00:00:00 2001 From: Guy Luz Date: Sat, 14 Oct 2023 01:21:24 +0300 Subject: [PATCH 12/18] Transition complete of controlling devices to cbj_integrations_controller package --- bin/cbj_hub.dart | 27 +- lib/application/boot_up/boot_up.dart | 22 +- lib/application/connector/connector.dart | 11 +- .../i_app_communication_repository.dart | 4 - lib/domain/binding/binding_cbj_entity.dart | 61 --- lib/domain/binding/binding_cbj_errors.dart | 16 - lib/domain/binding/binding_cbj_failures.dart | 38 -- .../binding/binding_cbj_validators.dart | 130 ----- .../binding/i_binding_cbj_repository.dart | 27 - .../binding/value_objects_routine_cbj.dart | 231 --------- .../i_cbj_web_server_repository.dart | 4 - lib/domain/room/room_entity.dart | 117 ----- lib/domain/room/room_errors.dart | 14 - lib/domain/room/room_failures.dart | 33 -- lib/domain/room/room_validators.dart | 62 --- lib/domain/room/value_objects_room.dart | 168 ------- lib/domain/rooms/i_saved_rooms_repo.dart | 49 -- .../routine/i_routine_cbj_repository.dart | 30 -- lib/domain/routine/routine_cbj_entity.dart | 77 --- lib/domain/routine/routine_cbj_errors.dart | 16 - lib/domain/routine/routine_cbj_failures.dart | 38 -- .../routine/routine_cbj_validators.dart | 180 ------- .../routine/value_objects_routine_cbj.dart | 283 ----------- lib/domain/scene/i_scene_cbj_repository.dart | 87 ---- lib/domain/scene/scene_cbj_entity.dart | 61 --- lib/domain/scene/scene_cbj_errors.dart | 14 - lib/domain/scene/scene_cbj_failures.dart | 38 -- lib/domain/scene/scene_cbj_validators.dart | 126 ----- lib/domain/scene/value_objects_scene_cbj.dart | 229 --------- .../app_communication_repository.dart | 50 +- .../app_communication/hub_app_server.dart | 6 +- .../bindings/binding_cbj_dtos.dart | 77 --- .../bindings/binding_repository.dart | 108 ---- .../cbj_web_server_repository.dart | 3 +- .../mqtt_server/mqtt_server_repository.dart | 7 +- .../node_red/node_red_converter.dart | 305 ----------- .../node_red/node_red_repository.dart | 215 -------- .../remote_pipes/remote_pipes_client.dart | 6 +- lib/infrastructure/room/room_entity_dtos.dart | 65 --- lib/infrastructure/room/saved_rooms_repo.dart | 476 ------------------ .../routines/routine_cbj_dtos.dart | 89 ---- .../routines/routine_repository.dart | 121 ----- .../bed_room_area_actions.dart | 204 -------- .../outside_area_actions.dart | 200 -------- .../study_room_area_actions.dart | 209 -------- .../video_games_area_actions.dart | 210 -------- .../work_room_area_actions.dart | 208 -------- .../area_type_with_device_type_preset.dart | 181 ------- ...on_devices_scenes_presets_for_devices.dart | 391 -------------- lib/infrastructure/scenes/scene_cbj_dtos.dart | 77 --- .../scenes/scene_repository.dart | 471 ----------------- lib/infrastructure/shared_variables.dart | 54 -- pubspec.yaml | 25 +- 53 files changed, 72 insertions(+), 5879 deletions(-) delete mode 100644 lib/domain/binding/binding_cbj_entity.dart delete mode 100644 lib/domain/binding/binding_cbj_errors.dart delete mode 100644 lib/domain/binding/binding_cbj_failures.dart delete mode 100644 lib/domain/binding/binding_cbj_validators.dart delete mode 100644 lib/domain/binding/i_binding_cbj_repository.dart delete mode 100644 lib/domain/binding/value_objects_routine_cbj.dart delete mode 100644 lib/domain/room/room_entity.dart delete mode 100644 lib/domain/room/room_errors.dart delete mode 100644 lib/domain/room/room_failures.dart delete mode 100644 lib/domain/room/room_validators.dart delete mode 100644 lib/domain/room/value_objects_room.dart delete mode 100644 lib/domain/rooms/i_saved_rooms_repo.dart delete mode 100644 lib/domain/routine/i_routine_cbj_repository.dart delete mode 100644 lib/domain/routine/routine_cbj_entity.dart delete mode 100644 lib/domain/routine/routine_cbj_errors.dart delete mode 100644 lib/domain/routine/routine_cbj_failures.dart delete mode 100644 lib/domain/routine/routine_cbj_validators.dart delete mode 100644 lib/domain/routine/value_objects_routine_cbj.dart delete mode 100644 lib/domain/scene/i_scene_cbj_repository.dart delete mode 100644 lib/domain/scene/scene_cbj_entity.dart delete mode 100644 lib/domain/scene/scene_cbj_errors.dart delete mode 100644 lib/domain/scene/scene_cbj_failures.dart delete mode 100644 lib/domain/scene/scene_cbj_validators.dart delete mode 100644 lib/domain/scene/value_objects_scene_cbj.dart delete mode 100644 lib/infrastructure/bindings/binding_cbj_dtos.dart delete mode 100644 lib/infrastructure/bindings/binding_repository.dart delete mode 100644 lib/infrastructure/node_red/node_red_converter.dart delete mode 100644 lib/infrastructure/node_red/node_red_repository.dart delete mode 100644 lib/infrastructure/room/room_entity_dtos.dart delete mode 100644 lib/infrastructure/room/saved_rooms_repo.dart delete mode 100644 lib/infrastructure/routines/routine_cbj_dtos.dart delete mode 100644 lib/infrastructure/routines/routine_repository.dart delete mode 100644 lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/bed_room_area_actions.dart delete mode 100644 lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/outside_area_actions.dart delete mode 100644 lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/study_room_area_actions.dart delete mode 100644 lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/video_games_area_actions.dart delete mode 100644 lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/work_room_area_actions.dart delete mode 100644 lib/infrastructure/scenes/area_types_scientific_presets/area_type_with_device_type_preset.dart delete mode 100644 lib/infrastructure/scenes/area_types_scientific_presets/common_devices_scenes_presets_for_devices.dart delete mode 100644 lib/infrastructure/scenes/scene_cbj_dtos.dart delete mode 100644 lib/infrastructure/scenes/scene_repository.dart delete mode 100644 lib/infrastructure/shared_variables.dart diff --git a/bin/cbj_hub.dart b/bin/cbj_hub.dart index e94b882c..beba9b65 100644 --- a/bin/cbj_hub.dart +++ b/bin/cbj_hub.dart @@ -1,12 +1,37 @@ import 'package:cbj_hub/application/boot_up/boot_up.dart'; +import 'package:cbj_hub/infrastructure/cbj_web_server/cbj_web_server_repository.dart'; +import 'package:cbj_hub/infrastructure/mqtt_server/mqtt_server_repository.dart'; +import 'package:cbj_integrations_controller/infrastructure/bindings/binding_repository.dart'; +import 'package:cbj_integrations_controller/infrastructure/local_db/local_db_hive_repository.dart'; +import 'package:cbj_integrations_controller/infrastructure/node_red/node_red_repository.dart'; +import 'package:cbj_integrations_controller/infrastructure/room/saved_rooms_repo.dart'; +import 'package:cbj_integrations_controller/infrastructure/routines/routine_repository.dart'; +import 'package:cbj_integrations_controller/infrastructure/saved_devices/saved_devices_repo.dart'; +import 'package:cbj_integrations_controller/infrastructure/scenes/scene_repository.dart'; +import 'package:cbj_integrations_controller/infrastructure/shared_variables.dart'; import 'package:cbj_integrations_controller/initialize_integrations_controller.dart'; import 'package:cbj_integrations_controller/injection.dart'; import 'package:network_tools/network_tools.dart' as network; Future main(List arguments) async { + setInstancesOfRepos(); // arguments[0] is the location of the project network.configureNetworkTools('network_tools_db'); - await initializeIntegrationsController(arguments: arguments, env: Env.prod); + await initializeIntegrationsController(arguments: arguments, env: Env.devPc); await BootUp.setup(); } + +/// All instances of Repos +void setInstancesOfRepos() { + MqttServerRepository(); + CbjWebServerRepository(); + SavedRoomsRepo(); + SavedDevicesRepo(); + RoutineCbjRepository(); + HiveRepository(); + NodeRedRepository(); + BindingCbjRepository(); + SceneCbjRepository(); + SharedVariables(); +} diff --git a/lib/application/boot_up/boot_up.dart b/lib/application/boot_up/boot_up.dart index aff965c0..643c2eff 100644 --- a/lib/application/boot_up/boot_up.dart +++ b/lib/application/boot_up/boot_up.dart @@ -1,7 +1,6 @@ import 'package:cbj_hub/application/connector/connector.dart'; -import 'package:cbj_hub/infrastructure/cbj_web_server/cbj_web_server_repository.dart'; -import 'package:cbj_hub/infrastructure/mqtt_server/mqtt_server_repository.dart'; -import 'package:cbj_hub/infrastructure/room/saved_rooms_repo.dart'; +import 'package:cbj_integrations_controller/domain/rooms/i_saved_rooms_repo.dart'; +import 'package:cbj_integrations_controller/domain/scene/i_scene_cbj_repository.dart'; import 'package:cbj_integrations_controller/initialize_integrations_controller.dart'; class BootUp { @@ -11,25 +10,12 @@ class BootUp { static Future setup() async { // Return all saved rooms - // TODO: Fix after new cbj_integrations_controller - // final ISavedRoomsRepo savedRoomsRepo = ISavedRoomsRepo.instance; - // TODO: Fix after new cbj_integrations_controller - // final ISceneCbjRepository savedScenesRepo = getItCbj(); + await ISavedRoomsRepo.instance.getAllRooms(); - // await savedRoomsRepo.getAllRooms(); - // - // await savedScenesRepo.getAllScenesAsMap(); - setInstancesOfRepos(); + await ISceneCbjRepository.instance.getAllScenesAsMap(); await setupIntegrationsController(); Connector.startConnector(); } - - /// All instances of Repos - static void setInstancesOfRepos() { - MqttServerRepository(); - CbjWebServerRepository(); - SavedRoomsRepo(); - } } diff --git a/lib/application/connector/connector.dart b/lib/application/connector/connector.dart index c31e15cf..f831db4a 100644 --- a/lib/application/connector/connector.dart +++ b/lib/application/connector/connector.dart @@ -1,17 +1,16 @@ import 'dart:async'; import 'dart:convert'; -import 'package:cbj_hub/domain/room/room_entity.dart'; -import 'package:cbj_hub/domain/room/value_objects_room.dart'; -import 'package:cbj_hub/domain/rooms/i_saved_rooms_repo.dart'; import 'package:cbj_hub/infrastructure/app_communication/app_communication_repository.dart'; import 'package:cbj_integrations_controller/domain/mqtt_server/i_mqtt_server_repository.dart'; +import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; +import 'package:cbj_integrations_controller/domain/room/value_objects_room.dart'; +import 'package:cbj_integrations_controller/domain/rooms/i_saved_rooms_repo.dart'; import 'package:cbj_integrations_controller/domain/saved_devices/i_saved_devices_repo.dart'; import 'package:cbj_integrations_controller/infrastructure/devices/companies_connector_conjector.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_abstract.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:cbj_integrations_controller/injection.dart'; import 'package:cbj_integrations_controller/utils.dart'; import 'package:mqtt_client/mqtt_client.dart'; import 'package:rxdart/rxdart.dart'; @@ -33,7 +32,7 @@ class Connector { } }); - final ISavedDevicesRepo savedDevicesRepo = getItCbj(); + final ISavedDevicesRepo savedDevicesRepo = ISavedDevicesRepo.instance; final Map allDevices = await savedDevicesRepo.getAllDevices(); @@ -66,7 +65,7 @@ class Connector { static Future updateDevicesFromMqttDeviceChange( MapEntry> deviceChangeFromMqtt, ) async { - final ISavedDevicesRepo savedDevicesRepo = getItCbj(); + final ISavedDevicesRepo savedDevicesRepo = ISavedDevicesRepo.instance; final Map allDevices = await savedDevicesRepo.getAllDevices(); diff --git a/lib/domain/app_communication/i_app_communication_repository.dart b/lib/domain/app_communication/i_app_communication_repository.dart index e726f147..48219709 100644 --- a/lib/domain/app_communication/i_app_communication_repository.dart +++ b/lib/domain/app_communication/i_app_communication_repository.dart @@ -2,10 +2,6 @@ import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/pr import 'package:mqtt_client/mqtt_client.dart'; abstract class IAppCommunicationRepository { - IAppCommunicationRepository() { - instance = this; - } - static late IAppCommunicationRepository instance; Future getFromApp({ diff --git a/lib/domain/binding/binding_cbj_entity.dart b/lib/domain/binding/binding_cbj_entity.dart deleted file mode 100644 index b6d62cd6..00000000 --- a/lib/domain/binding/binding_cbj_entity.dart +++ /dev/null @@ -1,61 +0,0 @@ -import 'package:cbj_hub/domain/binding/value_objects_routine_cbj.dart'; -import 'package:cbj_hub/infrastructure/bindings/binding_cbj_dtos.dart'; -import 'package:cbj_integrations_controller/domain/core/value_objects.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'binding_cbj_entity.freezed.dart'; - -@freezed -class BindingCbjEntity with _$BindingCbjEntity { - const factory BindingCbjEntity({ - /// The unique id of the binding, will alsow be used as the flow/tab id. - required UniqueId uniqueId, - - /// Name of the automation, will be shown to the user. - required BindingCbjName name, - required BindingCbjBackgroundColor backgroundColor, - - /// All the automation as string. - required BindingCbjAutomationString automationString, - - /// Node-Red flow id of the scene - required BindingCbjNodeRedFlowId nodeRedFlowId, - - /// The actual id of the first node, most of the time will be the same as - /// uniqueId variable. - required BindingCbjFirstNodeId firstNodeId, - - /// The Unicode code point at which this icon is stored in the icon font. - required BindingCbjIconCodePoint iconCodePoint, - required BindingCbjBackgroundImage image, - required BindingCbjLastDateOfExecute lastDateOfExecute, - required BindingCbjStateMassage stateMassage, - required BindingCbjSenderDeviceOs senderDeviceOs, - required BindingCbjSenderDeviceModel senderDeviceModel, - required BindingCbjSenderId senderId, - required BindingCbjCompUuid compUuid, - required BindingCbjDeviceStateGRPC entityStateGRPC, - }) = _BindingCbjEntity; - - const BindingCbjEntity._(); - - BindingCbjDtos toInfrastructure() { - return BindingCbjDtos( - uniqueId: uniqueId.getOrCrash(), - name: name.getOrCrash(), - backgroundColor: backgroundColor.getOrCrash(), - automationString: automationString.getOrCrash(), - nodeRedFlowId: nodeRedFlowId.getOrCrash(), - firstNodeId: firstNodeId.getOrCrash(), - iconCodePoint: iconCodePoint.getOrCrash(), - image: image.getOrCrash(), - lastDateOfExecute: lastDateOfExecute.getOrCrash(), - entityStateGRPC: entityStateGRPC.getOrCrash(), - senderDeviceModel: senderDeviceModel.getOrCrash(), - senderDeviceOs: senderDeviceOs.getOrCrash(), - senderId: senderId.getOrCrash(), - compUuid: compUuid.getOrCrash(), - stateMassage: stateMassage.getOrCrash(), - ); - } -} diff --git a/lib/domain/binding/binding_cbj_errors.dart b/lib/domain/binding/binding_cbj_errors.dart deleted file mode 100644 index bcdfbc1d..00000000 --- a/lib/domain/binding/binding_cbj_errors.dart +++ /dev/null @@ -1,16 +0,0 @@ -import 'package:cbj_hub/domain/binding/binding_cbj_failures.dart'; - -class BindingCbjUnexpectedValueError extends Error { - BindingCbjUnexpectedValueError(this.bindingsValueFailure); - - final BindingCbjFailure bindingsValueFailure; - - @override - String toString() { - const explanation = - 'Encountered a ValueFailure at an unrecoverable point. Terminating.'; - return Error.safeToString( - '$explanation Failure was: $bindingsValueFailure', - ); - } -} diff --git a/lib/domain/binding/binding_cbj_failures.dart b/lib/domain/binding/binding_cbj_failures.dart deleted file mode 100644 index 68818fe2..00000000 --- a/lib/domain/binding/binding_cbj_failures.dart +++ /dev/null @@ -1,38 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'binding_cbj_failures.freezed.dart'; - -@freezed -class BindingCbjFailure { - const factory BindingCbjFailure.unexpected() = _Unexpected; - - const factory BindingCbjFailure.insufficientPermission() = - _InsufficientPermission; - - const factory BindingCbjFailure.unableToUpdate() = _UnableToUpdate; - - const factory BindingCbjFailure.empty({ - required T failedValue, - }) = _Empty; - - const factory BindingCbjFailure.actionExcecuter({ - required T failedValue, - }) = _ActionExcecuter; - - const factory BindingCbjFailure.exceedingLength({ - required T failedValue, - required int max, - }) = _ExceedingLength; - - const factory BindingCbjFailure.powerConsumptionIsNotNumber() = - _PowerConsumptionIsNotNumber; - - const factory BindingCbjFailure.roomsActionDoesNotExist() = - _RoomsActionDoesNotExist; - - const factory BindingCbjFailure.roomsTypeDoesNotExist() = - _RoomsTypeDoesNotExist; - - const factory BindingCbjFailure.bindingStateDoesNotExist() = - _BindingStateDoesNotExist; -} diff --git a/lib/domain/binding/binding_cbj_validators.dart b/lib/domain/binding/binding_cbj_validators.dart deleted file mode 100644 index 241d4f1e..00000000 --- a/lib/domain/binding/binding_cbj_validators.dart +++ /dev/null @@ -1,130 +0,0 @@ -import 'package:cbj_hub/domain/binding/binding_cbj_failures.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_devices/device_type_enums.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateBindingNotEmpty( - String input, -) { - if (input.isNotEmpty) { - return right(input); - } else { - return left( - BindingCbjFailure.empty( - failedValue: input, - ), - ); - } -} - -Either, String> validateBindingMaxNameLength( - String input, - int maxLength, -) { - if (input.length <= maxLength) { - return right(input); - } else { - return left( - BindingCbjFailure.exceedingLength( - failedValue: input, - max: maxLength, - ), - ); - } -} - -Either, String> - validateBindingCbjBackgroundColorNotEmpty( - String input, -) { - return right(input); -} - -Either, String?> - validateBindingCbjAutomationStringLugit( - String? input, -) { - return right(input); -} - -Either, String?> validateBindingCbjNodeRedFlowId( - String? input, -) { - return right(input); -} - -Either, String?> validateBindingCbjFirstNodeId( - String? input, -) { - return right(input); -} - -Either, String?> validateBindingCbjIconCodePoint( - String? input, -) { - return right(input); -} - -Either, String?> validateBindingCbjBackgroundImage( - String? input, -) { - return right(input); -} - -Either, String?> validateBindingCbjLastDateOfExecute( - String? input, -) { - return right(input); -} - -Either, String?> validateBindingCbjStateMassage( - String? input, -) { - return right(input); -} - -Either, String?> validateBindingCbjSenderDeviceOs( - String? input, -) { - return right(input); -} - -Either, String?> validateBindingCbjSenderDeviceModel( - String? input, -) { - return right(input); -} - -Either, String?> validateBindingCbjSenderId( - String? input, -) { - return right(input); -} - -Either, String?> validateBindingCbjCompUuid( - String? input, -) { - return right(input); -} - -Either, String> validateBindingCbjDeviceStateGRPC( - String input, -) { - if (input.isNotEmpty) { - return right(input); - } else { - return left( - BindingCbjFailure.empty( - failedValue: input, - ), - ); - } -} - -Either, String> validateBindingStateExist( - String input, -) { - if (EnumHelperCbj.stringToDeviceState(input) != null) { - return right(input); - } - return left(const BindingCbjFailure.bindingStateDoesNotExist()); -} diff --git a/lib/domain/binding/i_binding_cbj_repository.dart b/lib/domain/binding/i_binding_cbj_repository.dart deleted file mode 100644 index 36b101dd..00000000 --- a/lib/domain/binding/i_binding_cbj_repository.dart +++ /dev/null @@ -1,27 +0,0 @@ -import 'package:cbj_hub/domain/binding/binding_cbj_entity.dart'; -import 'package:cbj_hub/domain/binding/binding_cbj_failures.dart'; -import 'package:cbj_integrations_controller/domain/local_db/local_db_failures.dart'; -import 'package:dartz/dartz.dart'; - -abstract class IBindingCbjRepository { - /// Setting up all bindings from db - Future setUpAllFromDb(); - - Future> getAllBindingsAsList(); - - Future> getAllBindingsAsMap(); - - /// Sending the new binding to the hub to get added - Future> addNewBinding( - BindingCbjEntity bindingCbj, - ); - - Future> saveAndActivateBindingToDb(); - - Future activateBinding( - BindingCbjEntity bindingCbj, - ); - - /// Get entity and return the full MQTT path to it - Future getFullMqttPathOfBinding(BindingCbjEntity bindingCbj); -} diff --git a/lib/domain/binding/value_objects_routine_cbj.dart b/lib/domain/binding/value_objects_routine_cbj.dart deleted file mode 100644 index 971f5c52..00000000 --- a/lib/domain/binding/value_objects_routine_cbj.dart +++ /dev/null @@ -1,231 +0,0 @@ -import 'package:cbj_hub/domain/binding/binding_cbj_errors.dart'; -import 'package:cbj_hub/domain/binding/binding_cbj_failures.dart'; -import 'package:cbj_hub/domain/binding/binding_cbj_validators.dart'; -import 'package:dartz/dartz.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:uuid/uuid.dart'; - -@immutable -abstract class ValueObjectBindingsCbj { - const ValueObjectBindingsCbj(); - - Either, T> get value; - - /// Throws [UnexpectedValueError] containing the [AuthValueFailure] - T getOrCrash() { - // id = identity - same as writing (right) => right - return value.fold((f) => throw BindingCbjUnexpectedValueError(f), id); - } - - Either, Unit> get failureOrUnit { - return value.fold((l) => left(l), (r) => right(unit)); - } - - bool isValid() => value.isRight(); - - @override - String toString() => 'Value($value)'; - - @override - @nonVirtual - bool operator ==(Object o) { - if (identical(this, o)) return true; - return o is ValueObjectBindingsCbj && o.value == value; - } - - @override - int get hashCode => value.hashCode; -} - -class BindingUniqueId extends ValueObjectBindingsCbj { - factory BindingUniqueId() { - return BindingUniqueId._(right(const Uuid().v1())); - } - - factory BindingUniqueId.fromUniqueString(String uniqueId) { - return BindingUniqueId._(right(uniqueId)); - } - - factory BindingUniqueId.discoveredBindingId() { - return BindingUniqueId._(right('00000000-0000-0000-0000-000000000000')); - } - - const BindingUniqueId._(this.value); - - @override - final Either, String> value; -} - -class BindingCbjName extends ValueObjectBindingsCbj { - factory BindingCbjName(String input) { - return BindingCbjName._( - validateBindingNotEmpty(input) - .flatMap((a) => validateBindingMaxNameLength(input, maxLength)), - ); - } - - factory BindingCbjName.discoveredBindingName() { - return BindingCbjName._(right('Discovered')); - } - - const BindingCbjName._(this.value); - - @override - final Either, String> value; - - static const maxLength = 1000; -} - -class BindingCbjBackgroundColor extends ValueObjectBindingsCbj { - factory BindingCbjBackgroundColor(String input) { - return BindingCbjBackgroundColor._( - validateBindingCbjBackgroundColorNotEmpty(input), - ); - } - - const BindingCbjBackgroundColor._(this.value); - - @override - final Either, String> value; -} - -class BindingCbjAutomationString extends ValueObjectBindingsCbj { - factory BindingCbjAutomationString(String? input) { - return BindingCbjAutomationString._( - validateBindingCbjAutomationStringLugit(input), - ); - } - - const BindingCbjAutomationString._(this.value); - - @override - final Either, String?> value; -} - -class BindingCbjNodeRedFlowId extends ValueObjectBindingsCbj { - factory BindingCbjNodeRedFlowId(String? input) { - return BindingCbjNodeRedFlowId._(validateBindingCbjNodeRedFlowId(input)); - } - - const BindingCbjNodeRedFlowId._(this.value); - - @override - final Either, String?> value; -} - -class BindingCbjFirstNodeId extends ValueObjectBindingsCbj { - factory BindingCbjFirstNodeId(String? input) { - return BindingCbjFirstNodeId._(validateBindingCbjFirstNodeId(input)); - } - - const BindingCbjFirstNodeId._(this.value); - - @override - final Either, String?> value; -} - -class BindingCbjIconCodePoint extends ValueObjectBindingsCbj { - factory BindingCbjIconCodePoint(String? input) { - return BindingCbjIconCodePoint._(validateBindingCbjIconCodePoint(input)); - } - - const BindingCbjIconCodePoint._(this.value); - - @override - final Either, String?> value; -} - -class BindingCbjBackgroundImage extends ValueObjectBindingsCbj { - factory BindingCbjBackgroundImage(String? input) { - return BindingCbjBackgroundImage._(validateBindingCbjIconCodePoint(input)); - } - - const BindingCbjBackgroundImage._(this.value); - - @override - final Either, String?> value; -} - -class BindingCbjLastDateOfExecute extends ValueObjectBindingsCbj { - factory BindingCbjLastDateOfExecute(String? input) { - return BindingCbjLastDateOfExecute._( - validateBindingCbjIconCodePoint(input), - ); - } - - const BindingCbjLastDateOfExecute._(this.value); - - @override - final Either, String?> value; -} - -class BindingCbjStateMassage extends ValueObjectBindingsCbj { - factory BindingCbjStateMassage(String? input) { - return BindingCbjStateMassage._(validateBindingCbjStateMassage(input)); - } - - const BindingCbjStateMassage._(this.value); - - @override - final Either, String?> value; -} - -class BindingCbjSenderDeviceOs extends ValueObjectBindingsCbj { - factory BindingCbjSenderDeviceOs(String? input) { - return BindingCbjSenderDeviceOs._(validateBindingCbjSenderDeviceOs(input)); - } - - const BindingCbjSenderDeviceOs._(this.value); - - @override - final Either, String?> value; -} - -class BindingCbjSenderDeviceModel extends ValueObjectBindingsCbj { - factory BindingCbjSenderDeviceModel(String? input) { - return BindingCbjSenderDeviceModel._( - validateBindingCbjSenderDeviceModel(input), - ); - } - - const BindingCbjSenderDeviceModel._(this.value); - - @override - final Either, String?> value; -} - -class BindingCbjSenderId extends ValueObjectBindingsCbj { - factory BindingCbjSenderId(String? input) { - return BindingCbjSenderId._(validateBindingCbjSenderId(input)); - } - - const BindingCbjSenderId._(this.value); - - @override - final Either, String?> value; -} - -class BindingCbjCompUuid extends ValueObjectBindingsCbj { - factory BindingCbjCompUuid(String? input) { - return BindingCbjCompUuid._(validateBindingCbjCompUuid(input)); - } - - const BindingCbjCompUuid._(this.value); - - @override - final Either, String?> value; -} - -class BindingCbjDeviceStateGRPC extends ValueObjectBindingsCbj { - factory BindingCbjDeviceStateGRPC(String? input) { - return BindingCbjDeviceStateGRPC._( - validateBindingCbjDeviceStateGRPC(input!) - .flatMap((a) => validateBindingStateExist(input)), - ); - } - - const BindingCbjDeviceStateGRPC._(this.value); - - @override - final Either, String?> value; -} diff --git a/lib/domain/cbj_web_server/i_cbj_web_server_repository.dart b/lib/domain/cbj_web_server/i_cbj_web_server_repository.dart index d08dcb9a..9b93f32b 100644 --- a/lib/domain/cbj_web_server/i_cbj_web_server_repository.dart +++ b/lib/domain/cbj_web_server/i_cbj_web_server_repository.dart @@ -2,10 +2,6 @@ /// well as website to change devices state locally on the network without /// the need of installing any app. abstract class ICbjWebServerRepository { - ICbjWebServerRepository() { - instance = this; - } - static late ICbjWebServerRepository instance; /// Start the web server diff --git a/lib/domain/room/room_entity.dart b/lib/domain/room/room_entity.dart deleted file mode 100644 index 908a5f8d..00000000 --- a/lib/domain/room/room_entity.dart +++ /dev/null @@ -1,117 +0,0 @@ -import 'package:cbj_hub/domain/room/room_failures.dart'; -import 'package:cbj_hub/domain/room/value_objects_room.dart'; -import 'package:cbj_hub/infrastructure/room/room_entity_dtos.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:dartz/dartz.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'room_entity.freezed.dart'; - -@unfreezed -abstract class RoomEntity implements _$RoomEntity { - factory RoomEntity({ - required RoomUniqueId uniqueId, - required RoomDefaultName cbjEntityName, - required RoomBackground background, - required RoomTypes roomTypes, - required RoomDevicesId roomDevicesId, - required RoomScenesId roomScenesId, - required RoomRoutinesId roomRoutinesId, - required RoomBindingsId roomBindingsId, - - /// Who is using this room - required RoomMostUsedBy roomMostUsedBy, - - /// Room permissions by users id - required RoomPermissions roomPermissions, - }) = _RoomEntity; - - const RoomEntity._(); - - factory RoomEntity.empty() => RoomEntity( - uniqueId: RoomUniqueId(), - cbjEntityName: RoomDefaultName('Empty Room Name'), - background: RoomBackground( - 'https://live.staticflickr.com/5220/5486044345_f67abff3e9_h.jpg', - ), - roomDevicesId: RoomDevicesId(const []), - roomScenesId: RoomScenesId(const []), - roomRoutinesId: RoomRoutinesId(const []), - roomBindingsId: RoomBindingsId(const []), - roomMostUsedBy: RoomMostUsedBy(const []), - roomPermissions: RoomPermissions(const []), - roomTypes: RoomTypes(const []), - ); - - /// Will add new device id to the devices in the room list - void addDeviceId(String newDeviceId) { - final List tempList = []; - tempList.addAll(roomDevicesId.getOrCrash()); - tempList.add(newDeviceId); - try { - roomDevicesId = RoomDevicesId(tempList); - } catch (e) { - logger.e('addDeviceId will not work if list got created with const'); - } - } - - /// Will add new scene id to the scenes in the room list - void addSceneId(String newSceneId) { - final List tempList = []; - tempList.addAll(roomScenesId.getOrCrash()); - tempList.add(newSceneId); - try { - roomScenesId = RoomScenesId(tempList); - } catch (e) { - logger.e('addSceneId will not work if list got created with const'); - } - } - - /// Will add new routine id to the scenes in the room list - void addRoutineId(String newRoutineId) { - final List tempList = []; - tempList.addAll(roomRoutinesId.getOrCrash()); - tempList.add(newRoutineId); - try { - roomRoutinesId = RoomRoutinesId(tempList); - } catch (e) { - logger.e('addRoutineId will not work if list got created with const'); - } - } - - /// Will add new Binding id to the scenes in the room list - void addBindingId(String newSceneId) { - try { - roomBindingsId.getOrCrash().add(newSceneId); - } catch (e) { - logger.e('addBindingId will not work if list got created with const'); - } - } - - /// Return new RoomDevicesId object without id if it exist in roomDevicesId - RoomDevicesId deleteIdIfExist(String id) { - final List tempList = List.from(roomDevicesId.getOrCrash()); - tempList.removeWhere((element) => element == id); - - return RoomDevicesId(tempList); - } - - Option> get failureOption { - return cbjEntityName.value.fold((f) => some(f), (_) => none()); - } - - RoomEntityDtos toInfrastructure() { - return RoomEntityDtos( - uniqueId: uniqueId.getOrCrash(), - cbjEntityName: cbjEntityName.getOrCrash(), - background: background.getOrCrash(), - roomTypes: roomTypes.getOrCrash(), - roomDevicesId: roomDevicesId.getOrCrash(), - roomScenesId: roomScenesId.getOrCrash(), - roomRoutinesId: roomRoutinesId.getOrCrash(), - roomBindingsId: roomBindingsId.getOrCrash(), - roomMostUsedBy: roomMostUsedBy.getOrCrash(), - roomPermissions: roomPermissions.getOrCrash(), - ); - } -} diff --git a/lib/domain/room/room_errors.dart b/lib/domain/room/room_errors.dart deleted file mode 100644 index 4d0f385f..00000000 --- a/lib/domain/room/room_errors.dart +++ /dev/null @@ -1,14 +0,0 @@ -import 'package:cbj_hub/domain/room/room_failures.dart'; - -class RoomUnexpectedValueError extends Error { - RoomUnexpectedValueError(this.roomsValueFailure); - - final RoomFailure roomsValueFailure; - - @override - String toString() { - const explanation = - 'Encountered a ValueFailure at an unrecoverable point. Terminating.'; - return Error.safeToString('$explanation Failure was: $roomsValueFailure'); - } -} diff --git a/lib/domain/room/room_failures.dart b/lib/domain/room/room_failures.dart deleted file mode 100644 index 199bcf4d..00000000 --- a/lib/domain/room/room_failures.dart +++ /dev/null @@ -1,33 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'room_failures.freezed.dart'; - -@freezed -class RoomFailure { - const factory RoomFailure.empty({ - required T failedValue, - }) = _Empty; - - const factory RoomFailure.actionExcecuter({ - required T failedValue, - }) = _ActionExcecuter; - - const factory RoomFailure.exceedingLength({ - required T failedValue, - required int max, - }) = _ExceedingLength; - - const factory RoomFailure.unexpected() = _Unexpected; - - const factory RoomFailure.insufficientPermission() = _InsufficientPermission; - - const factory RoomFailure.unableToUpdate() = _UnableToUpdate; - - const factory RoomFailure.powerConsumptionIsNotNumber() = - _PowerConsumptionIsNotNumber; - - const factory RoomFailure.roomsActionDoesNotExist() = - _RoomsActionDoesNotExist; - - const factory RoomFailure.roomsTypeDoesNotExist() = _RoomsTypeDoesNotExist; -} diff --git a/lib/domain/room/room_validators.dart b/lib/domain/room/room_validators.dart deleted file mode 100644 index a26ace1f..00000000 --- a/lib/domain/room/room_validators.dart +++ /dev/null @@ -1,62 +0,0 @@ -import 'package:cbj_hub/domain/room/room_failures.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateRoomNotEmpty(String input) { - if (input.isNotEmpty) { - return right(input); - } else { - return left( - RoomFailure.empty( - failedValue: input, - ), - ); - } -} - -Either, String> validateRoomBackgroundNotEmpty( - String input, -) { - if (input.isNotEmpty) { - return right(input); - } else { - return left( - RoomFailure.empty( - failedValue: input, - ), - ); - } -} - -Either, String> validateRoomMaxNameLength( - String input, - int maxLength, -) { - if (input.length <= maxLength) { - return right(input); - } else { - return left( - RoomFailure.exceedingLength( - failedValue: input, - max: maxLength, - ), - ); - } -} - -Either>, List> validateRoomTypesExist( - List input, -) { - return right(input); -} - -Either>, List> validateRoomTypsValid( - List input, -) { - return right(input); -} - -Either>, List> validateUserIdsValid( - List input, -) { - return right(input); -} diff --git a/lib/domain/room/value_objects_room.dart b/lib/domain/room/value_objects_room.dart deleted file mode 100644 index 12df9988..00000000 --- a/lib/domain/room/value_objects_room.dart +++ /dev/null @@ -1,168 +0,0 @@ -import 'package:cbj_hub/domain/room/room_errors.dart'; -import 'package:cbj_hub/domain/room/room_failures.dart'; -import 'package:cbj_hub/domain/room/room_validators.dart'; -import 'package:dartz/dartz.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:uuid/uuid.dart'; - -@immutable -abstract class ValueObjectRooms { - const ValueObjectRooms(); - - Either, T> get value; - - /// Throws [UnexpectedValueError] containing the [AuthValueFailure] - T getOrCrash() { - // id = identity - same as writing (right) => right - return value.fold((f) => throw RoomUnexpectedValueError(f), id); - } - - Either, Unit> get failureOrUnit { - return value.fold((l) => left(l), (r) => right(unit)); - } - - bool isValid() => value.isRight(); - - @override - String toString() => 'Value($value)'; - - @override - @nonVirtual - bool operator ==(Object o) { - if (identical(this, o)) return true; - return o is ValueObjectRooms && o.value == value; - } - - @override - int get hashCode => value.hashCode; -} - -class RoomUniqueId extends ValueObjectRooms { - factory RoomUniqueId() { - return RoomUniqueId._(right(const Uuid().v1())); - } - - factory RoomUniqueId.fromUniqueString(String uniqueId) { - return RoomUniqueId._(right(uniqueId)); - } - - factory RoomUniqueId.discoveredRoomId() { - return RoomUniqueId._(right('00000000-0000-0000-0000-000000000000')); - } - - const RoomUniqueId._(this.value); - - @override - final Either, String> value; -} - -class RoomDefaultName extends ValueObjectRooms { - factory RoomDefaultName(String input) { - return RoomDefaultName._( - validateRoomNotEmpty(input) - .flatMap((a) => validateRoomMaxNameLength(input, maxLength)), - ); - } - - factory RoomDefaultName.discoveredRoomName() { - return RoomDefaultName._(right('Discovered')); - } - - const RoomDefaultName._(this.value); - - @override - final Either, String> value; - - static const maxLength = 1000; -} - -/// Can be an image or a color hex value -class RoomBackground extends ValueObjectRooms { - factory RoomBackground(String input) { - return RoomBackground._( - validateRoomBackgroundNotEmpty(input), - ); - } - - const RoomBackground._(this.value); - - @override - final Either, String> value; -} - -class RoomTypes extends ValueObjectRooms> { - factory RoomTypes(List input) { - return RoomTypes._(validateRoomTypesExist(input)); - } - - const RoomTypes._(this.value); - - @override - final Either>, List> value; -} - -class RoomDevicesId extends ValueObjectRooms> { - factory RoomDevicesId(List input) { - return RoomDevicesId._(validateRoomTypsValid(input)); - } - - const RoomDevicesId._(this.value); - - @override - final Either>, List> value; -} - -class RoomScenesId extends ValueObjectRooms> { - factory RoomScenesId(List input) { - return RoomScenesId._(validateRoomTypsValid(input)); - } - - const RoomScenesId._(this.value); - - @override - final Either>, List> value; -} - -class RoomRoutinesId extends ValueObjectRooms> { - factory RoomRoutinesId(List input) { - return RoomRoutinesId._(validateRoomTypsValid(input)); - } - - const RoomRoutinesId._(this.value); - - @override - final Either>, List> value; -} - -class RoomBindingsId extends ValueObjectRooms> { - factory RoomBindingsId(List input) { - return RoomBindingsId._(validateRoomTypsValid(input)); - } - - const RoomBindingsId._(this.value); - - @override - final Either>, List> value; -} - -class RoomMostUsedBy extends ValueObjectRooms> { - factory RoomMostUsedBy(List input) { - return RoomMostUsedBy._(validateUserIdsValid(input)); - } - - const RoomMostUsedBy._(this.value); - - @override - final Either>, List> value; -} - -class RoomPermissions extends ValueObjectRooms> { - factory RoomPermissions(List input) { - return RoomPermissions._(validateUserIdsValid(input)); - } - - const RoomPermissions._(this.value); - - @override - final Either>, List> value; -} diff --git a/lib/domain/rooms/i_saved_rooms_repo.dart b/lib/domain/rooms/i_saved_rooms_repo.dart deleted file mode 100644 index 92ef21c2..00000000 --- a/lib/domain/rooms/i_saved_rooms_repo.dart +++ /dev/null @@ -1,49 +0,0 @@ -import 'package:cbj_hub/domain/binding/binding_cbj_entity.dart'; -import 'package:cbj_hub/domain/room/room_entity.dart'; -import 'package:cbj_hub/domain/routine/routine_cbj_entity.dart'; -import 'package:cbj_hub/domain/scene/scene_cbj_entity.dart'; -import 'package:cbj_integrations_controller/domain/local_db/local_db_failures.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:dartz/dartz.dart'; - -abstract class ISavedRoomsRepo { - ISavedRoomsRepo() { - instance = this; - } - - static late ISavedRoomsRepo instance; - - /// Setting up all rooms from db - Future setUpAllFromDb(); - - /// Add new room to saved rooms list - RoomEntity addOrUpdateRoom(RoomEntity roomEntity); - - /// Check if the device exist in one of the rooms, if not will add it to - /// Discovered room - void addDeviceToRoomDiscoveredIfNotExist(DeviceEntityAbstract deviceEntity); - - /// Check if the scene exist in one of the rooms, if not will add it to - /// Discovered room - void addSceneToRoomDiscoveredIfNotExist(SceneCbjEntity sceneCbjEntity); - - /// Check if the routine exist in one of the rooms, if not will add it to - /// Discovered room - void addRoutineToRoomDiscoveredIfNotExist(RoutineCbjEntity routineCbjEntity); - - /// Check if the binding exist in one of the rooms, if not will add it to - /// Discovered room - void addBindingToRoomDiscoveredIfNotExist(BindingCbjEntity bindingCbjEntity); - - Future> saveAndActiveRoomToDb({ - required RoomEntity roomEntity, - }); - - Future> - createScenesForAllSelectedRoomTypes({ - required RoomEntity roomEntity, - }); - - /// Get all saved rooms - Future> getAllRooms(); -} diff --git a/lib/domain/routine/i_routine_cbj_repository.dart b/lib/domain/routine/i_routine_cbj_repository.dart deleted file mode 100644 index a043685e..00000000 --- a/lib/domain/routine/i_routine_cbj_repository.dart +++ /dev/null @@ -1,30 +0,0 @@ -import 'package:cbj_integrations_controller/domain/local_db/local_db_failures.dart'; -import 'package:cbj_hub/domain/routine/routine_cbj_entity.dart'; -import 'package:cbj_hub/domain/routine/routine_cbj_failures.dart'; -import 'package:dartz/dartz.dart'; - -abstract class IRoutineCbjRepository { - /// Setting up all routines from db - Future setUpAllFromDb(); - - Future> getAllRoutinesAsList(); - - Future> getAllRoutinesAsMap(); - - /// Sending the new routine to the hub to get added, will not save it to local db - Future> addNewRoutine( - RoutineCbjEntity routineCbj, - ); - - /// Sending the new routine to the hub to get added, and saves it to local db - Future> addNewRoutineAndSaveItToLocalDb( - RoutineCbjEntity routineCbj, - ); - - Future> saveAndActivateRoutineToDb(); - - Future activateRoutine(RoutineCbjEntity routineCbj); - - /// Get entity and return the full MQTT path to it - Future getFullMqttPathOfRoutine(RoutineCbjEntity routineCbj); -} diff --git a/lib/domain/routine/routine_cbj_entity.dart b/lib/domain/routine/routine_cbj_entity.dart deleted file mode 100644 index 8a62b280..00000000 --- a/lib/domain/routine/routine_cbj_entity.dart +++ /dev/null @@ -1,77 +0,0 @@ -import 'package:cbj_hub/domain/routine/value_objects_routine_cbj.dart'; -import 'package:cbj_hub/infrastructure/routines/routine_cbj_dtos.dart'; -import 'package:cbj_integrations_controller/domain/core/value_objects.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'routine_cbj_entity.freezed.dart'; - -@freezed -class RoutineCbjEntity with _$RoutineCbjEntity { - const factory RoutineCbjEntity({ - /// The unique id of the routine, will alsow be used as the flow/tab id. - required UniqueId uniqueId, - - /// Name of the automation, will be shown to the user. - required RoutineCbjName name, - required RoutineCbjBackgroundColor backgroundColor, - - /// All the automation as string. - required RoutineCbjAutomationString automationString, - - /// Node-Red flow id of the scene - required RoutineCbjNodeRedFlowId nodeRedFlowId, - - /// The actual id of the first node, most of the time will be the same as - /// uniqueId variable. - required RoutineCbjFirstNodeId firstNodeId, - - /// The Unicode code point at which this icon is stored in the icon font. - required RoutineCbjIconCodePoint iconCodePoint, - required RoutineCbjBackgroundImage image, - required RoutineCbjLastDateOfExecute lastDateOfExecute, - required RoutineCbjStateMassage stateMassage, - required RoutineCbjSenderDeviceOs senderDeviceOs, - required RoutineCbjSenderDeviceModel senderDeviceModel, - required RoutineCbjSenderId senderId, - required RoutineCbjCompUuid compUuid, - required RoutineCbjDeviceStateGRPC entityStateGRPC, - - /// Repeat type, at a specific time/ interval/ iterval between times - required RoutineCbjRepeatType repeateType, - - /// In what days to repeat in - required RoutineCbjRepeatDateDays repeateDateDays, - - /// In what hour to repeat in - required RoutineCbjRepeatDateHour repeateDateHour, - - /// In what minute to repeat in - required RoutineCbjRepeatDateMinute repeateDateMinute, - }) = _RoutineCbjEntity; - - const RoutineCbjEntity._(); - - RoutineCbjDtos toInfrastructure() { - return RoutineCbjDtos( - uniqueId: uniqueId.getOrCrash(), - name: name.getOrCrash(), - backgroundColor: backgroundColor.getOrCrash(), - automationString: automationString.getOrCrash(), - nodeRedFlowId: nodeRedFlowId.getOrCrash(), - firstNodeId: firstNodeId.getOrCrash(), - iconCodePoint: iconCodePoint.getOrCrash(), - image: image.getOrCrash(), - lastDateOfExecute: lastDateOfExecute.getOrCrash(), - entityStateGRPC: entityStateGRPC.getOrCrash(), - senderDeviceModel: senderDeviceModel.getOrCrash(), - senderDeviceOs: senderDeviceOs.getOrCrash(), - senderId: senderId.getOrCrash(), - compUuid: compUuid.getOrCrash(), - stateMassage: stateMassage.getOrCrash(), - repeateType: repeateType.getOrCrash(), - repeateDateDays: repeateDateDays.getOrCrash(), - repeateDateHour: repeateDateHour.getOrCrash(), - repeateDateMinute: repeateDateMinute.getOrCrash(), - ); - } -} diff --git a/lib/domain/routine/routine_cbj_errors.dart b/lib/domain/routine/routine_cbj_errors.dart deleted file mode 100644 index 887376c1..00000000 --- a/lib/domain/routine/routine_cbj_errors.dart +++ /dev/null @@ -1,16 +0,0 @@ -import 'package:cbj_hub/domain/routine/routine_cbj_failures.dart'; - -class RoutineCbjUnexpectedValueError extends Error { - RoutineCbjUnexpectedValueError(this.routinesValueFailure); - - final RoutineCbjFailure routinesValueFailure; - - @override - String toString() { - const explanation = - 'Encountered a ValueFailure at an unrecoverable point. Terminating.'; - return Error.safeToString( - '$explanation Failure was: $routinesValueFailure', - ); - } -} diff --git a/lib/domain/routine/routine_cbj_failures.dart b/lib/domain/routine/routine_cbj_failures.dart deleted file mode 100644 index d4e43b62..00000000 --- a/lib/domain/routine/routine_cbj_failures.dart +++ /dev/null @@ -1,38 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'routine_cbj_failures.freezed.dart'; - -@freezed -class RoutineCbjFailure { - const factory RoutineCbjFailure.unexpected() = _Unexpected; - - const factory RoutineCbjFailure.insufficientPermission() = - _InsufficientPermission; - - const factory RoutineCbjFailure.unableToUpdate() = _UnableToUpdate; - - const factory RoutineCbjFailure.empty({ - required T failedValue, - }) = _Empty; - - const factory RoutineCbjFailure.actionExcecuter({ - required T failedValue, - }) = _ActionExcecuter; - - const factory RoutineCbjFailure.exceedingLength({ - required T failedValue, - required int max, - }) = _ExceedingLength; - - const factory RoutineCbjFailure.powerConsumptionIsNotNumber() = - _PowerConsumptionIsNotNumber; - - const factory RoutineCbjFailure.roomsActionDoesNotExist() = - _RoomsActionDoesNotExist; - - const factory RoutineCbjFailure.roomsTypeDoesNotExist() = - _RoomsTypeDoesNotExist; - - const factory RoutineCbjFailure.routineStateDoesNotExist() = - _RoutineStateDoesNotExist; -} diff --git a/lib/domain/routine/routine_cbj_validators.dart b/lib/domain/routine/routine_cbj_validators.dart deleted file mode 100644 index ec917630..00000000 --- a/lib/domain/routine/routine_cbj_validators.dart +++ /dev/null @@ -1,180 +0,0 @@ -import 'package:cbj_hub/domain/routine/routine_cbj_failures.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_devices/device_type_enums.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateRoutineNotEmpty( - String input, -) { - if (input.isNotEmpty) { - return right(input); - } else { - return left( - RoutineCbjFailure.empty( - failedValue: input, - ), - ); - } -} - -Either, String> validateRoutineMaxNameLength( - String input, - int maxLength, -) { - if (input.length <= maxLength) { - return right(input); - } else { - return left( - RoutineCbjFailure.exceedingLength( - failedValue: input, - max: maxLength, - ), - ); - } -} - -Either, String> - validateRoutineCbjBackgroundColorNotEmpty( - String input, -) { - return right(input); -} - -Either, String?> - validateRoutineCbjAutomationStringLugit( - String? input, -) { - return right(input); -} - -Either, String?> validateRoutineCbjNodeRedFlowId( - String? input, -) { - return right(input); -} - -Either, String?> validateRoutineCbjFirstNodeId( - String? input, -) { - return right(input); -} - -Either, String?> validateRoutineCbjIconCodePoint( - String? input, -) { - return right(input); -} - -Either, String?> validateRoutineCbjBackgroundImage( - String? input, -) { - return right(input); -} - -Either, String?> validateRoutineCbjLastDateOfExecute( - String? input, -) { - return right(input); -} - -Either, String?> validateRoutineCbjStateMassage( - String? input, -) { - return right(input); -} - -Either, String?> validateRoutineCbjSenderDeviceOs( - String? input, -) { - return right(input); -} - -Either, String?> validateRoutineCbjSenderDeviceModel( - String? input, -) { - return right(input); -} - -Either, String?> validateRoutineCbjSenderId( - String? input, -) { - return right(input); -} - -Either, String?> validateRoutineCbjCompUuid( - String? input, -) { - return right(input); -} - -Either, String> validateRoutineCbjDeviceStateGRPC( - String input, -) { - if (input.isNotEmpty) { - return right(input); - } else { - return left( - RoutineCbjFailure.empty( - failedValue: input, - ), - ); - } -} - -Either, String> validateRoutineStateExist( - String input, -) { - if (EnumHelperCbj.stringToDeviceState(input) != null) { - return right(input); - } - return left(const RoutineCbjFailure.routineStateDoesNotExist()); -} - -Either, String> validateRoutineCbjTypeExist( - String input, -) { - // TODO: Should check if exist in WhenToExecute - return right(input); -} - -Either>, List> - validateRoutineCbjDateDaysValid( - List input, -) { - final List inputMutable = List.from(input); - for (int index = 0; index < input.length; index++) { - final String day = input[index].toLowerCase(); - - if (day == 'sunday' || day == 'sun' || day == 'su') { - inputMutable[index] = 'sunday'; - } else if (day == 'monday' || day == 'mon' || day == 'mo') { - inputMutable[index] = 'monday'; - } else if (day == 'tuesday' || day == 'tue' || day == 'tu') { - inputMutable[index] = 'tuesday'; - } else if (day == 'wednesday' || day == 'wed' || day == 'we') { - inputMutable[index] = 'wednesday'; - } else if (day == 'thursday' || day == 'thu' || day == 'th') { - inputMutable[index] = 'thursday'; - } else if (day == 'friday' || day == 'fri' || day == 'fr') { - inputMutable[index] = 'friday'; - } else if (day == 'saturday' || day == 'sat' || day == 'sa') { - inputMutable[index] = 'saturday'; - } else { - return left(const RoutineCbjFailure.unexpected()); - } - } - return right(inputMutable); -} - -Either, String> validateRoutineCbjRepeatDateHourValid( - String input, -) { - // TODO: Check if this is valid hour - return right(input); -} - -Either, String> validateRoutineRepeatDateMinuteValid( - String input, -) { - // TODO: Check if this is valid minute - return right(input); -} diff --git a/lib/domain/routine/value_objects_routine_cbj.dart b/lib/domain/routine/value_objects_routine_cbj.dart deleted file mode 100644 index b87acc9d..00000000 --- a/lib/domain/routine/value_objects_routine_cbj.dart +++ /dev/null @@ -1,283 +0,0 @@ -import 'package:cbj_hub/domain/routine/routine_cbj_errors.dart'; -import 'package:cbj_hub/domain/routine/routine_cbj_failures.dart'; -import 'package:cbj_hub/domain/routine/routine_cbj_validators.dart'; -import 'package:dartz/dartz.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:uuid/uuid.dart'; - -@immutable -abstract class ValueObjectRoutinesCbj { - const ValueObjectRoutinesCbj(); - - Either, T> get value; - - /// Throws [UnexpectedValueError] containing the [AuthValueFailure] - T getOrCrash() { - // id = identity - same as writing (right) => right - return value.fold((f) => throw RoutineCbjUnexpectedValueError(f), id); - } - - Either, Unit> get failureOrUnit { - return value.fold((l) => left(l), (r) => right(unit)); - } - - bool isValid() => value.isRight(); - - @override - String toString() => 'Value($value)'; - - @override - @nonVirtual - bool operator ==(Object o) { - if (identical(this, o)) return true; - return o is ValueObjectRoutinesCbj && o.value == value; - } - - @override - int get hashCode => value.hashCode; -} - -class RoutineUniqueId extends ValueObjectRoutinesCbj { - factory RoutineUniqueId() { - return RoutineUniqueId._(right(const Uuid().v1())); - } - - factory RoutineUniqueId.fromUniqueString(String uniqueId) { - return RoutineUniqueId._(right(uniqueId)); - } - - factory RoutineUniqueId.discoveredRoutineId() { - return RoutineUniqueId._(right('00000000-0000-0000-0000-000000000000')); - } - - const RoutineUniqueId._(this.value); - - @override - final Either, String> value; -} - -class RoutineCbjName extends ValueObjectRoutinesCbj { - factory RoutineCbjName(String input) { - return RoutineCbjName._( - validateRoutineNotEmpty(input) - .flatMap((a) => validateRoutineMaxNameLength(input, maxLength)), - ); - } - - factory RoutineCbjName.discoveredRoutineName() { - return RoutineCbjName._(right('Discovered')); - } - - const RoutineCbjName._(this.value); - - @override - final Either, String> value; - - static const maxLength = 1000; -} - -class RoutineCbjBackgroundColor extends ValueObjectRoutinesCbj { - factory RoutineCbjBackgroundColor(String input) { - return RoutineCbjBackgroundColor._( - validateRoutineCbjBackgroundColorNotEmpty(input), - ); - } - - const RoutineCbjBackgroundColor._(this.value); - - @override - final Either, String> value; -} - -class RoutineCbjAutomationString extends ValueObjectRoutinesCbj { - factory RoutineCbjAutomationString(String? input) { - return RoutineCbjAutomationString._( - validateRoutineCbjAutomationStringLugit(input), - ); - } - - const RoutineCbjAutomationString._(this.value); - - @override - final Either, String?> value; -} - -class RoutineCbjNodeRedFlowId extends ValueObjectRoutinesCbj { - factory RoutineCbjNodeRedFlowId(String? input) { - return RoutineCbjNodeRedFlowId._(validateRoutineCbjNodeRedFlowId(input)); - } - - const RoutineCbjNodeRedFlowId._(this.value); - - @override - final Either, String?> value; -} - -class RoutineCbjFirstNodeId extends ValueObjectRoutinesCbj { - factory RoutineCbjFirstNodeId(String? input) { - return RoutineCbjFirstNodeId._(validateRoutineCbjFirstNodeId(input)); - } - - const RoutineCbjFirstNodeId._(this.value); - - @override - final Either, String?> value; -} - -class RoutineCbjIconCodePoint extends ValueObjectRoutinesCbj { - factory RoutineCbjIconCodePoint(String? input) { - return RoutineCbjIconCodePoint._(validateRoutineCbjIconCodePoint(input)); - } - - const RoutineCbjIconCodePoint._(this.value); - - @override - final Either, String?> value; -} - -class RoutineCbjBackgroundImage extends ValueObjectRoutinesCbj { - factory RoutineCbjBackgroundImage(String? input) { - return RoutineCbjBackgroundImage._(validateRoutineCbjIconCodePoint(input)); - } - - const RoutineCbjBackgroundImage._(this.value); - - @override - final Either, String?> value; -} - -class RoutineCbjLastDateOfExecute extends ValueObjectRoutinesCbj { - factory RoutineCbjLastDateOfExecute(String? input) { - return RoutineCbjLastDateOfExecute._( - validateRoutineCbjIconCodePoint(input), - ); - } - - const RoutineCbjLastDateOfExecute._(this.value); - - @override - final Either, String?> value; -} - -class RoutineCbjStateMassage extends ValueObjectRoutinesCbj { - factory RoutineCbjStateMassage(String? input) { - return RoutineCbjStateMassage._(validateRoutineCbjStateMassage(input)); - } - - const RoutineCbjStateMassage._(this.value); - - @override - final Either, String?> value; -} - -class RoutineCbjSenderDeviceOs extends ValueObjectRoutinesCbj { - factory RoutineCbjSenderDeviceOs(String? input) { - return RoutineCbjSenderDeviceOs._(validateRoutineCbjSenderDeviceOs(input)); - } - - const RoutineCbjSenderDeviceOs._(this.value); - - @override - final Either, String?> value; -} - -class RoutineCbjSenderDeviceModel extends ValueObjectRoutinesCbj { - factory RoutineCbjSenderDeviceModel(String? input) { - return RoutineCbjSenderDeviceModel._( - validateRoutineCbjSenderDeviceModel(input), - ); - } - - const RoutineCbjSenderDeviceModel._(this.value); - - @override - final Either, String?> value; -} - -class RoutineCbjSenderId extends ValueObjectRoutinesCbj { - factory RoutineCbjSenderId(String? input) { - return RoutineCbjSenderId._(validateRoutineCbjSenderId(input)); - } - - const RoutineCbjSenderId._(this.value); - - @override - final Either, String?> value; -} - -class RoutineCbjCompUuid extends ValueObjectRoutinesCbj { - factory RoutineCbjCompUuid(String? input) { - return RoutineCbjCompUuid._(validateRoutineCbjCompUuid(input)); - } - - const RoutineCbjCompUuid._(this.value); - - @override - final Either, String?> value; -} - -class RoutineCbjDeviceStateGRPC extends ValueObjectRoutinesCbj { - factory RoutineCbjDeviceStateGRPC(String? input) { - return RoutineCbjDeviceStateGRPC._( - validateRoutineCbjDeviceStateGRPC(input!) - .flatMap((a) => validateRoutineStateExist(input)), - ); - } - - const RoutineCbjDeviceStateGRPC._(this.value); - - @override - final Either, String?> value; -} - -class RoutineCbjRepeatType extends ValueObjectRoutinesCbj { - factory RoutineCbjRepeatType(String? input) { - return RoutineCbjRepeatType._( - validateRoutineCbjTypeExist(input!), - ); - } - - const RoutineCbjRepeatType._(this.value); - - @override - final Either, String?> value; -} - -class RoutineCbjRepeatDateDays extends ValueObjectRoutinesCbj?> { - factory RoutineCbjRepeatDateDays(List? input) { - return RoutineCbjRepeatDateDays._( - validateRoutineCbjDateDaysValid(input!), - ); - } - - const RoutineCbjRepeatDateDays._(this.value); - - @override - final Either?>, List?> value; -} - -class RoutineCbjRepeatDateHour extends ValueObjectRoutinesCbj { - factory RoutineCbjRepeatDateHour(String? input) { - return RoutineCbjRepeatDateHour._( - validateRoutineCbjRepeatDateHourValid(input!), - ); - } - - const RoutineCbjRepeatDateHour._(this.value); - - @override - final Either, String?> value; -} - -class RoutineCbjRepeatDateMinute extends ValueObjectRoutinesCbj { - factory RoutineCbjRepeatDateMinute(String? input) { - return RoutineCbjRepeatDateMinute._( - validateRoutineRepeatDateMinuteValid(input!), - ); - } - - const RoutineCbjRepeatDateMinute._(this.value); - - @override - final Either, String?> value; -} diff --git a/lib/domain/scene/i_scene_cbj_repository.dart b/lib/domain/scene/i_scene_cbj_repository.dart deleted file mode 100644 index b6e7976e..00000000 --- a/lib/domain/scene/i_scene_cbj_repository.dart +++ /dev/null @@ -1,87 +0,0 @@ -import 'package:cbj_hub/domain/scene/scene_cbj_entity.dart'; -import 'package:cbj_hub/domain/scene/scene_cbj_failures.dart'; -import 'package:cbj_integrations_controller/domain/local_db/local_db_failures.dart'; -import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:dartz/dartz.dart'; -import 'package:kt_dart/collection.dart'; -import 'package:rxdart/rxdart.dart'; - -abstract class ISceneCbjRepository { - /// Setting up all scenes from db - Future setUpAllFromDb(); - - Future> getAllScenesAsList(); - - Future> getAllScenesAsMap(); - - /// Will add new scene without saving it in the local db - Future> addNewScene( - SceneCbjEntity sceneCbj, - ); - - /// Sending the new scene to the hub to get added - Future> addNewSceneAndSaveInDb( - SceneCbjEntity sceneCbj, - ); - - Future> - saveAndActivateScenesAndSmartDevicesToDb(); - - Future activateScene( - SceneCbjEntity sceneCbj, - ); - - /// Get entity and return the full MQTT path to it - Future getFullMqttPathOfScene(SceneCbjEntity sceneCbj); - - Stream>> watchAllScenes(); - - /// Sending the new scene to the hub to get added - Future> addOrUpdateNewSceneInHub( - SceneCbjEntity sceneCbjEntity, - ); - - /// Activate action of all scene list - Future> activateScenes( - KtList scenesList, - ); - - /// Sending the new scene to the hub to get added - Future> - addOrUpdateNewSceneInHubFromDevicesPropertyActionList( - String sceneName, - List>> - smartDevicesWithActionToAdd, - AreaPurposesTypes areaPurposesTypes, - ); - - /// Will add all the devices to area scene, for each device will use the preselected - /// actions for that area type - Future> - addDevicesToMultipleScenesAreaTypeWithPreSetActions({ - required List devicesId, - required List scenesId, - required List areaTypes, - }); - - /// Will add all the devices to area scene, for each device will use the preselected - /// actions for that area type - Future> - addDevicesToSceneAreaTypeWithPreSetActions({ - required List devicesId, - required String sceneId, - required AreaPurposesTypes areaType, - }); - - /// Sending the new scene from the hub to the app scene list - void addOrUpdateNewSceneInApp( - SceneCbjEntity sceneCbj, - ); - - Future initiateHubConnection(); - - BehaviorSubject> - scenesResponseFromTheHubStreamController = - BehaviorSubject>(); -} diff --git a/lib/domain/scene/scene_cbj_entity.dart b/lib/domain/scene/scene_cbj_entity.dart deleted file mode 100644 index 8c19ac50..00000000 --- a/lib/domain/scene/scene_cbj_entity.dart +++ /dev/null @@ -1,61 +0,0 @@ -import 'package:cbj_integrations_controller/domain/core/value_objects.dart'; -import 'package:cbj_hub/domain/scene/value_objects_scene_cbj.dart'; -import 'package:cbj_hub/infrastructure/scenes/scene_cbj_dtos.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'scene_cbj_entity.freezed.dart'; - -@freezed -class SceneCbjEntity with _$SceneCbjEntity { - const factory SceneCbjEntity({ - /// The unique id of the scene, will alsow be used as the flow/tab id. - required UniqueId uniqueId, - - /// Name of the automation, will be shown to the user. - required SceneCbjName name, - required SceneCbjBackgroundColor backgroundColor, - - /// All the automation as string. - required SceneCbjAutomationString automationString, - - /// Node-Red flow id of the scene - required SceneCbjNodeRedFlowId nodeRedFlowId, - - /// The actual id of the first node, most of the time will be the same as - /// uniqueId variable. - required SceneCbjFirstNodeId firstNodeId, - - /// The Unicode code point at which this icon is stored in the icon font. - required SceneCbjIconCodePoint iconCodePoint, - required SceneCbjBackgroundImage image, - required SceneCbjLastDateOfExecute lastDateOfExecute, - required SceneCbjStateMassage stateMassage, - required SceneCbjSenderDeviceOs senderDeviceOs, - required SceneCbjSenderDeviceModel senderDeviceModel, - required SceneCbjSenderId senderId, - required SceneCbjCompUuid compUuid, - required SceneCbjDeviceStateGRPC entityStateGRPC, - }) = _SceneCbjEntity; - - const SceneCbjEntity._(); - - SceneCbjDtos toInfrastructure() { - return SceneCbjDtos( - uniqueId: uniqueId.getOrCrash(), - name: name.getOrCrash(), - backgroundColor: backgroundColor.getOrCrash(), - automationString: automationString.getOrCrash(), - nodeRedFlowId: nodeRedFlowId.getOrCrash(), - firstNodeId: firstNodeId.getOrCrash(), - iconCodePoint: iconCodePoint.getOrCrash(), - image: image.getOrCrash(), - lastDateOfExecute: lastDateOfExecute.getOrCrash(), - entityStateGRPC: entityStateGRPC.getOrCrash(), - senderDeviceModel: senderDeviceModel.getOrCrash(), - senderDeviceOs: senderDeviceOs.getOrCrash(), - senderId: senderId.getOrCrash(), - compUuid: compUuid.getOrCrash(), - stateMassage: stateMassage.getOrCrash(), - ); - } -} diff --git a/lib/domain/scene/scene_cbj_errors.dart b/lib/domain/scene/scene_cbj_errors.dart deleted file mode 100644 index 06f832f3..00000000 --- a/lib/domain/scene/scene_cbj_errors.dart +++ /dev/null @@ -1,14 +0,0 @@ -import 'package:cbj_hub/domain/scene/scene_cbj_failures.dart'; - -class SceneCbjUnexpectedValueError extends Error { - SceneCbjUnexpectedValueError(this.scenesValueFailure); - - final SceneCbjFailure scenesValueFailure; - - @override - String toString() { - const explanation = - 'Encountered a ValueFailure at an unrecoverable point. Terminating.'; - return Error.safeToString('$explanation Failure was: $scenesValueFailure'); - } -} diff --git a/lib/domain/scene/scene_cbj_failures.dart b/lib/domain/scene/scene_cbj_failures.dart deleted file mode 100644 index 8b9758be..00000000 --- a/lib/domain/scene/scene_cbj_failures.dart +++ /dev/null @@ -1,38 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'scene_cbj_failures.freezed.dart'; - -@freezed -class SceneCbjFailure { - const factory SceneCbjFailure.unexpected() = _Unexpected; - - const factory SceneCbjFailure.insufficientPermission() = - _InsufficientPermission; - - const factory SceneCbjFailure.unableToUpdate() = _UnableToUpdate; - - const factory SceneCbjFailure.empty({ - required T failedValue, - }) = _Empty; - - const factory SceneCbjFailure.actionExcecuter({ - required T failedValue, - }) = _ActionExcecuter; - - const factory SceneCbjFailure.exceedingLength({ - required T failedValue, - required int max, - }) = _ExceedingLength; - - const factory SceneCbjFailure.powerConsumptionIsNotNumber() = - _PowerConsumptionIsNotNumber; - - const factory SceneCbjFailure.roomsActionDoesNotExist() = - _RoomsActionDoesNotExist; - - const factory SceneCbjFailure.roomsTypeDoesNotExist() = - _RoomsTypeDoesNotExist; - - const factory SceneCbjFailure.sceneStateDoesNotExist() = - _SceneStateDoesNotExist; -} diff --git a/lib/domain/scene/scene_cbj_validators.dart b/lib/domain/scene/scene_cbj_validators.dart deleted file mode 100644 index e2c6db5b..00000000 --- a/lib/domain/scene/scene_cbj_validators.dart +++ /dev/null @@ -1,126 +0,0 @@ -import 'package:cbj_integrations_controller/infrastructure/generic_devices/device_type_enums.dart'; -import 'package:cbj_hub/domain/scene/scene_cbj_failures.dart'; -import 'package:dartz/dartz.dart'; - -Either, String> validateSceneNotEmpty(String input) { - if (input.isNotEmpty) { - return right(input); - } else { - return left( - SceneCbjFailure.empty( - failedValue: input, - ), - ); - } -} - -Either, String> validateSceneMaxNameLength( - String input, - int maxLength, -) { - if (input.length <= maxLength) { - return right(input); - } else { - return left( - SceneCbjFailure.exceedingLength( - failedValue: input, - max: maxLength, - ), - ); - } -} - -Either, String> validateSceneCbjBackgroundColorNotEmpty( - String input, -) { - return right(input); -} - -Either, String?> validateSceneCbjAutomationStringLugit( - String? input, -) { - return right(input); -} - -Either, String?> validateSceneCbjNodeRedFlowId( - String? input, -) { - return right(input); -} - -Either, String?> validateSceneCbjFirstNodeId( - String? input, -) { - return right(input); -} - -Either, String?> validateSceneCbjIconCodePoint( - String? input, -) { - return right(input); -} - -Either, String?> validateSceneCbjBackgroundImage( - String? input, -) { - return right(input); -} - -Either, String?> validateSceneCbjLastDateOfExecute( - String? input, -) { - return right(input); -} - -Either, String?> validateSceneCbjStateMassage( - String? input, -) { - return right(input); -} - -Either, String?> validateSceneCbjSenderDeviceOs( - String? input, -) { - return right(input); -} - -Either, String?> validateSceneCbjSenderDeviceModel( - String? input, -) { - return right(input); -} - -Either, String?> validateSceneCbjSenderId( - String? input, -) { - return right(input); -} - -Either, String?> validateSceneCbjCompUuid( - String? input, -) { - return right(input); -} - -Either, String> validateSceneCbjDeviceStateGRPC( - String input, -) { - if (input.isNotEmpty) { - return right(input); - } else { - return left( - SceneCbjFailure.empty( - failedValue: input, - ), - ); - } -} - -Either, String> validateSceneStateExist( - String input, -) { - if (EnumHelperCbj.stringToDeviceState(input) != null) { - return right(input); - } - return left(const SceneCbjFailure.sceneStateDoesNotExist()); -} diff --git a/lib/domain/scene/value_objects_scene_cbj.dart b/lib/domain/scene/value_objects_scene_cbj.dart deleted file mode 100644 index 3589de7b..00000000 --- a/lib/domain/scene/value_objects_scene_cbj.dart +++ /dev/null @@ -1,229 +0,0 @@ -import 'package:cbj_hub/domain/scene/scene_cbj_errors.dart'; -import 'package:cbj_hub/domain/scene/scene_cbj_failures.dart'; -import 'package:cbj_hub/domain/scene/scene_cbj_validators.dart'; -import 'package:dartz/dartz.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:uuid/uuid.dart'; - -@immutable -abstract class ValueObjectScenesCbj { - const ValueObjectScenesCbj(); - - Either, T> get value; - - /// Throws [UnexpectedValueError] containing the [AuthValueFailure] - T getOrCrash() { - // id = identity - same as writing (right) => right - return value.fold((f) => throw SceneCbjUnexpectedValueError(f), id); - } - - Either, Unit> get failureOrUnit { - return value.fold((l) => left(l), (r) => right(unit)); - } - - bool isValid() => value.isRight(); - - @override - String toString() => 'Value($value)'; - - @override - @nonVirtual - bool operator ==(Object o) { - if (identical(this, o)) return true; - return o is ValueObjectScenesCbj && o.value == value; - } - - @override - int get hashCode => value.hashCode; -} - -class SceneUniqueId extends ValueObjectScenesCbj { - factory SceneUniqueId() { - return SceneUniqueId._(right(const Uuid().v1())); - } - - factory SceneUniqueId.fromUniqueString(String uniqueId) { - return SceneUniqueId._(right(uniqueId)); - } - - factory SceneUniqueId.discoveredSceneId() { - return SceneUniqueId._(right('00000000-0000-0000-0000-000000000000')); - } - - const SceneUniqueId._(this.value); - - @override - final Either, String> value; -} - -class SceneCbjName extends ValueObjectScenesCbj { - factory SceneCbjName(String input) { - return SceneCbjName._( - validateSceneNotEmpty(input) - .flatMap((a) => validateSceneMaxNameLength(input, maxLength)), - ); - } - - factory SceneCbjName.discoveredSceneName() { - return SceneCbjName._(right('Discovered')); - } - - const SceneCbjName._(this.value); - - @override - final Either, String> value; - - static const maxLength = 1000; -} - -class SceneCbjBackgroundColor extends ValueObjectScenesCbj { - factory SceneCbjBackgroundColor(String input) { - return SceneCbjBackgroundColor._( - validateSceneCbjBackgroundColorNotEmpty(input), - ); - } - - const SceneCbjBackgroundColor._(this.value); - - @override - final Either, String> value; -} - -class SceneCbjAutomationString extends ValueObjectScenesCbj { - factory SceneCbjAutomationString(String? input) { - return SceneCbjAutomationString._( - validateSceneCbjAutomationStringLugit(input), - ); - } - - const SceneCbjAutomationString._(this.value); - - @override - final Either, String?> value; -} - -class SceneCbjNodeRedFlowId extends ValueObjectScenesCbj { - factory SceneCbjNodeRedFlowId(String? input) { - return SceneCbjNodeRedFlowId._(validateSceneCbjNodeRedFlowId(input)); - } - - const SceneCbjNodeRedFlowId._(this.value); - - @override - final Either, String?> value; -} - -class SceneCbjFirstNodeId extends ValueObjectScenesCbj { - factory SceneCbjFirstNodeId(String? input) { - return SceneCbjFirstNodeId._(validateSceneCbjFirstNodeId(input)); - } - - const SceneCbjFirstNodeId._(this.value); - - @override - final Either, String?> value; -} - -class SceneCbjIconCodePoint extends ValueObjectScenesCbj { - factory SceneCbjIconCodePoint(String? input) { - return SceneCbjIconCodePoint._(validateSceneCbjIconCodePoint(input)); - } - - const SceneCbjIconCodePoint._(this.value); - - @override - final Either, String?> value; -} - -class SceneCbjBackgroundImage extends ValueObjectScenesCbj { - factory SceneCbjBackgroundImage(String? input) { - return SceneCbjBackgroundImage._(validateSceneCbjIconCodePoint(input)); - } - - const SceneCbjBackgroundImage._(this.value); - - @override - final Either, String?> value; -} - -class SceneCbjLastDateOfExecute extends ValueObjectScenesCbj { - factory SceneCbjLastDateOfExecute(String? input) { - return SceneCbjLastDateOfExecute._(validateSceneCbjIconCodePoint(input)); - } - - const SceneCbjLastDateOfExecute._(this.value); - - @override - final Either, String?> value; -} - -class SceneCbjStateMassage extends ValueObjectScenesCbj { - factory SceneCbjStateMassage(String? input) { - return SceneCbjStateMassage._(validateSceneCbjStateMassage(input)); - } - - const SceneCbjStateMassage._(this.value); - - @override - final Either, String?> value; -} - -class SceneCbjSenderDeviceOs extends ValueObjectScenesCbj { - factory SceneCbjSenderDeviceOs(String? input) { - return SceneCbjSenderDeviceOs._(validateSceneCbjSenderDeviceOs(input)); - } - - const SceneCbjSenderDeviceOs._(this.value); - - @override - final Either, String?> value; -} - -class SceneCbjSenderDeviceModel extends ValueObjectScenesCbj { - factory SceneCbjSenderDeviceModel(String? input) { - return SceneCbjSenderDeviceModel._( - validateSceneCbjSenderDeviceModel(input), - ); - } - - const SceneCbjSenderDeviceModel._(this.value); - - @override - final Either, String?> value; -} - -class SceneCbjSenderId extends ValueObjectScenesCbj { - factory SceneCbjSenderId(String? input) { - return SceneCbjSenderId._(validateSceneCbjSenderId(input)); - } - - const SceneCbjSenderId._(this.value); - - @override - final Either, String?> value; -} - -class SceneCbjCompUuid extends ValueObjectScenesCbj { - factory SceneCbjCompUuid(String? input) { - return SceneCbjCompUuid._(validateSceneCbjCompUuid(input)); - } - - const SceneCbjCompUuid._(this.value); - - @override - final Either, String?> value; -} - -class SceneCbjDeviceStateGRPC extends ValueObjectScenesCbj { - factory SceneCbjDeviceStateGRPC(String? input) { - return SceneCbjDeviceStateGRPC._( - validateSceneCbjDeviceStateGRPC(input!) - .flatMap((a) => validateSceneStateExist(input)), - ); - } - - const SceneCbjDeviceStateGRPC._(this.value); - - @override - final Either, String?> value; -} diff --git a/lib/infrastructure/app_communication/app_communication_repository.dart b/lib/infrastructure/app_communication/app_communication_repository.dart index bba3e457..fed94f4c 100644 --- a/lib/infrastructure/app_communication/app_communication_repository.dart +++ b/lib/infrastructure/app_communication/app_communication_repository.dart @@ -2,22 +2,21 @@ import 'dart:async'; import 'dart:convert'; import 'package:cbj_hub/domain/app_communication/i_app_communication_repository.dart'; -import 'package:cbj_hub/domain/room/room_entity.dart'; -import 'package:cbj_hub/domain/rooms/i_saved_rooms_repo.dart'; -import 'package:cbj_hub/domain/routine/i_routine_cbj_repository.dart'; -import 'package:cbj_hub/domain/routine/routine_cbj_entity.dart'; -import 'package:cbj_hub/domain/scene/i_scene_cbj_repository.dart'; -import 'package:cbj_hub/domain/scene/scene_cbj_entity.dart'; -import 'package:cbj_hub/domain/scene/value_objects_scene_cbj.dart'; +import 'package:cbj_hub/domain/remote_pipes/remote_pipes_entity.dart'; import 'package:cbj_hub/infrastructure/app_communication/hub_app_server.dart'; import 'package:cbj_hub/infrastructure/remote_pipes/remote_pipes_client.dart'; -import 'package:cbj_hub/infrastructure/room/room_entity_dtos.dart'; -import 'package:cbj_hub/infrastructure/routines/routine_cbj_dtos.dart'; -import 'package:cbj_hub/infrastructure/scenes/scene_cbj_dtos.dart'; +import 'package:cbj_hub/infrastructure/remote_pipes/remote_pipes_dtos.dart'; import 'package:cbj_hub/utils.dart'; import 'package:cbj_integrations_controller/domain/core/value_objects.dart'; import 'package:cbj_integrations_controller/domain/mqtt_server/i_mqtt_server_repository.dart'; +import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; +import 'package:cbj_integrations_controller/domain/rooms/i_saved_rooms_repo.dart'; +import 'package:cbj_integrations_controller/domain/routine/i_routine_cbj_repository.dart'; +import 'package:cbj_integrations_controller/domain/routine/routine_cbj_entity.dart'; import 'package:cbj_integrations_controller/domain/saved_devices/i_saved_devices_repo.dart'; +import 'package:cbj_integrations_controller/domain/scene/i_scene_cbj_repository.dart'; +import 'package:cbj_integrations_controller/domain/scene/scene_cbj_entity.dart'; +import 'package:cbj_integrations_controller/domain/scene/value_objects_scene_cbj.dart'; import 'package:cbj_integrations_controller/domain/vendors/login_abstract/login_entity_abstract.dart'; import 'package:cbj_integrations_controller/infrastructure/devices/device_helper/device_helper.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; @@ -26,6 +25,9 @@ import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstr import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/value_objects_core.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_empty_device/generic_empty_entity.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_vendors_login/vendor_helper.dart'; +import 'package:cbj_integrations_controller/infrastructure/room/room_entity_dtos.dart'; +import 'package:cbj_integrations_controller/infrastructure/routines/routine_cbj_dtos.dart'; +import 'package:cbj_integrations_controller/infrastructure/scenes/scene_cbj_dtos.dart'; import 'package:cbj_integrations_controller/injection.dart'; import 'package:grpc/grpc.dart'; import 'package:internet_connection_checker/internet_connection_checker.dart'; @@ -96,14 +98,14 @@ class AppCommunicationRepository extends IAppCommunicationRepository { dataToSend.listen((MqttPublishMessage event) async { logger.i('Got hub requests to app'); - (await getItCbj().getAllDevices()) + (await ISavedDevicesRepo.instance.getAllDevices()) .forEach((String id, deviceEntityToSend) { final DeviceEntityDtoAbstract deviceDtoAbstract = DeviceHelper.convertDomainToDto(deviceEntityToSend); HubRequestsToApp.streamRequestsToApp.sink.add(deviceDtoAbstract); }); - (await getItCbj().getAllScenesAsMap()) + (await ISceneCbjRepository.instance.getAllScenesAsMap()) .forEach((key, value) { HubRequestsToApp.streamRequestsToApp.sink.add(value.toInfrastructure()); }); @@ -147,7 +149,7 @@ class AppCommunicationRepository extends IAppCommunicationRepository { final LoginEntityAbstract loginEntityFromApp = VendorHelper.convertJsonStringToDomain(event.allRemoteCommands); - getItCbj() + ISavedDevicesRepo.instance .saveAndActivateVendorLoginCredentialsDomainToDb( loginEntity: loginEntityFromApp, ); @@ -156,12 +158,12 @@ class AppCommunicationRepository extends IAppCommunicationRepository { AppCommunicationRepository.sendAllDevicesFromHubRequestsStream(); AppCommunicationRepository.sendAllScenesFromHubRequestsStream(); } else if (event.sendingType == SendingType.remotePipesInformation) { + final Map jsonDecoded = + jsonDecode(event.allRemoteCommands) as Map; + final RemotePipesEntity remotePipes = + RemotePipesDtos.fromJson(jsonDecoded).toDomain(); // TODO: Fix after new cbj_integrations_controller - // final Map jsonDecoded = - // jsonDecode(event.allRemoteCommands) as Map; - // final RemotePipesEntity remotePipes = - // RemotePipesDtos.fromJson(jsonDecoded).toDomain(); - // getItCbj() + // ISavedDevicesRepo.instance // .saveAndActivateRemotePipesDomainToDb(remotePipes: remotePipes); } else if (event.sendingType == SendingType.sceneType) { final Map jsonSceneFromJsonString = @@ -180,9 +182,9 @@ class AppCommunicationRepository extends IAppCommunicationRepository { // ); if (sceneStateGrpcTemp == EntityStateGRPC.addingNewScene.toString()) { - getItCbj().addNewSceneAndSaveInDb(sceneCbj); + ISceneCbjRepository.instance.addNewSceneAndSaveInDb(sceneCbj); } else { - getItCbj().activateScene(sceneCbj); + ISceneCbjRepository.instance.activateScene(sceneCbj); } } else if (event.sendingType == SendingType.routineType) { final Map jsonRoutineFromJsonString = @@ -202,11 +204,11 @@ class AppCommunicationRepository extends IAppCommunicationRepository { if (routineStateGrpcTemp == EntityStateGRPC.addingNewRoutine.toString()) { - getItCbj() + IRoutineCbjRepository.instance .addNewRoutineAndSaveItToLocalDb(routineCbj); } else { // For a way to active it manually - // getItCbj().activateRoutine(routineCbj); + // IRoutineCbjRepository.instance.activateRoutine(routineCbj); } } else { logger.w('Request from app does not support this sending device type'); @@ -279,7 +281,7 @@ class AppCommunicationRepository extends IAppCommunicationRepository { /// HubRequestsToApp stream static Future sendAllDevicesFromHubRequestsStream() async { final Map allDevices = - await getItCbj().getAllDevices(); + await ISavedDevicesRepo.instance.getAllDevices(); final Map allRooms = await ISavedRoomsRepo.instance.getAllRooms(); @@ -308,7 +310,7 @@ class AppCommunicationRepository extends IAppCommunicationRepository { /// HubRequestsToApp stream static Future sendAllScenesFromHubRequestsStream() async { final Map allScenes = - await getItCbj().getAllScenesAsMap(); + await ISceneCbjRepository.instance.getAllScenesAsMap(); if (allScenes.isNotEmpty) { allScenes.map((String id, SceneCbjEntity d) { diff --git a/lib/infrastructure/app_communication/hub_app_server.dart b/lib/infrastructure/app_communication/hub_app_server.dart index 8d6c9f32..ac6fe575 100644 --- a/lib/infrastructure/app_communication/hub_app_server.dart +++ b/lib/infrastructure/app_communication/hub_app_server.dart @@ -3,14 +3,14 @@ import 'dart:io'; import 'package:cbj_hub/domain/app_communication/i_app_communication_repository.dart'; import 'package:cbj_hub/infrastructure/app_communication/app_communication_repository.dart'; -import 'package:cbj_hub/infrastructure/room/room_entity_dtos.dart'; -import 'package:cbj_hub/infrastructure/routines/routine_cbj_dtos.dart'; -import 'package:cbj_hub/infrastructure/scenes/scene_cbj_dtos.dart'; import 'package:cbj_hub/utils.dart'; import 'package:cbj_integrations_controller/infrastructure/devices/device_helper/device_helper.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/proto_gen_date.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; +import 'package:cbj_integrations_controller/infrastructure/room/room_entity_dtos.dart'; +import 'package:cbj_integrations_controller/infrastructure/routines/routine_cbj_dtos.dart'; +import 'package:cbj_integrations_controller/infrastructure/scenes/scene_cbj_dtos.dart'; import 'package:grpc/service_api.dart'; /// Server to get and send information to the app diff --git a/lib/infrastructure/bindings/binding_cbj_dtos.dart b/lib/infrastructure/bindings/binding_cbj_dtos.dart deleted file mode 100644 index 5e423a37..00000000 --- a/lib/infrastructure/bindings/binding_cbj_dtos.dart +++ /dev/null @@ -1,77 +0,0 @@ -import 'package:cbj_hub/domain/binding/binding_cbj_entity.dart'; -import 'package:cbj_hub/domain/binding/value_objects_routine_cbj.dart'; -import 'package:cbj_integrations_controller/domain/core/value_objects.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'binding_cbj_dtos.freezed.dart'; -part 'binding_cbj_dtos.g.dart'; - -@freezed -abstract class BindingCbjDtos implements _$BindingCbjDtos { - factory BindingCbjDtos({ - // @JsonKey(ignore: true) - required String uniqueId, - required String name, - required String backgroundColor, - required String? entityStateGRPC, - required String? senderDeviceOs, - required String? senderDeviceModel, - required String? senderId, - required String? compUuid, - required String? stateMassage, - String? automationString, - String? nodeRedFlowId, - String? firstNodeId, - String? iconCodePoint, - String? image, - String? lastDateOfExecute, - // required ServerTimestampConverter() FieldValue serverTimeStamp, - }) = _BindingCbjDtos; - - BindingCbjDtos._(); - - factory BindingCbjDtos.fromDomain(BindingCbjEntity bindingCbj) { - return BindingCbjDtos( - uniqueId: bindingCbj.uniqueId.getOrCrash(), - name: bindingCbj.name.getOrCrash(), - backgroundColor: bindingCbj.backgroundColor.getOrCrash(), - automationString: bindingCbj.automationString.getOrCrash(), - nodeRedFlowId: bindingCbj.nodeRedFlowId.getOrCrash(), - firstNodeId: bindingCbj.firstNodeId.getOrCrash(), - iconCodePoint: bindingCbj.iconCodePoint.getOrCrash(), - image: bindingCbj.image.getOrCrash(), - lastDateOfExecute: bindingCbj.lastDateOfExecute.getOrCrash(), - entityStateGRPC: bindingCbj.entityStateGRPC.getOrCrash(), - senderDeviceModel: bindingCbj.senderDeviceModel.getOrCrash(), - senderDeviceOs: bindingCbj.senderDeviceOs.getOrCrash(), - senderId: bindingCbj.senderId.getOrCrash(), - compUuid: bindingCbj.compUuid.getOrCrash(), - stateMassage: bindingCbj.stateMassage.getOrCrash(), - ); - } - - factory BindingCbjDtos.fromJson(Map json) => - _$BindingCbjDtosFromJson(json); - - final String deviceDtoClassInstance = (BindingCbjDtos).toString(); - - BindingCbjEntity toDomain() { - return BindingCbjEntity( - uniqueId: UniqueId.fromUniqueString(uniqueId), - name: BindingCbjName(name), - backgroundColor: BindingCbjBackgroundColor(backgroundColor), - automationString: BindingCbjAutomationString(automationString), - nodeRedFlowId: BindingCbjNodeRedFlowId(nodeRedFlowId), - firstNodeId: BindingCbjFirstNodeId(firstNodeId), - iconCodePoint: BindingCbjIconCodePoint(iconCodePoint), - image: BindingCbjBackgroundImage(image), - lastDateOfExecute: BindingCbjLastDateOfExecute(lastDateOfExecute), - entityStateGRPC: BindingCbjDeviceStateGRPC(entityStateGRPC), - senderDeviceModel: BindingCbjSenderDeviceModel(senderDeviceModel), - senderDeviceOs: BindingCbjSenderDeviceOs(senderDeviceOs), - senderId: BindingCbjSenderId(senderId), - compUuid: BindingCbjCompUuid(compUuid), - stateMassage: BindingCbjStateMassage(stateMassage), - ); - } -} diff --git a/lib/infrastructure/bindings/binding_repository.dart b/lib/infrastructure/bindings/binding_repository.dart deleted file mode 100644 index 6a5ccc82..00000000 --- a/lib/infrastructure/bindings/binding_repository.dart +++ /dev/null @@ -1,108 +0,0 @@ -import 'package:cbj_hub/domain/binding/binding_cbj_entity.dart'; -import 'package:cbj_hub/domain/binding/binding_cbj_failures.dart'; -import 'package:cbj_hub/domain/binding/i_binding_cbj_repository.dart'; -import 'package:cbj_hub/domain/rooms/i_saved_rooms_repo.dart'; -import 'package:cbj_integrations_controller/domain/local_db/local_db_failures.dart'; -import 'package:cbj_integrations_controller/domain/mqtt_server/i_mqtt_server_repository.dart'; -import 'package:cbj_integrations_controller/domain/saved_devices/i_saved_devices_repo.dart'; -import 'package:cbj_integrations_controller/injection.dart'; -import 'package:dartz/dartz.dart'; -import 'package:injectable/injectable.dart'; - -@LazySingleton(as: IBindingCbjRepository) -class BindingCbjRepository implements IBindingCbjRepository { - final Map _allBindings = {}; - - @override - Future setUpAllFromDb() async { - // TODO: Fix after new cbj_integrations_controller - // await getItCbj().getBindingsFromDb().then((value) { - // value.fold((l) => null, (r) async { - // for (final element in r) { - // await addNewBinding(element); - // } - // }); - // }); - } - - @override - Future> getAllBindingsAsList() async { - return _allBindings.values.toList(); - } - - @override - Future> getAllBindingsAsMap() async { - return _allBindings; - } - - @override - Future> saveAndActivateBindingToDb() async { - // TODO: Fix after new cbj_integrations_controller - // return getItCbj().saveBindings( - // bindingList: List.from(_allBindings.values), - // ); - return left(const LocalDbFailures.unableToUpdate()); - } - - @override - Future> addNewBinding( - BindingCbjEntity bindingCbj, - ) async { - BindingCbjEntity tempBindingCbj = bindingCbj; - - /// Check if binding already exist - if (findBindingIfAlreadyBeenAdded(tempBindingCbj) == null) { - _allBindings.addEntries( - [MapEntry(tempBindingCbj.uniqueId.getOrCrash(), tempBindingCbj)], - ); - - final String entityId = tempBindingCbj.uniqueId.getOrCrash(); - - /// If it is new binding - _allBindings[entityId] = tempBindingCbj; - - await getItCbj().saveAndActivateSmartDevicesToDb(); - ISavedRoomsRepo.instance - .addBindingToRoomDiscoveredIfNotExist(tempBindingCbj); - // TODO: Fix after new cbj_integrations_controller - // final String bindingNodeRedFlowId = await getItCbj() - // .createNewNodeRedBinding(tempBindingCbj); - // if (bindingNodeRedFlowId.isNotEmpty) { - // tempBindingCbj = tempBindingCbj.copyWith( - // nodeRedFlowId: BindingCbjNodeRedFlowId(bindingNodeRedFlowId), - // ); - // } - await saveAndActivateBindingToDb(); - } - return right(unit); - } - - @override - Future activateBinding(BindingCbjEntity bindingCbj) async { - final String fullPathOfBinding = await getFullMqttPathOfBinding(bindingCbj); - IMqttServerRepository.instance - .publishMessage(fullPathOfBinding, DateTime.now().toString()); - - return true; - } - - /// Get entity and return the full MQTT path to it - @override - Future getFullMqttPathOfBinding(BindingCbjEntity bindingCbj) async { - final String hubBaseTopic = - IMqttServerRepository.instance.getHubBaseTopic(); - final String bindingsTopicTypeName = - IMqttServerRepository.instance.getBindingsTopicTypeName(); - final String bindingId = bindingCbj.firstNodeId.getOrCrash()!; - - return '$hubBaseTopic/$bindingsTopicTypeName/$bindingId'; - } - - /// Check if all bindings does not contain the same binding already - /// Will compare the unique id's that each company sent us - BindingCbjEntity? findBindingIfAlreadyBeenAdded( - BindingCbjEntity bindingEntity, - ) { - return _allBindings[bindingEntity.uniqueId.getOrCrash()]; - } -} diff --git a/lib/infrastructure/cbj_web_server/cbj_web_server_repository.dart b/lib/infrastructure/cbj_web_server/cbj_web_server_repository.dart index c13e34c3..a13c3674 100644 --- a/lib/infrastructure/cbj_web_server/cbj_web_server_repository.dart +++ b/lib/infrastructure/cbj_web_server/cbj_web_server_repository.dart @@ -5,7 +5,6 @@ import 'package:cbj_hub/utils.dart'; import 'package:cbj_integrations_controller/domain/saved_devices/i_saved_devices_repo.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_abstract.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; -import 'package:cbj_integrations_controller/injection.dart'; /// A cbj web server to interact with get current state requests from mqtt as /// well as website to change devices state locally on the network without @@ -28,7 +27,7 @@ class CbjWebServerRepository extends ICbjWebServerRepository { final String deviceId = pathArgs[1]; final ISavedDevicesRepo savedDevicesRepo = - getItCbj(); + ISavedDevicesRepo.instance; final Map allDevices = await savedDevicesRepo.getAllDevices(); diff --git a/lib/infrastructure/mqtt_server/mqtt_server_repository.dart b/lib/infrastructure/mqtt_server/mqtt_server_repository.dart index 6379dfa1..35e3fd04 100644 --- a/lib/infrastructure/mqtt_server/mqtt_server_repository.dart +++ b/lib/infrastructure/mqtt_server/mqtt_server_repository.dart @@ -17,7 +17,6 @@ import 'package:cbj_integrations_controller/infrastructure/generic_devices/gener import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_smart_plug_device/generic_smart_plug_entity.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_smart_tv/generic_smart_tv_entity.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_switch_device/generic_switch_entity.dart'; -import 'package:cbj_integrations_controller/injection.dart'; import 'package:mqtt_client/mqtt_client.dart'; import 'package:mqtt_client/mqtt_server_client.dart'; // ignore: implementation_imports @@ -220,7 +219,7 @@ class MqttServerRepository extends IMqttServerRepository { deviceDeviceTypeThatChanged: mqttPublishMessage[0].payload, }; - final ISavedDevicesRepo savedDevicesRepo = getItCbj(); + final ISavedDevicesRepo savedDevicesRepo = ISavedDevicesRepo.instance; final Map allDevices = await savedDevicesRepo.getAllDevices(); @@ -383,7 +382,7 @@ class MqttServerRepository extends IMqttServerRepository { /// Resend the device object throw mqtt Future findDeviceAndResendItToMqtt(String deviceId) async { - final ISavedDevicesRepo savedDevicesRepo = getItCbj(); + final ISavedDevicesRepo savedDevicesRepo = ISavedDevicesRepo.instance; final Map allDevices = await savedDevicesRepo.getAllDevices(); @@ -412,7 +411,7 @@ class MqttServerRepository extends IMqttServerRepository { bool? gotFromApp, }) async { if (entityFromTheApp is DeviceEntityAbstract) { - final ISavedDevicesRepo savedDevicesRepo = getItCbj(); + final ISavedDevicesRepo savedDevicesRepo = ISavedDevicesRepo.instance; final Map allDevices = await savedDevicesRepo.getAllDevices(); final DeviceEntityAbstract? savedDeviceEntity = diff --git a/lib/infrastructure/node_red/node_red_converter.dart b/lib/infrastructure/node_red/node_red_converter.dart deleted file mode 100644 index 35fa51b8..00000000 --- a/lib/infrastructure/node_red/node_red_converter.dart +++ /dev/null @@ -1,305 +0,0 @@ -import 'package:cbj_hub/domain/binding/binding_cbj_entity.dart'; -import 'package:cbj_hub/domain/binding/value_objects_routine_cbj.dart'; -import 'package:cbj_hub/domain/routine/routine_cbj_entity.dart'; -import 'package:cbj_hub/domain/routine/value_objects_routine_cbj.dart'; -import 'package:cbj_hub/domain/scene/scene_cbj_entity.dart'; -import 'package:cbj_hub/domain/scene/value_objects_scene_cbj.dart'; -import 'package:cbj_integrations_controller/domain/core/value_objects.dart'; -import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:nodered/nodered.dart'; -import 'package:uuid/uuid.dart'; - -class NodeRedConverter { - static const String hubBaseTopic = 'CBJ_Hub_Topic'; - - static const String devicesTopicTypeName = 'Devices'; - static const String scenesTopicTypeName = 'Scenes'; - static const String routinesTopicTypeName = 'Routines'; - static const String bindingsTopicTypeName = 'bindings'; - static const String nodeRedPluginsApi = 'nodeRedPluginsApi'; - - static SceneCbjEntity convertToSceneNodes({ - required String nodeName, - required List>> - devicesPropertyAction, - required String sceneColor, - }) { - final NodeRedMqttBrokerNode brokerNode = - NodeRedMqttBrokerNode(name: 'CyBear Jinni Broker'); - - final MapEntry> - allNodesAsWellAsAllNodeRedIdToConnectTo = - getAllNodesAsWellAsAllNodeRedIdToConnectTo( - devicesPropertyAction: devicesPropertyAction, - brokerNodeId: brokerNode.id, - ); - - String nodes = allNodesAsWellAsAllNodeRedIdToConnectTo.key; - final List allNodeRedIdToConnectTo = - allNodesAsWellAsAllNodeRedIdToConnectTo.value; - - final MapEntry startingSceneNode = createStartingSceneNode( - nodeName: nodeName, - brokerId: brokerNode.id, - wires: allNodeRedIdToConnectTo, - ); - if (nodes.isEmpty) { - nodes = '[${startingSceneNode.value}, $brokerNode]'; - } else { - nodes = '[${startingSceneNode.value}, $nodes, $brokerNode]'; - } - - return SceneCbjEntity( - uniqueId: UniqueId(), - name: SceneCbjName(nodeName), - backgroundColor: SceneCbjBackgroundColor(sceneColor), - automationString: SceneCbjAutomationString(nodes), - nodeRedFlowId: SceneCbjNodeRedFlowId(null), - firstNodeId: SceneCbjFirstNodeId(startingSceneNode.key), - iconCodePoint: SceneCbjIconCodePoint(null), - image: SceneCbjBackgroundImage(null), - lastDateOfExecute: SceneCbjLastDateOfExecute(null), - entityStateGRPC: SceneCbjDeviceStateGRPC( - EntityStateGRPC.addingNewScene.toString(), - ), - senderDeviceModel: SceneCbjSenderDeviceModel(null), - senderDeviceOs: SceneCbjSenderDeviceOs(null), - senderId: SceneCbjSenderId(null), - compUuid: SceneCbjCompUuid(null), - stateMassage: SceneCbjStateMassage(null), - ); - } - - static RoutineCbjEntity convertToRoutineNodes({ - required String nodeName, - required List>> - devicesPropertyAction, - required RoutineCbjRepeatDateDays daysToRepeat, - required RoutineCbjRepeatDateHour hourToRepeat, - required RoutineCbjRepeatDateMinute minutesToRepeat, - required String routineColor, - }) { - final NodeRedMqttBrokerNode brokerNode = - NodeRedMqttBrokerNode(name: 'CyBear Jinni Broker'); - - final MapEntry> - allNodesAsWellAsAllNodeRedIdToConnectTo = - getAllNodesAsWellAsAllNodeRedIdToConnectTo( - devicesPropertyAction: devicesPropertyAction, - brokerNodeId: brokerNode.id, - ); - - String nodes = allNodesAsWellAsAllNodeRedIdToConnectTo.key; - final List allNodeRedIdToConnectTo = - allNodesAsWellAsAllNodeRedIdToConnectTo.value; - - final MapEntry startingRoutineNode = - createStartingRoutineNode( - nodeName: nodeName, - wires: allNodeRedIdToConnectTo, - daysToRepeat: daysToRepeat, - hourToRepeat: hourToRepeat, - minutesToRepeat: minutesToRepeat, - ); - - nodes = '[${startingRoutineNode.value}, $nodes, $brokerNode]'; - - return RoutineCbjEntity( - uniqueId: UniqueId(), - name: RoutineCbjName(nodeName), - backgroundColor: RoutineCbjBackgroundColor(routineColor), - automationString: RoutineCbjAutomationString(nodes), - nodeRedFlowId: RoutineCbjNodeRedFlowId(null), - firstNodeId: RoutineCbjFirstNodeId(startingRoutineNode.key), - iconCodePoint: RoutineCbjIconCodePoint(null), - image: RoutineCbjBackgroundImage(null), - lastDateOfExecute: RoutineCbjLastDateOfExecute(null), - entityStateGRPC: RoutineCbjDeviceStateGRPC( - EntityStateGRPC.addingNewRoutine.toString(), - ), - senderDeviceModel: RoutineCbjSenderDeviceModel(null), - senderDeviceOs: RoutineCbjSenderDeviceOs(null), - senderId: RoutineCbjSenderId(null), - compUuid: RoutineCbjCompUuid(null), - stateMassage: RoutineCbjStateMassage(null), - repeateType: - RoutineCbjRepeatType(WhenToExecute.betweenSelectedTime.toString()), - repeateDateDays: RoutineCbjRepeatDateDays(daysToRepeat.getOrCrash()), - repeateDateHour: RoutineCbjRepeatDateHour(hourToRepeat.getOrCrash()), - repeateDateMinute: - RoutineCbjRepeatDateMinute(minutesToRepeat.getOrCrash()), - ); - } - - static BindingCbjEntity convertToBindingNodes({ - required String nodeName, - required List>> - devicesPropertyAction, - required String bindingColor, - }) { - final NodeRedMqttBrokerNode brokerNode = - NodeRedMqttBrokerNode(name: 'CyBear Jinni Broker'); - - final MapEntry> - allNodesAsWellAsAllNodeRedIdToConnectTo = - getAllNodesAsWellAsAllNodeRedIdToConnectTo( - devicesPropertyAction: devicesPropertyAction, - brokerNodeId: brokerNode.id, - ); - - String nodes = allNodesAsWellAsAllNodeRedIdToConnectTo.key; - final List allNodeRedIdToConnectTo = - allNodesAsWellAsAllNodeRedIdToConnectTo.value; - - final MapEntry startingBindingNode = - createStartingBindingNode( - nodeName: nodeName, - brokerNodeId: brokerNode.id, - wires: allNodeRedIdToConnectTo, - ); - - nodes = '[${startingBindingNode.value}, $nodes, $brokerNode]'; - - return BindingCbjEntity( - uniqueId: UniqueId(), - name: BindingCbjName(nodeName), - backgroundColor: BindingCbjBackgroundColor(bindingColor), - automationString: BindingCbjAutomationString(nodes), - nodeRedFlowId: BindingCbjNodeRedFlowId(null), - firstNodeId: BindingCbjFirstNodeId(startingBindingNode.key), - iconCodePoint: BindingCbjIconCodePoint(null), - image: BindingCbjBackgroundImage(null), - lastDateOfExecute: BindingCbjLastDateOfExecute(null), - entityStateGRPC: BindingCbjDeviceStateGRPC( - EntityStateGRPC.addingNewBinding.toString(), - ), - senderDeviceModel: BindingCbjSenderDeviceModel(null), - senderDeviceOs: BindingCbjSenderDeviceOs(null), - senderId: BindingCbjSenderId(null), - compUuid: BindingCbjCompUuid(null), - stateMassage: BindingCbjStateMassage(null), - ); - } - - /// Returns the string id of the function to connect to and the whole function - /// plus mqtt out string as node-red structure - static MapEntry convertToNodeString({ - required DeviceEntityAbstract device, - required String property, - required String action, - required String brokerNodeId, - }) { - final String topic = - '$hubBaseTopic/$devicesTopicTypeName/${device.uniqueId.getOrCrash()}/$property'; - final NodeRedMqttOutNode mqttNode = NodeRedMqttOutNode( - brokerNodeId: brokerNodeId, - topic: topic, - name: '${device.cbjEntityName.getOrCrash()} - $property', - ); - - final NodeRedFunctionNode functionForNode = - NodeRedFunctionNode.passOnlyNewAction( - action: action, - name: action, - wires: [ - [ - mqttNode.id, - ] - ], - ); - - return MapEntry( - functionForNode.id, - '$functionForNode, $mqttNode', - ); - } - - static MapEntry createStartingSceneNode({ - required String nodeName, - required String brokerId, - required List wires, - }) { - final String mqttInNodeId = const Uuid().v1(); - final String topic = '$hubBaseTopic/$scenesTopicTypeName/$mqttInNodeId'; - final NodeRedMqttInNode nodeRedMqttInNode = NodeRedMqttInNode( - name: nodeName, - brokerNodeId: brokerId, - topic: topic, - wires: [wires], - tempId: mqttInNodeId, - ); - return MapEntry(nodeRedMqttInNode.id, nodeRedMqttInNode.toString()); - } - - static MapEntry createStartingRoutineNode({ - required String nodeName, - required List wires, - required RoutineCbjRepeatDateDays daysToRepeat, - required RoutineCbjRepeatDateHour hourToRepeat, - required RoutineCbjRepeatDateMinute minutesToRepeat, - }) { - final String injectNodeId = const Uuid().v1(); - final NodeRedInjectAtASpecificTimeNode nodeRedInjectNode = - NodeRedInjectAtASpecificTimeNode( - name: nodeName, - wires: [wires], - tempId: injectNodeId, - daysToRepeat: daysToRepeat.getOrCrash(), - hourToRepeat: hourToRepeat.getOrCrash(), - minutesToRepeat: minutesToRepeat.getOrCrash(), - ); - return MapEntry(nodeRedInjectNode.id, nodeRedInjectNode.toString()); - } - - static MapEntry createStartingBindingNode({ - required String nodeName, - required String brokerNodeId, - required List wires, - }) { - final String mqttInNodeId = const Uuid().v1(); - final String topic = '$hubBaseTopic/$bindingsTopicTypeName/$mqttInNodeId'; - final NodeRedMqttInNode nodeRedMqttInNode = NodeRedMqttInNode( - name: nodeName, - brokerNodeId: brokerNodeId, - topic: topic, - wires: [wires], - tempId: mqttInNodeId, - ); - return MapEntry(nodeRedMqttInNode.id, nodeRedMqttInNode.toString()); - } - - static MapEntry> - getAllNodesAsWellAsAllNodeRedIdToConnectTo({ - required List>> - devicesPropertyAction, - required String brokerNodeId, - }) { - final List allNodeRedIdToConnectTo = []; - String nodes = ''; - - for (final MapEntry> deviceEntry in devicesPropertyAction) { - final DeviceEntityAbstract device = deviceEntry.key; - final String? property = deviceEntry.value.key; - final String? action = deviceEntry.value.value; - - if (property == null || action == null) { - continue; - } - final MapEntry nodeRedStringNode = convertToNodeString( - brokerNodeId: brokerNodeId, - device: device, - property: property, - action: action, - ); - - if (nodes.isNotEmpty) { - nodes += ', '; - } - nodes += nodeRedStringNode.value; - allNodeRedIdToConnectTo.add(nodeRedStringNode.key); - } - return MapEntry(nodes, allNodeRedIdToConnectTo); - } -} diff --git a/lib/infrastructure/node_red/node_red_repository.dart b/lib/infrastructure/node_red/node_red_repository.dart deleted file mode 100644 index e16e44a0..00000000 --- a/lib/infrastructure/node_red/node_red_repository.dart +++ /dev/null @@ -1,215 +0,0 @@ -import 'dart:convert'; - -import 'package:cbj_hub/domain/binding/binding_cbj_entity.dart'; -import 'package:cbj_hub/domain/routine/routine_cbj_entity.dart'; -import 'package:cbj_hub/domain/scene/scene_cbj_entity.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:http/src/response.dart'; -import 'package:injectable/injectable.dart'; -import 'package:nodered/nodered.dart'; - -/// Control Node-RED, create scenes and more -@LazySingleton() -class NodeRedRepository extends INodeRedRepository { - static NodeRedAPI nodeRedApi = NodeRedAPI(); - - // /// List of all the scenes JSONs in Node-RED - // List scenesList = []; - // - // /// List of all the routines JSONs in Node-RED - // List routinesList = []; - // - // /// List of all the bindings JSONs in Node-RED - // List bindingsList = []; - - /// Function to create new scene in Node-RED - Future createNewNodeRedScene(SceneCbjEntity sceneCbj) async { - // final String flowId = sceneCbj.uniqueId.getOrCrash(); - - try { - if (sceneCbj.nodeRedFlowId.getOrCrash() != null) { - await nodeRedApi.deleteFlowById( - id: sceneCbj.nodeRedFlowId.getOrCrash()!, - ); - } - final Response response = await nodeRedApi.postFlow( - label: sceneCbj.name.getOrCrash(), - nodes: sceneCbj.automationString.getOrCrash()!, - flowId: sceneCbj.uniqueId.getOrCrash(), - ); - if (response.statusCode == 200) { - final Map responseBodyJson = - json.decode(response.body) as Map; - final String flowId = responseBodyJson["id"] as String; - return flowId; - } else if (response.statusCode == 400) { - logger.w( - 'Scene probably already exist in node red status code\n${response.statusCode}', - ); - } else { - logger.e( - 'Error setting scene in node red status code\n${response.statusCode}', - ); - } - } catch (e) { - if (e.toString() == - 'The remote computer refused the network connection.\r\n') { - logger.e('Node-RED is not installed'); - } else { - logger.e('Node-RED create new scene error:\n$e'); - } - } - return ""; - } - - /// Function to create new routine in Node-RED - Future createNewNodeRedRoutine(RoutineCbjEntity routineCbj) async { - // await _deviceIsReadyToSendInternetRequests; - // final String flowId = routineCbj.uniqueId.getOrCrash(); - - try { - // if (routinesList.contains(routineCbj.uniqueId.getOrCrash())) { - // await nodeRedApi.deleteFlowById(id: flowId); - // } - final Response response = await nodeRedApi.postFlow( - label: routineCbj.name.getOrCrash(), - nodes: routineCbj.automationString.getOrCrash()!, - flowId: routineCbj.uniqueId.getOrCrash(), - ); - if (response.statusCode == 200) { - final Map responseBodyJson = - json.decode(response.body) as Map; - final String flowId = responseBodyJson["id"] as String; - return flowId; - } else if (response.statusCode == 400) { - logger.w( - 'Routine probably already exist in node red status code\n${response.statusCode}', - ); - } else { - logger.e( - 'Error setting routine in node red status code\n${response.statusCode}', - ); - } - } catch (e) { - if (e.toString() == - 'The remote computer refused the network connection.\r\n') { - logger.e('Node-RED is not installed'); - } else { - logger.e('Node-RED create new routine error:\n$e'); - } - } - return ""; - } - - /// Function to create new binding in Node-RED - Future createNewNodeRedBinding(BindingCbjEntity bindingCbj) async { - try { - // if (bindingsList.contains(bindingCbj.uniqueId.getOrCrash())) { - // await nodeRedApi.deleteFlowById(id: flowId); - // } - final Response response = await nodeRedApi.postFlow( - label: bindingCbj.name.getOrCrash(), - nodes: bindingCbj.automationString.getOrCrash()!, - flowId: bindingCbj.uniqueId.getOrCrash(), - ); - if (response.statusCode == 200) { - final Map responseBodyJson = - json.decode(response.body) as Map; - final String flowId = responseBodyJson["id"] as String; - return flowId; - } else if (response.statusCode == 400) { - logger.w( - 'Binding probably already exist in node red status code\n${response.statusCode}', - ); - } else { - logger.e( - 'Error setting binding in node red status code\n${response.statusCode}', - ); - } - } catch (e) { - if (e.toString() == - 'The remote computer refused the network connection.\r\n') { - logger.e('Node-RED is not installed'); - } else { - logger.e('Node-RED create new Binding error:\n$e'); - } - } - return ""; - } - - @override - Future setFlowWithModule({ - required String moduleToUse, - required String label, - required String nodes, - required String flowId, - }) async { - // TODO: check if hub crash when trying to download new node inside node red without internet connection - - try { - /// Install the new node module - await nodeRedApi.postNodes(module: moduleToUse); - - final Response response = await nodeRedApi.postFlow( - label: label, - nodes: nodes, - flowId: flowId, - ); - if (response.statusCode != 200) { - logger.e('Error sending nodeRED flow request\n${response.body}'); - } - final String returnedFlowId = jsonDecode(response.body)['id'] as String; - return returnedFlowId; - } catch (e) { - if (e.toString() == - 'The remote computer refused the network connection.\r\n') { - logger.e('Node-RED is not installed'); - } else { - logger.e('Node-RED setting flow with module $moduleToUse\n$e'); - } - } - return ""; - } - - @override - Future setGlobalNodes({ - required String? moduleToUse, - required String nodes, - }) async { - try { - /// Install the new node module - if (moduleToUse != null) { - await nodeRedApi.postNodes(module: moduleToUse); - } - final Response response = await nodeRedApi.postGlobalNode( - nodes: nodes, - ); - if (response.statusCode != 200) { - logger.e('Error sending nodeRED global node request\n${response.body}'); - } - } catch (e) { - logger.e('Node-RED setting global node with module $moduleToUse\n$e'); - return e.toString(); - } - return "ok"; - } - - @override - Future updateFlowNodes({ - required String nodes, - required String flowId, - }) async { - try { - final Response response = await nodeRedApi.putFlowById( - nodes: nodes, - flowId: flowId, - ); - if (response.statusCode != 200) { - logger.e('Error updating nodeRED flow node request\n${response.body}'); - } - } catch (e) { - logger.e('Node-RED updating flow\n$e'); - } - return ""; - } -} diff --git a/lib/infrastructure/remote_pipes/remote_pipes_client.dart b/lib/infrastructure/remote_pipes/remote_pipes_client.dart index aeeaa982..51f0b24c 100644 --- a/lib/infrastructure/remote_pipes/remote_pipes_client.dart +++ b/lib/infrastructure/remote_pipes/remote_pipes_client.dart @@ -3,15 +3,15 @@ import 'dart:convert'; import 'package:cbj_hub/domain/app_communication/i_app_communication_repository.dart'; import 'package:cbj_hub/infrastructure/app_communication/app_communication_repository.dart'; -import 'package:cbj_hub/infrastructure/room/room_entity_dtos.dart'; -import 'package:cbj_hub/infrastructure/routines/routine_cbj_dtos.dart'; -import 'package:cbj_hub/infrastructure/scenes/scene_cbj_dtos.dart'; import 'package:cbj_hub/utils.dart'; import 'package:cbj_integrations_controller/infrastructure/devices/device_helper/device_helper.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_ping_device/generic_ping_device_dtos.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_ping_device/generic_ping_entity.dart'; +import 'package:cbj_integrations_controller/infrastructure/room/room_entity_dtos.dart'; +import 'package:cbj_integrations_controller/infrastructure/routines/routine_cbj_dtos.dart'; +import 'package:cbj_integrations_controller/infrastructure/scenes/scene_cbj_dtos.dart'; import 'package:grpc/grpc.dart'; import 'package:rxdart/rxdart.dart'; diff --git a/lib/infrastructure/room/room_entity_dtos.dart b/lib/infrastructure/room/room_entity_dtos.dart deleted file mode 100644 index 4b9a1e1b..00000000 --- a/lib/infrastructure/room/room_entity_dtos.dart +++ /dev/null @@ -1,65 +0,0 @@ -import 'package:cbj_hub/domain/room/room_entity.dart'; -import 'package:cbj_hub/domain/room/value_objects_room.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'room_entity_dtos.freezed.dart'; -part 'room_entity_dtos.g.dart'; - -@freezed -abstract class RoomEntityDtos implements _$RoomEntityDtos { - factory RoomEntityDtos({ - required String uniqueId, - required String cbjEntityName, - required String background, - required List roomTypes, - required List roomDevicesId, - required List roomScenesId, - required List roomRoutinesId, - required List roomBindingsId, - - /// Who is using this room - required List roomMostUsedBy, - - /// Room permissions by users id - required List roomPermissions, - - // required ServerTimestampConverter() FieldValue serverTimeStamp, - }) = _RoomEntityDtos; - - RoomEntityDtos._(); - - factory RoomEntityDtos.fromDomain(RoomEntity roomEntityDE) { - return RoomEntityDtos( - uniqueId: roomEntityDE.uniqueId.getOrCrash(), - cbjEntityName: roomEntityDE.cbjEntityName.getOrCrash(), - background: roomEntityDE.background.getOrCrash(), - roomTypes: roomEntityDE.roomTypes.getOrCrash(), - roomDevicesId: roomEntityDE.roomDevicesId.getOrCrash(), - roomScenesId: roomEntityDE.roomScenesId.getOrCrash(), - roomRoutinesId: roomEntityDE.roomRoutinesId.getOrCrash(), - roomBindingsId: roomEntityDE.roomBindingsId.getOrCrash(), - roomMostUsedBy: roomEntityDE.roomMostUsedBy.getOrCrash(), - roomPermissions: roomEntityDE.roomPermissions.getOrCrash(), - ); - } - - factory RoomEntityDtos.fromJson(Map json) => - _$RoomEntityDtosFromJson(json); - - RoomEntity toDomain() { - return RoomEntity( - uniqueId: RoomUniqueId.fromUniqueString(uniqueId), - cbjEntityName: RoomDefaultName(cbjEntityName), - background: RoomBackground(background), - roomTypes: RoomTypes(roomTypes), - roomDevicesId: RoomDevicesId(roomDevicesId), - roomScenesId: RoomScenesId(roomScenesId), - roomRoutinesId: RoomRoutinesId(roomRoutinesId), - roomBindingsId: RoomBindingsId(roomBindingsId), - roomMostUsedBy: RoomMostUsedBy(roomMostUsedBy), - roomPermissions: RoomPermissions(roomPermissions), - ); - } - - final String deviceDtoClassInstance = (RoomEntityDtos).toString(); -} diff --git a/lib/infrastructure/room/saved_rooms_repo.dart b/lib/infrastructure/room/saved_rooms_repo.dart deleted file mode 100644 index 38d0f1e7..00000000 --- a/lib/infrastructure/room/saved_rooms_repo.dart +++ /dev/null @@ -1,476 +0,0 @@ -import 'dart:collection'; -import 'dart:math'; - -import 'package:cbj_hub/domain/binding/binding_cbj_entity.dart'; -import 'package:cbj_hub/domain/room/room_entity.dart'; -import 'package:cbj_hub/domain/room/value_objects_room.dart'; -import 'package:cbj_hub/domain/rooms/i_saved_rooms_repo.dart'; -import 'package:cbj_hub/domain/routine/routine_cbj_entity.dart'; -import 'package:cbj_hub/domain/scene/i_scene_cbj_repository.dart'; -import 'package:cbj_hub/domain/scene/scene_cbj_entity.dart'; -import 'package:cbj_hub/domain/scene/scene_cbj_failures.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:cbj_integrations_controller/domain/local_db/local_db_failures.dart'; -import 'package:cbj_integrations_controller/domain/saved_devices/i_saved_devices_repo.dart'; -import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_integrations_controller/injection.dart'; -import 'package:dartz/dartz.dart'; - -class SavedRoomsRepo extends ISavedRoomsRepo { - SavedRoomsRepo() { - ISavedRoomsRepo.instance = this; - } - - static final HashMap _allRooms = - HashMap(); - - @override - Future setUpAllFromDb() async { - // TODO: Fix after new cbj_integrations_controller - // await getItCbj().getRoomsFromDb().then((value) { - // value.fold((l) => null, (rooms) { - // /// Gets all rooms from db, if there are non it will create and return - // /// only a discovered room - // if (rooms.isEmpty) { - // final RoomEntity discoveredRoom = RoomEntity.empty().copyWith( - // uniqueId: RoomUniqueId.discoveredRoomId(), - // cbjEntityName: RoomDefaultName.discoveredRoomName(), - // ); - // rooms.add(discoveredRoom); - // } - // for (final element in rooms) { - // addOrUpdateRoom(element); - // } - // }); - // }); - } - - @override - Future> getAllRooms() async { - return _allRooms; - } - - RoomEntity? getRoomDeviceExistIn(DeviceEntityAbstract deviceEntityAbstract) { - final String uniqueId = deviceEntityAbstract.uniqueId.getOrCrash(); - for (final RoomEntity roomEntity in _allRooms.values) { - if (roomEntity.roomDevicesId.getOrCrash().contains(uniqueId)) { - return roomEntity; - } - } - return null; - } - - RoomEntity? getRoomSceneExistIn(SceneCbjEntity sceneCbj) { - final String uniqueId = sceneCbj.uniqueId.getOrCrash(); - for (final RoomEntity roomEntity in _allRooms.values) { - if (roomEntity.roomScenesId.getOrCrash().contains(uniqueId)) { - return roomEntity; - } - } - return null; - } - - RoomEntity? getRoomRoutineExistIn(RoutineCbjEntity routineCbj) { - final String uniqueId = routineCbj.uniqueId.getOrCrash(); - for (final RoomEntity roomEntity in _allRooms.values) { - if (roomEntity.roomRoutinesId.getOrCrash().contains(uniqueId)) { - return roomEntity; - } - } - return null; - } - - RoomEntity? getRoomBindingExistIn(BindingCbjEntity bindingCbj) { - final String uniqueId = bindingCbj.uniqueId.getOrCrash(); - for (final RoomEntity roomEntity in _allRooms.values) { - if (roomEntity.roomBindingsId.getOrCrash().contains(uniqueId)) { - return roomEntity; - } - } - return null; - } - - @override - RoomEntity addOrUpdateRoom(RoomEntity roomEntity) { - RoomEntity newRoomEntity = roomEntity; - - final RoomEntity? roomFromAllRoomsList = - _allRooms[roomEntity.uniqueId.getOrCrash()]; - - /// TODO: Check if this should only happen in discover room - if (roomFromAllRoomsList != null) { - /// For devices in the room - final List allDevicesInNewRoom = - roomEntity.roomDevicesId.getOrCrash(); - final List allDevicesInExistingRoom = - roomFromAllRoomsList.roomDevicesId.getOrCrash(); - - final HashSet tempAddDevicesList = HashSet(); - tempAddDevicesList.addAll(allDevicesInNewRoom); - tempAddDevicesList.addAll(allDevicesInExistingRoom); - newRoomEntity = newRoomEntity.copyWith( - roomDevicesId: RoomDevicesId(List.from(tempAddDevicesList)), - ); - - /// For scenes in the room - final List allScenesInNewRoom = - roomEntity.roomScenesId.getOrCrash(); - final List allScenesInExistingRoom = - roomFromAllRoomsList.roomDevicesId.getOrCrash(); - - final HashSet tempAddScenesList = HashSet(); - tempAddScenesList.addAll(allScenesInNewRoom); - tempAddScenesList.addAll(allScenesInExistingRoom); - newRoomEntity = newRoomEntity.copyWith( - roomScenesId: RoomScenesId(List.from(tempAddScenesList)), - ); - - /// For Routines in the room - final List allRoutinesInNewRoom = - roomEntity.roomRoutinesId.getOrCrash(); - final List allRoutinesInExistingRoom = - roomFromAllRoomsList.roomRoutinesId.getOrCrash(); - - final HashSet tempAddRoutinesList = HashSet(); - tempAddRoutinesList.addAll(allRoutinesInNewRoom); - tempAddRoutinesList.addAll(allRoutinesInExistingRoom); - newRoomEntity = newRoomEntity.copyWith( - roomRoutinesId: RoomRoutinesId(List.from(tempAddRoutinesList)), - ); - - /// For Bindings in the room - final List allBindingsInNewRoom = - roomEntity.roomBindingsId.getOrCrash(); - final List allBindingsInExistingRoom = - roomFromAllRoomsList.roomBindingsId.getOrCrash(); - - final HashSet tempAddBindingsList = HashSet(); - tempAddBindingsList.addAll(allBindingsInNewRoom); - tempAddBindingsList.addAll(allBindingsInExistingRoom); - newRoomEntity = newRoomEntity.copyWith( - roomBindingsId: RoomBindingsId(List.from(tempAddBindingsList)), - ); - } - - _allRooms.addEntries([ - MapEntry( - newRoomEntity.uniqueId.getOrCrash(), - newRoomEntity, - ), - ]); - return newRoomEntity; - } - - @override - void addDeviceToRoomDiscoveredIfNotExist(DeviceEntityAbstract deviceEntity) { - final RoomEntity? roomEntity = getRoomDeviceExistIn(deviceEntity); - if (roomEntity != null) { - return; - } - - final RoomEntity discoverRoom = createRoomDiscoverIfNotExist(); - - _allRooms[discoverRoom.uniqueId.getOrCrash()]! - .addDeviceId(deviceEntity.uniqueId.getOrCrash()); - } - - @override - void addSceneToRoomDiscoveredIfNotExist(SceneCbjEntity sceneCbjEntity) { - final RoomEntity? roomEntity = getRoomSceneExistIn(sceneCbjEntity); - if (roomEntity != null) { - return; - } - - final RoomEntity discoverRoom = createRoomDiscoverIfNotExist(); - - _allRooms[discoverRoom.uniqueId.getOrCrash()]! - .addSceneId(sceneCbjEntity.uniqueId.getOrCrash()); - } - - @override - void addRoutineToRoomDiscoveredIfNotExist(RoutineCbjEntity routineCbjEntity) { - final RoomEntity? roomEntity = getRoomRoutineExistIn(routineCbjEntity); - if (roomEntity != null) { - return; - } - final RoomEntity discoverRoom = createRoomDiscoverIfNotExist(); - - _allRooms[discoverRoom.uniqueId.getOrCrash()]! - .addRoutineId(routineCbjEntity.uniqueId.getOrCrash()); - } - - @override - void addBindingToRoomDiscoveredIfNotExist(BindingCbjEntity bindingCbjEntity) { - final RoomEntity? roomEntity = getRoomBindingExistIn(bindingCbjEntity); - if (roomEntity != null) { - return; - } - final RoomEntity discoverRoom = createRoomDiscoverIfNotExist(); - - _allRooms[discoverRoom.uniqueId.getOrCrash()]! - .addBindingId(bindingCbjEntity.uniqueId.getOrCrash()); - } - - @override - Future> saveAndActiveRoomToDb({ - required RoomEntity roomEntity, - }) async { - // TODO: Rewrite it to call addOrUpdateRoom and just save the final state - RoomEntity roomEntityTemp = roomEntity; - final String roomId = roomEntityTemp.uniqueId.getOrCrash(); - - await removeSameDevicesFromOtherRooms(roomEntityTemp); - - List newDevicesList = roomEntityTemp.roomDevicesId.getOrCrash(); - - bool newRoom = false; - if (_allRooms[roomId] == null) { - final String roomImage = pickRoomImage(); - roomEntityTemp = - roomEntityTemp.copyWith(background: RoomBackground(roomImage)); - - _allRooms.addEntries([MapEntry(roomId, roomEntityTemp)]); - newRoom = true; - } else { - final RoomEntity savedRoom = _allRooms[roomId]!; - newDevicesList = getOnlyWhatOnlyExistInFirsList( - roomEntityTemp.roomDevicesId.getOrCrash(), - savedRoom.roomDevicesId.getOrCrash(), - ); - - final RoomEntity roomEntityCombinedDevices = roomEntityTemp.copyWith( - roomDevicesId: RoomDevicesId( - combineNoDuplicateListOfString( - savedRoom.roomDevicesId.getOrCrash(), - roomEntityTemp.roomDevicesId.getOrCrash(), - ), - ), - roomTypes: RoomTypes( - // Getting handled in createScenesForAllSelectedRoomTypes - savedRoom.roomTypes.getOrCrash(), - ), - roomScenesId: RoomScenesId( - combineNoDuplicateListOfString( - savedRoom.roomScenesId.getOrCrash(), - roomEntityTemp.roomScenesId.getOrCrash(), - ), - ), - background: savedRoom.background, - ); - _allRooms[roomId] = roomEntityCombinedDevices; - } - // TODO: check if this line is not redundant - await getItCbj().saveAndActivateSmartDevicesToDb(); - - await createScenesForAllSelectedRoomTypes( - roomEntity: roomEntityTemp, - newRoom: newRoom, - ); - - await getItCbj() - .addDevicesToMultipleScenesAreaTypeWithPreSetActions( - devicesId: newDevicesList, - scenesId: _allRooms[roomId]!.roomScenesId.getOrCrash(), - areaTypes: _allRooms[roomId]!.roomTypes.getOrCrash(), - ); - // TODO: Fix after new cbj_integrations_controller - // final Future> saveRoomToDbResponse = - // getItCbj().saveRoomsToDb( - // roomsList: List.from(_allRooms.values), - // ); - // - // AppCommunicationRepository.sendAllRoomsFromHubRequestsStream(); - // return saveRoomToDbResponse; - return left(const LocalDbFailures.unableToUpdate()); - } - - @override - Future> - createScenesForAllSelectedRoomTypes({ - required RoomEntity roomEntity, - bool newRoom = false, - }) async { - try { - // To make lists mutable - final RoomEntity roomEntityTemp = roomEntity.copyWith( - roomTypes: RoomTypes(roomEntity.roomTypes.getOrCrash().toList()), - roomDevicesId: - RoomDevicesId(roomEntity.roomDevicesId.getOrCrash().toList()), - roomScenesId: - RoomScenesId(roomEntity.roomScenesId.getOrCrash().toList()), - roomRoutinesId: - RoomRoutinesId(roomEntity.roomRoutinesId.getOrCrash().toList()), - roomBindingsId: - RoomBindingsId(roomEntity.roomBindingsId.getOrCrash().toList()), - roomMostUsedBy: - RoomMostUsedBy(roomEntity.roomMostUsedBy.getOrCrash().toList()), - roomPermissions: - RoomPermissions(roomEntity.roomPermissions.getOrCrash().toList()), - ); - - final List tempList = - _allRooms[roomEntityTemp.uniqueId.getOrCrash()] - ?.roomTypes - .getOrCrash() ?? - []; - final List roomTypesToAdd; - - if (newRoom) { - roomTypesToAdd = roomEntity.roomTypes.getOrCrash(); - } else { - roomTypesToAdd = getOnlyWhatOnlyExistInFirsList( - roomEntity.roomTypes.getOrCrash(), - tempList, - ); - } - - for (final String roomTypeNumber in roomTypesToAdd) { - final AreaPurposesTypes areaPurposeType = - AreaPurposesTypes.values[int.parse(roomTypeNumber)]; - - final String areaNameEdited = areaNameCapsWithSpces(areaPurposeType); - - final Either sceneOrFailure = - await getItCbj() - .addOrUpdateNewSceneInHubFromDevicesPropertyActionList( - areaNameEdited, - [], - areaPurposeType, - ); - sceneOrFailure.fold( - (l) => logger.e('Error creating scene from room type'), - (r) { - //Add scene id to room - roomEntityTemp.addSceneId(r.uniqueId.getOrCrash()); - }, - ); - _allRooms[roomEntityTemp.uniqueId.getOrCrash()] = roomEntityTemp; - } - return right(_allRooms[roomEntityTemp.uniqueId.getOrCrash()]!); - } catch (e) { - logger.e('Error setting new scene from room type\n$e'); - return left(const LocalDbFailures.unexpected()); - } - } - - /// Remove all devices in our room from all the rooms to prevent duplicate - Future removeSameDevicesFromOtherRooms(RoomEntity roomEntity) async { - final List devicesIdInThePassedRoom = - List.from(roomEntity.roomDevicesId.getOrCrash()); - if (devicesIdInThePassedRoom.isEmpty) { - return; - } - - for (RoomEntity roomEntityTemp in _allRooms.values) { - if (roomEntityTemp.roomDevicesId.failureOrUnit != right(unit)) { - continue; - } - final List devicesIdInTheRoom = - List.from(roomEntityTemp.roomDevicesId.getOrCrash()); - - for (final String deviceIdInTheRoom in devicesIdInTheRoom) { - final int indexOfDeviceId = - devicesIdInThePassedRoom.indexOf(deviceIdInTheRoom); - - /// If device id exist in other room than delete it from that room - if (indexOfDeviceId != -1) { - roomEntityTemp = roomEntityTemp.copyWith( - roomDevicesId: roomEntityTemp.deleteIdIfExist(deviceIdInTheRoom), - ); - _allRooms[roomEntityTemp.uniqueId.getOrCrash()] = roomEntityTemp; - } - } - } - } - - List combineNoDuplicateListOfString( - List devicesId, - List newDevicesId, - ) { - final HashSet hashSetDevicesId = HashSet(); - hashSetDevicesId.addAll(devicesId); - hashSetDevicesId.addAll(newDevicesId); - return List.from(hashSetDevicesId); - } - - List getOnlyWhatOnlyExistInFirsList( - List firstList, - List secondList, - ) { - final List tempList = []; - - for (final String stringText in firstList) { - if (!secondList.contains(stringText)) { - tempList.add(stringText); - } - } - - return tempList; - } - - static String areaNameCapsWithSpces(AreaPurposesTypes areaPurposeType) { - final String tempAreaName = - areaPurposeType.name.substring(1, areaPurposeType.name.length); - String areaNameEdited = areaPurposeType.name.substring(0, 1).toUpperCase(); - for (int tempNum = 0; tempNum < tempAreaName.length; tempNum++) { - final String charFromAreaType = tempAreaName[tempNum]; - if (charFromAreaType[0] == charFromAreaType[0].toUpperCase()) { - areaNameEdited += ' '; - } - areaNameEdited += charFromAreaType; - } - return areaNameEdited; - } - - static AreaPurposesTypes? getAreaTypeFromNameCapsWithSpcaes( - String areaNameCapsAndSpaces, - ) { - String tempString = areaNameCapsAndSpaces.replaceAll(' ', ''); - - tempString = - tempString.substring(0, 1).toLowerCase() + tempString.substring(1); - - final AreaPurposesTypes areaPTemp = AreaPurposesTypes.values - .firstWhere((element) => element.name == tempString); - return areaPTemp; - } - - static String pickRoomImage() { - final List roomImages = [ - 'https://live.staticflickr.com/5220/5486044345_f67abff3e9_h.jpg', - 'https://live.staticflickr.com/7850/31597166847_486557e555_h.jpg', - 'https://images.pexels.com/photos/459654/pexels-photo-459654.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260', - 'https://live.staticflickr.com/7034/13522716673_1e13298046_h.jpg', - 'https://live.staticflickr.com/8430/7731774826_7c1627cfcd_h.jpg', - 'https://images.pexels.com/photos/2343475/pexels-photo-2343475.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260', - 'https://live.staticflickr.com/7160/6470998009_b7107d55fe_h.jpg', - 'https://live.staticflickr.com/1256/1471268812_c73d690f26_h.jpg', - 'https://live.staticflickr.com/1415/4592575839_15ca3982b7_c.jpg', - 'https://images.pexels.com/photos/1457842/pexels-photo-1457842.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260', - 'https://images.pexels.com/photos/259588/pexels-photo-259588.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260', - 'https://images.unsplash.com/photo-1564829439675-0eec72f0b695?ixlib=rb-1.2.1&ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&auto=format&fit=crop&w=700&q=80', - ]; - - return roomImages[Random().nextInt(roomImages.length - 1)]; - } - - /// Create discovered room if not exist and returns it. - static RoomEntity createRoomDiscoverIfNotExist() { - final String discoveredRoomId = - RoomUniqueId.discoveredRoomId().getOrCrash(); - - if (_allRooms[discoveredRoomId] == null) { - _allRooms.addEntries([ - MapEntry( - discoveredRoomId, - RoomEntity.empty().copyWith( - uniqueId: RoomUniqueId.fromUniqueString(discoveredRoomId), - cbjEntityName: RoomDefaultName.discoveredRoomName(), - ), - ), - ]); - } - return _allRooms[discoveredRoomId]!; - } -} diff --git a/lib/infrastructure/routines/routine_cbj_dtos.dart b/lib/infrastructure/routines/routine_cbj_dtos.dart deleted file mode 100644 index 55130474..00000000 --- a/lib/infrastructure/routines/routine_cbj_dtos.dart +++ /dev/null @@ -1,89 +0,0 @@ -import 'package:cbj_integrations_controller/domain/core/value_objects.dart'; -import 'package:cbj_hub/domain/routine/routine_cbj_entity.dart'; -import 'package:cbj_hub/domain/routine/value_objects_routine_cbj.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'routine_cbj_dtos.freezed.dart'; -part 'routine_cbj_dtos.g.dart'; - -@freezed -abstract class RoutineCbjDtos implements _$RoutineCbjDtos { - factory RoutineCbjDtos({ - // @JsonKey(ignore: true) - required String uniqueId, - required String name, - required String backgroundColor, - required String? entityStateGRPC, - required String? senderDeviceOs, - required String? senderDeviceModel, - required String? senderId, - required String? compUuid, - required String? stateMassage, - required String? repeateType, - required List? repeateDateDays, - required String? repeateDateHour, - required String? repeateDateMinute, - String? automationString, - String? nodeRedFlowId, - String? firstNodeId, - String? iconCodePoint, - String? image, - String? lastDateOfExecute, - // required ServerTimestampConverter() FieldValue serverTimeStamp, - }) = _RoutineCbjDtos; - - RoutineCbjDtos._(); - - factory RoutineCbjDtos.fromDomain(RoutineCbjEntity routineCbj) { - return RoutineCbjDtos( - uniqueId: routineCbj.uniqueId.getOrCrash(), - name: routineCbj.name.getOrCrash(), - backgroundColor: routineCbj.backgroundColor.getOrCrash(), - automationString: routineCbj.automationString.getOrCrash(), - nodeRedFlowId: routineCbj.nodeRedFlowId.getOrCrash(), - firstNodeId: routineCbj.firstNodeId.getOrCrash(), - iconCodePoint: routineCbj.iconCodePoint.getOrCrash(), - image: routineCbj.image.getOrCrash(), - lastDateOfExecute: routineCbj.lastDateOfExecute.getOrCrash(), - entityStateGRPC: routineCbj.entityStateGRPC.getOrCrash(), - senderDeviceModel: routineCbj.senderDeviceModel.getOrCrash(), - senderDeviceOs: routineCbj.senderDeviceOs.getOrCrash(), - senderId: routineCbj.senderId.getOrCrash(), - compUuid: routineCbj.compUuid.getOrCrash(), - stateMassage: routineCbj.stateMassage.getOrCrash(), - repeateType: routineCbj.repeateType.getOrCrash(), - repeateDateDays: routineCbj.repeateDateDays.getOrCrash(), - repeateDateHour: routineCbj.repeateDateHour.getOrCrash(), - repeateDateMinute: routineCbj.repeateDateMinute.getOrCrash(), - ); - } - - factory RoutineCbjDtos.fromJson(Map json) => - _$RoutineCbjDtosFromJson(json); - - final String deviceDtoClassInstance = (RoutineCbjDtos).toString(); - - RoutineCbjEntity toDomain() { - return RoutineCbjEntity( - uniqueId: UniqueId.fromUniqueString(uniqueId), - name: RoutineCbjName(name), - backgroundColor: RoutineCbjBackgroundColor(backgroundColor), - automationString: RoutineCbjAutomationString(automationString), - nodeRedFlowId: RoutineCbjNodeRedFlowId(nodeRedFlowId), - firstNodeId: RoutineCbjFirstNodeId(firstNodeId), - iconCodePoint: RoutineCbjIconCodePoint(iconCodePoint), - image: RoutineCbjBackgroundImage(image), - lastDateOfExecute: RoutineCbjLastDateOfExecute(lastDateOfExecute), - entityStateGRPC: RoutineCbjDeviceStateGRPC(entityStateGRPC), - senderDeviceModel: RoutineCbjSenderDeviceModel(senderDeviceModel), - senderDeviceOs: RoutineCbjSenderDeviceOs(senderDeviceOs), - senderId: RoutineCbjSenderId(senderId), - compUuid: RoutineCbjCompUuid(compUuid), - stateMassage: RoutineCbjStateMassage(stateMassage), - repeateType: RoutineCbjRepeatType(repeateType), - repeateDateDays: RoutineCbjRepeatDateDays(repeateDateDays), - repeateDateHour: RoutineCbjRepeatDateHour(repeateDateHour), - repeateDateMinute: RoutineCbjRepeatDateMinute(repeateDateMinute), - ); - } -} diff --git a/lib/infrastructure/routines/routine_repository.dart b/lib/infrastructure/routines/routine_repository.dart deleted file mode 100644 index 6875b018..00000000 --- a/lib/infrastructure/routines/routine_repository.dart +++ /dev/null @@ -1,121 +0,0 @@ -import 'package:cbj_hub/domain/rooms/i_saved_rooms_repo.dart'; -import 'package:cbj_hub/domain/routine/i_routine_cbj_repository.dart'; -import 'package:cbj_hub/domain/routine/routine_cbj_entity.dart'; -import 'package:cbj_hub/domain/routine/routine_cbj_failures.dart'; -import 'package:cbj_integrations_controller/domain/local_db/local_db_failures.dart'; -import 'package:cbj_integrations_controller/domain/mqtt_server/i_mqtt_server_repository.dart'; -import 'package:cbj_integrations_controller/domain/saved_devices/i_saved_devices_repo.dart'; -import 'package:cbj_integrations_controller/injection.dart'; -import 'package:dartz/dartz.dart'; -import 'package:injectable/injectable.dart'; - -@LazySingleton(as: IRoutineCbjRepository) -class RoutineCbjRepository implements IRoutineCbjRepository { - final Map _allRoutines = {}; - - @override - Future setUpAllFromDb() async { - // TODO: Fix after new cbj_integrations_controller - // await getItCbj().getRoutinesFromDb().then((value) { - // value.fold((l) => null, (r) async { - // for (final element in r) { - // await addNewRoutine(element); - // } - // }); - // }); - } - - @override - Future> getAllRoutinesAsList() async { - return _allRoutines.values.toList(); - } - - @override - Future> getAllRoutinesAsMap() async { - return _allRoutines; - } - - @override - Future> saveAndActivateRoutineToDb() async { - // TODO: Fix after new cbj_integrations_controller - // - // return getItCbj().saveRoutines( - // routineList: List.from(_allRoutines.values), - // ); - return left(const LocalDbFailures.unableToUpdate()); - } - - @override - Future> addNewRoutine( - RoutineCbjEntity routineCbj, - ) async { - final RoutineCbjEntity tempRoutineCbj = routineCbj; - - /// Check if routine already exist - if (findRoutineIfAlreadyBeenAdded(tempRoutineCbj) == null) { - _allRoutines.addEntries( - [MapEntry(tempRoutineCbj.uniqueId.getOrCrash(), tempRoutineCbj)], - ); - - final String entityId = tempRoutineCbj.uniqueId.getOrCrash(); - - /// If it is new routine - _allRoutines[entityId] = tempRoutineCbj; - - ISavedRoomsRepo.instance - .addRoutineToRoomDiscoveredIfNotExist(tempRoutineCbj); - // TODO: Fix after new cbj_integrations_controller - // final String routineNodeRedFlowId = await getItCbj() - // .createNewNodeRedRoutine(tempRoutineCbj); - // if (routineNodeRedFlowId.isNotEmpty) { - // tempRoutineCbj = tempRoutineCbj.copyWith( - // nodeRedFlowId: RoutineCbjNodeRedFlowId(routineNodeRedFlowId), - // ); - // } - return left(const RoutineCbjFailure.unableToUpdate()); - } - return right(unit); - } - - @override - Future> addNewRoutineAndSaveItToLocalDb( - RoutineCbjEntity routineCbj, - ) async { - await addNewRoutine(routineCbj); - await getItCbj().saveAndActivateSmartDevicesToDb(); - await saveAndActivateRoutineToDb(); - - return right(unit); - } - - @override - Future activateRoutine( - RoutineCbjEntity routineCbj, - ) async { - final String fullPathOfRoutine = await getFullMqttPathOfRoutine(routineCbj); - IMqttServerRepository.instance - .publishMessage(fullPathOfRoutine, DateTime.now().toString()); - - return true; - } - - /// Get entity and return the full MQTT path to it - @override - Future getFullMqttPathOfRoutine(RoutineCbjEntity routineCbj) async { - final String hubBaseTopic = - IMqttServerRepository.instance.getHubBaseTopic(); - final String routinesTopicTypeName = - IMqttServerRepository.instance.getRoutinesTopicTypeName(); - final String routineId = routineCbj.firstNodeId.getOrCrash()!; - - return '$hubBaseTopic/$routinesTopicTypeName/$routineId'; - } - - /// Check if all routines does not contain the same routine already - /// Will compare the unique id's that each company sent us - RoutineCbjEntity? findRoutineIfAlreadyBeenAdded( - RoutineCbjEntity routineEntity, - ) { - return _allRoutines[routineEntity.uniqueId.getOrCrash()]; - } -} diff --git a/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/bed_room_area_actions.dart b/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/bed_room_area_actions.dart deleted file mode 100644 index b37de67d..00000000 --- a/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/bed_room_area_actions.dart +++ /dev/null @@ -1,204 +0,0 @@ -import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/scene/scene_cbj_failures.dart'; -import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/scenes/area_types_scientific_presets/common_devices_scenes_presets_for_devices.dart'; -import 'package:dartz/dartz.dart'; - -class BedRoomAreaAction { - Future>> bedRoomSleepDeviceAction( - DeviceEntityAbstract deviceEntity, - String brokerNodeId, - ) async { - final EntityTypes deviceType = EntityTypes.values.firstWhere( - (element) => element.name == deviceEntity.entityTypes.getOrCrash(), - ); - final Map actionsList = {}; - - switch (deviceType) { - case EntityTypes.AirConditioner: - // TODO: Turn on on sleep mode?. - break; - case EntityTypes.babyMonitor: - // TODO: Open and ready. - break; - case EntityTypes.bed: - // TODO: Change angle to be straight for sleep (not with angle for reading). - break; - case EntityTypes.blinds: - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.blindsDownPreset( - deviceEntity, - brokerNodeId, - ), - ]); - case EntityTypes.boiler: - break; - case EntityTypes.browserApp: - // TODO: Handle this case. - break; - case EntityTypes.button: - // TODO: Handle this case. - break; - case EntityTypes.buttonWithLight: - // TODO: Turn off button light for better sleep? or turn on so that it will be easy to find the button at the dart. - break; - case EntityTypes.cctLight: - // TODO: Turn off dim light in case it turned on in the night. - break; - case EntityTypes.coffeeMachine: - // TODO: Turn off. - break; - case EntityTypes.computerApp: - // TODO: Turn sleep mode. - break; - case EntityTypes.dimmableLight: - // TODO: Turn off dim light in case it turned on in the night. - break; - case EntityTypes.dishwasher: - // TODO: Turn off. - break; - case EntityTypes.hub: - // TODO: Handle this case. - break; - case EntityTypes.humiditySensor: - // TODO: Handle this case. - break; - case EntityTypes.kettle: - // TODO: Turn off. - break; - case EntityTypes.light: - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.lightOffPreset( - deviceEntity, - brokerNodeId, - ), - ]); - case EntityTypes.lightSensor: - // TODO: Handle this case. - break; - case EntityTypes.microphone: - // TODO: Handle this case. - break; - case EntityTypes.motionSensor: - // TODO: Handle this case. - break; - case EntityTypes.oven: - // TODO: Handle this case. - break; - case EntityTypes.oxygenSensor: - // TODO: Handle this case. - break; - case EntityTypes.phoneApp: - // TODO: Put phone on sleep mode, gray screen as well as quite and maybe set alarm clock for the morning. - break; - case EntityTypes.printer: - // TODO: Postpone maintenance. - break; - case EntityTypes.printerWithScanner: - // TODO: Postpone maintenance. - break; - case EntityTypes.refrigerator: - // TODO: Handle this case. - break; - case EntityTypes.rgbLights: - // TODO: Turn off and dim light in case it turned on in the night. - break; - case EntityTypes.rgbcctLights: - // TODO: Turn off and dim light in case it turned on in the night. - break; - case EntityTypes.rgbwLights: - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.rgbwLightOffPreset( - deviceEntity, - brokerNodeId, - ), - ]); - case EntityTypes.scanner: - // TODO: Handle this case. - break; - case EntityTypes.securityCamera: - // TODO: Handle this case. - break; - case EntityTypes.smartPlug: - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.smartPlugOffPreset( - deviceEntity, - brokerNodeId, - ), - ]); - case EntityTypes.smartSpeakers: - // TODO: Handle this case. - break; - case EntityTypes.smartTV: - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.smartTvOffPreset( - deviceEntity, - brokerNodeId, - ), - ]); - case EntityTypes.smartWatch: - // TODO: Handle this case. - break; - case EntityTypes.smartWaterBottle: - // TODO: Handle this case. - break; - case EntityTypes.smokeDetector: - // TODO: Handle this case. - break; - case EntityTypes.smokeSensor: - // TODO: Handle this case. - break; - case EntityTypes.soundSensor: - // TODO: Handle this case. - break; - case EntityTypes.switch_: - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.switchOffPreset( - deviceEntity, - brokerNodeId, - ), - ]); - case EntityTypes.teapot: - // TODO: Turn off. - break; - case EntityTypes.temperatureSensor: - // TODO: Handle this case. - break; - case EntityTypes.toaster: - // TODO: Handle this case. - break; - case EntityTypes.smartTypeNotSupported: - // TODO: Handle this case. - break; - case EntityTypes.vacuumCleaner: - // TODO: Turn off. - break; - case EntityTypes.washingMachine: - // TODO: Turn off. - break; - case EntityTypes.emptyEntity: - // TODO: Handle this case. - break; - case EntityTypes.pingEntity: - // TODO: Handle this case. - break; - case EntityTypes.smartComputer: - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.smartComputerSuspend( - deviceEntity, - brokerNodeId, - ), - ]); - case EntityTypes.playerEntity: - // TODO: Handle this case. - break; - case EntityTypes.routerEntity: - // TODO: Handle this case. - break; - case EntityTypes.voiceAssistant: - // TODO: Handle this case. - break; - } - return right(actionsList); - } -} diff --git a/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/outside_area_actions.dart b/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/outside_area_actions.dart deleted file mode 100644 index 3348d664..00000000 --- a/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/outside_area_actions.dart +++ /dev/null @@ -1,200 +0,0 @@ -import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/scene/scene_cbj_failures.dart'; -import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/scenes/area_types_scientific_presets/common_devices_scenes_presets_for_devices.dart'; -import 'package:dartz/dartz.dart'; - -class OutsideAreaAction { - Future>> outsideOffDeviceAction( - DeviceEntityAbstract deviceEntity, - String brokerNodeId, - ) async { - final EntityTypes deviceType = EntityTypes.values.firstWhere( - (element) => element.name == deviceEntity.entityTypes.getOrCrash(), - ); - final Map actionsList = {}; - - switch (deviceType) { - case EntityTypes.AirConditioner: - // TODO: Handle this case. - break; - case EntityTypes.babyMonitor: - // TODO: Handle this case. - break; - case EntityTypes.bed: - // TODO: Handle this case. - break; - case EntityTypes.blinds: - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.blindsDownPreset( - deviceEntity, - brokerNodeId, - ), - ]); - case EntityTypes.boiler: - break; - case EntityTypes.browserApp: - // TODO: Handle this case. - break; - case EntityTypes.button: - // TODO: Handle this case. - break; - case EntityTypes.buttonWithLight: - // TODO: Handle this case. - break; - case EntityTypes.cctLight: - // TODO: Handle this case. - break; - case EntityTypes.coffeeMachine: - // TODO: Handle this case. - break; - case EntityTypes.computerApp: - // TODO: Handle this case. - break; - case EntityTypes.dimmableLight: - // TODO: Handle this case. - break; - case EntityTypes.dishwasher: - // TODO: Handle this case. - break; - case EntityTypes.hub: - // TODO: Handle this case. - break; - case EntityTypes.humiditySensor: - // TODO: Handle this case. - break; - case EntityTypes.kettle: - // TODO: Handle this case. - break; - case EntityTypes.light: - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.lightOffPreset( - deviceEntity, - brokerNodeId, - ), - ]); - case EntityTypes.lightSensor: - // TODO: Handle this case. - break; - case EntityTypes.microphone: - // TODO: Handle this case. - break; - case EntityTypes.motionSensor: - // TODO: Handle this case. - break; - case EntityTypes.oven: - // TODO: Handle this case. - break; - case EntityTypes.oxygenSensor: - // TODO: Handle this case. - break; - case EntityTypes.phoneApp: - // TODO: Handle this case. - break; - case EntityTypes.printer: - // TODO: Handle this case. - break; - case EntityTypes.printerWithScanner: - // TODO: Handle this case. - break; - case EntityTypes.refrigerator: - // TODO: Handle this case. - break; - case EntityTypes.rgbLights: - // TODO: Handle this case. - break; - case EntityTypes.rgbcctLights: - // TODO: Handle this case. - break; - case EntityTypes.rgbwLights: - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.rgbwLightOffPreset( - deviceEntity, - brokerNodeId, - ), - ]); - case EntityTypes.scanner: - // TODO: Handle this case. - break; - case EntityTypes.securityCamera: - // TODO: Handle this case. - break; - case EntityTypes.smartPlug: - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.smartPlugOffPreset( - deviceEntity, - brokerNodeId, - ), - ]); - case EntityTypes.smartSpeakers: - // TODO: Handle this case. - break; - case EntityTypes.smartTV: - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.smartTvOffPreset( - deviceEntity, - brokerNodeId, - ), - ]); - case EntityTypes.smartWatch: - // TODO: Handle this case. - break; - case EntityTypes.smartWaterBottle: - // TODO: Handle this case. - break; - case EntityTypes.smokeDetector: - // TODO: Handle this case. - break; - case EntityTypes.smokeSensor: - // TODO: Handle this case. - break; - case EntityTypes.soundSensor: - // TODO: Handle this case. - break; - case EntityTypes.switch_: - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.switchOffPreset( - deviceEntity, - brokerNodeId, - ), - ]); - case EntityTypes.teapot: - // TODO: Handle this case. - break; - case EntityTypes.temperatureSensor: - // TODO: Handle this case. - break; - case EntityTypes.toaster: - // TODO: Handle this case. - break; - case EntityTypes.smartTypeNotSupported: - // TODO: Handle this case. - break; - case EntityTypes.emptyEntity: - // TODO: Handle this case. - break; - case EntityTypes.pingEntity: - // TODO: Handle this case. - break; - case EntityTypes.vacuumCleaner: - // TODO: Handle this case. - break; - case EntityTypes.washingMachine: - // TODO: Handle this case. - break; - case EntityTypes.smartComputer: - // TODO: Handle this case. - break; - case EntityTypes.playerEntity: - // TODO: Handle this case. - break; - case EntityTypes.routerEntity: - // TODO: Handle this case. - break; - case EntityTypes.voiceAssistant: - // TODO: Handle this case. - break; - } - return right(actionsList); - } -} diff --git a/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/study_room_area_actions.dart b/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/study_room_area_actions.dart deleted file mode 100644 index abb9b9db..00000000 --- a/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/study_room_area_actions.dart +++ /dev/null @@ -1,209 +0,0 @@ -import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/scene/scene_cbj_failures.dart'; -import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/scenes/area_types_scientific_presets/common_devices_scenes_presets_for_devices.dart'; -import 'package:dartz/dartz.dart'; - -class StudyRoomAreaAction { - Future>> studyRoomDeviceAction( - DeviceEntityAbstract deviceEntity, - String brokerNodeId, - ) async { - final EntityTypes deviceType = EntityTypes.values.firstWhere( - (element) => element.name == deviceEntity.entityTypes.getOrCrash(), - ); - - final Map actionsList = {}; - - switch (deviceType) { - case EntityTypes.AirConditioner: - // TODO: Handle this case. - break; - case EntityTypes.babyMonitor: - // TODO: Handle this case. - break; - case EntityTypes.bed: - // TODO: Handle this case. - break; - case EntityTypes.blinds: - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.blindsUpPreset( - deviceEntity, - brokerNodeId, - ), - ]); - case EntityTypes.boiler: - break; - case EntityTypes.browserApp: - // TODO: Handle this case. - break; - case EntityTypes.button: - // TODO: Handle this case. - break; - case EntityTypes.buttonWithLight: - // TODO: Handle this case. - break; - case EntityTypes.cctLight: - // TODO: Handle this case. - break; - case EntityTypes.coffeeMachine: - // TODO: Handle this case. - break; - case EntityTypes.computerApp: - // TODO: Handle this case. - break; - case EntityTypes.dimmableLight: - // TODO: Handle this case. - break; - case EntityTypes.dishwasher: - // TODO: Handle this case. - break; - case EntityTypes.hub: - // TODO: Handle this case. - break; - case EntityTypes.humiditySensor: - // TODO: Handle this case. - break; - case EntityTypes.kettle: - // TODO: Handle this case. - break; - case EntityTypes.light: - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.lightOnPreset( - deviceEntity, - brokerNodeId, - ), - ]); - case EntityTypes.lightSensor: - // TODO: Handle this case. - break; - case EntityTypes.microphone: - // TODO: Handle this case. - break; - case EntityTypes.motionSensor: - // TODO: Handle this case. - break; - case EntityTypes.oven: - // TODO: Handle this case. - break; - case EntityTypes.oxygenSensor: - // TODO: Handle this case. - break; - case EntityTypes.phoneApp: - // TODO: Handle this case. - break; - case EntityTypes.printer: - // TODO: Handle this case. - break; - case EntityTypes.printerWithScanner: - // TODO: Handle this case. - break; - case EntityTypes.refrigerator: - // TODO: Handle this case. - break; - case EntityTypes.rgbLights: - // TODO: Handle this case. - break; - case EntityTypes.rgbcctLights: - // TODO: Handle this case. - break; - case EntityTypes.rgbwLights: - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.rgbLightWhitePreset( - deviceEntity, - brokerNodeId, - ), - ]); - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.rgbLightMaxBrightnessPreset( - deviceEntity, - brokerNodeId, - ), - ]); - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.rgbwLightOnPreset( - deviceEntity, - brokerNodeId, - ), - ]); - return right(actionsList); - case EntityTypes.scanner: - // TODO: Handle this case. - break; - case EntityTypes.securityCamera: - // TODO: Handle this case. - break; - case EntityTypes.smartPlug: - break; - case EntityTypes.smartSpeakers: - // TODO: Handle this case. - break; - case EntityTypes.smartTV: - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.smartTvOffPreset( - deviceEntity, - brokerNodeId, - ), - ]); - case EntityTypes.smartWatch: - // TODO: Handle this case. - break; - case EntityTypes.smartWaterBottle: - // TODO: Handle this case. - break; - case EntityTypes.smokeDetector: - // TODO: Handle this case. - break; - case EntityTypes.smokeSensor: - // TODO: Handle this case. - break; - case EntityTypes.soundSensor: - // TODO: Handle this case. - break; - case EntityTypes.switch_: - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.switchOnPreset( - deviceEntity, - brokerNodeId, - ), - ]); - case EntityTypes.teapot: - // TODO: Handle this case. - break; - case EntityTypes.temperatureSensor: - // TODO: Handle this case. - break; - case EntityTypes.toaster: - // TODO: Handle this case. - break; - case EntityTypes.smartTypeNotSupported: - // TODO: Handle this case. - break; - case EntityTypes.emptyEntity: - // TODO: Handle this case. - break; - case EntityTypes.pingEntity: - // TODO: Handle this case. - break; - case EntityTypes.vacuumCleaner: - // TODO: Handle this case. - break; - case EntityTypes.washingMachine: - // TODO: Handle this case. - break; - case EntityTypes.smartComputer: - // TODO: Handle this case. - break; - case EntityTypes.playerEntity: - // TODO: Handle this case. - break; - case EntityTypes.routerEntity: - // TODO: Handle this case. - break; - case EntityTypes.voiceAssistant: - // TODO: Handle this case. - break; - } - return right(actionsList); - } -} diff --git a/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/video_games_area_actions.dart b/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/video_games_area_actions.dart deleted file mode 100644 index 419467ec..00000000 --- a/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/video_games_area_actions.dart +++ /dev/null @@ -1,210 +0,0 @@ -import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/scene/scene_cbj_failures.dart'; -import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/scenes/area_types_scientific_presets/common_devices_scenes_presets_for_devices.dart'; -import 'package:dartz/dartz.dart'; - -class VideoGamesAreaAction { - Future>> - videoGamesRgbModDeviceAction( - DeviceEntityAbstract deviceEntity, - String brokerNodeId, - ) async { - final EntityTypes deviceType = EntityTypes.values.firstWhere( - (element) => element.name == deviceEntity.entityTypes.getOrCrash(), - ); - - final Map actionsList = {}; - - switch (deviceType) { - case EntityTypes.AirConditioner: - // TODO: Handle this case. - break; - case EntityTypes.babyMonitor: - // TODO: Handle this case. - break; - case EntityTypes.bed: - // TODO: Handle this case. - break; - case EntityTypes.blinds: - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.blindsUpPreset( - deviceEntity, - brokerNodeId, - ), - ]); - case EntityTypes.boiler: - break; - case EntityTypes.browserApp: - // TODO: Handle this case. - break; - case EntityTypes.button: - // TODO: Handle this case. - break; - case EntityTypes.buttonWithLight: - // TODO: Handle this case. - break; - case EntityTypes.cctLight: - // TODO: Handle this case. - break; - case EntityTypes.coffeeMachine: - // TODO: Handle this case. - break; - case EntityTypes.computerApp: - // TODO: Handle this case. - break; - case EntityTypes.dimmableLight: - // TODO: Handle this case. - break; - case EntityTypes.dishwasher: - // TODO: Handle this case. - break; - case EntityTypes.hub: - // TODO: Handle this case. - break; - case EntityTypes.humiditySensor: - // TODO: Handle this case. - break; - case EntityTypes.kettle: - // TODO: Handle this case. - break; - case EntityTypes.light: - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.lightOnPreset( - deviceEntity, - brokerNodeId, - ), - ]); - case EntityTypes.lightSensor: - // TODO: Handle this case. - break; - case EntityTypes.microphone: - // TODO: Handle this case. - break; - case EntityTypes.motionSensor: - // TODO: Handle this case. - break; - case EntityTypes.oven: - // TODO: Handle this case. - break; - case EntityTypes.oxygenSensor: - // TODO: Handle this case. - break; - case EntityTypes.phoneApp: - // TODO: Handle this case. - break; - case EntityTypes.printer: - // TODO: Handle this case. - break; - case EntityTypes.printerWithScanner: - // TODO: Handle this case. - break; - case EntityTypes.refrigerator: - // TODO: Handle this case. - break; - case EntityTypes.rgbLights: - // TODO: Handle this case. - break; - case EntityTypes.rgbcctLights: - // TODO: Handle this case. - break; - case EntityTypes.rgbwLights: - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.rgbLightOrangePreset( - deviceEntity, - brokerNodeId, - ), - ]); - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.rgbLightMaxBrightnessPreset( - deviceEntity, - brokerNodeId, - ), - ]); - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.rgbwLightOnPreset( - deviceEntity, - brokerNodeId, - ), - ]); - // TODO: add light color changing in cycles - case EntityTypes.scanner: - // TODO: Handle this case. - break; - case EntityTypes.securityCamera: - // TODO: Handle this case. - break; - case EntityTypes.smartPlug: - break; - case EntityTypes.smartSpeakers: - // TODO: Handle this case. - break; - case EntityTypes.smartTV: - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.smartTvOffPreset( - deviceEntity, - brokerNodeId, - ), - ]); - case EntityTypes.smartWatch: - // TODO: Handle this case. - break; - case EntityTypes.smartWaterBottle: - // TODO: Handle this case. - break; - case EntityTypes.smokeDetector: - // TODO: Handle this case. - break; - case EntityTypes.smokeSensor: - // TODO: Handle this case. - break; - case EntityTypes.soundSensor: - // TODO: Handle this case. - break; - case EntityTypes.switch_: - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.switchOnPreset( - deviceEntity, - brokerNodeId, - ), - ]); - case EntityTypes.teapot: - // TODO: Handle this case. - break; - case EntityTypes.temperatureSensor: - // TODO: Handle this case. - break; - case EntityTypes.toaster: - // TODO: Handle this case. - break; - case EntityTypes.smartTypeNotSupported: - // TODO: Handle this case. - break; - case EntityTypes.emptyEntity: - // TODO: Handle this case. - break; - case EntityTypes.pingEntity: - // TODO: Handle this case. - break; - case EntityTypes.vacuumCleaner: - // TODO: Handle this case. - break; - case EntityTypes.washingMachine: - // TODO: Handle this case. - break; - case EntityTypes.smartComputer: - // TODO: Handle this case. - break; - case EntityTypes.playerEntity: - // TODO: Handle this case. - break; - case EntityTypes.routerEntity: - // TODO: Handle this case. - break; - case EntityTypes.voiceAssistant: - // TODO: Handle this case. - break; - } - return right(actionsList); - } -} diff --git a/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/work_room_area_actions.dart b/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/work_room_area_actions.dart deleted file mode 100644 index d9dfca36..00000000 --- a/lib/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/work_room_area_actions.dart +++ /dev/null @@ -1,208 +0,0 @@ -import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_hub/domain/scene/scene_cbj_failures.dart'; -import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_hub/infrastructure/scenes/area_types_scientific_presets/common_devices_scenes_presets_for_devices.dart'; -import 'package:dartz/dartz.dart'; - -class WorkRoomAreaAction { - Future>> workRoomDeviceAction( - DeviceEntityAbstract deviceEntity, - String brokerNodeId, - ) async { - final EntityTypes deviceType = EntityTypes.values.firstWhere( - (element) => element.name == deviceEntity.entityTypes.getOrCrash(), - ); - - final Map actionsList = {}; - - switch (deviceType) { - case EntityTypes.AirConditioner: - // TODO: Handle this case. - break; - case EntityTypes.babyMonitor: - // TODO: Handle this case. - break; - case EntityTypes.bed: - // TODO: Handle this case. - break; - case EntityTypes.blinds: - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.blindsUpPreset( - deviceEntity, - brokerNodeId, - ), - ]); - case EntityTypes.boiler: - break; - case EntityTypes.browserApp: - // TODO: Handle this case. - break; - case EntityTypes.button: - // TODO: Handle this case. - break; - case EntityTypes.buttonWithLight: - // TODO: Handle this case. - break; - case EntityTypes.cctLight: - // TODO: Handle this case. - break; - case EntityTypes.coffeeMachine: - // TODO: Handle this case. - break; - case EntityTypes.computerApp: - // TODO: Handle this case. - break; - case EntityTypes.dimmableLight: - // TODO: Handle this case. - break; - case EntityTypes.dishwasher: - // TODO: Handle this case. - break; - case EntityTypes.hub: - // TODO: Handle this case. - break; - case EntityTypes.humiditySensor: - // TODO: Handle this case. - break; - case EntityTypes.kettle: - // TODO: Handle this case. - break; - case EntityTypes.light: - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.lightOnPreset( - deviceEntity, - brokerNodeId, - ), - ]); - case EntityTypes.lightSensor: - // TODO: Handle this case. - break; - case EntityTypes.microphone: - // TODO: Handle this case. - break; - case EntityTypes.motionSensor: - // TODO: Handle this case. - break; - case EntityTypes.oven: - // TODO: Handle this case. - break; - case EntityTypes.oxygenSensor: - // TODO: Handle this case. - break; - case EntityTypes.phoneApp: - // TODO: Handle this case. - break; - case EntityTypes.printer: - // TODO: Handle this case. - break; - case EntityTypes.printerWithScanner: - // TODO: Handle this case. - break; - case EntityTypes.refrigerator: - // TODO: Handle this case. - break; - case EntityTypes.rgbLights: - // TODO: Handle this case. - break; - case EntityTypes.rgbcctLights: - // TODO: Handle this case. - break; - case EntityTypes.rgbwLights: - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.rgbLightBluePreset( - deviceEntity, - brokerNodeId, - ), - ]); - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.rgbLightMaxBrightnessPreset( - deviceEntity, - brokerNodeId, - ), - ]); - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.rgbwLightOnPreset( - deviceEntity, - brokerNodeId, - ), - ]); - case EntityTypes.scanner: - // TODO: Handle this case. - break; - case EntityTypes.securityCamera: - // TODO: Handle this case. - break; - case EntityTypes.smartPlug: - break; - case EntityTypes.smartSpeakers: - // TODO: Handle this case. - break; - case EntityTypes.smartTV: - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.smartTvOffPreset( - deviceEntity, - brokerNodeId, - ), - ]); - case EntityTypes.smartWatch: - // TODO: Handle this case. - break; - case EntityTypes.smartWaterBottle: - // TODO: Handle this case. - break; - case EntityTypes.smokeDetector: - // TODO: Handle this case. - break; - case EntityTypes.smokeSensor: - // TODO: Handle this case. - break; - case EntityTypes.soundSensor: - // TODO: Handle this case. - break; - case EntityTypes.switch_: - actionsList.addEntries([ - CommonDevicesScenesPresetsForDevices.switchOnPreset( - deviceEntity, - brokerNodeId, - ), - ]); - case EntityTypes.teapot: - // TODO: Handle this case. - break; - case EntityTypes.temperatureSensor: - // TODO: Handle this case. - break; - case EntityTypes.toaster: - // TODO: Handle this case. - break; - case EntityTypes.smartTypeNotSupported: - // TODO: Handle this case. - break; - case EntityTypes.emptyEntity: - // TODO: Handle this case. - break; - case EntityTypes.pingEntity: - // TODO: Handle this case. - break; - case EntityTypes.vacuumCleaner: - // TODO: Handle this case. - break; - case EntityTypes.washingMachine: - // TODO: Handle this case. - break; - case EntityTypes.smartComputer: - // TODO: Handle this case. - break; - case EntityTypes.playerEntity: - // TODO: Handle this case. - break; - case EntityTypes.routerEntity: - // TODO: Handle this case. - break; - case EntityTypes.voiceAssistant: - // TODO: Handle this case. - break; - } - return right(actionsList); - } -} diff --git a/lib/infrastructure/scenes/area_types_scientific_presets/area_type_with_device_type_preset.dart b/lib/infrastructure/scenes/area_types_scientific_presets/area_type_with_device_type_preset.dart deleted file mode 100644 index 772da4c5..00000000 --- a/lib/infrastructure/scenes/area_types_scientific_presets/area_type_with_device_type_preset.dart +++ /dev/null @@ -1,181 +0,0 @@ -import 'package:cbj_hub/domain/scene/scene_cbj_failures.dart'; -import 'package:cbj_hub/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/bed_room_area_actions.dart'; -import 'package:cbj_hub/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/outside_area_actions.dart'; -import 'package:cbj_hub/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/study_room_area_actions.dart'; -import 'package:cbj_hub/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/video_games_area_actions.dart'; -import 'package:cbj_hub/infrastructure/scenes/area_types_scientific_presets/actions_for_area_types/work_room_area_actions.dart'; -import 'package:cbj_integrations_controller/domain/local_db/local_db_failures.dart'; -import 'package:cbj_integrations_controller/domain/matirial_colors/colors.dart'; -import 'package:cbj_integrations_controller/domain/saved_devices/i_saved_devices_repo.dart'; -import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_integrations_controller/injection.dart'; -import 'package:dartz/dartz.dart'; - -/// Pre define actions for each device in each area type -class AreaTypeWithDeviceTypePreset { - static Future>> - getPreDefineActionForDeviceInArea({ - required String deviceId, - required AreaPurposesTypes areaPurposeType, - required String brokerNodeId, - }) async { - final Either dTemp = - await getItCbj().getDeviceById(deviceId); - if (dTemp.isLeft()) { - return left(const SceneCbjFailure.unexpected()); - } - late DeviceEntityAbstract deviceEntity; - - dTemp.fold((l) => null, (r) { - deviceEntity = r; - }); - - switch (areaPurposeType) { - case AreaPurposesTypes.attic: - // TODO: Handle this case. - break; - case AreaPurposesTypes.bathtub: - // TODO: Handle this case. - break; - case AreaPurposesTypes.bedroom: - return BedRoomAreaAction() - .bedRoomSleepDeviceAction(deviceEntity, brokerNodeId); - case AreaPurposesTypes.boardGames: - // TODO: Handle this case. - break; - case AreaPurposesTypes.childrenRoom: - // TODO: Handle this case. - break; - case AreaPurposesTypes.cinemaRoom: - // TODO: Handle this case. - break; - case AreaPurposesTypes.diningRoom: - // TODO: Handle this case. - break; - case AreaPurposesTypes.holidayCabin: - // TODO: Handle this case. - break; - case AreaPurposesTypes.kitchen: - // TODO: Handle this case. - break; - case AreaPurposesTypes.laundryRoom: - // TODO: Handle this case. - break; - case AreaPurposesTypes.livingRoom: - // TODO: Handle this case. - break; - case AreaPurposesTypes.meditation: - // TODO: Handle this case. - break; - case AreaPurposesTypes.outside: - return OutsideAreaAction() - .outsideOffDeviceAction(deviceEntity, brokerNodeId); - case AreaPurposesTypes.outsideNotPrimary: - // TODO: Handle this case. - break; - case AreaPurposesTypes.outsidePrimary: - // TODO: Handle this case. - break; - case AreaPurposesTypes.protectedSpace: - // TODO: Handle this case. - break; - case AreaPurposesTypes.romantic: - // TODO: Handle this case. - break; - case AreaPurposesTypes.safeRoom: - // TODO: Handle this case. - break; - case AreaPurposesTypes.shower: - // TODO: Handle this case. - break; - case AreaPurposesTypes.stairsInside: - // TODO: Handle this case. - break; - case AreaPurposesTypes.stairsOutside: - // TODO: Handle this case. - break; - case AreaPurposesTypes.studyRoom: - return StudyRoomAreaAction() - .studyRoomDeviceAction(deviceEntity, brokerNodeId); - case AreaPurposesTypes.toiletRoom: - // TODO: Handle this case. - break; - case AreaPurposesTypes.trainingRoom: - // TODO: Handle this case. - break; - case AreaPurposesTypes.tvRoom: - // TODO: Handle this case. - break; - case AreaPurposesTypes.videoGames: - return VideoGamesAreaAction() - .videoGamesRgbModDeviceAction(deviceEntity, brokerNodeId); - case AreaPurposesTypes.workRoom: - return WorkRoomAreaAction() - .workRoomDeviceAction(deviceEntity, brokerNodeId); - } - return left(const SceneCbjFailure.unexpected()); - } - - static String getColorForAreaType(AreaPurposesTypes areaPurposeType) { - Colors color = Colors.orange; - - switch (areaPurposeType) { - case AreaPurposesTypes.attic: - color = Colors.amberAccent; - case AreaPurposesTypes.bathtub: - color = Colors.lightBlue; - case AreaPurposesTypes.bedroom: - color = Colors.cyan; - case AreaPurposesTypes.boardGames: - color = Colors.brown; - case AreaPurposesTypes.childrenRoom: - color = Colors.lightBlueAccent; - case AreaPurposesTypes.cinemaRoom: - color = Colors.pink; - case AreaPurposesTypes.diningRoom: - color = Colors.amber; - case AreaPurposesTypes.holidayCabin: - color = Colors.lightGreen; - case AreaPurposesTypes.kitchen: - color = Colors.redAccent; - case AreaPurposesTypes.laundryRoom: - color = Colors.white12; - case AreaPurposesTypes.livingRoom: - color = Colors.orangeAccent; - case AreaPurposesTypes.meditation: - color = Colors.purple; - case AreaPurposesTypes.outside: - color = Colors.green; - case AreaPurposesTypes.outsideNotPrimary: - color = Colors.greenAccent; - case AreaPurposesTypes.outsidePrimary: - color = Colors.lightGreenAccent; - case AreaPurposesTypes.protectedSpace: - color = Colors.blueGrey; - case AreaPurposesTypes.romantic: - color = Colors.pinkAccent; - case AreaPurposesTypes.safeRoom: - color = Colors.indigo; - case AreaPurposesTypes.shower: - color = Colors.blueAccent; - case AreaPurposesTypes.stairsInside: - color = Colors.brown; - case AreaPurposesTypes.stairsOutside: - color = Colors.brown; - case AreaPurposesTypes.studyRoom: - color = Colors.deepPurpleAccent; - case AreaPurposesTypes.toiletRoom: - color = Colors.green; - case AreaPurposesTypes.trainingRoom: - color = Colors.redAccent; - case AreaPurposesTypes.tvRoom: - color = Colors.deepPurple; - case AreaPurposesTypes.videoGames: - color = Colors.tealAccent; - case AreaPurposesTypes.workRoom: - color = Colors.blue; - } - return color.value; - } -} diff --git a/lib/infrastructure/scenes/area_types_scientific_presets/common_devices_scenes_presets_for_devices.dart b/lib/infrastructure/scenes/area_types_scientific_presets/common_devices_scenes_presets_for_devices.dart deleted file mode 100644 index ab3471ef..00000000 --- a/lib/infrastructure/scenes/area_types_scientific_presets/common_devices_scenes_presets_for_devices.dart +++ /dev/null @@ -1,391 +0,0 @@ -import 'package:cbj_hub/infrastructure/node_red/node_red_converter.dart'; -import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_blinds_device/generic_blinds_entity.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_boiler_device/generic_boiler_entity.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_light_device/generic_light_entity.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_rgbw_light_device/generic_rgbw_light_entity.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_smart_computer_device/generic_smart_computer_entity.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_smart_plug_device/generic_smart_plug_entity.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_smart_tv/generic_smart_tv_entity.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_devices/generic_switch_device/generic_switch_entity.dart'; - -class CommonDevicesScenesPresetsForDevices { - /// TODO: add TypeNotSupported preset - - /// Light preset - - static MapEntry lightOnPreset( - DeviceEntityAbstract deviceEntity, - String brokerNodeId, - ) { - final String property = - GenericLightDE.empty().getListOfPropertiesToChange()[0]; - final String action = EntityActions.on.toString(); - - return NodeRedConverter.convertToNodeString( - device: deviceEntity, - brokerNodeId: brokerNodeId, - property: property, - action: action, - ); - } - - static MapEntry lightOffPreset( - DeviceEntityAbstract deviceEntity, - String brokerNodeId, - ) { - final String property = - GenericLightDE.empty().getListOfPropertiesToChange()[0]; - final String action = EntityActions.off.toString(); - - return NodeRedConverter.convertToNodeString( - device: deviceEntity, - brokerNodeId: brokerNodeId, - property: property, - action: action, - ); - } - - /// Blinds preset - - static MapEntry blindsUpPreset( - DeviceEntityAbstract deviceEntity, - String brokerNodeId, - ) { - final String property = - GenericBlindsDE.empty().getListOfPropertiesToChange()[0]; - final String action = EntityActions.moveUp.toString(); - - return NodeRedConverter.convertToNodeString( - device: deviceEntity, - brokerNodeId: brokerNodeId, - property: property, - action: action, - ); - } - - static MapEntry blindsStopPreset( - DeviceEntityAbstract deviceEntity, - String brokerNodeId, - ) { - final String property = - GenericBlindsDE.empty().getListOfPropertiesToChange()[0]; - final String action = EntityActions.stop.toString(); - - return NodeRedConverter.convertToNodeString( - device: deviceEntity, - brokerNodeId: brokerNodeId, - property: property, - action: action, - ); - } - - static MapEntry blindsDownPreset( - DeviceEntityAbstract deviceEntity, - String brokerNodeId, - ) { - final String property = - GenericBlindsDE.empty().getListOfPropertiesToChange()[0]; - final String action = EntityActions.moveDown.toString(); - - return NodeRedConverter.convertToNodeString( - device: deviceEntity, - brokerNodeId: brokerNodeId, - property: property, - action: action, - ); - } - - /// Boiler preset - - static MapEntry boilerOnPreset( - DeviceEntityAbstract deviceEntity, - String brokerNodeId, - ) { - final String property = - GenericBoilerDE.empty().getListOfPropertiesToChange()[0]; - final String action = EntityActions.on.toString(); - - return NodeRedConverter.convertToNodeString( - device: deviceEntity, - brokerNodeId: brokerNodeId, - property: property, - action: action, - ); - } - - static MapEntry boilerOffPreset( - DeviceEntityAbstract deviceEntity, - String brokerNodeId, - ) { - final String property = - GenericBoilerDE.empty().getListOfPropertiesToChange()[0]; - final String action = EntityActions.off.toString(); - - return NodeRedConverter.convertToNodeString( - device: deviceEntity, - brokerNodeId: brokerNodeId, - property: property, - action: action, - ); - } - - /// TODO: Add Button preset - /// TODO: Add ButtonWithLight preset - /// TODO: Add Hub preset - /// TODO: Add PhoneApp preset - /// TODO: Add ComputerApp preset - /// TODO: Add BrowserApp preset - - /// Switch_ preset - - static MapEntry switchOnPreset( - DeviceEntityAbstract deviceEntity, - String brokerNodeId, - ) { - final String property = - GenericSwitchDE.empty().getListOfPropertiesToChange()[0]; - final String action = EntityActions.on.toString(); - - return NodeRedConverter.convertToNodeString( - device: deviceEntity, - brokerNodeId: brokerNodeId, - property: property, - action: action, - ); - } - - static MapEntry switchOffPreset( - DeviceEntityAbstract deviceEntity, - String brokerNodeId, - ) { - final String property = - GenericSwitchDE.empty().getListOfPropertiesToChange()[0]; - final String action = EntityActions.off.toString(); - - return NodeRedConverter.convertToNodeString( - device: deviceEntity, - brokerNodeId: brokerNodeId, - property: property, - action: action, - ); - } - - /// TODO: Add DimmableLight preset - /// TODO: Add CctLight preset - /// TODO: Add RgbLights preset - - /// RgbwLights preset - static MapEntry rgbwLightOnPreset( - DeviceEntityAbstract deviceEntity, - String brokerNodeId, - ) { - final String property = - GenericRgbwLightDE.empty().getListOfPropertiesToChange()[0]; - final String action = EntityActions.on.toString(); - - return NodeRedConverter.convertToNodeString( - device: deviceEntity, - brokerNodeId: brokerNodeId, - property: property, - action: action, - ); - } - - static MapEntry rgbwLightOffPreset( - DeviceEntityAbstract deviceEntity, - String brokerNodeId, - ) { - final String property = - GenericRgbwLightDE.empty().getListOfPropertiesToChange()[0]; - final String action = EntityActions.off.toString(); - - return NodeRedConverter.convertToNodeString( - device: deviceEntity, - brokerNodeId: brokerNodeId, - property: property, - action: action, - ); - } - - static MapEntry rgbLightOrangePreset( - DeviceEntityAbstract deviceEntity, - String brokerNodeId, - ) { - final String property = - GenericRgbwLightDE.empty().getListOfPropertiesToChange()[1]; - const String action = '2500'; - - return NodeRedConverter.convertToNodeString( - device: deviceEntity, - brokerNodeId: brokerNodeId, - property: property, - action: action, - ); - } - - static MapEntry rgbLightWhitePreset( - DeviceEntityAbstract deviceEntity, - String brokerNodeId, - ) { - final String property = - GenericRgbwLightDE.empty().getListOfPropertiesToChange()[1]; - const String action = '5400'; - - return NodeRedConverter.convertToNodeString( - device: deviceEntity, - brokerNodeId: brokerNodeId, - property: property, - action: action, - ); - } - - static MapEntry rgbLightBluePreset( - DeviceEntityAbstract deviceEntity, - String brokerNodeId, - ) { - final String property = - GenericRgbwLightDE.empty().getListOfPropertiesToChange()[1]; - const String action = '8800'; - - return NodeRedConverter.convertToNodeString( - device: deviceEntity, - brokerNodeId: brokerNodeId, - property: property, - action: action, - ); - } - - static MapEntry rgbLightMaxBrightnessPreset( - DeviceEntityAbstract deviceEntity, - String brokerNodeId, - ) { - final String property = - GenericRgbwLightDE.empty().getListOfPropertiesToChange()[6]; - final String action = 100.toString(); - - return NodeRedConverter.convertToNodeString( - device: deviceEntity, - brokerNodeId: brokerNodeId, - property: property, - action: action, - ); - } - - /// TODO: Add RgbcctLights preset - - /// TODO: Add SmartTV preset - - static MapEntry smartTvOffPreset( - DeviceEntityAbstract deviceEntity, - String brokerNodeId, - ) { - final String property = - GenericSmartTvDE.empty().getListOfPropertiesToChange()[0]; - final String action = EntityActions.off.toString(); - - return NodeRedConverter.convertToNodeString( - device: deviceEntity, - brokerNodeId: brokerNodeId, - property: property, - action: action, - ); - } - - static MapEntry smartTvOnPreset( - DeviceEntityAbstract deviceEntity, - String brokerNodeId, - ) { - final String property = - GenericSmartTvDE.empty().getListOfPropertiesToChange()[0]; - final String action = EntityActions.on.toString(); - - return NodeRedConverter.convertToNodeString( - device: deviceEntity, - brokerNodeId: brokerNodeId, - property: property, - action: action, - ); - } - - /// TODO: Add SmartSpeakers preset - /// TODO: Add CoffeeMachine preset - /// TODO: Add Kettle preset - /// TODO: Add Teapot preset - /// TODO: Add WashingMachine preset - /// TODO: Add Dishwasher preset - /// TODO: Add Toaster preset - /// TODO: Add VacuumCleaner preset - /// TODO: Add Refrigerator preset - /// TODO: Add Bed preset - /// TODO: Add Oven preset - /// TODO: Add AirConditioner preset - /// TODO: Add SmartWatch preset - /// TODO: Add SmartWaterBottle preset - /// TODO: Add Microphone preset - /// TODO: Add SecurityCamera preset - /// TODO: Add BabyMonitor preset - /// TODO: Add MotionSensor preset - /// TODO: Add TemperatureSensor preset - /// TODO: Add HumiditySensor preset - /// TODO: Add LightSensor preset - /// TODO: Add SoundSensor preset - /// TODO: Add SmokeSensor preset - /// TODO: Add SmokeDetector preset - /// TODO: Add OxygenSensor preset - - /// SmartPlug preset - - static MapEntry smartPlugOnPreset( - DeviceEntityAbstract deviceEntity, - String brokerNodeId, - ) { - final String property = - GenericSmartPlugDE.empty().getListOfPropertiesToChange()[0]; - final String action = EntityActions.on.toString(); - - return NodeRedConverter.convertToNodeString( - device: deviceEntity, - brokerNodeId: brokerNodeId, - property: property, - action: action, - ); - } - - static MapEntry smartPlugOffPreset( - DeviceEntityAbstract deviceEntity, - String brokerNodeId, - ) { - final String property = - GenericSmartPlugDE.empty().getListOfPropertiesToChange()[0]; - final String action = EntityActions.off.toString(); - - return NodeRedConverter.convertToNodeString( - device: deviceEntity, - brokerNodeId: brokerNodeId, - property: property, - action: action, - ); - } - - static MapEntry smartComputerSuspend( - DeviceEntityAbstract deviceEntity, - String brokerNodeId, - ) { - final String property = - GenericSmartComputerDE.empty().getListOfPropertiesToChange()[0]; - final String action = EntityActions.suspend.toString(); - - return NodeRedConverter.convertToNodeString( - device: deviceEntity, - brokerNodeId: brokerNodeId, - property: property, - action: action, - ); - } - - /// TODO: Add Printer preset - /// TODO: Add Scanner preset - /// TODO: Add Printer with scanner preset -} diff --git a/lib/infrastructure/scenes/scene_cbj_dtos.dart b/lib/infrastructure/scenes/scene_cbj_dtos.dart deleted file mode 100644 index cbc17859..00000000 --- a/lib/infrastructure/scenes/scene_cbj_dtos.dart +++ /dev/null @@ -1,77 +0,0 @@ -import 'package:cbj_integrations_controller/domain/core/value_objects.dart'; -import 'package:cbj_hub/domain/scene/scene_cbj_entity.dart'; -import 'package:cbj_hub/domain/scene/value_objects_scene_cbj.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'scene_cbj_dtos.freezed.dart'; -part 'scene_cbj_dtos.g.dart'; - -@freezed -abstract class SceneCbjDtos implements _$SceneCbjDtos { - factory SceneCbjDtos({ - // @JsonKey(ignore: true) - required String uniqueId, - required String name, - required String backgroundColor, - required String? entityStateGRPC, - required String? senderDeviceOs, - required String? senderDeviceModel, - required String? senderId, - required String? compUuid, - required String? stateMassage, - String? automationString, - String? nodeRedFlowId, - String? firstNodeId, - String? iconCodePoint, - String? image, - String? lastDateOfExecute, - // required ServerTimestampConverter() FieldValue serverTimeStamp, - }) = _SceneCbjDtos; - - SceneCbjDtos._(); - - factory SceneCbjDtos.fromDomain(SceneCbjEntity sceneCbj) { - return SceneCbjDtos( - uniqueId: sceneCbj.uniqueId.getOrCrash(), - name: sceneCbj.name.getOrCrash(), - backgroundColor: sceneCbj.backgroundColor.getOrCrash(), - automationString: sceneCbj.automationString.getOrCrash(), - nodeRedFlowId: sceneCbj.nodeRedFlowId.getOrCrash(), - firstNodeId: sceneCbj.firstNodeId.getOrCrash(), - iconCodePoint: sceneCbj.iconCodePoint.getOrCrash(), - image: sceneCbj.image.getOrCrash(), - lastDateOfExecute: sceneCbj.lastDateOfExecute.getOrCrash(), - entityStateGRPC: sceneCbj.entityStateGRPC.getOrCrash(), - senderDeviceModel: sceneCbj.senderDeviceModel.getOrCrash(), - senderDeviceOs: sceneCbj.senderDeviceOs.getOrCrash(), - senderId: sceneCbj.senderId.getOrCrash(), - compUuid: sceneCbj.compUuid.getOrCrash(), - stateMassage: sceneCbj.stateMassage.getOrCrash(), - ); - } - - factory SceneCbjDtos.fromJson(Map json) => - _$SceneCbjDtosFromJson(json); - - final String deviceDtoClassInstance = (SceneCbjDtos).toString(); - - SceneCbjEntity toDomain() { - return SceneCbjEntity( - uniqueId: UniqueId.fromUniqueString(uniqueId), - name: SceneCbjName(name), - backgroundColor: SceneCbjBackgroundColor(backgroundColor), - automationString: SceneCbjAutomationString(automationString), - nodeRedFlowId: SceneCbjNodeRedFlowId(nodeRedFlowId), - firstNodeId: SceneCbjFirstNodeId(firstNodeId), - iconCodePoint: SceneCbjIconCodePoint(iconCodePoint), - image: SceneCbjBackgroundImage(image), - lastDateOfExecute: SceneCbjLastDateOfExecute(lastDateOfExecute), - entityStateGRPC: SceneCbjDeviceStateGRPC(entityStateGRPC), - senderDeviceModel: SceneCbjSenderDeviceModel(senderDeviceModel), - senderDeviceOs: SceneCbjSenderDeviceOs(senderDeviceOs), - senderId: SceneCbjSenderId(senderId), - compUuid: SceneCbjCompUuid(compUuid), - stateMassage: SceneCbjStateMassage(stateMassage), - ); - } -} diff --git a/lib/infrastructure/scenes/scene_repository.dart b/lib/infrastructure/scenes/scene_repository.dart deleted file mode 100644 index c1fca5fb..00000000 --- a/lib/infrastructure/scenes/scene_repository.dart +++ /dev/null @@ -1,471 +0,0 @@ -import 'dart:collection'; -import 'dart:convert'; - -import 'package:cbj_hub/domain/rooms/i_saved_rooms_repo.dart'; -import 'package:cbj_hub/domain/scene/i_scene_cbj_repository.dart'; -import 'package:cbj_hub/domain/scene/scene_cbj_entity.dart'; -import 'package:cbj_hub/domain/scene/scene_cbj_failures.dart'; -import 'package:cbj_hub/domain/scene/value_objects_scene_cbj.dart'; -import 'package:cbj_hub/infrastructure/app_communication/app_communication_repository.dart'; -import 'package:cbj_hub/infrastructure/node_red/node_red_converter.dart'; -import 'package:cbj_hub/infrastructure/room/saved_rooms_repo.dart'; -import 'package:cbj_hub/infrastructure/scenes/area_types_scientific_presets/area_type_with_device_type_preset.dart'; -import 'package:cbj_hub/utils.dart'; -import 'package:cbj_integrations_controller/domain/local_db/local_db_failures.dart'; -import 'package:cbj_integrations_controller/domain/mqtt_server/i_mqtt_server_repository.dart'; -import 'package:cbj_integrations_controller/domain/saved_devices/i_saved_devices_repo.dart'; -import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_abstract.dart'; -import 'package:cbj_integrations_controller/injection.dart'; -import 'package:dartz/dartz.dart'; -import 'package:injectable/injectable.dart'; -import 'package:kt_dart/kt.dart'; -import 'package:rxdart/rxdart.dart'; - -@LazySingleton(as: ISceneCbjRepository) -class SceneCbjRepository implements ISceneCbjRepository { - final HashMap _allScenes = HashMap(); - - @override - Future setUpAllFromDb() async { - // TODO: Fix after new cbj_integrations_controller - // await getItCbj().getScenesFromDb().then((value) { - // value.fold((l) => null, (r) { - // for (final element in r) { - // addNewScene(element); - // } - // }); - // }); - } - - @override - Future> getAllScenesAsList() async { - return _allScenes.values.toList(); - } - - @override - Future> getAllScenesAsMap() async { - return _allScenes; - } - - @override - Future> - saveAndActivateScenesAndSmartDevicesToDb() async { - await getItCbj().saveAndActivateSmartDevicesToDb(); - - // TODO: Fix after new cbj_integrations_controller - // return getItCbj().saveScenes( - // sceneList: List.from(_allScenes.values), - // ); - return left(const LocalDbFailures.unableToUpdate()); - } - - @override - Future> addNewScene( - SceneCbjEntity sceneCbj, - ) async { - SceneCbjEntity tempSceneCbj = sceneCbj; - - final SceneCbjEntity? existingScene = - findSceneIfAlreadyBeenAdded(tempSceneCbj); - - /// Check if scene already exist - if (existingScene != null) { - tempSceneCbj = - tempSceneCbj.copyWith(nodeRedFlowId: existingScene.nodeRedFlowId); - } - _allScenes.addEntries( - [MapEntry(tempSceneCbj.uniqueId.getOrCrash(), tempSceneCbj)], - ); - - final String entityId = tempSceneCbj.uniqueId.getOrCrash(); - - /// If it is new scene - _allScenes[entityId] = tempSceneCbj; - - String sceneNodeRedFlowId = ''; - - if (existingScene == null || - tempSceneCbj.automationString.getOrCrash() != - existingScene.automationString.getOrCrash()) { - // TODO: Fix after new cbj_integrations_controller - // sceneNodeRedFlowId = - // await getItCbj().createNewNodeRedScene(tempSceneCbj); - } - - if (sceneNodeRedFlowId.isNotEmpty) { - tempSceneCbj = tempSceneCbj.copyWith( - nodeRedFlowId: SceneCbjNodeRedFlowId(sceneNodeRedFlowId), - ); - } - ISavedRoomsRepo.instance.addSceneToRoomDiscoveredIfNotExist(tempSceneCbj); - _allScenes[tempSceneCbj.uniqueId.getOrCrash()] = tempSceneCbj; - return right(sceneNodeRedFlowId); - } - - @override - Future> addNewSceneAndSaveInDb( - SceneCbjEntity sceneCbj, - ) async { - final Either sceneNodeRedFlowId = - await addNewScene(sceneCbj); - await saveAndActivateScenesAndSmartDevicesToDb(); - return sceneNodeRedFlowId; - } - - @override - Future activateScene(SceneCbjEntity sceneCbj) async { - final String fullPathOfScene = await getFullMqttPathOfScene(sceneCbj); - IMqttServerRepository.instance - .publishMessage(fullPathOfScene, DateTime.now().toString()); - - return true; - } - - /// Get entity and return the full MQTT path to it - @override - Future getFullMqttPathOfScene(SceneCbjEntity sceneCbj) async { - final String hubBaseTopic = - IMqttServerRepository.instance.getHubBaseTopic(); - final String scenesTopicTypeName = - IMqttServerRepository.instance.getScenesTopicTypeName(); - final String sceneId = sceneCbj.firstNodeId.getOrCrash()!; - - return '$hubBaseTopic/$scenesTopicTypeName/$sceneId'; - } - - /// Check if all scenes does not contain the same scene already - /// Will compare the unique id's that each company sent us - SceneCbjEntity? findSceneIfAlreadyBeenAdded( - SceneCbjEntity sceneEntity, - ) { - return _allScenes[sceneEntity.uniqueId.getOrCrash()]; - } - - @override - Future> addOrUpdateNewSceneInHub( - SceneCbjEntity sceneCbjEntity, - ) async { - SceneCbjEntity sceneCbjEntityTemp = sceneCbjEntity; - final String sceneId = sceneCbjEntityTemp.uniqueId.getOrCrash(); - String nodeRedFlowId = ''; - - (await addNewSceneAndSaveInDb(sceneCbjEntityTemp)).fold((l) {}, (r) { - nodeRedFlowId = r; - }); - - if (nodeRedFlowId.isNotEmpty) { - sceneCbjEntityTemp = sceneCbjEntityTemp.copyWith( - nodeRedFlowId: SceneCbjNodeRedFlowId(nodeRedFlowId), - ); - } else { - final SceneCbjEntity? tempScene = - findSceneIfAlreadyBeenAdded(sceneCbjEntityTemp); - if (tempScene != null) { - sceneCbjEntityTemp = - sceneCbjEntityTemp.copyWith(nodeRedFlowId: tempScene.nodeRedFlowId); - // TODO: Fix after new cbj_integrations_controller - // nodeRedFlowId = await getItCbj() - // .createNewNodeRedScene(sceneCbjEntityTemp); - - sceneCbjEntityTemp = sceneCbjEntityTemp.copyWith( - nodeRedFlowId: SceneCbjNodeRedFlowId(nodeRedFlowId), - ); - } - } - - _allScenes[sceneId] = sceneCbjEntityTemp; - - saveAndActivateScenesAndSmartDevicesToDb(); - - AppCommunicationRepository.sendAllScenesFromHubRequestsStream(); - - return right(sceneCbjEntityTemp); - } - - @override - Future> - addOrUpdateNewSceneInHubFromDevicesPropertyActionList( - String sceneName, - List>> - smartDevicesWithActionToAdd, - AreaPurposesTypes areaPurposesTypes, - ) async { - final String colorForArea = - AreaTypeWithDeviceTypePreset.getColorForAreaType(areaPurposesTypes); - - final SceneCbjEntity newCbjScene = NodeRedConverter.convertToSceneNodes( - nodeName: sceneName, - devicesPropertyAction: smartDevicesWithActionToAdd, - sceneColor: colorForArea, - ); - return addOrUpdateNewSceneInHub(newCbjScene); - } - - @override - Future> activateScenes( - KtList scenesList, - ) async { - for (final SceneCbjEntity sceneCbjEntity in scenesList.asList()) { - addOrUpdateNewSceneInHub( - sceneCbjEntity.copyWith( - entityStateGRPC: SceneCbjDeviceStateGRPC( - EntityStateGRPC.waitingInCloud.toString(), - ), - ), - ); - } - return right(unit); - } - - @override - void addOrUpdateNewSceneInApp(SceneCbjEntity sceneCbj) { - _allScenes[sceneCbj.uniqueId.getOrCrash()] = sceneCbj; - - scenesResponseFromTheHubStreamController.sink - .add(_allScenes.values.toImmutableList()); - } - - @override - Future initiateHubConnection() async {} - - @override - Stream>> - watchAllScenes() async* { - yield* scenesResponseFromTheHubStreamController.stream - .map((event) => right(event)); - } - - @override - BehaviorSubject> - scenesResponseFromTheHubStreamController = - BehaviorSubject>(); - - @override - Future> - addDevicesToMultipleScenesAreaTypeWithPreSetActions({ - required List devicesId, - required List scenesId, - required List areaTypes, - }) async { - final List> areaTypeWithSceneIdList = - []; - - for (final String sceneId in scenesId) { - if (_allScenes[sceneId] == null) { - logger.w('Scene ID does not exist in saved scenes list\n $sceneId'); - continue; - } - final SceneCbjEntity sceneCbjEntity = _allScenes[sceneId]!; - - final AreaPurposesTypes? areaTypeForScene = - SavedRoomsRepo.getAreaTypeFromNameCapsWithSpcaes( - sceneCbjEntity.name.getOrCrash(), - ); - - if (areaTypeForScene != null) { - areaTypeWithSceneIdList.add(MapEntry(sceneId, areaTypeForScene)); - } - } - - for (final MapEntry areaTypeWithSceneId - in areaTypeWithSceneIdList) { - addDevicesToSceneAreaTypeWithPreSetActions( - devicesId: devicesId, - sceneId: areaTypeWithSceneId.key, - areaType: areaTypeWithSceneId.value, - ); - } - - return right(unit); - } - - @override - Future> - addDevicesToSceneAreaTypeWithPreSetActions({ - required List devicesId, - required String sceneId, - required AreaPurposesTypes areaType, - }) async { - SceneCbjEntity? scene = _allScenes[sceneId]; - - if (scene == null || scene.automationString.getOrCrash() == null) { - return left(const SceneCbjFailure.unexpected()); - } - - final String sceneAutomationString = scene.automationString.getOrCrash()!; - late String brokerNodeId; - try { - final String? tempValue = getPropertyValueFromAutomation( - sceneAutomationString, - 'mqtt-broker', - 'id', - ); - if (tempValue == null) { - return left(const SceneCbjFailure.unexpected()); - } - brokerNodeId = tempValue; - } catch (e) { - logger.e('Error decoding automation string\n$sceneAutomationString'); - } - final Map nodeActionsMap = {}; - final List nodeRedFuncNodesIds = []; - - for (final String deviceId in devicesId) { - if (!scene.automationString.getOrCrash()!.contains(deviceId)) { - // TODO: change to List so that each type will be able to create multiple scenes - final Either> - actionForDevicesInArea = await AreaTypeWithDeviceTypePreset - .getPreDefineActionForDeviceInArea( - deviceId: deviceId, - areaPurposeType: areaType, - brokerNodeId: brokerNodeId, - ); - if (actionForDevicesInArea.isRight()) { - actionForDevicesInArea.fold( - (l) => null, - (Map r) { - nodeActionsMap.addAll(r); - nodeRedFuncNodesIds.addAll(r.keys); - }, - ); - } - } - } - - final String colorForArea = - AreaTypeWithDeviceTypePreset.getColorForAreaType(areaType); - - // Removing start and end curly braces of the map object - - final String sceneAutomationStringNoBrackets = - sceneAutomationString.substring(1, sceneAutomationString.length - 1); - - // Using nodeActionsMap.values.toString() some times creates wrong string with 3 dots that looks like that - // "wires": [] - // }, ..., { - // "id": , - List nodActionsMapValues = []; - if (nodeActionsMap.values.isNotEmpty) { - nodActionsMapValues = nodeActionsMap.values.toList(); - } - - String mapAutomationFixed = ''; - for (final String actionValue in nodActionsMapValues) { - mapAutomationFixed += actionValue; - if (actionValue != nodActionsMapValues.last) { - mapAutomationFixed += ", "; - } - } - - String tempNewAutomation; - if (mapAutomationFixed.isEmpty) { - tempNewAutomation = '[\n$sceneAutomationStringNoBrackets\n]'; - } else { - /// Add all automations id (functions) to mqttIn wires - String nodeIdsToAddToMqttIn = nodeRedFuncNodesIds - .toString() - .substring(1, nodeRedFuncNodesIds.toString().length - 1); - nodeIdsToAddToMqttIn = - '"${nodeIdsToAddToMqttIn.replaceAll(', ', '", "')}"'; - final String mapAutomationFixedWithNewWires = - changePropertyValueInAutomation( - sceneAutomationStringNoBrackets, - 'mqtt in', - 'wires', - '[[$nodeIdsToAddToMqttIn]]', - ); - tempNewAutomation = - '[\n$mapAutomationFixedWithNewWires, $mapAutomationFixed\n]'; - } - scene = scene.copyWith( - automationString: SceneCbjAutomationString(tempNewAutomation), - backgroundColor: SceneCbjBackgroundColor(colorForArea), - ); - - String nodeRedFlowId = ''; - - (await addNewSceneAndSaveInDb(scene)).fold((l) {}, (r) { - nodeRedFlowId = r; - }); - - if (nodeRedFlowId.isNotEmpty) { - scene = - scene.copyWith(nodeRedFlowId: SceneCbjNodeRedFlowId(nodeRedFlowId)); - } else { - final SceneCbjEntity? tempScene = findSceneIfAlreadyBeenAdded(scene); - if (tempScene != null) { - scene = scene.copyWith(nodeRedFlowId: tempScene.nodeRedFlowId); - - // TODO: Fix after new cbj_integrations_controller - // nodeRedFlowId = - // await getItCbj().createNewNodeRedScene(scene); - - scene = - scene.copyWith(nodeRedFlowId: SceneCbjNodeRedFlowId(nodeRedFlowId)); - } - } - - _allScenes[sceneId] = scene; - - saveAndActivateScenesAndSmartDevicesToDb(); - - //TODO: add to the automationString part the new automation for devices String from actionForDevicesInArea and connect all to first node id - return right(scene); - } - - static String? getPropertyValueFromAutomation( - String sceneAutomationString, - String nodeType, - String keyToGetFromNode, - ) { - try { - final List> sceneAutomationJson = - (jsonDecode(sceneAutomationString) as List) - .map((e) => e as Map) - .toList(); - for (final Map fullNode in sceneAutomationJson) { - if (fullNode['type'] == nodeType) { - return fullNode[keyToGetFromNode].toString(); - } - } - } catch (e) { - logger.e('Error decoding automation string\n$sceneAutomationString'); - } - return null; - } - - static String changePropertyValueInAutomation( - String sceneAutomationString, - String nodeType, - String keyToChange, - String valueToInsert, - ) { - try { - final int locationOfNodeType = - sceneAutomationString.indexOf('"type": "$nodeType",'); - final String sceneAutomationStringBeforeType = - sceneAutomationString.substring(0, locationOfNodeType); - final String sceneAutomationStringAfterType = - sceneAutomationString.substring(locationOfNodeType); - - final int locationOfKeyToChange = - sceneAutomationStringAfterType.indexOf('"$keyToChange"'); - final String sceneAutomationStringBeforeKey = - sceneAutomationStringAfterType.substring(0, locationOfKeyToChange); - String sceneAutomationStringAfterKey = - sceneAutomationStringAfterType.substring(locationOfKeyToChange); - sceneAutomationStringAfterKey = sceneAutomationStringAfterKey - .substring(sceneAutomationStringAfterKey.indexOf('},')); - - final String finalString = - '$sceneAutomationStringBeforeType$sceneAutomationStringBeforeKey"$keyToChange": $valueToInsert\n$sceneAutomationStringAfterKey'; - return finalString; - } catch (e) { - logger.e( - 'Wrong node or key in node $sceneAutomationString $nodeType $keyToChange $valueToInsert\n $e', - ); - } - return sceneAutomationString; - } -} diff --git a/lib/infrastructure/shared_variables.dart b/lib/infrastructure/shared_variables.dart deleted file mode 100644 index 2472c19b..00000000 --- a/lib/infrastructure/shared_variables.dart +++ /dev/null @@ -1,54 +0,0 @@ -import 'dart:io'; - -import 'package:cbj_hub/utils.dart'; -import 'package:injectable/injectable.dart'; - -@singleton -class SharedVariables { - Future asyncConstractor(String projectRootDirectoryPath) async { - _projectRootDirectoryPath = projectRootDirectoryPath; - logger.t('PATH: $_projectRootDirectoryPath'); - } - - /// Save the location of all the files that were created during the snapcraft - late String _projectRootDirectoryPath; - - String getProjectRootDirectoryPath() => _projectRootDirectoryPath; - - /// Getting snap location environment variable value of $SNAP - String? getSnapLocationEnvironmentVariable() { - if (!_projectRootDirectoryPath.contains('/snap/')) { - return null; - } - return '/snap/cbj-hub/current'; - } - - /// Getting snap common environment variable value of SNAP_COMMON - String? getSnapCommonEnvironmentVariable() { - if (!_projectRootDirectoryPath.contains('/snap/')) { - return null; - } - return '/var/snap/cbj-hub/common'; - } - - /// Getting snap user common environment variable, value of $SNAP_USER_COMMON - String? getSnapUserCommonEnvironmentVariable() { - if (!_projectRootDirectoryPath.contains('/snap/')) { - return null; - } - return '/root/snap/cbj-hub/common'; - } - - /// Get Ip info - Future getIps() async { - for (final NetworkInterface interface in await NetworkInterface.list()) { -// print('== Interface: ${interface.name} =='); - for (final InternetAddress address in interface.addresses) { -// print( -// '${addr.address} ${addr.host} ${addr.isLoopback} ${addr.rawAddress} ${addr.type.name}'); - return address.address; - } - } - return null; - } -} diff --git a/pubspec.yaml b/pubspec.yaml index 8a67b5d1..06f1a2f0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -19,11 +19,6 @@ dependencies: compute: ^1.0.2 # Collection of cyclic redundancy check (CRC) routines as Dart converters. crclib: ^3.0.0 - # Interact directly with eWeLink API - dart_ewelink_api: - git: - url: 'https://github.com/guyluz11/dart_ewelink_api.git' - ref: 'develop' # Functional programming thingies, let you use multiple return types dartz: ^0.10.1 # Allow returning more than one type of object @@ -38,10 +33,6 @@ dependencies: hive: ^2.2.3 # Library for making HTTP requests. http: ^1.1.0 - # Philips Hue API - hue_dart: - git: - url: 'https://github.com/guyluz11/hue_dart.git' # Convenient code generator for get_it injectable: ^2.3.1 # Utility library that checks for an Active Internet connection @@ -54,35 +45,20 @@ dependencies: json_serializable: ^6.7.1 # Port of Kotlin's Kotlin Standard library for Dart/Flutter projects kt_dart: ^1.1.0 - # Implementation of the LIFX HTTP API - lifx_http_api: ^0.0.17 # Small, easy to use and extensible logger which prints beautiful logs. logger: ^2.0.2+1 - # A server and browser based MQTT client for Dart. - mi_iot_token: ^1.1.0 # Server and browser based MQTT client mqtt_client: ^10.0.0 # Service discovery over multicast DNS (mDNS), Bonjour, and Avahi. multicast_dns: ^0.3.2+4 # Helps you discover open ports, devices on subnet and more. network_tools: ^4.0.1 - # Interact directly with NodeRED API - nodered: ^1.0.1+1 # Provides runtime support for a Dart implementation of protobufs. protobuf: ^3.1.0 - # Python Environment Manager and Executor for dart and flutter - python_shell: - git: 'https://github.com/guyluz11/python_shell.dart.git' # Extends the capabilities of Dart Streams and StreamControllers. rxdart: ^0.27.7 - # Communicate with Shelly smart devices - shelly: ^1.0.0 - # Control Switcher smart home accessories - switcher_dart: ^1.0.0 # Simple, fast generation of RFC4122 UUIDs. uuid: ^4.1.0 - # Dart library for controlling Yeelight products over LAN. - yeedart: ^0.3.2 dependency_overrides: # Defines the annotations used by json_serializable @@ -91,6 +67,7 @@ dependency_overrides: dev_dependencies: # A build system for Dart code generation and modular compilation. build_runner: + # A generator for injectable library # Code generator for unions/pattern-matching/copy. freezed: ^2.4.1 From f001370d273ffa19dfcd096f4844368e114846fb Mon Sep 17 00:00:00 2001 From: Guy Luz Date: Sat, 14 Oct 2023 20:10:01 +0300 Subject: [PATCH 13/18] Fixed changes needed for cbj_integrations_controller with the app --- bin/cbj_hub.dart | 2 ++ lib/injection.config.dart | 71 --------------------------------------- pubspec.yaml | 2 -- 3 files changed, 2 insertions(+), 73 deletions(-) delete mode 100644 lib/injection.config.dart diff --git a/bin/cbj_hub.dart b/bin/cbj_hub.dart index beba9b65..e8e946eb 100644 --- a/bin/cbj_hub.dart +++ b/bin/cbj_hub.dart @@ -9,6 +9,7 @@ import 'package:cbj_integrations_controller/infrastructure/routines/routine_repo import 'package:cbj_integrations_controller/infrastructure/saved_devices/saved_devices_repo.dart'; import 'package:cbj_integrations_controller/infrastructure/scenes/scene_repository.dart'; import 'package:cbj_integrations_controller/infrastructure/shared_variables.dart'; +import 'package:cbj_integrations_controller/infrastructure/system_commands/system_commands_manager_d.dart'; import 'package:cbj_integrations_controller/initialize_integrations_controller.dart'; import 'package:cbj_integrations_controller/injection.dart'; import 'package:network_tools/network_tools.dart' as network; @@ -24,6 +25,7 @@ Future main(List arguments) async { /// All instances of Repos void setInstancesOfRepos() { + SystemCommandsManager(); MqttServerRepository(); CbjWebServerRepository(); SavedRoomsRepo(); diff --git a/lib/injection.config.dart b/lib/injection.config.dart deleted file mode 100644 index 01b5a25b..00000000 --- a/lib/injection.config.dart +++ /dev/null @@ -1,71 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -// ************************************************************************** -// InjectableConfigGenerator -// ************************************************************************** - -// ignore_for_file: unnecessary_lambdas -// ignore_for_file: lines_longer_than_80_chars -// coverage:ignore-file - -// ignore_for_file: no_leading_underscores_for_library_prefixes -import 'package:cbj_hub/domain/app_communication/i_app_communication_repository.dart' - as _i3; -import 'package:cbj_hub/domain/binding/i_binding_cbj_repository.dart' as _i5; -import 'package:cbj_hub/domain/cbj_web_server/i_cbj_web_server_repository.dart' - as _i7; -import 'package:cbj_hub/domain/rooms/i_saved_rooms_repo.dart' as _i15; -import 'package:cbj_hub/domain/routine/i_routine_cbj_repository.dart' as _i11; -import 'package:cbj_hub/domain/scene/i_scene_cbj_repository.dart' as _i17; -import 'package:cbj_hub/infrastructure/app_communication/app_communication_repository.dart' - as _i4; -import 'package:cbj_hub/infrastructure/bindings/binding_repository.dart' as _i6; -import 'package:cbj_hub/infrastructure/cbj_web_server/cbj_web_server_repository.dart' - as _i8; -import 'package:cbj_hub/infrastructure/mqtt_server/mqtt_server_repository.dart' - as _i10; -import 'package:cbj_hub/infrastructure/node_red/node_red_repository.dart' - as _i19; -import 'package:cbj_hub/infrastructure/room/saved_rooms_repo.dart' as _i16; -import 'package:cbj_hub/infrastructure/routines/routine_repository.dart' - as _i12; -import 'package:cbj_hub/infrastructure/saved_devices/saved_devices_repo.dart' - as _i14; -import 'package:cbj_hub/infrastructure/scenes/scene_repository.dart' as _i18; -import 'package:cbj_hub/infrastructure/shared_variables.dart' as _i20; -import 'package:cbj_integrations_controller/domain/mqtt_server/i_mqtt_server_repository.dart' - as _i9; -import 'package:cbj_integrations_controller/domain/saved_devices/i_saved_devices_repo.dart' - as _i13; -import 'package:get_it/get_it.dart' as _i1; -import 'package:injectable/injectable.dart' as _i2; - -extension GetItInjectableX on _i1.GetIt { -// initializes the registration of main-scope dependencies inside of GetIt - _i1.GetIt init({ - String? environment, - _i2.EnvironmentFilter? environmentFilter, - }) { - final gh = _i2.GetItHelper( - this, - environment, - environmentFilter, - ); - gh.lazySingleton<_i3.IAppCommunicationRepository>( - () => _i4.AppCommunicationRepository()); - gh.lazySingleton<_i5.IBindingCbjRepository>( - () => _i6.BindingCbjRepository()); - gh.lazySingleton<_i7.ICbjWebServerRepository>( - () => _i8.CbjWebServerRepository()); - gh.lazySingleton<_i9.IMqttServerRepository>( - () => _i10.MqttServerRepository()); - gh.lazySingleton<_i11.IRoutineCbjRepository>( - () => _i12.RoutineCbjRepository()); - gh.lazySingleton<_i13.ISavedDevicesRepo>(() => _i14.SavedDevicesRepo()); - gh.lazySingleton<_i15.ISavedRoomsRepo>(() => _i16.SavedRoomsRepo()); - gh.lazySingleton<_i17.ISceneCbjRepository>(() => _i18.SceneCbjRepository()); - gh.lazySingleton<_i19.NodeRedRepository>(() => _i19.NodeRedRepository()); - gh.singleton<_i20.SharedVariables>(_i20.SharedVariables()); - return this; - } -} diff --git a/pubspec.yaml b/pubspec.yaml index 06f1a2f0..205152b5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -51,8 +51,6 @@ dependencies: mqtt_client: ^10.0.0 # Service discovery over multicast DNS (mDNS), Bonjour, and Avahi. multicast_dns: ^0.3.2+4 - # Helps you discover open ports, devices on subnet and more. - network_tools: ^4.0.1 # Provides runtime support for a Dart implementation of protobufs. protobuf: ^3.1.0 # Extends the capabilities of Dart Streams and StreamControllers. From 32383a2b6f9a0fc8d3abb4fc8993bc0bd33ccdc3 Mon Sep 17 00:00:00 2001 From: Guy Luz Date: Sat, 14 Oct 2023 20:47:05 +0300 Subject: [PATCH 14/18] Using cbj_integrations_controller from git --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 205152b5..5516967c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,7 +12,7 @@ dependencies: # Contains utility classes in the style of dart:async to work with asynchronous computations. async: ^2.11.0 cbj_integrations_controller: - path: ../cbj_integrations_controller + git: https://github.com/CyBear-Jinni/cbj_integrations_controller.git # Package to create, convert, alter, and compare colors in a variety of colorspaces. color: ^3.0.0 # Compute function made available for all non-Flutter Dart programs From 8452864f1aecba9e47181e84631cb554b875dccb Mon Sep 17 00:00:00 2001 From: Guy Luz Date: Sun, 15 Oct 2023 01:54:44 +0300 Subject: [PATCH 15/18] Removed some lint warnings --- .../app_communication/app_communication_repository.dart | 5 ++--- pubspec.yaml | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/infrastructure/app_communication/app_communication_repository.dart b/lib/infrastructure/app_communication/app_communication_repository.dart index fed94f4c..947b2ab6 100644 --- a/lib/infrastructure/app_communication/app_communication_repository.dart +++ b/lib/infrastructure/app_communication/app_communication_repository.dart @@ -2,7 +2,6 @@ import 'dart:async'; import 'dart:convert'; import 'package:cbj_hub/domain/app_communication/i_app_communication_repository.dart'; -import 'package:cbj_hub/domain/remote_pipes/remote_pipes_entity.dart'; import 'package:cbj_hub/infrastructure/app_communication/hub_app_server.dart'; import 'package:cbj_hub/infrastructure/remote_pipes/remote_pipes_client.dart'; import 'package:cbj_hub/infrastructure/remote_pipes/remote_pipes_dtos.dart'; @@ -160,9 +159,9 @@ class AppCommunicationRepository extends IAppCommunicationRepository { } else if (event.sendingType == SendingType.remotePipesInformation) { final Map jsonDecoded = jsonDecode(event.allRemoteCommands) as Map; - final RemotePipesEntity remotePipes = - RemotePipesDtos.fromJson(jsonDecoded).toDomain(); // TODO: Fix after new cbj_integrations_controller + // final RemotePipesEntity remotePipes = + RemotePipesDtos.fromJson(jsonDecoded).toDomain(); // ISavedDevicesRepo.instance // .saveAndActivateRemotePipesDomainToDb(remotePipes: remotePipes); } else if (event.sendingType == SendingType.sceneType) { diff --git a/pubspec.yaml b/pubspec.yaml index 5516967c..325db32e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -51,6 +51,8 @@ dependencies: mqtt_client: ^10.0.0 # Service discovery over multicast DNS (mDNS), Bonjour, and Avahi. multicast_dns: ^0.3.2+4 + # Helps you discover open ports, devices on subnet and more. + network_tools: ^4.0.1 # Provides runtime support for a Dart implementation of protobufs. protobuf: ^3.1.0 # Extends the capabilities of Dart Streams and StreamControllers. From dfef1494dd88972a407aa0bf8232e09344315742 Mon Sep 17 00:00:00 2001 From: Guy Luz Date: Tue, 7 Nov 2023 11:36:06 +0200 Subject: [PATCH 16/18] Removed injectable package --- .../app_communication_repository.dart | 11 --------- .../app_communication/hub_app_server.dart | 4 ---- lib/injection.dart | 23 ------------------- pubspec.yaml | 8 ------- 4 files changed, 46 deletions(-) delete mode 100644 lib/injection.dart diff --git a/lib/infrastructure/app_communication/app_communication_repository.dart b/lib/infrastructure/app_communication/app_communication_repository.dart index 947b2ab6..e618a5ba 100644 --- a/lib/infrastructure/app_communication/app_communication_repository.dart +++ b/lib/infrastructure/app_communication/app_communication_repository.dart @@ -348,14 +348,3 @@ class HubRequestsToApp { static BehaviorSubject streamRequestsToApp = BehaviorSubject(); } - -/// Requests and updates from app to the hub -class AppRequestsToHub { - /// Stream controller of the requests from the hub - static final appRequestsToHubStreamController = - StreamController(); - - /// Stream of the requests from the hub - static Stream get appRequestsToHubStream => - appRequestsToHubStreamController.stream; -} diff --git a/lib/infrastructure/app_communication/hub_app_server.dart b/lib/infrastructure/app_communication/hub_app_server.dart index ac6fe575..bdef519e 100644 --- a/lib/infrastructure/app_communication/hub_app_server.dart +++ b/lib/infrastructure/app_communication/hub_app_server.dart @@ -15,10 +15,6 @@ import 'package:grpc/service_api.dart'; /// Server to get and send information to the app class HubAppServer extends CbjHubServiceBase { - /// The app call this method and getting stream of all the changes of the - /// internet devices - Stream> streamOfChanges() async* {} - @override Stream clientTransferEntities( ServiceCall call, diff --git a/lib/injection.dart b/lib/injection.dart deleted file mode 100644 index a10cd1cf..00000000 --- a/lib/injection.dart +++ /dev/null @@ -1,23 +0,0 @@ -// import 'package:cbj_hub/injection.config.dart'; -// import 'package:cbj_hub/utils.dart'; -// import 'package:get_it/get_it.dart'; -// import 'package:injectable/injectable.dart'; -// -// final getIt = GetIt.instance; -// -// /// Saves the current environment for manual use -// late String currentEnv; -// -// @injectableInit -// Future configureInjection(String environment) async { -// currentEnv = environment; -// logger.i('Current CyBear Jinni Hub environment name: $currentEnv'); -// getIt.init(environment: environment); -// } -// -// abstract class Env { -// static const String test = 'test'; -// static const String devPc = 'dev_pc'; -// static const String devPi = 'dev_pi'; -// static const String prod = 'prod'; -// } diff --git a/pubspec.yaml b/pubspec.yaml index 325db32e..077af920 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -33,8 +33,6 @@ dependencies: hive: ^2.2.3 # Library for making HTTP requests. http: ^1.1.0 - # Convenient code generator for get_it - injectable: ^2.3.1 # Utility library that checks for an Active Internet connection internet_connection_checker: ^1.0.0+1 # Extremely fast, easy to use, and fully async NoSQL database. @@ -60,10 +58,6 @@ dependencies: # Simple, fast generation of RFC4122 UUIDs. uuid: ^4.1.0 -dependency_overrides: - # Defines the annotations used by json_serializable - get_it: ^7.6.0 - dev_dependencies: # A build system for Dart code generation and modular compilation. build_runner: @@ -73,8 +67,6 @@ dev_dependencies: freezed: ^2.4.1 # Automatically generates Hive TypeAdapters to store any class hive_generator: ^2.0.1 - # Injectable is a convenient code generator for get _it. - injectable_generator: ^2.4.0 # Code generator for the Isar Database. Finds classes annotated with @Collection. # isar_generator: ^3.0.5 # Collection of lint rules for Dart and Flutter projects From 70f39f8e03daa0ecbd2178557fd51e9965c11fdd Mon Sep 17 00:00:00 2001 From: Guy Luz Date: Thu, 9 Nov 2023 00:05:21 +0200 Subject: [PATCH 17/18] Reverted to network_tools: ^3.2.1 --- bin/cbj_hub.dart | 11 ++++++----- pubspec.yaml | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/bin/cbj_hub.dart b/bin/cbj_hub.dart index e8e946eb..c56f0272 100644 --- a/bin/cbj_hub.dart +++ b/bin/cbj_hub.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:cbj_hub/application/boot_up/boot_up.dart'; import 'package:cbj_hub/infrastructure/cbj_web_server/cbj_web_server_repository.dart'; import 'package:cbj_hub/infrastructure/mqtt_server/mqtt_server_repository.dart'; @@ -12,19 +14,18 @@ import 'package:cbj_integrations_controller/infrastructure/shared_variables.dart import 'package:cbj_integrations_controller/infrastructure/system_commands/system_commands_manager_d.dart'; import 'package:cbj_integrations_controller/initialize_integrations_controller.dart'; import 'package:cbj_integrations_controller/injection.dart'; -import 'package:network_tools/network_tools.dart' as network; Future main(List arguments) async { - setInstancesOfRepos(); + setInstancesOfRepos(arguments.firstOrNull ?? Directory.current.path); // arguments[0] is the location of the project - network.configureNetworkTools('network_tools_db'); + // network.configureNetworkTools('network_tools_db'); await initializeIntegrationsController(arguments: arguments, env: Env.devPc); await BootUp.setup(); } /// All instances of Repos -void setInstancesOfRepos() { +void setInstancesOfRepos(String projectRootDirectoryPath) { SystemCommandsManager(); MqttServerRepository(); CbjWebServerRepository(); @@ -35,5 +36,5 @@ void setInstancesOfRepos() { NodeRedRepository(); BindingCbjRepository(); SceneCbjRepository(); - SharedVariables(); + SharedVariables(projectRootDirectoryPath); } diff --git a/pubspec.yaml b/pubspec.yaml index 077af920..56b33ae5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -50,7 +50,7 @@ dependencies: # Service discovery over multicast DNS (mDNS), Bonjour, and Avahi. multicast_dns: ^0.3.2+4 # Helps you discover open ports, devices on subnet and more. - network_tools: ^4.0.1 + network_tools: ^3.2.1 # Provides runtime support for a Dart implementation of protobufs. protobuf: ^3.1.0 # Extends the capabilities of Dart Streams and StreamControllers. From 45a0a79db5ddd277ce9aa49d2b20f705a8f23094 Mon Sep 17 00:00:00 2001 From: Guy Luz Date: Thu, 9 Nov 2023 21:53:42 +0200 Subject: [PATCH 18/18] Updated packages --- bin/cbj_hub.dart | 9 +++++++-- pubspec.yaml | 10 +++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/bin/cbj_hub.dart b/bin/cbj_hub.dart index c56f0272..49ecf7f8 100644 --- a/bin/cbj_hub.dart +++ b/bin/cbj_hub.dart @@ -14,12 +14,17 @@ import 'package:cbj_integrations_controller/infrastructure/shared_variables.dart import 'package:cbj_integrations_controller/infrastructure/system_commands/system_commands_manager_d.dart'; import 'package:cbj_integrations_controller/initialize_integrations_controller.dart'; import 'package:cbj_integrations_controller/injection.dart'; +import 'package:network_tools/network_tools.dart'; Future main(List arguments) async { + configureNetworkTools('network_tools_db'); + setInstancesOfRepos(arguments.firstOrNull ?? Directory.current.path); // arguments[0] is the location of the project - // network.configureNetworkTools('network_tools_db'); - await initializeIntegrationsController(arguments: arguments, env: Env.devPc); + await initializeIntegrationsController( + projectRootDirectoryPath: arguments.firstOrNull ?? Directory.current.path, + env: Env.devPc, + ); await BootUp.setup(); } diff --git a/pubspec.yaml b/pubspec.yaml index 56b33ae5..f88b9887 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -50,13 +50,13 @@ dependencies: # Service discovery over multicast DNS (mDNS), Bonjour, and Avahi. multicast_dns: ^0.3.2+4 # Helps you discover open ports, devices on subnet and more. - network_tools: ^3.2.1 + network_tools: ^4.0.1 # Provides runtime support for a Dart implementation of protobufs. protobuf: ^3.1.0 # Extends the capabilities of Dart Streams and StreamControllers. rxdart: ^0.27.7 # Simple, fast generation of RFC4122 UUIDs. - uuid: ^4.1.0 + uuid: ^4.2.1 dev_dependencies: # A build system for Dart code generation and modular compilation. @@ -64,14 +64,14 @@ dev_dependencies: # A generator for injectable library # Code generator for unions/pattern-matching/copy. - freezed: ^2.4.1 + freezed: ^2.4.5 # Automatically generates Hive TypeAdapters to store any class hive_generator: ^2.0.1 # Code generator for the Isar Database. Finds classes annotated with @Collection. # isar_generator: ^3.0.5 # Collection of lint rules for Dart and Flutter projects - lint: ^2.1.2 + lint: ^2.2.0 # Library for mocks mockito: ^5.4.2 # A full featured library for writing and running Dart tests across platforms. - test: ^1.24.7 + test: ^1.24.9