@homebridge-plugins/homebridge-tuya 3.0.0-beta.3 → 3.0.0-beta.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +364 -142
- package/config.schema.json +1299 -894
- package/dist/cloud/api/TuyaOpenAPI.js +108 -60
- package/dist/cloud/api/TuyaOpenAPI.js.map +1 -1
- package/dist/cloud/api/TuyaOpenMQ.js +45 -22
- package/dist/cloud/api/TuyaOpenMQ.js.map +1 -1
- package/dist/cloud/device/{TuyaDeviceManager.js → TuyaCloudDeviceManager.js} +146 -96
- package/dist/cloud/device/TuyaCloudDeviceManager.js.map +1 -0
- package/dist/cloud/device/TuyaCustomDeviceManager.js +75 -5
- package/dist/cloud/device/TuyaCustomDeviceManager.js.map +1 -1
- package/dist/cloud/device/TuyaDevice.js.map +1 -1
- package/dist/cloud/device/TuyaHomeDeviceManager.js +81 -13
- package/dist/cloud/device/TuyaHomeDeviceManager.js.map +1 -1
- package/dist/config.js +26 -5
- package/dist/config.js.map +1 -1
- package/dist/local/DynamicChildDiscovery.js +2 -1
- package/dist/local/DynamicChildDiscovery.js.map +1 -1
- package/dist/local/LocalDevice.js +108 -11
- package/dist/local/LocalDevice.js.map +1 -1
- package/dist/local/LocalDeviceManager.js +362 -177
- package/dist/local/LocalDeviceManager.js.map +1 -1
- package/dist/local/TuyaDiscovery.js +17 -8
- package/dist/local/TuyaDiscovery.js.map +1 -1
- package/dist/local/ZigbeeGatewayDetection.js +7 -4
- package/dist/local/ZigbeeGatewayDetection.js.map +1 -1
- package/dist/local/protocol/ProtocolUtilities.js +61 -27
- package/dist/local/protocol/ProtocolUtilities.js.map +1 -1
- package/dist/local/protocol/ProtocolV31V32.js +61 -11
- package/dist/local/protocol/ProtocolV31V32.js.map +1 -1
- package/dist/local/protocol/ProtocolV33.js +4 -2
- package/dist/local/protocol/ProtocolV33.js.map +1 -1
- package/dist/local/protocol/ProtocolV34.js +10 -5
- package/dist/local/protocol/ProtocolV34.js.map +1 -1
- package/dist/local/protocol/ProtocolV35.js +17 -6
- package/dist/local/protocol/ProtocolV35.js.map +1 -1
- package/dist/platform.js +263 -497
- package/dist/platform.js.map +1 -1
- package/dist/settings.js +0 -2
- package/dist/settings.js.map +1 -1
- package/dist/shared/TuyaDeviceManager.js +147 -0
- package/dist/shared/TuyaDeviceManager.js.map +1 -0
- package/dist/shared/TuyaHybridDeviceManager.js +219 -0
- package/dist/shared/TuyaHybridDeviceManager.js.map +1 -0
- package/dist/shared/accessory/AccessoryFactory.js +359 -0
- package/dist/shared/accessory/AccessoryFactory.js.map +1 -0
- package/dist/shared/{accessories → accessory}/AirConditionerAccessory.js +129 -23
- package/dist/shared/accessory/AirConditionerAccessory.js.map +1 -0
- package/dist/shared/{accessories → accessory}/AirPurifierAccessory.js.map +1 -1
- package/dist/shared/accessory/AirQualitySensorAccessory.js.map +1 -0
- package/dist/shared/{accessories → accessory}/BaseAccessory.js +47 -97
- package/dist/shared/accessory/BaseAccessory.js.map +1 -0
- package/dist/shared/{accessories → accessory}/BlindsAccessory.js.map +1 -1
- package/dist/shared/{accessories → accessory}/CameraAccessory.js +9 -3
- package/dist/shared/accessory/CameraAccessory.js.map +1 -0
- package/dist/shared/{accessories → accessory}/CarbonDioxideSensorAccessory.js.map +1 -1
- package/dist/shared/{accessories → accessory}/CarbonMonoxideSensorAccessory.js.map +1 -1
- package/dist/shared/accessory/CatToiletAccessory.js +130 -0
- package/dist/shared/accessory/CatToiletAccessory.js.map +1 -0
- package/dist/shared/{accessories → accessory}/ContactSensorAccessory.js.map +1 -1
- package/dist/shared/{accessories → accessory}/DehumidifierAccessory.js.map +1 -1
- package/dist/shared/{accessories → accessory}/DiffuserAccessory.js.map +1 -1
- package/dist/shared/{accessories → accessory}/DimmerAccessory.js.map +1 -1
- package/dist/shared/{accessories → accessory}/DoorbellAccessory.js.map +1 -1
- package/dist/shared/{accessories → accessory}/ExtractionHoodAccessory.js.map +1 -1
- package/dist/shared/{accessories → accessory}/FanAccessory.js +16 -4
- package/dist/shared/accessory/FanAccessory.js.map +1 -0
- package/dist/shared/{accessories → accessory}/GarageDoorAccessory.js +19 -2
- package/dist/shared/accessory/GarageDoorAccessory.js.map +1 -0
- package/dist/shared/{accessories → accessory}/HeaterAccessory.js +3 -0
- package/dist/shared/accessory/HeaterAccessory.js.map +1 -0
- package/dist/shared/{accessories → accessory}/HeaterAccessory_old.js.map +1 -1
- package/dist/shared/accessory/HumanPresenceSensorAccessory.js.map +1 -0
- package/dist/shared/{accessories → accessory}/HumidifierAccessory.js.map +1 -1
- package/dist/shared/accessory/IRAdapter.js +169 -0
- package/dist/shared/accessory/IRAdapter.js.map +1 -0
- package/dist/shared/{accessories → accessory}/IRAirConditionerAccessory.js +2 -2
- package/dist/shared/accessory/IRAirConditionerAccessory.js.map +1 -0
- package/dist/shared/accessory/IRControlHubAccessory.js.map +1 -0
- package/dist/shared/accessory/IRControlHubSubAccessory.js.map +1 -0
- package/dist/shared/accessory/IRFanAccessory.js +109 -0
- package/dist/shared/accessory/IRFanAccessory.js.map +1 -0
- package/dist/shared/accessory/IRGenericAccessory.js.map +1 -0
- package/dist/shared/{accessories → accessory}/LeakSensorAccessory.js.map +1 -1
- package/dist/shared/{accessories → accessory}/LightAccessory.js.map +1 -1
- package/dist/shared/{accessories → accessory}/LightSensorAccessory.js.map +1 -1
- package/dist/shared/{accessories → accessory}/LocationWeatherAccessory.js +9 -36
- package/dist/shared/accessory/LocationWeatherAccessory.js.map +1 -0
- package/dist/shared/{accessories → accessory}/LockAccessory.js +3 -3
- package/dist/shared/{accessories → accessory}/LockAccessory.js.map +1 -1
- package/dist/shared/accessory/MotionSensorAccessory.js.map +1 -0
- package/dist/shared/accessory/OutletAccessory.js.map +1 -0
- package/dist/shared/{accessories → accessory}/PetFeederAccessory.js.map +1 -1
- package/dist/shared/accessory/SaunaAccessory.js +134 -0
- package/dist/shared/accessory/SaunaAccessory.js.map +1 -0
- package/dist/shared/{accessories → accessory}/SceneAccessory.js +1 -1
- package/dist/shared/accessory/SceneAccessory.js.map +1 -0
- package/dist/shared/accessory/SceneSwitchAccessory.js.map +1 -0
- package/dist/shared/{accessories → accessory}/SecuritySystemAccessory.js +4 -4
- package/dist/shared/accessory/SecuritySystemAccessory.js.map +1 -0
- package/dist/shared/{accessories → accessory}/SmokeSensorAccessory.js.map +1 -1
- package/dist/shared/{accessories → accessory}/SwitchAccessory.js +1 -45
- package/dist/shared/accessory/SwitchAccessory.js.map +1 -0
- package/dist/shared/accessory/TemperatureHumiditySensorAccessory.js.map +1 -0
- package/dist/shared/{accessories → accessory}/ThermostatAccessory.js.map +1 -1
- package/dist/shared/{accessories → accessory}/TowerRackAccessory.js.map +1 -1
- package/dist/shared/{accessories → accessory}/ValveAccessory.js.map +1 -1
- package/dist/shared/{accessories → accessory}/VibrationSensorAccessory.js.map +1 -1
- package/dist/shared/accessory/WeatherStationAccessory.js.map +1 -0
- package/dist/shared/accessory/WetBulbGlobeTemperatureAccessory.js.map +1 -0
- package/dist/shared/{accessories → accessory}/WhiteNoiseLightAccessory.js +1 -0
- package/dist/shared/accessory/WhiteNoiseLightAccessory.js.map +1 -0
- package/dist/shared/accessory/WindowAccessory.js.map +1 -0
- package/dist/shared/{accessories → accessory}/WindowCoveringAccessory.js.map +1 -1
- package/dist/shared/{accessories → accessory}/WirelessSwitchAccessory.js.map +1 -1
- package/dist/shared/accessory/characteristic/Active.js.map +1 -0
- package/dist/shared/accessory/characteristic/AirQuality.js.map +1 -0
- package/dist/shared/{accessories → accessory}/characteristic/CurrentRelativeHumidity.js +3 -0
- package/dist/shared/accessory/characteristic/CurrentRelativeHumidity.js.map +1 -0
- package/dist/shared/accessory/characteristic/CurrentTemperature.js.map +1 -0
- package/dist/shared/accessory/characteristic/CurrentWeather.js.map +1 -0
- package/dist/shared/accessory/characteristic/CurrentWeatherByOpenMeteo.js.map +1 -0
- package/dist/shared/{accessories → accessory}/characteristic/CurrentWetBulbGlobeTemperature.js +3 -2
- package/dist/shared/accessory/characteristic/CurrentWetBulbGlobeTemperature.js.map +1 -0
- package/dist/shared/{accessories → accessory}/characteristic/EnergyUsage.js +0 -5
- package/dist/shared/accessory/characteristic/EnergyUsage.js.map +1 -0
- package/dist/shared/accessory/characteristic/EnumOn.js +48 -0
- package/dist/shared/accessory/characteristic/EnumOn.js.map +1 -0
- package/dist/shared/accessory/characteristic/ExtraCharacteristicAdapter.js +197 -0
- package/dist/shared/accessory/characteristic/ExtraCharacteristicAdapter.js.map +1 -0
- package/dist/shared/{accessories → accessory}/characteristic/Light.js +62 -12
- package/dist/shared/accessory/characteristic/Light.js.map +1 -0
- package/dist/shared/accessory/characteristic/LightSensor.js.map +1 -0
- package/dist/shared/{accessories → accessory}/characteristic/LockPhysicalControls.js +3 -0
- package/dist/shared/accessory/characteristic/LockPhysicalControls.js.map +1 -0
- package/dist/shared/accessory/characteristic/MotionDetected.js.map +1 -0
- package/dist/shared/accessory/characteristic/Name.js.map +1 -0
- package/dist/shared/accessory/characteristic/OccupancyDetected.js.map +1 -0
- package/dist/shared/{accessories → accessory}/characteristic/On.js +3 -2
- package/dist/shared/accessory/characteristic/On.js.map +1 -0
- package/dist/shared/accessory/characteristic/OutletInUse.js.map +1 -0
- package/dist/shared/accessory/characteristic/ProgrammableSwitchEvent.js.map +1 -0
- package/dist/shared/accessory/characteristic/RawOn.js +93 -0
- package/dist/shared/accessory/characteristic/RawOn.js.map +1 -0
- package/dist/shared/{accessories → accessory}/characteristic/RelativeHumidityDehumidifierThreshold.js +3 -0
- package/dist/shared/accessory/characteristic/RelativeHumidityDehumidifierThreshold.js.map +1 -0
- package/dist/shared/accessory/characteristic/RotationSpeed.js +157 -0
- package/dist/shared/accessory/characteristic/RotationSpeed.js.map +1 -0
- package/dist/shared/accessory/characteristic/SecuritySystemState.js.map +1 -0
- package/dist/shared/{accessories → accessory}/characteristic/SwingMode.js +3 -0
- package/dist/shared/accessory/characteristic/SwingMode.js.map +1 -0
- package/dist/shared/accessory/characteristic/TargetTemperature.js.map +1 -0
- package/dist/shared/{accessories → accessory}/characteristic/TemperatureDisplayUnits.js +9 -2
- package/dist/shared/accessory/characteristic/TemperatureDisplayUnits.js.map +1 -0
- package/dist/shared/util/ConfigHash.js +2 -2
- package/dist/shared/util/ConfigHash.js.map +1 -1
- package/dist/shared/util/ConfigMigrator.js +222 -0
- package/dist/shared/util/ConfigMigrator.js.map +1 -0
- package/dist/shared/util/FfmpegStreamingProcess.js +62 -0
- package/dist/shared/util/FfmpegStreamingProcess.js.map +1 -1
- package/dist/shared/util/InfraredTool.js +0 -2
- package/dist/shared/util/InfraredTool.js.map +1 -1
- package/dist/shared/util/Logger.js +85 -10
- package/dist/shared/util/Logger.js.map +1 -1
- package/dist/shared/util/TuyaStreamDelegate.js +201 -99
- package/dist/shared/util/TuyaStreamDelegate.js.map +1 -1
- package/dist/shared/util/color.js +15 -4
- package/dist/shared/util/color.js.map +1 -1
- package/dist/shared/util/util.js +91 -5
- package/dist/shared/util/util.js.map +1 -1
- package/docs/ADVANCED_OPTIONS.md +623 -0
- package/docs/CONFIG_GUIDE.md +616 -0
- package/docs/Get-Local-Keys-for-Your-Devices.md +246 -0
- package/{SUPPORTED_DEVICES.md → docs/SUPPORTED_DEVICES.md} +27 -5
- package/eslint.config.mjs +0 -1
- package/{jest.config.js → jest.config.ts} +5 -2
- package/package.json +14 -11
- package/test/ConfigMigrator.test.ts +1060 -0
- package/test/FanAccessory.test.ts +458 -0
- package/test/Light.test.ts +424 -0
- package/test/Logger.test.ts +482 -0
- package/test/ProtocolV31V32.test.ts +42 -0
- package/test/accessoryFactory.data.test.ts +176 -0
- package/test/accessoryFactory.test.ts +65 -35
- package/test/airConditioner.swing.test.ts +226 -0
- package/test/airConditioner.test.ts +770 -0
- package/test/color.test.ts +52 -0
- package/test/config.test.ts +17 -13
- package/test/custom.test.ts +2 -2
- package/test/errorHandling.test.ts +12 -12
- package/test/fanAccessory.test.ts +458 -0
- package/test/home.test.ts +1 -1
- package/test/hybridDeviceManager.test.ts +808 -0
- package/test/infraredTools.test.ts +67 -0
- package/test/light.test.ts +424 -0
- package/test/localDevice.test.ts +31 -53
- package/test/localDeviceManager.behavior.test.ts +211 -37
- package/test/localDeviceManager.test.ts +124 -41
- package/test/mqttMessages.test.ts +40 -16
- package/test/platform.test.ts +380 -814
- package/test/platform.validation.local.test.ts +90 -120
- package/test/protocol.test.ts +27 -12
- package/test/protocol35Frames.test.ts +204 -0
- package/test/rotationSpeed.test.ts +150 -0
- package/test/tuyaCustomDeviceManager.test.ts +111 -17
- package/test/tuyaDeviceManager.test.ts +655 -645
- package/test/tuyaDiscovery.test.ts +21 -33
- package/test/tuyaHomeDeviceManager.test.ts +114 -19
- package/test/tuyaOpenAPI.test.ts +25 -44
- package/test/tuyaOpenMQ.test.ts +15 -23
- package/test/util.test.ts +107 -7
- package/test/zigbee/LocalDevice.zigbee.test.ts +14 -18
- package/test/zigbee/LocalDeviceManager.cloud-discovery.test.ts +19 -20
- package/test/zigbee/LocalDeviceManager.zigbee.reconnect.test.ts +19 -20
- package/test/zigbee/LocalDeviceManager.zigbee.test.ts +73 -35
- package/test/zigbee/ZigbeeGatewayDetection.test.ts +2 -2
- package/ADVANCED_OPTIONS.md +0 -267
- package/dist/cloud/device/TuyaDeviceManager.js.map +0 -1
- package/dist/local/CloudLocalReconciliation.js +0 -180
- package/dist/local/CloudLocalReconciliation.js.map +0 -1
- package/dist/shared/accessories/AccessoryFactory.js +0 -309
- package/dist/shared/accessories/AccessoryFactory.js.map +0 -1
- package/dist/shared/accessories/AirConditionerAccessory.js.map +0 -1
- package/dist/shared/accessories/AirQualitySensorAccessory.js.map +0 -1
- package/dist/shared/accessories/BaseAccessory.js.map +0 -1
- package/dist/shared/accessories/CameraAccessory.js.map +0 -1
- package/dist/shared/accessories/FanAccessory.js.map +0 -1
- package/dist/shared/accessories/GarageDoorAccessory.js.map +0 -1
- package/dist/shared/accessories/HeaterAccessory.js.map +0 -1
- package/dist/shared/accessories/HumanPresenceSensorAccessory.js.map +0 -1
- package/dist/shared/accessories/IRAirConditionerAccessory.js.map +0 -1
- package/dist/shared/accessories/IRControlHubAccessory.js.map +0 -1
- package/dist/shared/accessories/IRControlHubSubAccessory.js.map +0 -1
- package/dist/shared/accessories/IRGenericAccessory.js.map +0 -1
- package/dist/shared/accessories/LocationWeatherAccessory.js.map +0 -1
- package/dist/shared/accessories/MotionSensorAccessory.js.map +0 -1
- package/dist/shared/accessories/OutletAccessory.js.map +0 -1
- package/dist/shared/accessories/SceneAccessory.js.map +0 -1
- package/dist/shared/accessories/SceneSwitchAccessory.js.map +0 -1
- package/dist/shared/accessories/SecuritySystemAccessory.js.map +0 -1
- package/dist/shared/accessories/SwitchAccessory.js.map +0 -1
- package/dist/shared/accessories/TemperatureHumiditySensorAccessory.js.map +0 -1
- package/dist/shared/accessories/WeatherStationAccessory.js.map +0 -1
- package/dist/shared/accessories/WetBulbGlobeTemperatureAccessory.js.map +0 -1
- package/dist/shared/accessories/WhiteNoiseLightAccessory.js.map +0 -1
- package/dist/shared/accessories/WindowAccessory.js.map +0 -1
- package/dist/shared/accessories/characteristic/Active.js.map +0 -1
- package/dist/shared/accessories/characteristic/AirQuality.js.map +0 -1
- package/dist/shared/accessories/characteristic/CurrentRelativeHumidity.js.map +0 -1
- package/dist/shared/accessories/characteristic/CurrentTemperature.js.map +0 -1
- package/dist/shared/accessories/characteristic/CurrentWeather.js.map +0 -1
- package/dist/shared/accessories/characteristic/CurrentWeatherByOpenMeteo.js.map +0 -1
- package/dist/shared/accessories/characteristic/CurrentWetBulbGlobeTemperature.js.map +0 -1
- package/dist/shared/accessories/characteristic/EnergyUsage.js.map +0 -1
- package/dist/shared/accessories/characteristic/Light.js.map +0 -1
- package/dist/shared/accessories/characteristic/LightSensor.js.map +0 -1
- package/dist/shared/accessories/characteristic/LockPhysicalControls.js.map +0 -1
- package/dist/shared/accessories/characteristic/MotionDetected.js.map +0 -1
- package/dist/shared/accessories/characteristic/Name.js.map +0 -1
- package/dist/shared/accessories/characteristic/OccupancyDetected.js.map +0 -1
- package/dist/shared/accessories/characteristic/On.js.map +0 -1
- package/dist/shared/accessories/characteristic/OutletInUse.js.map +0 -1
- package/dist/shared/accessories/characteristic/ProgrammableSwitchEvent.js.map +0 -1
- package/dist/shared/accessories/characteristic/RelativeHumidityDehumidifierThreshold.js.map +0 -1
- package/dist/shared/accessories/characteristic/RotationSpeed.js +0 -78
- package/dist/shared/accessories/characteristic/RotationSpeed.js.map +0 -1
- package/dist/shared/accessories/characteristic/SecuritySystemState.js.map +0 -1
- package/dist/shared/accessories/characteristic/SwingMode.js.map +0 -1
- package/dist/shared/accessories/characteristic/TargetTemperature.js.map +0 -1
- package/dist/shared/accessories/characteristic/TemperatureDisplayUnits.js.map +0 -1
- package/test/zigbee/CloudLocalReconciliation.test.ts +0 -284
- package/tuya-local-configs/dev-1.hash +0 -1
- package/tuya-local-configs/device1.hash +0 -1
- package/wiki/Get-Local-Keys-for-Your-Devices.md +0 -85
- /package/dist/shared/{accessories → accessory}/AirPurifierAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/AirQualitySensorAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/BlindsAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/CarbonDioxideSensorAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/CarbonMonoxideSensorAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/ContactSensorAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/DehumidifierAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/DiffuserAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/DimmerAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/DoorbellAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/ExtractionHoodAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/HeaterAccessory_old.js +0 -0
- /package/dist/shared/{accessories → accessory}/HumanPresenceSensorAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/HumidifierAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/IRControlHubAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/IRControlHubSubAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/IRGenericAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/LeakSensorAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/LightAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/LightSensorAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/MotionSensorAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/OutletAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/PetFeederAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/SceneSwitchAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/SmokeSensorAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/TemperatureHumiditySensorAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/ThermostatAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/TowerRackAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/ValveAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/VibrationSensorAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/WeatherStationAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/WetBulbGlobeTemperatureAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/WindowAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/WindowCoveringAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/WirelessSwitchAccessory.js +0 -0
- /package/dist/shared/{accessories → accessory}/characteristic/Active.js +0 -0
- /package/dist/shared/{accessories → accessory}/characteristic/AirQuality.js +0 -0
- /package/dist/shared/{accessories → accessory}/characteristic/CurrentTemperature.js +0 -0
- /package/dist/shared/{accessories → accessory}/characteristic/CurrentWeather.js +0 -0
- /package/dist/shared/{accessories → accessory}/characteristic/CurrentWeatherByOpenMeteo.js +0 -0
- /package/dist/shared/{accessories → accessory}/characteristic/LightSensor.js +0 -0
- /package/dist/shared/{accessories → accessory}/characteristic/MotionDetected.js +0 -0
- /package/dist/shared/{accessories → accessory}/characteristic/Name.js +0 -0
- /package/dist/shared/{accessories → accessory}/characteristic/OccupancyDetected.js +0 -0
- /package/dist/shared/{accessories → accessory}/characteristic/OutletInUse.js +0 -0
- /package/dist/shared/{accessories → accessory}/characteristic/ProgrammableSwitchEvent.js +0 -0
- /package/dist/shared/{accessories → accessory}/characteristic/SecuritySystemState.js +0 -0
- /package/dist/shared/{accessories → accessory}/characteristic/TargetTemperature.js +0 -0
package/test/platform.test.ts
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
import { describe, expect, test, beforeEach, jest } from '@jest/globals';
|
|
3
3
|
import { TuyaPlatform } from '../src/platform';
|
|
4
|
+
import { PlatformAccessory } from 'homebridge';
|
|
5
|
+
import { ExLogger, initLogger } from '../src/shared/util/Logger';
|
|
6
|
+
import { TuyaPluginMode } from '../src/config';
|
|
7
|
+
import LocalDeviceManager from '../src/local/LocalDeviceManager';
|
|
8
|
+
import TuyaHybridDeviceManager from '../src/shared/TuyaHybridDeviceManager';
|
|
9
|
+
import TuyaHomeDeviceManager from '../src/cloud/device/TuyaHomeDeviceManager';
|
|
10
|
+
import TuyaCustomDeviceManager from '../src/cloud/device/TuyaCustomDeviceManager';
|
|
11
|
+
|
|
12
|
+
// Mock Logger
|
|
13
|
+
const mockLogger: ExLogger = {
|
|
14
|
+
debug: jest.fn(),
|
|
15
|
+
info: jest.fn(),
|
|
16
|
+
warn: jest.fn(),
|
|
17
|
+
error: jest.fn(),
|
|
18
|
+
log: jest.fn(),
|
|
19
|
+
success: jest.fn(),
|
|
20
|
+
} as unknown as ExLogger;
|
|
4
21
|
|
|
5
22
|
// Mock Homebridge API
|
|
6
23
|
const mockHAP = {
|
|
@@ -11,6 +28,8 @@ const mockHAP = {
|
|
|
11
28
|
},
|
|
12
29
|
};
|
|
13
30
|
|
|
31
|
+
const errorStack:any[] = [];
|
|
32
|
+
|
|
14
33
|
const mockAPI = {
|
|
15
34
|
hap: mockHAP,
|
|
16
35
|
platformAccessory: jest.fn(),
|
|
@@ -19,20 +38,19 @@ const mockAPI = {
|
|
|
19
38
|
on: jest.fn(),
|
|
20
39
|
} as any;
|
|
21
40
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
info() {}
|
|
28
|
-
warn() {}
|
|
29
|
-
error() {}
|
|
30
|
-
},
|
|
31
|
-
PrefixLogger: class PrefixLogger {
|
|
32
|
-
constructor(public log: any, public name: string, public debug: boolean) {}
|
|
33
|
-
},
|
|
34
|
-
}));
|
|
41
|
+
jest.mock('jsonschema', () => {
|
|
42
|
+
return {
|
|
43
|
+
Validator: (
|
|
44
|
+
class MockValidator {
|
|
45
|
+
validate: ReturnType<typeof jest.fn>;
|
|
35
46
|
|
|
47
|
+
constructor() {
|
|
48
|
+
this.validate = jest.fn().mockReturnValue({ errors: errorStack });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
)
|
|
52
|
+
};
|
|
53
|
+
});
|
|
36
54
|
// Mock file system
|
|
37
55
|
jest.mock('fs', () => ({
|
|
38
56
|
readFileSync: jest.fn(),
|
|
@@ -42,7 +60,15 @@ jest.mock('fs', () => ({
|
|
|
42
60
|
// Mock Cloud components
|
|
43
61
|
jest.mock('../src/cloud/api/TuyaOpenAPI', () => {
|
|
44
62
|
return class MockTuyaOpenAPI {
|
|
45
|
-
log
|
|
63
|
+
log: Console;
|
|
64
|
+
|
|
65
|
+
constructor() {
|
|
66
|
+
this.log = console;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static getDefaultEndpoint() {
|
|
70
|
+
return 'mock-endpoint';
|
|
71
|
+
}
|
|
46
72
|
};
|
|
47
73
|
});
|
|
48
74
|
|
|
@@ -50,34 +76,100 @@ jest.mock('../src/cloud/api/TuyaOpenMQ', () => {
|
|
|
50
76
|
return class MockTuyaOpenMQ {};
|
|
51
77
|
});
|
|
52
78
|
|
|
53
|
-
jest.mock('../src/cloud/device/
|
|
54
|
-
return class MockTuyaDeviceManager {
|
|
79
|
+
jest.mock('../src/cloud/device/TuyaCloudDeviceManager', () => {
|
|
80
|
+
return class MockTuyaDeviceManager {
|
|
81
|
+
pullDevices: ReturnType<typeof jest.fn>;
|
|
82
|
+
updateInfraredRemotes: ReturnType<typeof jest.fn>;
|
|
83
|
+
on: ReturnType<typeof jest.fn>;
|
|
84
|
+
devices: unknown[];
|
|
85
|
+
|
|
86
|
+
constructor() {
|
|
87
|
+
this.pullDevices = jest.fn().mockReturnValue([]);
|
|
88
|
+
this.updateInfraredRemotes = jest.fn();
|
|
89
|
+
this.on = jest.fn();
|
|
90
|
+
this.devices = [];
|
|
91
|
+
}
|
|
92
|
+
};
|
|
55
93
|
});
|
|
56
94
|
|
|
57
95
|
jest.mock('../src/cloud/device/TuyaCustomDeviceManager', () => {
|
|
58
|
-
return class MockTuyaCustomDeviceManager {
|
|
96
|
+
return class MockTuyaCustomDeviceManager {
|
|
97
|
+
pullDevices: ReturnType<typeof jest.fn>;
|
|
98
|
+
updateInfraredRemotes: ReturnType<typeof jest.fn>;
|
|
99
|
+
on: ReturnType<typeof jest.fn>;
|
|
100
|
+
devices: unknown[];
|
|
101
|
+
|
|
102
|
+
constructor() {
|
|
103
|
+
this.pullDevices = jest.fn().mockReturnValue([]);
|
|
104
|
+
this.updateInfraredRemotes = jest.fn();
|
|
105
|
+
this.on = jest.fn();
|
|
106
|
+
this.devices = [];
|
|
107
|
+
}
|
|
108
|
+
};
|
|
59
109
|
});
|
|
60
110
|
|
|
61
111
|
jest.mock('../src/cloud/device/TuyaHomeDeviceManager', () => {
|
|
62
|
-
return class MockTuyaHomeDeviceManager {
|
|
112
|
+
return class MockTuyaHomeDeviceManager {
|
|
113
|
+
pullDevices: ReturnType<typeof jest.fn>;
|
|
114
|
+
updateInfraredRemotes: ReturnType<typeof jest.fn>;
|
|
115
|
+
on: ReturnType<typeof jest.fn>;
|
|
116
|
+
devices: unknown[];
|
|
117
|
+
|
|
118
|
+
constructor() {
|
|
119
|
+
this.pullDevices = jest.fn().mockReturnValue([]);
|
|
120
|
+
this.updateInfraredRemotes = jest.fn();
|
|
121
|
+
this.on = jest.fn();
|
|
122
|
+
this.devices = [];
|
|
123
|
+
}
|
|
124
|
+
};
|
|
63
125
|
});
|
|
64
126
|
|
|
65
127
|
// Mock Local components
|
|
66
128
|
jest.mock('../src/local/LocalDeviceManager', () => {
|
|
67
|
-
return class MockLocalDeviceManager {
|
|
129
|
+
return class MockLocalDeviceManager {
|
|
130
|
+
pullDevices: ReturnType<typeof jest.fn>;
|
|
131
|
+
updateInfraredRemotes: ReturnType<typeof jest.fn>;
|
|
132
|
+
on: ReturnType<typeof jest.fn>;
|
|
133
|
+
devices: unknown[];
|
|
134
|
+
|
|
135
|
+
constructor() {
|
|
136
|
+
this.pullDevices = jest.fn().mockReturnValue([]);
|
|
137
|
+
this.updateInfraredRemotes = jest.fn();
|
|
138
|
+
this.on = jest.fn();
|
|
139
|
+
this.devices = [];
|
|
140
|
+
}
|
|
141
|
+
static isTargetDevice:any = jest.fn(s => true);
|
|
142
|
+
};
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
jest.mock('../src/shared/TuyaHybridDeviceManager', () => {
|
|
146
|
+
return class MockTuyaHybridDeviceManager {
|
|
147
|
+
pullDevices: ReturnType<typeof jest.fn>;
|
|
148
|
+
updateInfraredRemotes: ReturnType<typeof jest.fn>;
|
|
149
|
+
on: ReturnType<typeof jest.fn>;
|
|
150
|
+
devices: unknown[];
|
|
151
|
+
|
|
152
|
+
constructor() {
|
|
153
|
+
this.pullDevices = jest.fn().mockReturnValue([]);
|
|
154
|
+
this.updateInfraredRemotes = jest.fn();
|
|
155
|
+
this.on = jest.fn();
|
|
156
|
+
this.devices = [];
|
|
157
|
+
}
|
|
158
|
+
};
|
|
68
159
|
});
|
|
69
160
|
|
|
70
161
|
// Mock Accessories
|
|
71
|
-
jest.mock('../src/shared/
|
|
162
|
+
jest.mock('../src/shared/accessory/AccessoryFactory', () => {
|
|
72
163
|
return {
|
|
73
164
|
default: class MockAccessoryFactory {},
|
|
74
165
|
};
|
|
75
166
|
});
|
|
76
167
|
|
|
77
|
-
jest.mock('../src/shared/util/
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
168
|
+
jest.mock('../src/shared/util/ConfigMigrator', () => {
|
|
169
|
+
return class ConfigMigrator {
|
|
170
|
+
migrate(arg:any) { return arg; }
|
|
171
|
+
}
|
|
172
|
+
});
|
|
81
173
|
|
|
82
174
|
describe('TuyaPlatform', () => {
|
|
83
175
|
let platform: TuyaPlatform;
|
|
@@ -85,18 +177,22 @@ describe('TuyaPlatform', () => {
|
|
|
85
177
|
let mockLog: any;
|
|
86
178
|
|
|
87
179
|
beforeEach(() => {
|
|
180
|
+
jest.clearAllMocks();
|
|
181
|
+
initLogger(mockLogger);
|
|
182
|
+
|
|
88
183
|
mockLog = {
|
|
89
184
|
debug: jest.fn(),
|
|
90
185
|
info: jest.fn(),
|
|
91
186
|
warn: jest.fn(),
|
|
92
187
|
error: jest.fn(),
|
|
188
|
+
success: jest.fn(),
|
|
93
189
|
};
|
|
94
190
|
|
|
95
191
|
mockConfig = {
|
|
96
192
|
platform: 'TuyaPlatform',
|
|
97
193
|
name: 'Tuya',
|
|
98
194
|
mode: 'cloud',
|
|
99
|
-
|
|
195
|
+
cloud: {
|
|
100
196
|
projectType: '2',
|
|
101
197
|
accessId: 'test_id',
|
|
102
198
|
accessKey: 'test_key',
|
|
@@ -109,6 +205,8 @@ describe('TuyaPlatform', () => {
|
|
|
109
205
|
},
|
|
110
206
|
};
|
|
111
207
|
|
|
208
|
+
process.removeAllListeners('uncaughtException');
|
|
209
|
+
process.removeAllListeners('unhandledRejection');
|
|
112
210
|
platform = new TuyaPlatform(mockLog, mockConfig, mockAPI);
|
|
113
211
|
});
|
|
114
212
|
|
|
@@ -136,8 +234,8 @@ describe('TuyaPlatform', () => {
|
|
|
136
234
|
});
|
|
137
235
|
|
|
138
236
|
test('initializes cached accessories array', () => {
|
|
139
|
-
expect(platform
|
|
140
|
-
expect(
|
|
237
|
+
expect(platform['platformAccessories']).toEqual(new Map());
|
|
238
|
+
expect(platform['platformAccessories'] instanceof Map).toBe(true);
|
|
141
239
|
});
|
|
142
240
|
|
|
143
241
|
test('initializes accessory handlers array', () => {
|
|
@@ -155,7 +253,7 @@ describe('TuyaPlatform', () => {
|
|
|
155
253
|
const localConfig = {
|
|
156
254
|
...mockConfig,
|
|
157
255
|
mode: 'local',
|
|
158
|
-
|
|
256
|
+
cloud: undefined,
|
|
159
257
|
local: {
|
|
160
258
|
devices: [],
|
|
161
259
|
},
|
|
@@ -180,16 +278,16 @@ describe('TuyaPlatform', () => {
|
|
|
180
278
|
});
|
|
181
279
|
|
|
182
280
|
describe('configuration validation', () => {
|
|
183
|
-
test('requires
|
|
184
|
-
const
|
|
281
|
+
test('requires cloud for cloud mode', () => {
|
|
282
|
+
const noCloudConfig = {
|
|
185
283
|
platform: 'TuyaPlatform',
|
|
186
284
|
name: 'Tuya',
|
|
187
285
|
mode: 'cloud',
|
|
188
|
-
|
|
286
|
+
cloud: undefined,
|
|
189
287
|
};
|
|
190
288
|
|
|
191
|
-
const
|
|
192
|
-
const isValid =
|
|
289
|
+
const noCloudPlatform = new TuyaPlatform(mockLog, noCloudConfig, mockAPI);
|
|
290
|
+
const isValid = noCloudPlatform.validate();
|
|
193
291
|
|
|
194
292
|
expect(isValid).toBe(false);
|
|
195
293
|
});
|
|
@@ -213,7 +311,7 @@ describe('TuyaPlatform', () => {
|
|
|
213
311
|
platform: 'TuyaPlatform',
|
|
214
312
|
name: 'Tuya',
|
|
215
313
|
mode: 'cloud',
|
|
216
|
-
|
|
314
|
+
cloud: {
|
|
217
315
|
projectType: '1',
|
|
218
316
|
endpoint: 'https://openapi.tuyaeu.com',
|
|
219
317
|
accessId: 'id',
|
|
@@ -226,7 +324,7 @@ describe('TuyaPlatform', () => {
|
|
|
226
324
|
};
|
|
227
325
|
|
|
228
326
|
const cloudPlatform = new TuyaPlatform(mockLog, cloudConfig, mockAPI);
|
|
229
|
-
expect(cloudPlatform.
|
|
327
|
+
expect(cloudPlatform.platformConfig!.cloud!.projectType).toBe('1');
|
|
230
328
|
});
|
|
231
329
|
|
|
232
330
|
test('validates cloud config with projectType 2', () => {
|
|
@@ -234,7 +332,7 @@ describe('TuyaPlatform', () => {
|
|
|
234
332
|
platform: 'TuyaPlatform',
|
|
235
333
|
name: 'Tuya',
|
|
236
334
|
mode: 'cloud',
|
|
237
|
-
|
|
335
|
+
cloud: {
|
|
238
336
|
projectType: '2',
|
|
239
337
|
accessId: 'id',
|
|
240
338
|
accessKey: 'key',
|
|
@@ -248,7 +346,7 @@ describe('TuyaPlatform', () => {
|
|
|
248
346
|
};
|
|
249
347
|
|
|
250
348
|
const cloudPlatform = new TuyaPlatform(mockLog, cloudConfig, mockAPI);
|
|
251
|
-
expect(cloudPlatform.
|
|
349
|
+
expect(cloudPlatform.platformConfig!.cloud!.projectType).toBe('2');
|
|
252
350
|
});
|
|
253
351
|
});
|
|
254
352
|
|
|
@@ -295,13 +393,13 @@ describe('TuyaPlatform', () => {
|
|
|
295
393
|
});
|
|
296
394
|
|
|
297
395
|
test('stores cloud options', () => {
|
|
298
|
-
expect(platform.
|
|
299
|
-
expect(platform.
|
|
396
|
+
expect(platform.platformConfig.cloud).toBeDefined();
|
|
397
|
+
expect(platform.platformConfig!.cloud!.projectType).toBe('2');
|
|
300
398
|
});
|
|
301
399
|
|
|
302
400
|
test('accesses credentials from config', () => {
|
|
303
|
-
expect(platform.
|
|
304
|
-
expect(platform.
|
|
401
|
+
expect(platform.platformConfig!.cloud!.accessId).toBe('test_id');
|
|
402
|
+
expect(platform.platformConfig!.cloud!.accessKey).toBe('test_key');
|
|
305
403
|
});
|
|
306
404
|
});
|
|
307
405
|
|
|
@@ -329,38 +427,62 @@ describe('TuyaPlatform', () => {
|
|
|
329
427
|
|
|
330
428
|
test('caches accessories', () => {
|
|
331
429
|
const mockAccessory = { UUID: 'uuid-1', displayName: 'Cached Device' };
|
|
332
|
-
platform.
|
|
430
|
+
platform.configureAccessory(mockAccessory as PlatformAccessory);
|
|
333
431
|
|
|
334
|
-
expect(platform.
|
|
432
|
+
expect(platform['platformAccessories'].size).toBe(1);
|
|
335
433
|
});
|
|
336
434
|
|
|
337
435
|
test('can restore cached accessories', () => {
|
|
338
436
|
const mockAccessory1 = { UUID: 'uuid-1', displayName: 'Device 1' };
|
|
339
437
|
const mockAccessory2 = { UUID: 'uuid-2', displayName: 'Device 2' };
|
|
438
|
+
[mockAccessory1, mockAccessory2].forEach(mockAccessory => platform.configureAccessory(mockAccessory as PlatformAccessory));
|
|
340
439
|
|
|
341
|
-
platform
|
|
342
|
-
|
|
343
|
-
expect(platform.cachedAccessories.length).toBe(2);
|
|
440
|
+
expect(platform['platformAccessories'].size).toBe(2);
|
|
344
441
|
});
|
|
345
442
|
});
|
|
346
443
|
|
|
347
444
|
describe('device manager initialization', () => {
|
|
348
|
-
test('can initialize
|
|
445
|
+
test('can initialize device manager', () => {
|
|
349
446
|
platform.deviceManager = {} as any;
|
|
350
447
|
expect(platform.deviceManager).toBeDefined();
|
|
351
448
|
});
|
|
352
449
|
|
|
353
|
-
test('
|
|
354
|
-
|
|
355
|
-
|
|
450
|
+
test('initialize custom device manager', () => {
|
|
451
|
+
mockConfig.mode = TuyaPluginMode.cloud;
|
|
452
|
+
mockConfig.cloud.projectType = '1';
|
|
453
|
+
const platform = new TuyaPlatform(mockLog, mockConfig, mockAPI);
|
|
454
|
+
platform.initDevices().then(() => {
|
|
455
|
+
expect(platform.mode).toBe(mockConfig.mode);
|
|
456
|
+
expect(platform.deviceManager).toBeInstanceOf(TuyaCustomDeviceManager);
|
|
457
|
+
});
|
|
356
458
|
});
|
|
357
459
|
|
|
358
|
-
test('
|
|
359
|
-
|
|
360
|
-
|
|
460
|
+
test('initialize home device manager', () => {
|
|
461
|
+
mockConfig.mode = TuyaPluginMode.cloud;
|
|
462
|
+
mockConfig.cloud.projectType = '2';
|
|
463
|
+
const platform = new TuyaPlatform(mockLog, mockConfig, mockAPI);
|
|
464
|
+
platform.initDevices().then(() => {
|
|
465
|
+
expect(platform.mode).toBe(mockConfig.mode);
|
|
466
|
+
expect(platform.deviceManager).toBeInstanceOf(TuyaHomeDeviceManager);
|
|
467
|
+
});
|
|
468
|
+
});
|
|
361
469
|
|
|
362
|
-
|
|
363
|
-
|
|
470
|
+
test('initialize local device manager', () => {
|
|
471
|
+
mockConfig.mode = TuyaPluginMode.local;
|
|
472
|
+
const platform = new TuyaPlatform(mockLog, mockConfig, mockAPI);
|
|
473
|
+
platform.initDevices().then(() => {
|
|
474
|
+
expect(platform.mode).toBe(mockConfig.mode);
|
|
475
|
+
expect(platform.deviceManager).toBeInstanceOf(LocalDeviceManager);
|
|
476
|
+
});
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
test('initialize both device manager', () => {
|
|
480
|
+
mockConfig.mode = TuyaPluginMode.both;
|
|
481
|
+
const platform = new TuyaPlatform(mockLog, mockConfig, mockAPI);
|
|
482
|
+
platform.initDevices().then(() => {
|
|
483
|
+
expect(platform.mode).toBe(mockConfig.mode);
|
|
484
|
+
expect(platform.deviceManager).toBeInstanceOf(TuyaHybridDeviceManager);
|
|
485
|
+
});
|
|
364
486
|
});
|
|
365
487
|
});
|
|
366
488
|
|
|
@@ -370,7 +492,7 @@ describe('TuyaPlatform', () => {
|
|
|
370
492
|
platform: 'TuyaPlatform',
|
|
371
493
|
name: 'Tuya',
|
|
372
494
|
mode: 'both',
|
|
373
|
-
|
|
495
|
+
cloud: {
|
|
374
496
|
projectType: '2',
|
|
375
497
|
accessId: 'id',
|
|
376
498
|
accessKey: 'key',
|
|
@@ -388,183 +510,8 @@ describe('TuyaPlatform', () => {
|
|
|
388
510
|
|
|
389
511
|
const bothPlatform = new TuyaPlatform(mockLog, bothConfig, mockAPI);
|
|
390
512
|
expect(bothPlatform.mode).toBe('both');
|
|
391
|
-
expect(bothPlatform.
|
|
392
|
-
expect(bothPlatform.platformConfig.local).toBeDefined();
|
|
393
|
-
});
|
|
394
|
-
|
|
395
|
-
test('enriches local config with cloud device details', async () => {
|
|
396
|
-
const bothConfig = {
|
|
397
|
-
platform: 'TuyaPlatform',
|
|
398
|
-
name: 'Tuya',
|
|
399
|
-
mode: 'both',
|
|
400
|
-
options: {
|
|
401
|
-
projectType: '2',
|
|
402
|
-
accessId: 'id',
|
|
403
|
-
accessKey: 'key',
|
|
404
|
-
countryCode: 1,
|
|
405
|
-
username: 'user',
|
|
406
|
-
password: 'pass',
|
|
407
|
-
appSchema: 'tuyaSmart',
|
|
408
|
-
generateWeatherAccessory: false,
|
|
409
|
-
weatherAPI: '',
|
|
410
|
-
},
|
|
411
|
-
local: {
|
|
412
|
-
devices: [],
|
|
413
|
-
},
|
|
414
|
-
};
|
|
415
|
-
|
|
416
|
-
const bothPlatform = new TuyaPlatform(mockLog, bothConfig, mockAPI);
|
|
417
|
-
|
|
418
|
-
// Mock cloud device
|
|
419
|
-
const mockCloudDevice = {
|
|
420
|
-
id: 'test-device-123',
|
|
421
|
-
uuid: 'test-device-123',
|
|
422
|
-
name: 'Test Device',
|
|
423
|
-
product_id: 'product-123',
|
|
424
|
-
} as any;
|
|
425
|
-
|
|
426
|
-
// Mock the getDeviceDetails response
|
|
427
|
-
const mockDeviceDetails = {
|
|
428
|
-
success: true,
|
|
429
|
-
result: {
|
|
430
|
-
id: 'test-device-123',
|
|
431
|
-
local_key: 'test-local-key-abcdef',
|
|
432
|
-
ip: '192.168.1.100',
|
|
433
|
-
},
|
|
434
|
-
};
|
|
435
|
-
|
|
436
|
-
bothPlatform.deviceManager = {
|
|
437
|
-
getDeviceDetails: async () => mockDeviceDetails,
|
|
438
|
-
} as any;
|
|
439
|
-
|
|
440
|
-
// Enrich local config
|
|
441
|
-
await bothPlatform.enrichLocalConfigFromCloud([mockCloudDevice]);
|
|
442
|
-
|
|
443
|
-
// Verify local config was enriched
|
|
444
|
-
expect(bothPlatform.platformConfig.local).toBeDefined();
|
|
445
|
-
if (bothPlatform.platformConfig.local?.devices) {
|
|
446
|
-
expect(bothPlatform.platformConfig.local.devices.length).toBeGreaterThan(0);
|
|
447
|
-
|
|
448
|
-
const enrichedDevice = bothPlatform.platformConfig.local.devices[0];
|
|
449
|
-
expect(enrichedDevice.tuyaDeviceId).toBe('test-device-123');
|
|
450
|
-
expect(enrichedDevice.tuyaKey).toBe('test-local-key-abcdef');
|
|
451
|
-
expect(enrichedDevice.ip).toBe('192.168.1.100');
|
|
452
|
-
}
|
|
453
|
-
});
|
|
454
|
-
|
|
455
|
-
test('preserves manual local config when enriching', async () => {
|
|
456
|
-
const bothConfig = {
|
|
457
|
-
platform: 'TuyaPlatform',
|
|
458
|
-
name: 'Tuya',
|
|
459
|
-
mode: 'both',
|
|
460
|
-
options: {
|
|
461
|
-
projectType: '2',
|
|
462
|
-
accessId: 'id',
|
|
463
|
-
accessKey: 'key',
|
|
464
|
-
countryCode: 1,
|
|
465
|
-
username: 'user',
|
|
466
|
-
password: 'pass',
|
|
467
|
-
appSchema: 'tuyaSmart',
|
|
468
|
-
generateWeatherAccessory: false,
|
|
469
|
-
weatherAPI: '',
|
|
470
|
-
},
|
|
471
|
-
local: {
|
|
472
|
-
devices: [
|
|
473
|
-
{
|
|
474
|
-
tuyaDeviceId: 'manual-device-456',
|
|
475
|
-
tuyaKey: 'manual-key-xyz',
|
|
476
|
-
name: 'Manual Device',
|
|
477
|
-
},
|
|
478
|
-
],
|
|
479
|
-
},
|
|
480
|
-
};
|
|
481
|
-
|
|
482
|
-
const bothPlatform = new TuyaPlatform(mockLog, bothConfig, mockAPI);
|
|
483
|
-
|
|
484
|
-
// Mock cloud device (different from manual one)
|
|
485
|
-
const mockCloudDevice = {
|
|
486
|
-
id: 'test-device-123',
|
|
487
|
-
uuid: 'test-device-123',
|
|
488
|
-
name: 'Test Device',
|
|
489
|
-
product_id: 'product-123',
|
|
490
|
-
} as any;
|
|
491
|
-
|
|
492
|
-
bothPlatform.deviceManager = {
|
|
493
|
-
getDeviceDetails: async () => ({
|
|
494
|
-
success: true,
|
|
495
|
-
result: {
|
|
496
|
-
id: 'test-device-123',
|
|
497
|
-
local_key: 'cloud-key-123',
|
|
498
|
-
ip: '192.168.1.100',
|
|
499
|
-
},
|
|
500
|
-
}),
|
|
501
|
-
} as any;
|
|
502
|
-
|
|
503
|
-
// Enrich local config
|
|
504
|
-
await bothPlatform.enrichLocalConfigFromCloud([mockCloudDevice]);
|
|
505
|
-
|
|
506
|
-
// Verify local config exists and has devices
|
|
507
|
-
expect(bothPlatform.platformConfig.local).toBeDefined();
|
|
508
|
-
if (bothPlatform.platformConfig.local?.devices) {
|
|
509
|
-
// Verify manual device is still there
|
|
510
|
-
const manualDevice = bothPlatform.platformConfig.local.devices.find(
|
|
511
|
-
d => d.tuyaDeviceId === 'manual-device-456'
|
|
512
|
-
);
|
|
513
|
-
expect(manualDevice).toBeDefined();
|
|
514
|
-
expect(manualDevice?.tuyaKey).toBe('manual-key-xyz');
|
|
515
|
-
|
|
516
|
-
// Verify new cloud device was added
|
|
517
|
-
const cloudDevice = bothPlatform.platformConfig.local.devices.find(
|
|
518
|
-
d => d.tuyaDeviceId === 'test-device-123'
|
|
519
|
-
);
|
|
520
|
-
expect(cloudDevice).toBeDefined();
|
|
521
|
-
expect(cloudDevice?.tuyaKey).toBe('cloud-key-123');
|
|
522
|
-
}
|
|
523
|
-
});
|
|
524
|
-
|
|
525
|
-
test('skips enrichment if cloud device details unavailable', async () => {
|
|
526
|
-
const bothConfig = {
|
|
527
|
-
platform: 'TuyaPlatform',
|
|
528
|
-
name: 'Tuya',
|
|
529
|
-
mode: 'both',
|
|
530
|
-
options: {
|
|
531
|
-
projectType: '2',
|
|
532
|
-
accessId: 'id',
|
|
533
|
-
accessKey: 'key',
|
|
534
|
-
countryCode: 1,
|
|
535
|
-
username: 'user',
|
|
536
|
-
password: 'pass',
|
|
537
|
-
appSchema: 'tuyaSmart',
|
|
538
|
-
generateWeatherAccessory: false,
|
|
539
|
-
weatherAPI: '',
|
|
540
|
-
},
|
|
541
|
-
local: {
|
|
542
|
-
devices: [],
|
|
543
|
-
},
|
|
544
|
-
};
|
|
545
|
-
|
|
546
|
-
const bothPlatform = new TuyaPlatform(mockLog, bothConfig, mockAPI);
|
|
547
|
-
|
|
548
|
-
const mockCloudDevice = {
|
|
549
|
-
id: 'test-device-123',
|
|
550
|
-
name: 'Test Device',
|
|
551
|
-
} as any;
|
|
552
|
-
|
|
553
|
-
bothPlatform.deviceManager = {
|
|
554
|
-
getDeviceDetails: async () => ({
|
|
555
|
-
success: false,
|
|
556
|
-
code: 'NOT_FOUND',
|
|
557
|
-
}),
|
|
558
|
-
} as any;
|
|
559
|
-
|
|
560
|
-
// Enrich local config
|
|
561
|
-
await bothPlatform.enrichLocalConfigFromCloud([mockCloudDevice]);
|
|
562
|
-
|
|
563
|
-
// Verify nothing was added (since API failed)
|
|
513
|
+
expect(bothPlatform.platformConfig.cloud).toBeDefined();
|
|
564
514
|
expect(bothPlatform.platformConfig.local).toBeDefined();
|
|
565
|
-
if (bothPlatform.platformConfig.local?.devices) {
|
|
566
|
-
expect(bothPlatform.platformConfig.local.devices.length).toBe(0);
|
|
567
|
-
}
|
|
568
515
|
});
|
|
569
516
|
});
|
|
570
517
|
|
|
@@ -624,13 +571,135 @@ describe('TuyaPlatform', () => {
|
|
|
624
571
|
});
|
|
625
572
|
});
|
|
626
573
|
|
|
574
|
+
describe('validate', () => {
|
|
575
|
+
test('local mode without local config', () => {
|
|
576
|
+
const invalidConfig = {
|
|
577
|
+
platform: 'TuyaPlatform',
|
|
578
|
+
name: 'Tuya',
|
|
579
|
+
mode: 'local',
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
const spyError = jest.spyOn(mockLog, 'error');
|
|
583
|
+
|
|
584
|
+
const invalidPlatform = new TuyaPlatform(mockLog, invalidConfig, mockAPI);
|
|
585
|
+
const isValid = invalidPlatform.validate();
|
|
586
|
+
|
|
587
|
+
expect(isValid).toBe(false);
|
|
588
|
+
expect(spyError).toHaveBeenCalledWith('mode is "local" but no "local" config block found.');
|
|
589
|
+
});
|
|
590
|
+
|
|
591
|
+
test('both mode without local config', () => {
|
|
592
|
+
const invalidConfig = {
|
|
593
|
+
platform: 'TuyaPlatform',
|
|
594
|
+
name: 'Tuya',
|
|
595
|
+
mode: 'both',
|
|
596
|
+
};
|
|
597
|
+
|
|
598
|
+
const spyError = jest.spyOn(mockLog, 'error');
|
|
599
|
+
|
|
600
|
+
const invalidPlatform = new TuyaPlatform(mockLog, invalidConfig, mockAPI);
|
|
601
|
+
const isValid = invalidPlatform.validate();
|
|
602
|
+
|
|
603
|
+
expect(isValid).toBe(false);
|
|
604
|
+
expect(spyError).toHaveBeenCalledWith('mode is "both" but no "local" config block found.');
|
|
605
|
+
});
|
|
606
|
+
|
|
607
|
+
test('cloud mode without cloud config', () => {
|
|
608
|
+
const invalidConfig = {
|
|
609
|
+
platform: 'TuyaPlatform',
|
|
610
|
+
name: 'Tuya',
|
|
611
|
+
mode: 'cloud',
|
|
612
|
+
};
|
|
613
|
+
|
|
614
|
+
const spyError = jest.spyOn(mockLog, 'error');
|
|
615
|
+
|
|
616
|
+
const invalidPlatform = new TuyaPlatform(mockLog, invalidConfig, mockAPI);
|
|
617
|
+
const isValid = invalidPlatform.validate();
|
|
618
|
+
|
|
619
|
+
expect(isValid).toBe(false);
|
|
620
|
+
expect(spyError).toHaveBeenCalledWith('Not configured — "cloud" block is required for cloud mode, exit.');
|
|
621
|
+
});
|
|
622
|
+
|
|
623
|
+
test('both mode without cloud config', () => {
|
|
624
|
+
const invalidConfig = {
|
|
625
|
+
platform: 'TuyaPlatform',
|
|
626
|
+
name: 'Tuya',
|
|
627
|
+
mode: 'both',
|
|
628
|
+
local: {}
|
|
629
|
+
};
|
|
630
|
+
|
|
631
|
+
const spyError = jest.spyOn(mockLog, 'error');
|
|
632
|
+
|
|
633
|
+
const invalidPlatform = new TuyaPlatform(mockLog, invalidConfig, mockAPI);
|
|
634
|
+
const isValid = invalidPlatform.validate();
|
|
635
|
+
|
|
636
|
+
expect(isValid).toBe(false);
|
|
637
|
+
expect(spyError).toHaveBeenCalledWith('Not configured — "cloud" block is required for cloud mode, exit.');
|
|
638
|
+
});
|
|
639
|
+
|
|
640
|
+
test('Validator().validate returns error', () => {
|
|
641
|
+
const invalidConfig = {
|
|
642
|
+
platform: 'TuyaPlatform',
|
|
643
|
+
name: 'Tuya',
|
|
644
|
+
mode: 'cloud',
|
|
645
|
+
cloud: { projectType: '1', deviceOverides: [] }
|
|
646
|
+
};
|
|
647
|
+
|
|
648
|
+
const stack = { stack: 'error stack' };
|
|
649
|
+
errorStack.push(stack);
|
|
650
|
+
|
|
651
|
+
const spyError = jest.spyOn(mockLog, 'error');
|
|
652
|
+
const invalidPlatform = new TuyaPlatform(mockLog, invalidConfig, mockAPI);
|
|
653
|
+
|
|
654
|
+
expect(spyError).toHaveBeenCalledWith(stack.stack);
|
|
655
|
+
errorStack.splice(0, errorStack.length);
|
|
656
|
+
});
|
|
657
|
+
|
|
658
|
+
test('cloud mode with invalid deviceOverrides', () => {
|
|
659
|
+
const invalidConfig = {
|
|
660
|
+
platform: 'TuyaPlatform',
|
|
661
|
+
name: 'Tuya',
|
|
662
|
+
mode: 'cloud',
|
|
663
|
+
cloud: { projectType: '1' }
|
|
664
|
+
};
|
|
665
|
+
|
|
666
|
+
const invalidPlatform = new TuyaPlatform(mockLog, invalidConfig, mockAPI);
|
|
667
|
+
invalidPlatform.validateDeviceOverrides = jest.fn(() => false);
|
|
668
|
+
const spyMethod = jest.spyOn(invalidPlatform, 'validateDeviceOverrides');
|
|
669
|
+
const isValid = invalidPlatform.validate();
|
|
670
|
+
|
|
671
|
+
expect(spyMethod).toHaveBeenCalledTimes(1);
|
|
672
|
+
expect(isValid).toBe(false);
|
|
673
|
+
});
|
|
674
|
+
|
|
675
|
+
test('cloud mode with invalid deviceOverride.schema', () => {
|
|
676
|
+
const invalidConfig = {
|
|
677
|
+
platform: 'TuyaPlatform',
|
|
678
|
+
name: 'Tuya',
|
|
679
|
+
mode: 'cloud',
|
|
680
|
+
cloud: { projectType: '1' }
|
|
681
|
+
};
|
|
682
|
+
|
|
683
|
+
const invalidPlatform = new TuyaPlatform(mockLog, invalidConfig, mockAPI);
|
|
684
|
+
invalidPlatform.validateDeviceOverrides = jest.fn(() => true);
|
|
685
|
+
invalidPlatform.validateSchema = jest.fn(() => false);
|
|
686
|
+
const spyMethod1 = jest.spyOn(invalidPlatform, 'validateDeviceOverrides');
|
|
687
|
+
const spyMethod2 = jest.spyOn(invalidPlatform, 'validateSchema');
|
|
688
|
+
const isValid = invalidPlatform.validate();
|
|
689
|
+
|
|
690
|
+
expect(spyMethod1).toHaveBeenCalledTimes(1);
|
|
691
|
+
expect(spyMethod2).toHaveBeenCalledTimes(1);
|
|
692
|
+
expect(isValid).toBe(false);
|
|
693
|
+
});
|
|
694
|
+
});
|
|
695
|
+
|
|
627
696
|
describe('configuration edge cases', () => {
|
|
628
697
|
test('handles missing project type', () => {
|
|
629
698
|
const noProjectTypeConfig = {
|
|
630
699
|
platform: 'TuyaPlatform',
|
|
631
700
|
name: 'Tuya',
|
|
632
701
|
mode: 'cloud',
|
|
633
|
-
|
|
702
|
+
cloud: {
|
|
634
703
|
accessId: 'id',
|
|
635
704
|
accessKey: 'key',
|
|
636
705
|
},
|
|
@@ -657,15 +726,15 @@ describe('TuyaPlatform', () => {
|
|
|
657
726
|
test('handles weather accessory option', () => {
|
|
658
727
|
const weatherConfig = {
|
|
659
728
|
...mockConfig,
|
|
660
|
-
|
|
661
|
-
...mockConfig.
|
|
729
|
+
cloud: {
|
|
730
|
+
...mockConfig.cloud,
|
|
662
731
|
generateWeatherAccessory: true,
|
|
663
732
|
weatherAPI: 'openweathermap',
|
|
664
733
|
},
|
|
665
734
|
};
|
|
666
735
|
|
|
667
736
|
const weatherPlatform = new TuyaPlatform(mockLog, weatherConfig, mockAPI);
|
|
668
|
-
expect((weatherPlatform.
|
|
737
|
+
expect((weatherPlatform.platformConfig.cloud as any).generateWeatherAccessory).toBe(true);
|
|
669
738
|
});
|
|
670
739
|
});
|
|
671
740
|
|
|
@@ -684,20 +753,21 @@ describe('TuyaPlatform', () => {
|
|
|
684
753
|
const platform1 = new TuyaPlatform(mockLog, config1, mockAPI);
|
|
685
754
|
const platform2 = new TuyaPlatform(mockLog, config2, mockAPI);
|
|
686
755
|
|
|
687
|
-
platform1.
|
|
756
|
+
platform1.configureAccessory({} as PlatformAccessory);
|
|
757
|
+
|
|
688
758
|
|
|
689
|
-
expect(platform1.
|
|
690
|
-
expect(platform2.
|
|
759
|
+
expect(platform1['platformAccessories'].size).toBe(1);
|
|
760
|
+
expect(platform2['platformAccessories'].size).toBe(0);
|
|
691
761
|
});
|
|
692
762
|
});
|
|
693
763
|
|
|
694
|
-
describe('
|
|
695
|
-
test('
|
|
764
|
+
describe('device ID consistency and deduplication', () => {
|
|
765
|
+
test('uses consistent UUID for same device across cloud and local', () => {
|
|
696
766
|
const bothConfig = {
|
|
697
767
|
platform: 'TuyaPlatform',
|
|
698
768
|
name: 'Tuya',
|
|
699
769
|
mode: 'both',
|
|
700
|
-
|
|
770
|
+
cloud: {
|
|
701
771
|
projectType: '2',
|
|
702
772
|
accessId: 'id',
|
|
703
773
|
accessKey: 'key',
|
|
@@ -715,595 +785,91 @@ describe('TuyaPlatform', () => {
|
|
|
715
785
|
|
|
716
786
|
const bothPlatform = new TuyaPlatform(mockLog, bothConfig, mockAPI);
|
|
717
787
|
|
|
788
|
+
// Create mock cloud and local devices with same ID
|
|
718
789
|
const mockCloudDevice = {
|
|
719
|
-
id: '
|
|
720
|
-
uuid: '
|
|
721
|
-
name: 'Test Device',
|
|
722
|
-
product_id: 'product-123',
|
|
790
|
+
id: 'same-device-id',
|
|
791
|
+
uuid: 'same-device-id',
|
|
792
|
+
name: 'Test Device (Cloud)',
|
|
723
793
|
} as any;
|
|
724
794
|
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
result: {
|
|
730
|
-
id: 'test-device-123',
|
|
731
|
-
localKey: 'alternate-format-key', // camelCase variant
|
|
732
|
-
ip: '192.168.1.100',
|
|
733
|
-
},
|
|
734
|
-
}),
|
|
795
|
+
const mockLocalDevice = {
|
|
796
|
+
id: 'same-device-id',
|
|
797
|
+
uuid: 'same-device-id',
|
|
798
|
+
name: 'Test Device (Local)',
|
|
735
799
|
} as any;
|
|
736
800
|
|
|
737
|
-
|
|
801
|
+
// Both should map to same UUID
|
|
802
|
+
const cloudUUID = bothPlatform.api.hap.uuid.generate(mockCloudDevice.id);
|
|
803
|
+
const localUUID = bothPlatform.api.hap.uuid.generate(mockLocalDevice.id);
|
|
738
804
|
|
|
739
|
-
|
|
740
|
-
const enrichedDevice = bothPlatform.platformConfig.local.devices[0];
|
|
741
|
-
expect(enrichedDevice.tuyaKey).toBe('alternate-format-key');
|
|
742
|
-
}
|
|
805
|
+
expect(cloudUUID).toBe(localUUID);
|
|
743
806
|
});
|
|
807
|
+
});
|
|
744
808
|
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
mode: 'both',
|
|
750
|
-
options: {
|
|
751
|
-
projectType: '2',
|
|
752
|
-
accessId: 'id',
|
|
753
|
-
accessKey: 'key',
|
|
754
|
-
countryCode: 1,
|
|
755
|
-
username: 'user',
|
|
756
|
-
password: 'pass',
|
|
757
|
-
appSchema: 'tuyaSmart',
|
|
758
|
-
generateWeatherAccessory: false,
|
|
759
|
-
weatherAPI: '',
|
|
760
|
-
},
|
|
761
|
-
local: {
|
|
762
|
-
devices: [],
|
|
763
|
-
},
|
|
809
|
+
describe('syncDeviceAndAccessory', () => {
|
|
810
|
+
test('device config changed', () => {
|
|
811
|
+
const mockDevice = {
|
|
812
|
+
id: 'mock-id'
|
|
764
813
|
};
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
result: {
|
|
777
|
-
id: 'test-device-456',
|
|
778
|
-
local_key: 'test-key-456',
|
|
779
|
-
address: '10.0.0.50', // Uses 'address' instead of 'ip'
|
|
780
|
-
},
|
|
781
|
-
}),
|
|
782
|
-
} as any;
|
|
783
|
-
|
|
784
|
-
await bothPlatform.enrichLocalConfigFromCloud([mockCloudDevice]);
|
|
785
|
-
|
|
786
|
-
if (bothPlatform.platformConfig.local?.devices) {
|
|
787
|
-
const enrichedDevice = bothPlatform.platformConfig.local.devices[0];
|
|
788
|
-
expect(enrichedDevice.ip).toBe('10.0.0.50');
|
|
789
|
-
}
|
|
790
|
-
});
|
|
791
|
-
|
|
792
|
-
test('uses uuid fallback when cloud device id is missing', async () => {
|
|
793
|
-
const bothConfig = {
|
|
794
|
-
platform: 'TuyaPlatform',
|
|
795
|
-
name: 'Tuya',
|
|
796
|
-
mode: 'both',
|
|
797
|
-
options: {
|
|
798
|
-
projectType: '2',
|
|
799
|
-
accessId: 'id',
|
|
800
|
-
accessKey: 'key',
|
|
801
|
-
countryCode: 1,
|
|
802
|
-
username: 'user',
|
|
803
|
-
password: 'pass',
|
|
804
|
-
appSchema: 'tuyaSmart',
|
|
805
|
-
generateWeatherAccessory: false,
|
|
806
|
-
weatherAPI: '',
|
|
807
|
-
},
|
|
808
|
-
local: {
|
|
809
|
-
devices: [],
|
|
810
|
-
},
|
|
811
|
-
};
|
|
812
|
-
|
|
813
|
-
const bothPlatform = new TuyaPlatform(mockLog, bothConfig, mockAPI);
|
|
814
|
-
|
|
815
|
-
const mockCloudDevice = {
|
|
816
|
-
uuid: 'fallback-device-123',
|
|
817
|
-
name: 'Fallback Device',
|
|
818
|
-
} as any;
|
|
819
|
-
|
|
820
|
-
bothPlatform.deviceManager = {
|
|
821
|
-
getDeviceDetails: async () => ({
|
|
822
|
-
success: true,
|
|
823
|
-
result: {
|
|
824
|
-
uuid: 'fallback-device-123',
|
|
825
|
-
local_key: 'fallback-key-123',
|
|
826
|
-
ip: '192.168.1.101',
|
|
814
|
+
const mockOldAccessory = {
|
|
815
|
+
context: { deviceConfigHash: 'hash2' },
|
|
816
|
+
services: [
|
|
817
|
+
{
|
|
818
|
+
UUID: 'service-uuid1',
|
|
819
|
+
characteristics: [
|
|
820
|
+
{ UUID: 'characteristic-uuid1' },
|
|
821
|
+
{ UUID: 'characteristic-uuid2' },
|
|
822
|
+
{ UUID: 'characteristic-uuid3' },
|
|
823
|
+
],
|
|
824
|
+
removeCharacteristic: jest.fn()
|
|
827
825
|
},
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
});
|
|
839
|
-
|
|
840
|
-
test('propagates cloud category into local config', async () => {
|
|
841
|
-
const bothConfig = {
|
|
842
|
-
platform: 'TuyaPlatform',
|
|
843
|
-
name: 'Tuya',
|
|
844
|
-
mode: 'both',
|
|
845
|
-
options: {
|
|
846
|
-
projectType: '2',
|
|
847
|
-
accessId: 'id',
|
|
848
|
-
accessKey: 'key',
|
|
849
|
-
countryCode: 1,
|
|
850
|
-
username: 'user',
|
|
851
|
-
password: 'pass',
|
|
852
|
-
appSchema: 'tuyaSmart',
|
|
853
|
-
generateWeatherAccessory: false,
|
|
854
|
-
weatherAPI: '',
|
|
855
|
-
},
|
|
856
|
-
local: {
|
|
857
|
-
devices: [],
|
|
858
|
-
},
|
|
859
|
-
};
|
|
860
|
-
|
|
861
|
-
const bothPlatform = new TuyaPlatform(mockLog, bothConfig, mockAPI);
|
|
862
|
-
|
|
863
|
-
const mockCloudDevice = {
|
|
864
|
-
id: 'category-device-123',
|
|
865
|
-
name: 'Category Device',
|
|
866
|
-
category: 'kg',
|
|
867
|
-
product_id: 'abc123',
|
|
868
|
-
} as any;
|
|
869
|
-
|
|
870
|
-
bothPlatform.deviceManager = {
|
|
871
|
-
getDeviceDetails: async () => ({
|
|
872
|
-
success: true,
|
|
873
|
-
result: {
|
|
874
|
-
id: 'category-device-123',
|
|
875
|
-
local_key: 'category-key-123',
|
|
876
|
-
ip: '192.168.1.102',
|
|
877
|
-
},
|
|
878
|
-
}),
|
|
879
|
-
} as any;
|
|
880
|
-
|
|
881
|
-
await bothPlatform.enrichLocalConfigFromCloud([mockCloudDevice]);
|
|
882
|
-
|
|
883
|
-
if (bothPlatform.platformConfig.local?.devices) {
|
|
884
|
-
const enrichedDevice = bothPlatform.platformConfig.local.devices[0];
|
|
885
|
-
expect(enrichedDevice.category).toBe('kg');
|
|
886
|
-
}
|
|
887
|
-
});
|
|
888
|
-
|
|
889
|
-
test('handles missing local_key gracefully', async () => {
|
|
890
|
-
const bothConfig = {
|
|
891
|
-
platform: 'TuyaPlatform',
|
|
892
|
-
name: 'Tuya',
|
|
893
|
-
mode: 'both',
|
|
894
|
-
options: {
|
|
895
|
-
projectType: '2',
|
|
896
|
-
accessId: 'id',
|
|
897
|
-
accessKey: 'key',
|
|
898
|
-
countryCode: 1,
|
|
899
|
-
username: 'user',
|
|
900
|
-
password: 'pass',
|
|
901
|
-
appSchema: 'tuyaSmart',
|
|
902
|
-
generateWeatherAccessory: false,
|
|
903
|
-
weatherAPI: '',
|
|
904
|
-
},
|
|
905
|
-
local: {
|
|
906
|
-
devices: [],
|
|
907
|
-
},
|
|
908
|
-
};
|
|
909
|
-
|
|
910
|
-
const bothPlatform = new TuyaPlatform(mockLog, bothConfig, mockAPI);
|
|
911
|
-
|
|
912
|
-
const mockCloudDevice = {
|
|
913
|
-
id: 'test-device-no-key',
|
|
914
|
-
name: 'Device Without Local Key',
|
|
915
|
-
} as any;
|
|
916
|
-
|
|
917
|
-
bothPlatform.deviceManager = {
|
|
918
|
-
getDeviceDetails: async () => ({
|
|
919
|
-
success: true,
|
|
920
|
-
result: {
|
|
921
|
-
id: 'test-device-no-key',
|
|
922
|
-
// No local_key or localKey provided
|
|
923
|
-
ip: '192.168.1.200',
|
|
924
|
-
},
|
|
925
|
-
}),
|
|
926
|
-
} as any;
|
|
927
|
-
|
|
928
|
-
await bothPlatform.enrichLocalConfigFromCloud([mockCloudDevice]);
|
|
929
|
-
|
|
930
|
-
// Device should not be added to local config without local_key
|
|
931
|
-
if (bothPlatform.platformConfig.local?.devices) {
|
|
932
|
-
expect(bothPlatform.platformConfig.local.devices.length).toBe(0);
|
|
933
|
-
}
|
|
934
|
-
});
|
|
935
|
-
|
|
936
|
-
test('handles API timeout with grace', async () => {
|
|
937
|
-
const bothConfig = {
|
|
938
|
-
platform: 'TuyaPlatform',
|
|
939
|
-
name: 'Tuya',
|
|
940
|
-
mode: 'both',
|
|
941
|
-
options: {
|
|
942
|
-
projectType: '2',
|
|
943
|
-
accessId: 'id',
|
|
944
|
-
accessKey: 'key',
|
|
945
|
-
countryCode: 1,
|
|
946
|
-
username: 'user',
|
|
947
|
-
password: 'pass',
|
|
948
|
-
appSchema: 'tuyaSmart',
|
|
949
|
-
generateWeatherAccessory: false,
|
|
950
|
-
weatherAPI: '',
|
|
951
|
-
},
|
|
952
|
-
local: {
|
|
953
|
-
devices: [],
|
|
954
|
-
},
|
|
955
|
-
};
|
|
956
|
-
|
|
957
|
-
const bothPlatform = new TuyaPlatform(mockLog, bothConfig, mockAPI);
|
|
958
|
-
|
|
959
|
-
const mockCloudDevice = {
|
|
960
|
-
id: 'test-device-timeout',
|
|
961
|
-
name: 'Timeout Device',
|
|
962
|
-
} as any;
|
|
963
|
-
|
|
964
|
-
bothPlatform.deviceManager = {
|
|
965
|
-
getDeviceDetails: async () => {
|
|
966
|
-
throw new Error('Request timeout');
|
|
967
|
-
},
|
|
968
|
-
} as any;
|
|
969
|
-
|
|
970
|
-
// Should not throw, but handle gracefully
|
|
971
|
-
await expect(bothPlatform.enrichLocalConfigFromCloud([mockCloudDevice])).resolves.toBeUndefined();
|
|
972
|
-
|
|
973
|
-
// Local devices should remain empty (timeout treated as error)
|
|
974
|
-
if (bothPlatform.platformConfig.local?.devices) {
|
|
975
|
-
expect(bothPlatform.platformConfig.local.devices.length).toBe(0);
|
|
976
|
-
}
|
|
977
|
-
});
|
|
978
|
-
});
|
|
979
|
-
|
|
980
|
-
describe('mixed config scenarios', () => {
|
|
981
|
-
test('updates manual local config with cloud-provided local_key', async () => {
|
|
982
|
-
const bothConfig = {
|
|
983
|
-
platform: 'TuyaPlatform',
|
|
984
|
-
name: 'Tuya',
|
|
985
|
-
mode: 'both',
|
|
986
|
-
options: {
|
|
987
|
-
projectType: '2',
|
|
988
|
-
accessId: 'id',
|
|
989
|
-
accessKey: 'key',
|
|
990
|
-
countryCode: 1,
|
|
991
|
-
username: 'user',
|
|
992
|
-
password: 'pass',
|
|
993
|
-
appSchema: 'tuyaSmart',
|
|
994
|
-
generateWeatherAccessory: false,
|
|
995
|
-
weatherAPI: '',
|
|
996
|
-
},
|
|
997
|
-
local: {
|
|
998
|
-
devices: [
|
|
999
|
-
{
|
|
1000
|
-
tuyaDeviceId: 'manual-device-xyz',
|
|
1001
|
-
// User provided device ID but no key
|
|
1002
|
-
name: 'Manual Device No Key',
|
|
1003
|
-
},
|
|
1004
|
-
],
|
|
1005
|
-
},
|
|
1006
|
-
};
|
|
1007
|
-
|
|
1008
|
-
const bothPlatform = new TuyaPlatform(mockLog, bothConfig, mockAPI);
|
|
1009
|
-
|
|
1010
|
-
const mockCloudDevice = {
|
|
1011
|
-
id: 'manual-device-xyz',
|
|
1012
|
-
name: 'Manual Device No Key',
|
|
1013
|
-
} as any;
|
|
1014
|
-
|
|
1015
|
-
bothPlatform.deviceManager = {
|
|
1016
|
-
getDeviceDetails: async () => ({
|
|
1017
|
-
success: true,
|
|
1018
|
-
result: {
|
|
1019
|
-
id: 'manual-device-xyz',
|
|
1020
|
-
local_key: 'cloud-filled-key',
|
|
1021
|
-
ip: '192.168.1.99',
|
|
1022
|
-
},
|
|
1023
|
-
}),
|
|
1024
|
-
} as any;
|
|
1025
|
-
|
|
1026
|
-
await bothPlatform.enrichLocalConfigFromCloud([mockCloudDevice]);
|
|
1027
|
-
|
|
1028
|
-
if (bothPlatform.platformConfig.local?.devices) {
|
|
1029
|
-
const enrichedDevice = bothPlatform.platformConfig.local.devices[0];
|
|
1030
|
-
expect(enrichedDevice.tuyaDeviceId).toBe('manual-device-xyz');
|
|
1031
|
-
expect(enrichedDevice.tuyaKey).toBe('cloud-filled-key');
|
|
1032
|
-
expect(enrichedDevice.ip).toBe('192.168.1.99');
|
|
1033
|
-
// Original name should be preserved
|
|
1034
|
-
expect(enrichedDevice.name).toBe('Manual Device No Key');
|
|
1035
|
-
}
|
|
1036
|
-
});
|
|
1037
|
-
|
|
1038
|
-
test('does not overwrite existing manual local_key', async () => {
|
|
1039
|
-
const bothConfig = {
|
|
1040
|
-
platform: 'TuyaPlatform',
|
|
1041
|
-
name: 'Tuya',
|
|
1042
|
-
mode: 'both',
|
|
1043
|
-
options: {
|
|
1044
|
-
projectType: '2',
|
|
1045
|
-
accessId: 'id',
|
|
1046
|
-
accessKey: 'key',
|
|
1047
|
-
countryCode: 1,
|
|
1048
|
-
username: 'user',
|
|
1049
|
-
password: 'pass',
|
|
1050
|
-
appSchema: 'tuyaSmart',
|
|
1051
|
-
generateWeatherAccessory: false,
|
|
1052
|
-
weatherAPI: '',
|
|
1053
|
-
},
|
|
1054
|
-
local: {
|
|
1055
|
-
devices: [
|
|
1056
|
-
{
|
|
1057
|
-
tuyaDeviceId: 'device-with-manual-key',
|
|
1058
|
-
tuyaKey: 'user-provided-key-123', // User explicitly set this
|
|
1059
|
-
name: 'Device With Manual Key',
|
|
1060
|
-
},
|
|
1061
|
-
],
|
|
1062
|
-
},
|
|
826
|
+
{
|
|
827
|
+
UUID: 'service-uuid2',
|
|
828
|
+
characteristics: [
|
|
829
|
+
{ UUID: 'characteristic-uuid1' },
|
|
830
|
+
{ UUID: 'characteristic-uuid3' },
|
|
831
|
+
{ UUID: 'characteristic-uuid4' },
|
|
832
|
+
]
|
|
833
|
+
}
|
|
834
|
+
],
|
|
835
|
+
removeService: jest.fn()
|
|
1063
836
|
};
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
getDeviceDetails: async () => ({
|
|
1074
|
-
success: true,
|
|
1075
|
-
result: {
|
|
1076
|
-
id: 'device-with-manual-key',
|
|
1077
|
-
local_key: 'different-cloud-key',
|
|
1078
|
-
ip: '192.168.1.88',
|
|
837
|
+
const mockNewAccessory = {
|
|
838
|
+
services: [
|
|
839
|
+
{
|
|
840
|
+
UUID: 'service-uuid1',
|
|
841
|
+
characteristics: [
|
|
842
|
+
{ UUID: 'characteristic-uuid1' },
|
|
843
|
+
{ UUID: 'characteristic-uuid3' },
|
|
844
|
+
{ UUID: 'characteristic-uuid5' },
|
|
845
|
+
]
|
|
1079
846
|
},
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
// Manual key should be skipped (device has tuyaKey already)
|
|
1088
|
-
expect(enrichedDevice.tuyaKey).toBe('user-provided-key-123');
|
|
1089
|
-
}
|
|
1090
|
-
});
|
|
1091
|
-
});
|
|
1092
|
-
|
|
1093
|
-
describe('multi-device enrichment', () => {
|
|
1094
|
-
test('enriches multiple cloud devices in parallel', async () => {
|
|
1095
|
-
const bothConfig = {
|
|
1096
|
-
platform: 'TuyaPlatform',
|
|
1097
|
-
name: 'Tuya',
|
|
1098
|
-
mode: 'both',
|
|
1099
|
-
options: {
|
|
1100
|
-
projectType: '2',
|
|
1101
|
-
accessId: 'id',
|
|
1102
|
-
accessKey: 'key',
|
|
1103
|
-
countryCode: 1,
|
|
1104
|
-
username: 'user',
|
|
1105
|
-
password: 'pass',
|
|
1106
|
-
appSchema: 'tuyaSmart',
|
|
1107
|
-
generateWeatherAccessory: false,
|
|
1108
|
-
weatherAPI: '',
|
|
1109
|
-
},
|
|
1110
|
-
local: {
|
|
1111
|
-
devices: [],
|
|
1112
|
-
},
|
|
1113
|
-
};
|
|
1114
|
-
|
|
1115
|
-
const bothPlatform = new TuyaPlatform(mockLog, bothConfig, mockAPI);
|
|
1116
|
-
|
|
1117
|
-
const mockCloudDevices = [
|
|
1118
|
-
{ id: 'device-1', uuid: 'device-1', name: 'Device 1', product_id: 'prod-1' },
|
|
1119
|
-
{ id: 'device-2', uuid: 'device-2', name: 'Device 2', product_id: 'prod-2' },
|
|
1120
|
-
{ id: 'device-3', uuid: 'device-3', name: 'Device 3', product_id: 'prod-3' },
|
|
1121
|
-
] as any;
|
|
1122
|
-
|
|
1123
|
-
const callCount: Record<string, number> = {};
|
|
1124
|
-
bothPlatform.deviceManager = {
|
|
1125
|
-
getDeviceDetails: async (deviceId: string) => {
|
|
1126
|
-
callCount[deviceId] = (callCount[deviceId] || 0) + 1;
|
|
1127
|
-
return {
|
|
1128
|
-
success: true,
|
|
1129
|
-
result: {
|
|
1130
|
-
id: deviceId,
|
|
1131
|
-
local_key: `key-${deviceId}`,
|
|
1132
|
-
ip: `192.168.1.${Math.floor(Math.random() * 254) + 1}`,
|
|
1133
|
-
},
|
|
1134
|
-
};
|
|
1135
|
-
},
|
|
1136
|
-
} as any;
|
|
1137
|
-
|
|
1138
|
-
await bothPlatform.enrichLocalConfigFromCloud(mockCloudDevices);
|
|
1139
|
-
|
|
1140
|
-
if (bothPlatform.platformConfig.local?.devices) {
|
|
1141
|
-
expect(bothPlatform.platformConfig.local.devices.length).toBe(3);
|
|
1142
|
-
|
|
1143
|
-
const device1 = bothPlatform.platformConfig.local.devices.find(d => d.tuyaDeviceId === 'device-1');
|
|
1144
|
-
const device2 = bothPlatform.platformConfig.local.devices.find(d => d.tuyaDeviceId === 'device-2');
|
|
1145
|
-
const device3 = bothPlatform.platformConfig.local.devices.find(d => d.tuyaDeviceId === 'device-3');
|
|
1146
|
-
|
|
1147
|
-
expect(device1?.tuyaKey).toBe('key-device-1');
|
|
1148
|
-
expect(device2?.tuyaKey).toBe('key-device-2');
|
|
1149
|
-
expect(device3?.tuyaKey).toBe('key-device-3');
|
|
1150
|
-
}
|
|
1151
|
-
});
|
|
1152
|
-
|
|
1153
|
-
test('continues enrichment if single device fails', async () => {
|
|
1154
|
-
const bothConfig = {
|
|
1155
|
-
platform: 'TuyaPlatform',
|
|
1156
|
-
name: 'Tuya',
|
|
1157
|
-
mode: 'both',
|
|
1158
|
-
options: {
|
|
1159
|
-
projectType: '2',
|
|
1160
|
-
accessId: 'id',
|
|
1161
|
-
accessKey: 'key',
|
|
1162
|
-
countryCode: 1,
|
|
1163
|
-
username: 'user',
|
|
1164
|
-
password: 'pass',
|
|
1165
|
-
appSchema: 'tuyaSmart',
|
|
1166
|
-
generateWeatherAccessory: false,
|
|
1167
|
-
weatherAPI: '',
|
|
1168
|
-
},
|
|
1169
|
-
local: {
|
|
1170
|
-
devices: [],
|
|
1171
|
-
},
|
|
1172
|
-
};
|
|
1173
|
-
|
|
1174
|
-
const bothPlatform = new TuyaPlatform(mockLog, bothConfig, mockAPI);
|
|
1175
|
-
|
|
1176
|
-
const mockCloudDevices = [
|
|
1177
|
-
{ id: 'device-ok-1', uuid: 'device-ok-1', name: 'OK Device 1' },
|
|
1178
|
-
{ id: 'device-fail', uuid: 'device-fail', name: 'Failing Device' },
|
|
1179
|
-
{ id: 'device-ok-2', uuid: 'device-ok-2', name: 'OK Device 2' },
|
|
1180
|
-
] as any;
|
|
1181
|
-
|
|
1182
|
-
bothPlatform.deviceManager = {
|
|
1183
|
-
getDeviceDetails: async (deviceId: string) => {
|
|
1184
|
-
if (deviceId === 'device-fail') {
|
|
1185
|
-
return { success: false, code: 'ERROR' };
|
|
847
|
+
{
|
|
848
|
+
UUID: 'service-uuid3',
|
|
849
|
+
characteristics: [
|
|
850
|
+
{ UUID: 'characteristic-uuid2' },
|
|
851
|
+
{ UUID: 'characteristic-uuid3' },
|
|
852
|
+
{ UUID: 'characteristic-uuid4' },
|
|
853
|
+
]
|
|
1186
854
|
}
|
|
1187
|
-
|
|
1188
|
-
success: true,
|
|
1189
|
-
result: {
|
|
1190
|
-
id: deviceId,
|
|
1191
|
-
local_key: `key-${deviceId}`,
|
|
1192
|
-
ip: '192.168.1.100',
|
|
1193
|
-
},
|
|
1194
|
-
};
|
|
1195
|
-
},
|
|
1196
|
-
} as any;
|
|
1197
|
-
|
|
1198
|
-
await bothPlatform.enrichLocalConfigFromCloud(mockCloudDevices);
|
|
1199
|
-
|
|
1200
|
-
if (bothPlatform.platformConfig.local?.devices) {
|
|
1201
|
-
// Should have 2 devices (one failed, skipped)
|
|
1202
|
-
expect(bothPlatform.platformConfig.local.devices.length).toBe(2);
|
|
1203
|
-
|
|
1204
|
-
const hasOk1 = bothPlatform.platformConfig.local.devices.some(d => d.tuyaDeviceId === 'device-ok-1');
|
|
1205
|
-
const hasOk2 = bothPlatform.platformConfig.local.devices.some(d => d.tuyaDeviceId === 'device-ok-2');
|
|
1206
|
-
const hasFailed = bothPlatform.platformConfig.local.devices.some(d => d.tuyaDeviceId === 'device-fail');
|
|
1207
|
-
|
|
1208
|
-
expect(hasOk1).toBe(true);
|
|
1209
|
-
expect(hasOk2).toBe(true);
|
|
1210
|
-
expect(hasFailed).toBe(false);
|
|
1211
|
-
}
|
|
1212
|
-
});
|
|
1213
|
-
});
|
|
1214
|
-
|
|
1215
|
-
describe('device ID consistency and deduplication', () => {
|
|
1216
|
-
test('uses consistent UUID for same device across cloud and local', () => {
|
|
1217
|
-
const bothConfig = {
|
|
1218
|
-
platform: 'TuyaPlatform',
|
|
1219
|
-
name: 'Tuya',
|
|
1220
|
-
mode: 'both',
|
|
1221
|
-
options: {
|
|
1222
|
-
projectType: '2',
|
|
1223
|
-
accessId: 'id',
|
|
1224
|
-
accessKey: 'key',
|
|
1225
|
-
countryCode: 1,
|
|
1226
|
-
username: 'user',
|
|
1227
|
-
password: 'pass',
|
|
1228
|
-
appSchema: 'tuyaSmart',
|
|
1229
|
-
generateWeatherAccessory: false,
|
|
1230
|
-
weatherAPI: '',
|
|
1231
|
-
},
|
|
1232
|
-
local: {
|
|
1233
|
-
devices: [],
|
|
1234
|
-
},
|
|
1235
|
-
};
|
|
1236
|
-
|
|
1237
|
-
const bothPlatform = new TuyaPlatform(mockLog, bothConfig, mockAPI);
|
|
1238
|
-
|
|
1239
|
-
// Create mock cloud and local devices with same ID
|
|
1240
|
-
const mockCloudDevice = {
|
|
1241
|
-
id: 'same-device-id',
|
|
1242
|
-
uuid: 'same-device-id',
|
|
1243
|
-
name: 'Test Device (Cloud)',
|
|
1244
|
-
} as any;
|
|
1245
|
-
|
|
1246
|
-
const mockLocalDevice = {
|
|
1247
|
-
id: 'same-device-id',
|
|
1248
|
-
uuid: 'same-device-id',
|
|
1249
|
-
name: 'Test Device (Local)',
|
|
1250
|
-
} as any;
|
|
1251
|
-
|
|
1252
|
-
// Both should map to same UUID
|
|
1253
|
-
const cloudUUID = bothPlatform.api.hap.uuid.generate(mockCloudDevice.id);
|
|
1254
|
-
const localUUID = bothPlatform.api.hap.uuid.generate(mockLocalDevice.id);
|
|
1255
|
-
|
|
1256
|
-
expect(cloudUUID).toBe(localUUID);
|
|
1257
|
-
});
|
|
1258
|
-
|
|
1259
|
-
test('enrichment preserves device ID for accessory mapping', async () => {
|
|
1260
|
-
const bothConfig = {
|
|
1261
|
-
platform: 'TuyaPlatform',
|
|
1262
|
-
name: 'Tuya',
|
|
1263
|
-
mode: 'both',
|
|
1264
|
-
options: {
|
|
1265
|
-
projectType: '2',
|
|
1266
|
-
accessId: 'id',
|
|
1267
|
-
accessKey: 'key',
|
|
1268
|
-
countryCode: 1,
|
|
1269
|
-
username: 'user',
|
|
1270
|
-
password: 'pass',
|
|
1271
|
-
appSchema: 'tuyaSmart',
|
|
1272
|
-
generateWeatherAccessory: false,
|
|
1273
|
-
weatherAPI: '',
|
|
1274
|
-
},
|
|
1275
|
-
local: {
|
|
1276
|
-
devices: [],
|
|
1277
|
-
},
|
|
855
|
+
]
|
|
1278
856
|
};
|
|
1279
857
|
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
const mockCloudDevice = {
|
|
1283
|
-
id: 'unique-device-id',
|
|
1284
|
-
uuid: 'unique-device-id',
|
|
1285
|
-
name: 'Device',
|
|
1286
|
-
product_id: 'product-123',
|
|
1287
|
-
} as any;
|
|
1288
|
-
|
|
1289
|
-
bothPlatform.deviceManager = {
|
|
1290
|
-
getDeviceDetails: async () => ({
|
|
1291
|
-
success: true,
|
|
1292
|
-
result: {
|
|
1293
|
-
id: 'unique-device-id',
|
|
1294
|
-
local_key: 'test-key',
|
|
1295
|
-
ip: '192.168.1.1',
|
|
1296
|
-
},
|
|
1297
|
-
}),
|
|
1298
|
-
} as any;
|
|
858
|
+
Object.assign(mockAPI, { updatePlatformAccessories: jest.fn() });
|
|
1299
859
|
|
|
1300
|
-
|
|
860
|
+
const mockPlatform = new TuyaPlatform(mockLog, mockConfig, mockAPI);
|
|
861
|
+
Object.assign(mockPlatform, {
|
|
862
|
+
deviceManager: { createDeviceConfigHash: jest.fn().mockReturnValue('hash1'), devices: []},
|
|
863
|
+
addAccessory: jest.fn().mockReturnValue(mockNewAccessory),
|
|
864
|
+
removeAccessory: jest.fn()
|
|
865
|
+
});
|
|
866
|
+
|
|
867
|
+
mockPlatform.syncDeviceAndAccessory(mockDevice as any, mockOldAccessory as any);
|
|
1301
868
|
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
}
|
|
869
|
+
const mockRemoveService = jest.spyOn(mockOldAccessory, 'removeService');
|
|
870
|
+
const mockRemoveCharacteristic = jest.spyOn(mockOldAccessory.services[0], 'removeCharacteristic');
|
|
871
|
+
expect(mockRemoveService).toHaveBeenCalledWith(mockOldAccessory.services[1]);
|
|
872
|
+
expect(mockRemoveCharacteristic).toHaveBeenCalledWith(mockOldAccessory.services[0].characteristics[1]);
|
|
1307
873
|
});
|
|
1308
874
|
});
|
|
1309
875
|
});
|