@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
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, jest, test } from '@jest/globals';
|
|
2
|
+
import BaseAccessory from '../src/shared/accessory/BaseAccessory';
|
|
3
|
+
import { configureRotationSpeed, enumToPercentageProperty, integerToPercentageProperty } from '../src/shared/accessory/characteristic/RotationSpeed';
|
|
4
|
+
import { TuyaDeviceSchemaMode, TuyaDeviceSchemaType, TuyaDeviceSchemaEnumProperty, TuyaDeviceSchemaIntegerProperty, TuyaDeviceStatus, TuyaDeviceSchema } from '../src/cloud/device/TuyaDevice';
|
|
5
|
+
import { CharacteristicProps, PartialAllowingNull, Service } from 'homebridge';
|
|
6
|
+
import { ExLogger, initLogger } from '../src/shared/util/Logger';
|
|
7
|
+
|
|
8
|
+
// モック用のダミーロガー
|
|
9
|
+
const mockDebug = jest.fn();
|
|
10
|
+
// Mock Logger
|
|
11
|
+
const mockLog: ExLogger = {
|
|
12
|
+
debug: mockDebug,
|
|
13
|
+
info: jest.fn(),
|
|
14
|
+
warn: jest.fn(),
|
|
15
|
+
error: jest.fn(),
|
|
16
|
+
log: jest.fn(),
|
|
17
|
+
success: jest.fn(),
|
|
18
|
+
} as unknown as ExLogger;
|
|
19
|
+
|
|
20
|
+
describe('configureRotationSpeed', () => {
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
jest.clearAllMocks();
|
|
23
|
+
initLogger(mockLog);
|
|
24
|
+
});
|
|
25
|
+
test('maps four-level fan_speed_percent values to HomeKit percentages', async () => {
|
|
26
|
+
let rawLevel = 1;
|
|
27
|
+
let getHandler: () => number = () => 0;
|
|
28
|
+
let setHandler: (value: number) => Promise<void> = async () => undefined;
|
|
29
|
+
const characteristic = {
|
|
30
|
+
onGet: jest.fn((handler: () => number) => {
|
|
31
|
+
getHandler = handler;
|
|
32
|
+
return characteristic;
|
|
33
|
+
}),
|
|
34
|
+
onSet: jest.fn((handler: (value: number) => Promise<void>) => {
|
|
35
|
+
setHandler = handler;
|
|
36
|
+
return characteristic;
|
|
37
|
+
}),
|
|
38
|
+
updateValue: jest.fn((value: number) => characteristic),
|
|
39
|
+
setProps: jest.fn((prop: PartialAllowingNull<CharacteristicProps>) => characteristic),
|
|
40
|
+
};
|
|
41
|
+
const service = {
|
|
42
|
+
getCharacteristic: jest.fn(() => characteristic),
|
|
43
|
+
};
|
|
44
|
+
const sendCommands = jest.fn(async (command: TuyaDeviceStatus[], debounce: boolean) => undefined);
|
|
45
|
+
const accessory = {
|
|
46
|
+
Characteristic: { RotationSpeed: 'RotationSpeed' },
|
|
47
|
+
getStatus: jest.fn(() => ({ code: 'fan_speed_percent', value: rawLevel })),
|
|
48
|
+
sendCommands,
|
|
49
|
+
log: { debug: jest.fn() }
|
|
50
|
+
} as unknown as BaseAccessory;
|
|
51
|
+
const schema = {
|
|
52
|
+
code: 'fan_speed_percent',
|
|
53
|
+
mode: TuyaDeviceSchemaMode.READ_WRITE,
|
|
54
|
+
type: TuyaDeviceSchemaType.Integer,
|
|
55
|
+
property: { min: 1, max: 4, scale: 0, step: 1, unit: '' },
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
configureRotationSpeed(accessory, service as never, schema);
|
|
59
|
+
|
|
60
|
+
expect(characteristic.setProps).toHaveBeenCalledWith({ minValue: 0, maxValue: 100, minStep: 25, unit: '%' });
|
|
61
|
+
expect(characteristic.updateValue).toHaveBeenCalledWith(25);
|
|
62
|
+
expect([1, 2, 3, 4].map(level => {
|
|
63
|
+
rawLevel = level;
|
|
64
|
+
return getHandler();
|
|
65
|
+
})).toEqual([25, 50, 75, 100]);
|
|
66
|
+
|
|
67
|
+
for (const [percent, level] of [[25, 1], [50, 2], [75, 3], [100, 4]]) {
|
|
68
|
+
await setHandler(percent);
|
|
69
|
+
expect(sendCommands).toHaveBeenLastCalledWith(
|
|
70
|
+
[{ code: 'fan_speed_percent', value: level }],
|
|
71
|
+
true,
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
await setHandler(0);
|
|
76
|
+
expect(sendCommands).toHaveBeenCalledTimes(4);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
describe('switching configuration method', () => {
|
|
81
|
+
test('Test whether the appropriate configure method is being selected and invoked correctly.', () => {
|
|
82
|
+
let getHandler: () => number = () => 0;
|
|
83
|
+
let setHandler: (value: number) => Promise<void> = async () => undefined;
|
|
84
|
+
const characteristic = {
|
|
85
|
+
onGet: jest.fn((handler: () => number) => {
|
|
86
|
+
getHandler = handler;
|
|
87
|
+
return characteristic;
|
|
88
|
+
}),
|
|
89
|
+
onSet: jest.fn((handler: (value: number) => Promise<void>) => {
|
|
90
|
+
setHandler = handler;
|
|
91
|
+
return characteristic;
|
|
92
|
+
}),
|
|
93
|
+
updateValue: jest.fn((value: number) => characteristic),
|
|
94
|
+
setProps: jest.fn((prop: PartialAllowingNull<CharacteristicProps>) => characteristic),
|
|
95
|
+
};
|
|
96
|
+
const accessory = {
|
|
97
|
+
log: mockLog,
|
|
98
|
+
Characteristic: { RotationSpeed: 'RotationSpeed' },
|
|
99
|
+
getStatus: jest.fn(() => ({ code: 'fan_speed_percent', value: 0 })),
|
|
100
|
+
} as unknown as BaseAccessory;
|
|
101
|
+
const service = { getCharacteristic: jest.fn(() => characteristic) } as unknown as Service;
|
|
102
|
+
const schemaEnum = { type: TuyaDeviceSchemaType.Enum, property: {range: ["slow", "medium", "fast", "auto"]} } as TuyaDeviceSchema;
|
|
103
|
+
const schemaInteger = { type: TuyaDeviceSchemaType.Integer, property: { min: 0, max: 50, step: 2, scale: 0, unit: 'percent' } } as TuyaDeviceSchema;
|
|
104
|
+
const schemaOther = { type: 'other' } as unknown as TuyaDeviceSchema;
|
|
105
|
+
|
|
106
|
+
mockDebug.mockReset();
|
|
107
|
+
// Call the function with different schema types
|
|
108
|
+
configureRotationSpeed(accessory, service, schemaEnum);
|
|
109
|
+
configureRotationSpeed(accessory, service, schemaInteger);
|
|
110
|
+
configureRotationSpeed(accessory, service, schemaOther);
|
|
111
|
+
configureRotationSpeed(accessory, service, undefined);
|
|
112
|
+
|
|
113
|
+
// Check if the correct functions were called
|
|
114
|
+
expect(mockDebug).toHaveBeenNthCalledWith(1, 'configureRotationSpeedEnum');
|
|
115
|
+
expect(mockDebug).toHaveBeenNthCalledWith(2, 'Set props for RotationSpeed:', {"maxValue": 100, "minStep": 33, "minValue": 0, "unit": "%"});
|
|
116
|
+
expect(mockDebug).toHaveBeenNthCalledWith(3, 'configureRotationSpeedInteger');
|
|
117
|
+
expect(mockDebug).toHaveBeenNthCalledWith(4, 'Set props for RotationSpeed:', {"maxValue": 100, "minStep": 4, "minValue": 0, "unit": "%"});
|
|
118
|
+
expect(mockDebug).toHaveBeenNthCalledWith(5, 'configureRotationSpeedOn');
|
|
119
|
+
expect(mockDebug).toHaveBeenNthCalledWith(6, 'Set props for RotationSpeed:', {"maxValue": 100, "minStep": 100, "minValue": 0, "unit": "%"});
|
|
120
|
+
expect(mockDebug).toHaveBeenCalledTimes(6);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
describe('convert property', () => {
|
|
125
|
+
test('integerToPercentageProperty no changes', () => {
|
|
126
|
+
const property = { min: 1, max: 100, step: 1, scale: 0, unit: '%' } as unknown as TuyaDeviceSchemaIntegerProperty;
|
|
127
|
+
expect(integerToPercentageProperty(property)).toEqual({ minValue: 0, maxValue: 100, minStep: 1, unit: '%' });
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test('integerToPercentageProperty returns 25% steps for 1..4 levels', () => {
|
|
131
|
+
const property = { min: 1, max: 4, step: 1, scale: 0, unit: '' } as unknown as TuyaDeviceSchemaIntegerProperty;
|
|
132
|
+
expect(integerToPercentageProperty(property)).toEqual({ minValue: 0, maxValue: 100, minStep: 25, unit: '%' });
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test('integerToPercentageProperty returns 33% steps for 0..3 levels', () => {
|
|
136
|
+
const property = { min: 0, max: 3, step: 1, scale: 0, unit: '' } as unknown as TuyaDeviceSchemaIntegerProperty;
|
|
137
|
+
expect(integerToPercentageProperty(property)).toEqual({ minValue: 0, maxValue: 100, minStep: 33, unit: '%' });
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
test('integerToPercentageProperty which step is not 1.', () => {
|
|
141
|
+
const property = { min: 0, max: 20, step: 2, scale: 0, unit: '' } as unknown as TuyaDeviceSchemaIntegerProperty;
|
|
142
|
+
expect(integerToPercentageProperty(property)).toEqual({ minValue: 0, maxValue: 100, minStep: 10, unit: '%' });
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
test('enumToPercentageProperty returns 25% steps for 4 enum values', () => {
|
|
146
|
+
const property = { range: ['low', 'medium', 'high', 'auto'] } as unknown as TuyaDeviceSchemaEnumProperty;
|
|
147
|
+
expect(enumToPercentageProperty(property)).toEqual({ minValue: 0, maxValue: 100, minStep: 25, unit: '%' });
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
});
|
|
@@ -2,25 +2,27 @@
|
|
|
2
2
|
import { describe, expect, test, beforeEach, jest } from '@jest/globals';
|
|
3
3
|
import TuyaCustomDeviceManager from '../src/cloud/device/TuyaCustomDeviceManager';
|
|
4
4
|
import TuyaDevice from '../src/cloud/device/TuyaDevice';
|
|
5
|
+
import { TuyaPlatformCustomConfig, TuyaPluginMode } from '../src/config';
|
|
6
|
+
import { ExLogger, initLogger } from '../src/shared/util/Logger';
|
|
5
7
|
|
|
6
8
|
// Mock Logger
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
PrefixLogger: class PrefixLogger {
|
|
16
|
-
constructor(public log: any, public name: string, public debug: boolean) {}
|
|
17
|
-
},
|
|
18
|
-
}));
|
|
9
|
+
const mockLog: ExLogger = {
|
|
10
|
+
debug: jest.fn(),
|
|
11
|
+
info: jest.fn(),
|
|
12
|
+
warn: jest.fn(),
|
|
13
|
+
error: jest.fn(),
|
|
14
|
+
log: jest.fn(),
|
|
15
|
+
success: jest.fn(),
|
|
16
|
+
} as unknown as ExLogger;
|
|
19
17
|
|
|
20
18
|
// Mock TuyaOpenMQ
|
|
21
19
|
jest.mock('../src/cloud/api/TuyaOpenMQ', () => {
|
|
22
20
|
return class MockTuyaOpenMQ {
|
|
23
|
-
version
|
|
21
|
+
version: string;
|
|
22
|
+
|
|
23
|
+
constructor() {
|
|
24
|
+
this.version = '1.0';
|
|
25
|
+
}
|
|
24
26
|
addMessageListener() {}
|
|
25
27
|
start() {}
|
|
26
28
|
stop() {}
|
|
@@ -30,16 +32,31 @@ jest.mock('../src/cloud/api/TuyaOpenMQ', () => {
|
|
|
30
32
|
describe('TuyaCustomDeviceManager', () => {
|
|
31
33
|
let manager: TuyaCustomDeviceManager;
|
|
32
34
|
let mockAPI: any;
|
|
35
|
+
let mockConfig: any;
|
|
33
36
|
|
|
34
37
|
beforeEach(() => {
|
|
38
|
+
jest.clearAllMocks();
|
|
39
|
+
initLogger(mockLog);
|
|
40
|
+
|
|
35
41
|
mockAPI = {
|
|
36
42
|
log: { log: console.log } as any,
|
|
37
43
|
post: jest.fn(),
|
|
38
44
|
get: jest.fn(),
|
|
39
45
|
tokenInfo: { uid: 'test_uid' },
|
|
40
46
|
};
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
mockConfig = {
|
|
48
|
+
projectType: '1',
|
|
49
|
+
endpoint: 'https://openapi.tuyaeu.com',
|
|
50
|
+
accessId: 'test_access_id',
|
|
51
|
+
accessKey: 'test_access_key',
|
|
52
|
+
username: 'user@example.com',
|
|
53
|
+
password: 'password',
|
|
54
|
+
generateWeatherAccessory: true,
|
|
55
|
+
weatherAPI: 'openweathermap',
|
|
56
|
+
forceIPv4: false
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
manager = new TuyaCustomDeviceManager(mockAPI, mockConfig, false);
|
|
43
60
|
});
|
|
44
61
|
|
|
45
62
|
describe('initialization', () => {
|
|
@@ -49,7 +66,7 @@ describe('TuyaCustomDeviceManager', () => {
|
|
|
49
66
|
});
|
|
50
67
|
|
|
51
68
|
test('sets MQTT version to 2.0', () => {
|
|
52
|
-
const customManager = new TuyaCustomDeviceManager(mockAPI, false);
|
|
69
|
+
const customManager = new TuyaCustomDeviceManager(mockAPI, mockConfig, false);
|
|
53
70
|
expect(customManager.mq.version).toBe('2.0');
|
|
54
71
|
});
|
|
55
72
|
|
|
@@ -59,7 +76,7 @@ describe('TuyaCustomDeviceManager', () => {
|
|
|
59
76
|
});
|
|
60
77
|
|
|
61
78
|
test('supports debug mode', () => {
|
|
62
|
-
const debugManager = new TuyaCustomDeviceManager(mockAPI, true);
|
|
79
|
+
const debugManager = new TuyaCustomDeviceManager(mockAPI, mockConfig, true);
|
|
63
80
|
expect(debugManager.debug).toBe(true);
|
|
64
81
|
});
|
|
65
82
|
});
|
|
@@ -466,4 +483,81 @@ describe('TuyaCustomDeviceManager', () => {
|
|
|
466
483
|
expect(mockAPI.post.mock.calls[0][1].asset_ids).toBe(assetIds.join(','));
|
|
467
484
|
});
|
|
468
485
|
});
|
|
486
|
+
|
|
487
|
+
describe('get device config', () => {
|
|
488
|
+
test('resolves device config precedence: device, then product, then global', () => {
|
|
489
|
+
const config = {
|
|
490
|
+
platform: 'TuyaPlatform',
|
|
491
|
+
name: 'Tuya',
|
|
492
|
+
mode: 'cloud',
|
|
493
|
+
cloud: {
|
|
494
|
+
projectType: '1',
|
|
495
|
+
endpoint: 'https://openapi.tuyaeu.com',
|
|
496
|
+
accessId: 'test_access_id',
|
|
497
|
+
accessKey: 'test_access_key',
|
|
498
|
+
username: 'user@example.com',
|
|
499
|
+
password: 'password',
|
|
500
|
+
generateWeatherAccessory: true,
|
|
501
|
+
weatherAPI: 'openweathermap',
|
|
502
|
+
forceIPv4: false,
|
|
503
|
+
deviceOverrides: [
|
|
504
|
+
{ id: 'global', category: 'global-cat', configFor: TuyaPluginMode.cloud },
|
|
505
|
+
{ id: 'prod-1', category: 'product-cat', configFor: TuyaPluginMode.cloud },
|
|
506
|
+
{ id: 'device-1', category: 'device-cat', configFor: TuyaPluginMode.cloud },
|
|
507
|
+
],
|
|
508
|
+
} as TuyaPlatformCustomConfig,
|
|
509
|
+
};
|
|
510
|
+
|
|
511
|
+
const deviceManager = new TuyaCustomDeviceManager(mockAPI, config.cloud, false);
|
|
512
|
+
|
|
513
|
+
const exact = deviceManager.getDeviceConfig({ id: 'device-1', uuid: 'uuid-1', product_id: 'prod-1' } as any);
|
|
514
|
+
const byProduct = deviceManager.getDeviceConfig({ id: 'device-2', uuid: 'uuid-2', product_id: 'prod-1' } as any);
|
|
515
|
+
const fallback = deviceManager.getDeviceConfig({ id: 'device-3', uuid: 'uuid-3', product_id: 'prod-3' } as any);
|
|
516
|
+
|
|
517
|
+
expect(exact?.category).toBe('device-cat');
|
|
518
|
+
expect(byProduct?.category).toBe('product-cat');
|
|
519
|
+
expect(fallback?.category).toBe('global-cat');
|
|
520
|
+
});
|
|
521
|
+
});
|
|
522
|
+
|
|
523
|
+
describe('get device config', () => {
|
|
524
|
+
test('finds schema config case-insensitively', () => {
|
|
525
|
+
const config = {
|
|
526
|
+
platform: 'TuyaPlatform',
|
|
527
|
+
name: 'Tuya',
|
|
528
|
+
mode: 'cloud',
|
|
529
|
+
cloud: {
|
|
530
|
+
projectType: '1',
|
|
531
|
+
endpoint: 'https://openapi.tuyaeu.com',
|
|
532
|
+
accessId: 'test_access_id',
|
|
533
|
+
accessKey: 'test_access_key',
|
|
534
|
+
username: 'user@example.com',
|
|
535
|
+
password: 'password',
|
|
536
|
+
generateWeatherAccessory: true,
|
|
537
|
+
weatherAPI: 'openweathermap',
|
|
538
|
+
forceIPv4: false,
|
|
539
|
+
deviceOverrides: [
|
|
540
|
+
{
|
|
541
|
+
id: 'device-1',
|
|
542
|
+
schema: [
|
|
543
|
+
{ code: 'switch_1', newCode: 'new_switch_1', hidden: true },
|
|
544
|
+
],
|
|
545
|
+
configFor: TuyaPluginMode.cloud
|
|
546
|
+
},
|
|
547
|
+
],
|
|
548
|
+
} as TuyaPlatformCustomConfig,
|
|
549
|
+
};
|
|
550
|
+
|
|
551
|
+
const deviceManager = new TuyaCustomDeviceManager(mockAPI, config.cloud, false);
|
|
552
|
+
|
|
553
|
+
const device = { id: 'device-1', uuid: 'device-1', product_id: 'prod-1' } as any;
|
|
554
|
+
|
|
555
|
+
const result = deviceManager!.getDeviceSchemaConfig(device, 'SWITCH_1');
|
|
556
|
+
|
|
557
|
+
expect(result).toBeDefined();
|
|
558
|
+
expect(result?.code).toBe('switch_1');
|
|
559
|
+
expect((result as any).newCode).toBe('new_switch_1');
|
|
560
|
+
expect(result?.hidden).toBe(true);
|
|
561
|
+
});
|
|
562
|
+
});
|
|
469
563
|
});
|