@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.
Files changed (321) hide show
  1. package/README.md +364 -142
  2. package/config.schema.json +1299 -894
  3. package/dist/cloud/api/TuyaOpenAPI.js +108 -60
  4. package/dist/cloud/api/TuyaOpenAPI.js.map +1 -1
  5. package/dist/cloud/api/TuyaOpenMQ.js +45 -22
  6. package/dist/cloud/api/TuyaOpenMQ.js.map +1 -1
  7. package/dist/cloud/device/{TuyaDeviceManager.js → TuyaCloudDeviceManager.js} +146 -96
  8. package/dist/cloud/device/TuyaCloudDeviceManager.js.map +1 -0
  9. package/dist/cloud/device/TuyaCustomDeviceManager.js +75 -5
  10. package/dist/cloud/device/TuyaCustomDeviceManager.js.map +1 -1
  11. package/dist/cloud/device/TuyaDevice.js.map +1 -1
  12. package/dist/cloud/device/TuyaHomeDeviceManager.js +81 -13
  13. package/dist/cloud/device/TuyaHomeDeviceManager.js.map +1 -1
  14. package/dist/config.js +26 -5
  15. package/dist/config.js.map +1 -1
  16. package/dist/local/DynamicChildDiscovery.js +2 -1
  17. package/dist/local/DynamicChildDiscovery.js.map +1 -1
  18. package/dist/local/LocalDevice.js +108 -11
  19. package/dist/local/LocalDevice.js.map +1 -1
  20. package/dist/local/LocalDeviceManager.js +362 -177
  21. package/dist/local/LocalDeviceManager.js.map +1 -1
  22. package/dist/local/TuyaDiscovery.js +17 -8
  23. package/dist/local/TuyaDiscovery.js.map +1 -1
  24. package/dist/local/ZigbeeGatewayDetection.js +7 -4
  25. package/dist/local/ZigbeeGatewayDetection.js.map +1 -1
  26. package/dist/local/protocol/ProtocolUtilities.js +61 -27
  27. package/dist/local/protocol/ProtocolUtilities.js.map +1 -1
  28. package/dist/local/protocol/ProtocolV31V32.js +61 -11
  29. package/dist/local/protocol/ProtocolV31V32.js.map +1 -1
  30. package/dist/local/protocol/ProtocolV33.js +4 -2
  31. package/dist/local/protocol/ProtocolV33.js.map +1 -1
  32. package/dist/local/protocol/ProtocolV34.js +10 -5
  33. package/dist/local/protocol/ProtocolV34.js.map +1 -1
  34. package/dist/local/protocol/ProtocolV35.js +17 -6
  35. package/dist/local/protocol/ProtocolV35.js.map +1 -1
  36. package/dist/platform.js +263 -497
  37. package/dist/platform.js.map +1 -1
  38. package/dist/settings.js +0 -2
  39. package/dist/settings.js.map +1 -1
  40. package/dist/shared/TuyaDeviceManager.js +147 -0
  41. package/dist/shared/TuyaDeviceManager.js.map +1 -0
  42. package/dist/shared/TuyaHybridDeviceManager.js +219 -0
  43. package/dist/shared/TuyaHybridDeviceManager.js.map +1 -0
  44. package/dist/shared/accessory/AccessoryFactory.js +359 -0
  45. package/dist/shared/accessory/AccessoryFactory.js.map +1 -0
  46. package/dist/shared/{accessories → accessory}/AirConditionerAccessory.js +129 -23
  47. package/dist/shared/accessory/AirConditionerAccessory.js.map +1 -0
  48. package/dist/shared/{accessories → accessory}/AirPurifierAccessory.js.map +1 -1
  49. package/dist/shared/accessory/AirQualitySensorAccessory.js.map +1 -0
  50. package/dist/shared/{accessories → accessory}/BaseAccessory.js +47 -97
  51. package/dist/shared/accessory/BaseAccessory.js.map +1 -0
  52. package/dist/shared/{accessories → accessory}/BlindsAccessory.js.map +1 -1
  53. package/dist/shared/{accessories → accessory}/CameraAccessory.js +9 -3
  54. package/dist/shared/accessory/CameraAccessory.js.map +1 -0
  55. package/dist/shared/{accessories → accessory}/CarbonDioxideSensorAccessory.js.map +1 -1
  56. package/dist/shared/{accessories → accessory}/CarbonMonoxideSensorAccessory.js.map +1 -1
  57. package/dist/shared/accessory/CatToiletAccessory.js +130 -0
  58. package/dist/shared/accessory/CatToiletAccessory.js.map +1 -0
  59. package/dist/shared/{accessories → accessory}/ContactSensorAccessory.js.map +1 -1
  60. package/dist/shared/{accessories → accessory}/DehumidifierAccessory.js.map +1 -1
  61. package/dist/shared/{accessories → accessory}/DiffuserAccessory.js.map +1 -1
  62. package/dist/shared/{accessories → accessory}/DimmerAccessory.js.map +1 -1
  63. package/dist/shared/{accessories → accessory}/DoorbellAccessory.js.map +1 -1
  64. package/dist/shared/{accessories → accessory}/ExtractionHoodAccessory.js.map +1 -1
  65. package/dist/shared/{accessories → accessory}/FanAccessory.js +16 -4
  66. package/dist/shared/accessory/FanAccessory.js.map +1 -0
  67. package/dist/shared/{accessories → accessory}/GarageDoorAccessory.js +19 -2
  68. package/dist/shared/accessory/GarageDoorAccessory.js.map +1 -0
  69. package/dist/shared/{accessories → accessory}/HeaterAccessory.js +3 -0
  70. package/dist/shared/accessory/HeaterAccessory.js.map +1 -0
  71. package/dist/shared/{accessories → accessory}/HeaterAccessory_old.js.map +1 -1
  72. package/dist/shared/accessory/HumanPresenceSensorAccessory.js.map +1 -0
  73. package/dist/shared/{accessories → accessory}/HumidifierAccessory.js.map +1 -1
  74. package/dist/shared/accessory/IRAdapter.js +169 -0
  75. package/dist/shared/accessory/IRAdapter.js.map +1 -0
  76. package/dist/shared/{accessories → accessory}/IRAirConditionerAccessory.js +2 -2
  77. package/dist/shared/accessory/IRAirConditionerAccessory.js.map +1 -0
  78. package/dist/shared/accessory/IRControlHubAccessory.js.map +1 -0
  79. package/dist/shared/accessory/IRControlHubSubAccessory.js.map +1 -0
  80. package/dist/shared/accessory/IRFanAccessory.js +109 -0
  81. package/dist/shared/accessory/IRFanAccessory.js.map +1 -0
  82. package/dist/shared/accessory/IRGenericAccessory.js.map +1 -0
  83. package/dist/shared/{accessories → accessory}/LeakSensorAccessory.js.map +1 -1
  84. package/dist/shared/{accessories → accessory}/LightAccessory.js.map +1 -1
  85. package/dist/shared/{accessories → accessory}/LightSensorAccessory.js.map +1 -1
  86. package/dist/shared/{accessories → accessory}/LocationWeatherAccessory.js +9 -36
  87. package/dist/shared/accessory/LocationWeatherAccessory.js.map +1 -0
  88. package/dist/shared/{accessories → accessory}/LockAccessory.js +3 -3
  89. package/dist/shared/{accessories → accessory}/LockAccessory.js.map +1 -1
  90. package/dist/shared/accessory/MotionSensorAccessory.js.map +1 -0
  91. package/dist/shared/accessory/OutletAccessory.js.map +1 -0
  92. package/dist/shared/{accessories → accessory}/PetFeederAccessory.js.map +1 -1
  93. package/dist/shared/accessory/SaunaAccessory.js +134 -0
  94. package/dist/shared/accessory/SaunaAccessory.js.map +1 -0
  95. package/dist/shared/{accessories → accessory}/SceneAccessory.js +1 -1
  96. package/dist/shared/accessory/SceneAccessory.js.map +1 -0
  97. package/dist/shared/accessory/SceneSwitchAccessory.js.map +1 -0
  98. package/dist/shared/{accessories → accessory}/SecuritySystemAccessory.js +4 -4
  99. package/dist/shared/accessory/SecuritySystemAccessory.js.map +1 -0
  100. package/dist/shared/{accessories → accessory}/SmokeSensorAccessory.js.map +1 -1
  101. package/dist/shared/{accessories → accessory}/SwitchAccessory.js +1 -45
  102. package/dist/shared/accessory/SwitchAccessory.js.map +1 -0
  103. package/dist/shared/accessory/TemperatureHumiditySensorAccessory.js.map +1 -0
  104. package/dist/shared/{accessories → accessory}/ThermostatAccessory.js.map +1 -1
  105. package/dist/shared/{accessories → accessory}/TowerRackAccessory.js.map +1 -1
  106. package/dist/shared/{accessories → accessory}/ValveAccessory.js.map +1 -1
  107. package/dist/shared/{accessories → accessory}/VibrationSensorAccessory.js.map +1 -1
  108. package/dist/shared/accessory/WeatherStationAccessory.js.map +1 -0
  109. package/dist/shared/accessory/WetBulbGlobeTemperatureAccessory.js.map +1 -0
  110. package/dist/shared/{accessories → accessory}/WhiteNoiseLightAccessory.js +1 -0
  111. package/dist/shared/accessory/WhiteNoiseLightAccessory.js.map +1 -0
  112. package/dist/shared/accessory/WindowAccessory.js.map +1 -0
  113. package/dist/shared/{accessories → accessory}/WindowCoveringAccessory.js.map +1 -1
  114. package/dist/shared/{accessories → accessory}/WirelessSwitchAccessory.js.map +1 -1
  115. package/dist/shared/accessory/characteristic/Active.js.map +1 -0
  116. package/dist/shared/accessory/characteristic/AirQuality.js.map +1 -0
  117. package/dist/shared/{accessories → accessory}/characteristic/CurrentRelativeHumidity.js +3 -0
  118. package/dist/shared/accessory/characteristic/CurrentRelativeHumidity.js.map +1 -0
  119. package/dist/shared/accessory/characteristic/CurrentTemperature.js.map +1 -0
  120. package/dist/shared/accessory/characteristic/CurrentWeather.js.map +1 -0
  121. package/dist/shared/accessory/characteristic/CurrentWeatherByOpenMeteo.js.map +1 -0
  122. package/dist/shared/{accessories → accessory}/characteristic/CurrentWetBulbGlobeTemperature.js +3 -2
  123. package/dist/shared/accessory/characteristic/CurrentWetBulbGlobeTemperature.js.map +1 -0
  124. package/dist/shared/{accessories → accessory}/characteristic/EnergyUsage.js +0 -5
  125. package/dist/shared/accessory/characteristic/EnergyUsage.js.map +1 -0
  126. package/dist/shared/accessory/characteristic/EnumOn.js +48 -0
  127. package/dist/shared/accessory/characteristic/EnumOn.js.map +1 -0
  128. package/dist/shared/accessory/characteristic/ExtraCharacteristicAdapter.js +197 -0
  129. package/dist/shared/accessory/characteristic/ExtraCharacteristicAdapter.js.map +1 -0
  130. package/dist/shared/{accessories → accessory}/characteristic/Light.js +62 -12
  131. package/dist/shared/accessory/characteristic/Light.js.map +1 -0
  132. package/dist/shared/accessory/characteristic/LightSensor.js.map +1 -0
  133. package/dist/shared/{accessories → accessory}/characteristic/LockPhysicalControls.js +3 -0
  134. package/dist/shared/accessory/characteristic/LockPhysicalControls.js.map +1 -0
  135. package/dist/shared/accessory/characteristic/MotionDetected.js.map +1 -0
  136. package/dist/shared/accessory/characteristic/Name.js.map +1 -0
  137. package/dist/shared/accessory/characteristic/OccupancyDetected.js.map +1 -0
  138. package/dist/shared/{accessories → accessory}/characteristic/On.js +3 -2
  139. package/dist/shared/accessory/characteristic/On.js.map +1 -0
  140. package/dist/shared/accessory/characteristic/OutletInUse.js.map +1 -0
  141. package/dist/shared/accessory/characteristic/ProgrammableSwitchEvent.js.map +1 -0
  142. package/dist/shared/accessory/characteristic/RawOn.js +93 -0
  143. package/dist/shared/accessory/characteristic/RawOn.js.map +1 -0
  144. package/dist/shared/{accessories → accessory}/characteristic/RelativeHumidityDehumidifierThreshold.js +3 -0
  145. package/dist/shared/accessory/characteristic/RelativeHumidityDehumidifierThreshold.js.map +1 -0
  146. package/dist/shared/accessory/characteristic/RotationSpeed.js +157 -0
  147. package/dist/shared/accessory/characteristic/RotationSpeed.js.map +1 -0
  148. package/dist/shared/accessory/characteristic/SecuritySystemState.js.map +1 -0
  149. package/dist/shared/{accessories → accessory}/characteristic/SwingMode.js +3 -0
  150. package/dist/shared/accessory/characteristic/SwingMode.js.map +1 -0
  151. package/dist/shared/accessory/characteristic/TargetTemperature.js.map +1 -0
  152. package/dist/shared/{accessories → accessory}/characteristic/TemperatureDisplayUnits.js +9 -2
  153. package/dist/shared/accessory/characteristic/TemperatureDisplayUnits.js.map +1 -0
  154. package/dist/shared/util/ConfigHash.js +2 -2
  155. package/dist/shared/util/ConfigHash.js.map +1 -1
  156. package/dist/shared/util/ConfigMigrator.js +222 -0
  157. package/dist/shared/util/ConfigMigrator.js.map +1 -0
  158. package/dist/shared/util/FfmpegStreamingProcess.js +62 -0
  159. package/dist/shared/util/FfmpegStreamingProcess.js.map +1 -1
  160. package/dist/shared/util/InfraredTool.js +0 -2
  161. package/dist/shared/util/InfraredTool.js.map +1 -1
  162. package/dist/shared/util/Logger.js +85 -10
  163. package/dist/shared/util/Logger.js.map +1 -1
  164. package/dist/shared/util/TuyaStreamDelegate.js +201 -99
  165. package/dist/shared/util/TuyaStreamDelegate.js.map +1 -1
  166. package/dist/shared/util/color.js +15 -4
  167. package/dist/shared/util/color.js.map +1 -1
  168. package/dist/shared/util/util.js +91 -5
  169. package/dist/shared/util/util.js.map +1 -1
  170. package/docs/ADVANCED_OPTIONS.md +623 -0
  171. package/docs/CONFIG_GUIDE.md +616 -0
  172. package/docs/Get-Local-Keys-for-Your-Devices.md +246 -0
  173. package/{SUPPORTED_DEVICES.md → docs/SUPPORTED_DEVICES.md} +27 -5
  174. package/eslint.config.mjs +0 -1
  175. package/{jest.config.js → jest.config.ts} +5 -2
  176. package/package.json +14 -11
  177. package/test/ConfigMigrator.test.ts +1060 -0
  178. package/test/FanAccessory.test.ts +458 -0
  179. package/test/Light.test.ts +424 -0
  180. package/test/Logger.test.ts +482 -0
  181. package/test/ProtocolV31V32.test.ts +42 -0
  182. package/test/accessoryFactory.data.test.ts +176 -0
  183. package/test/accessoryFactory.test.ts +65 -35
  184. package/test/airConditioner.swing.test.ts +226 -0
  185. package/test/airConditioner.test.ts +770 -0
  186. package/test/color.test.ts +52 -0
  187. package/test/config.test.ts +17 -13
  188. package/test/custom.test.ts +2 -2
  189. package/test/errorHandling.test.ts +12 -12
  190. package/test/fanAccessory.test.ts +458 -0
  191. package/test/home.test.ts +1 -1
  192. package/test/hybridDeviceManager.test.ts +808 -0
  193. package/test/infraredTools.test.ts +67 -0
  194. package/test/light.test.ts +424 -0
  195. package/test/localDevice.test.ts +31 -53
  196. package/test/localDeviceManager.behavior.test.ts +211 -37
  197. package/test/localDeviceManager.test.ts +124 -41
  198. package/test/mqttMessages.test.ts +40 -16
  199. package/test/platform.test.ts +380 -814
  200. package/test/platform.validation.local.test.ts +90 -120
  201. package/test/protocol.test.ts +27 -12
  202. package/test/protocol35Frames.test.ts +204 -0
  203. package/test/rotationSpeed.test.ts +150 -0
  204. package/test/tuyaCustomDeviceManager.test.ts +111 -17
  205. package/test/tuyaDeviceManager.test.ts +655 -645
  206. package/test/tuyaDiscovery.test.ts +21 -33
  207. package/test/tuyaHomeDeviceManager.test.ts +114 -19
  208. package/test/tuyaOpenAPI.test.ts +25 -44
  209. package/test/tuyaOpenMQ.test.ts +15 -23
  210. package/test/util.test.ts +107 -7
  211. package/test/zigbee/LocalDevice.zigbee.test.ts +14 -18
  212. package/test/zigbee/LocalDeviceManager.cloud-discovery.test.ts +19 -20
  213. package/test/zigbee/LocalDeviceManager.zigbee.reconnect.test.ts +19 -20
  214. package/test/zigbee/LocalDeviceManager.zigbee.test.ts +73 -35
  215. package/test/zigbee/ZigbeeGatewayDetection.test.ts +2 -2
  216. package/ADVANCED_OPTIONS.md +0 -267
  217. package/dist/cloud/device/TuyaDeviceManager.js.map +0 -1
  218. package/dist/local/CloudLocalReconciliation.js +0 -180
  219. package/dist/local/CloudLocalReconciliation.js.map +0 -1
  220. package/dist/shared/accessories/AccessoryFactory.js +0 -309
  221. package/dist/shared/accessories/AccessoryFactory.js.map +0 -1
  222. package/dist/shared/accessories/AirConditionerAccessory.js.map +0 -1
  223. package/dist/shared/accessories/AirQualitySensorAccessory.js.map +0 -1
  224. package/dist/shared/accessories/BaseAccessory.js.map +0 -1
  225. package/dist/shared/accessories/CameraAccessory.js.map +0 -1
  226. package/dist/shared/accessories/FanAccessory.js.map +0 -1
  227. package/dist/shared/accessories/GarageDoorAccessory.js.map +0 -1
  228. package/dist/shared/accessories/HeaterAccessory.js.map +0 -1
  229. package/dist/shared/accessories/HumanPresenceSensorAccessory.js.map +0 -1
  230. package/dist/shared/accessories/IRAirConditionerAccessory.js.map +0 -1
  231. package/dist/shared/accessories/IRControlHubAccessory.js.map +0 -1
  232. package/dist/shared/accessories/IRControlHubSubAccessory.js.map +0 -1
  233. package/dist/shared/accessories/IRGenericAccessory.js.map +0 -1
  234. package/dist/shared/accessories/LocationWeatherAccessory.js.map +0 -1
  235. package/dist/shared/accessories/MotionSensorAccessory.js.map +0 -1
  236. package/dist/shared/accessories/OutletAccessory.js.map +0 -1
  237. package/dist/shared/accessories/SceneAccessory.js.map +0 -1
  238. package/dist/shared/accessories/SceneSwitchAccessory.js.map +0 -1
  239. package/dist/shared/accessories/SecuritySystemAccessory.js.map +0 -1
  240. package/dist/shared/accessories/SwitchAccessory.js.map +0 -1
  241. package/dist/shared/accessories/TemperatureHumiditySensorAccessory.js.map +0 -1
  242. package/dist/shared/accessories/WeatherStationAccessory.js.map +0 -1
  243. package/dist/shared/accessories/WetBulbGlobeTemperatureAccessory.js.map +0 -1
  244. package/dist/shared/accessories/WhiteNoiseLightAccessory.js.map +0 -1
  245. package/dist/shared/accessories/WindowAccessory.js.map +0 -1
  246. package/dist/shared/accessories/characteristic/Active.js.map +0 -1
  247. package/dist/shared/accessories/characteristic/AirQuality.js.map +0 -1
  248. package/dist/shared/accessories/characteristic/CurrentRelativeHumidity.js.map +0 -1
  249. package/dist/shared/accessories/characteristic/CurrentTemperature.js.map +0 -1
  250. package/dist/shared/accessories/characteristic/CurrentWeather.js.map +0 -1
  251. package/dist/shared/accessories/characteristic/CurrentWeatherByOpenMeteo.js.map +0 -1
  252. package/dist/shared/accessories/characteristic/CurrentWetBulbGlobeTemperature.js.map +0 -1
  253. package/dist/shared/accessories/characteristic/EnergyUsage.js.map +0 -1
  254. package/dist/shared/accessories/characteristic/Light.js.map +0 -1
  255. package/dist/shared/accessories/characteristic/LightSensor.js.map +0 -1
  256. package/dist/shared/accessories/characteristic/LockPhysicalControls.js.map +0 -1
  257. package/dist/shared/accessories/characteristic/MotionDetected.js.map +0 -1
  258. package/dist/shared/accessories/characteristic/Name.js.map +0 -1
  259. package/dist/shared/accessories/characteristic/OccupancyDetected.js.map +0 -1
  260. package/dist/shared/accessories/characteristic/On.js.map +0 -1
  261. package/dist/shared/accessories/characteristic/OutletInUse.js.map +0 -1
  262. package/dist/shared/accessories/characteristic/ProgrammableSwitchEvent.js.map +0 -1
  263. package/dist/shared/accessories/characteristic/RelativeHumidityDehumidifierThreshold.js.map +0 -1
  264. package/dist/shared/accessories/characteristic/RotationSpeed.js +0 -78
  265. package/dist/shared/accessories/characteristic/RotationSpeed.js.map +0 -1
  266. package/dist/shared/accessories/characteristic/SecuritySystemState.js.map +0 -1
  267. package/dist/shared/accessories/characteristic/SwingMode.js.map +0 -1
  268. package/dist/shared/accessories/characteristic/TargetTemperature.js.map +0 -1
  269. package/dist/shared/accessories/characteristic/TemperatureDisplayUnits.js.map +0 -1
  270. package/test/zigbee/CloudLocalReconciliation.test.ts +0 -284
  271. package/tuya-local-configs/dev-1.hash +0 -1
  272. package/tuya-local-configs/device1.hash +0 -1
  273. package/wiki/Get-Local-Keys-for-Your-Devices.md +0 -85
  274. /package/dist/shared/{accessories → accessory}/AirPurifierAccessory.js +0 -0
  275. /package/dist/shared/{accessories → accessory}/AirQualitySensorAccessory.js +0 -0
  276. /package/dist/shared/{accessories → accessory}/BlindsAccessory.js +0 -0
  277. /package/dist/shared/{accessories → accessory}/CarbonDioxideSensorAccessory.js +0 -0
  278. /package/dist/shared/{accessories → accessory}/CarbonMonoxideSensorAccessory.js +0 -0
  279. /package/dist/shared/{accessories → accessory}/ContactSensorAccessory.js +0 -0
  280. /package/dist/shared/{accessories → accessory}/DehumidifierAccessory.js +0 -0
  281. /package/dist/shared/{accessories → accessory}/DiffuserAccessory.js +0 -0
  282. /package/dist/shared/{accessories → accessory}/DimmerAccessory.js +0 -0
  283. /package/dist/shared/{accessories → accessory}/DoorbellAccessory.js +0 -0
  284. /package/dist/shared/{accessories → accessory}/ExtractionHoodAccessory.js +0 -0
  285. /package/dist/shared/{accessories → accessory}/HeaterAccessory_old.js +0 -0
  286. /package/dist/shared/{accessories → accessory}/HumanPresenceSensorAccessory.js +0 -0
  287. /package/dist/shared/{accessories → accessory}/HumidifierAccessory.js +0 -0
  288. /package/dist/shared/{accessories → accessory}/IRControlHubAccessory.js +0 -0
  289. /package/dist/shared/{accessories → accessory}/IRControlHubSubAccessory.js +0 -0
  290. /package/dist/shared/{accessories → accessory}/IRGenericAccessory.js +0 -0
  291. /package/dist/shared/{accessories → accessory}/LeakSensorAccessory.js +0 -0
  292. /package/dist/shared/{accessories → accessory}/LightAccessory.js +0 -0
  293. /package/dist/shared/{accessories → accessory}/LightSensorAccessory.js +0 -0
  294. /package/dist/shared/{accessories → accessory}/MotionSensorAccessory.js +0 -0
  295. /package/dist/shared/{accessories → accessory}/OutletAccessory.js +0 -0
  296. /package/dist/shared/{accessories → accessory}/PetFeederAccessory.js +0 -0
  297. /package/dist/shared/{accessories → accessory}/SceneSwitchAccessory.js +0 -0
  298. /package/dist/shared/{accessories → accessory}/SmokeSensorAccessory.js +0 -0
  299. /package/dist/shared/{accessories → accessory}/TemperatureHumiditySensorAccessory.js +0 -0
  300. /package/dist/shared/{accessories → accessory}/ThermostatAccessory.js +0 -0
  301. /package/dist/shared/{accessories → accessory}/TowerRackAccessory.js +0 -0
  302. /package/dist/shared/{accessories → accessory}/ValveAccessory.js +0 -0
  303. /package/dist/shared/{accessories → accessory}/VibrationSensorAccessory.js +0 -0
  304. /package/dist/shared/{accessories → accessory}/WeatherStationAccessory.js +0 -0
  305. /package/dist/shared/{accessories → accessory}/WetBulbGlobeTemperatureAccessory.js +0 -0
  306. /package/dist/shared/{accessories → accessory}/WindowAccessory.js +0 -0
  307. /package/dist/shared/{accessories → accessory}/WindowCoveringAccessory.js +0 -0
  308. /package/dist/shared/{accessories → accessory}/WirelessSwitchAccessory.js +0 -0
  309. /package/dist/shared/{accessories → accessory}/characteristic/Active.js +0 -0
  310. /package/dist/shared/{accessories → accessory}/characteristic/AirQuality.js +0 -0
  311. /package/dist/shared/{accessories → accessory}/characteristic/CurrentTemperature.js +0 -0
  312. /package/dist/shared/{accessories → accessory}/characteristic/CurrentWeather.js +0 -0
  313. /package/dist/shared/{accessories → accessory}/characteristic/CurrentWeatherByOpenMeteo.js +0 -0
  314. /package/dist/shared/{accessories → accessory}/characteristic/LightSensor.js +0 -0
  315. /package/dist/shared/{accessories → accessory}/characteristic/MotionDetected.js +0 -0
  316. /package/dist/shared/{accessories → accessory}/characteristic/Name.js +0 -0
  317. /package/dist/shared/{accessories → accessory}/characteristic/OccupancyDetected.js +0 -0
  318. /package/dist/shared/{accessories → accessory}/characteristic/OutletInUse.js +0 -0
  319. /package/dist/shared/{accessories → accessory}/characteristic/ProgrammableSwitchEvent.js +0 -0
  320. /package/dist/shared/{accessories → accessory}/characteristic/SecuritySystemState.js +0 -0
  321. /package/dist/shared/{accessories → accessory}/characteristic/TargetTemperature.js +0 -0
@@ -0,0 +1,424 @@
1
+ import { beforeEach, describe, expect, jest, test } from '@jest/globals';
2
+ import Logger, { initLogger } from '../src/shared/util/Logger';
3
+ import { configureLight } from '../src/shared/accessory/characteristic/Light';
4
+ import { TuyaDeviceSchemaType } from '../src/cloud/device/TuyaDevice';
5
+
6
+ // Mock Logger
7
+ const mockLogger: Logger = {
8
+ debug: jest.fn(),
9
+ info: jest.fn(),
10
+ warn: jest.fn(),
11
+ error: jest.fn(),
12
+ log: jest.fn(),
13
+ } as unknown as Logger;
14
+
15
+ describe('Light Characteristic', () => {
16
+ let accessoryMock = {
17
+ getService: jest.fn(),
18
+ addService: jest.fn(),
19
+ removeService: jest.fn(),
20
+ getStatus: jest.fn(),
21
+ log: mockLogger,
22
+ deviceManager: {
23
+ getDevice: jest.fn(),
24
+ enableAdaptiveLighting: jest.fn(),
25
+ },
26
+ Characteristic: {
27
+ On: jest.fn(),
28
+ Brightness: jest.fn(),
29
+ ColorTemperature: jest.fn(),
30
+ Hue: jest.fn(),
31
+ Saturation: jest.fn(),
32
+ },
33
+ Service: {
34
+ Lightbulb: jest.fn(),
35
+ Switch: jest.fn(),
36
+ },
37
+ } as unknown as any;
38
+ let serviceMock = {
39
+ getCharacteristic: jest.fn().mockReturnValue({
40
+ onGet: jest.fn().mockReturnThis(),
41
+ onSet: jest.fn().mockReturnThis(),
42
+ setProps: jest.fn(),
43
+ updateValue: jest.fn(),
44
+ }),
45
+ } as unknown as any;
46
+
47
+ beforeEach(() => {
48
+ jest.resetModules();
49
+ initLogger(mockLogger);
50
+ });
51
+
52
+ describe('ensureHSVProperty', () => {
53
+ let spyLogDebug = jest.spyOn(mockLogger, 'debug').mockImplementation(() => {});
54
+
55
+ beforeEach(() => {
56
+ jest.resetModules();
57
+ spyLogDebug.mockClear();
58
+ });
59
+
60
+ test('color schema with defined property', () => {
61
+ const onSchema = { code: 'on', type: TuyaDeviceSchemaType.Boolean } as any;
62
+ const brightSchema = { code: 'bright', type: TuyaDeviceSchemaType.Integer } as any;
63
+ const tempSchema = { code: 'temp', type: TuyaDeviceSchemaType.Integer } as any;
64
+ const colorSchema = {
65
+ code: 'color',
66
+ type: TuyaDeviceSchemaType.Json,
67
+ property: {
68
+ h: { type: TuyaDeviceSchemaType.Integer, min: 0, max: 360, scale: 0 },
69
+ s: { type: TuyaDeviceSchemaType.Integer, min: 0, max: 1000, scale: 0 },
70
+ v: { type: TuyaDeviceSchemaType.Integer, min: 0, max: 1000, scale: 0 },
71
+ },
72
+ } as any;
73
+ const modeSchema = { code: 'mode', type: TuyaDeviceSchemaType.Enum, property: { range: ['colour', 'white'] } } as any;
74
+
75
+ configureLight(accessoryMock, serviceMock, onSchema, brightSchema, tempSchema, colorSchema, modeSchema);
76
+ expect(spyLogDebug).toHaveBeenCalledWith('hsvProperty: %O', colorSchema.property);
77
+ });
78
+
79
+ test('color schema without defined property but mode includes colour', () => {
80
+ const onSchema = { code: 'on', type: TuyaDeviceSchemaType.Boolean } as any;
81
+ const brightSchema = { code: 'bright', type: TuyaDeviceSchemaType.Integer } as any;
82
+ const tempSchema = { code: 'temp', type: TuyaDeviceSchemaType.Integer } as any;
83
+ const colorSchema = { code: 'color', type: TuyaDeviceSchemaType.Json } as any; // No property
84
+ const modeSchema = { code: 'mode', type: TuyaDeviceSchemaType.Enum, property: { range: ['colour', 'white'] } } as any;
85
+
86
+ configureLight(accessoryMock, serviceMock, onSchema, brightSchema, tempSchema, colorSchema, modeSchema);
87
+ expect(spyLogDebug).toHaveBeenCalledWith('hsvProperty: %O', {
88
+ h: { type: TuyaDeviceSchemaType.Integer, min: 0, max: 360, scale: 0 },
89
+ s: { type: TuyaDeviceSchemaType.Integer, min: 0, max: 1000, scale: 0 },
90
+ v: { type: TuyaDeviceSchemaType.Integer, min: 0, max: 1000, scale: 0 },
91
+ });
92
+ expect(colorSchema.property).toEqual({
93
+ h: { type: TuyaDeviceSchemaType.Integer, min: 0, max: 360, scale: 0 },
94
+ s: { type: TuyaDeviceSchemaType.Integer, min: 0, max: 1000, scale: 0 },
95
+ v: { type: TuyaDeviceSchemaType.Integer, min: 0, max: 1000, scale: 0 },
96
+ });
97
+ });
98
+
99
+ test('color schema without defined property and mode does not include colour', () => {
100
+ const onSchema = { code: 'on', type: TuyaDeviceSchemaType.Boolean } as any;
101
+ const brightSchema = { code: 'bright', type: TuyaDeviceSchemaType.Integer } as any;
102
+ const tempSchema = { code: 'temp', type: TuyaDeviceSchemaType.Integer } as any;
103
+ const colorSchema = { code: 'color', type: TuyaDeviceSchemaType.Json } as any; // No property
104
+ const modeSchema = { code: 'mode', type: TuyaDeviceSchemaType.Enum, property: { range: ['white'] } } as any;
105
+
106
+ configureLight(accessoryMock, serviceMock, onSchema, brightSchema, tempSchema, colorSchema, modeSchema);
107
+ expect(spyLogDebug).toHaveBeenCalledWith('hsvProperty: %O', {});
108
+ expect(colorSchema.property).toBeUndefined();
109
+ });
110
+
111
+ test('color schema with non JSON type but with defined property includes colour', () => {
112
+ const onSchema = { code: 'on', type: TuyaDeviceSchemaType.Boolean } as any;
113
+ const brightSchema = { code: 'bright', type: TuyaDeviceSchemaType.Integer } as any;
114
+ const tempSchema = { code: 'temp', type: TuyaDeviceSchemaType.Integer } as any;
115
+ const colorSchema = {
116
+ code: 'color',
117
+ type: 'unsupported',
118
+ property: {
119
+ h: { type: TuyaDeviceSchemaType.Integer, min: 0, max: 360, scale: 0 },
120
+ s: { type: TuyaDeviceSchemaType.Integer, min: 0, max: 1000, scale: 0 },
121
+ v: { type: TuyaDeviceSchemaType.Integer, min: 0, max: 1000, scale: 0 },
122
+ },
123
+ } as any;
124
+ const modeSchema = { code: 'mode', type: TuyaDeviceSchemaType.Enum, property: { range: ['colour', 'white'] } } as any;
125
+
126
+ configureLight(accessoryMock, serviceMock, onSchema, brightSchema, tempSchema, colorSchema, modeSchema);
127
+ expect(spyLogDebug).toHaveBeenCalledWith('hsvProperty: %O', colorSchema.property);
128
+ });
129
+ });
130
+
131
+ describe('getLightType', () => {
132
+ let spyLogInfo = jest.spyOn(mockLogger, 'info').mockImplementation(() => {});
133
+
134
+ beforeEach(() => {
135
+ jest.resetModules();
136
+ spyLogInfo.mockClear();
137
+ });
138
+
139
+ test('Unknown light type when no schemas are provided', () => {
140
+ const onSchema = { code: 'on', type: TuyaDeviceSchemaType.Boolean } as any;
141
+ const tempSchema = { code: 'temp', type: TuyaDeviceSchemaType.Integer } as any;
142
+ configureLight(accessoryMock, serviceMock, onSchema, undefined, tempSchema);
143
+ expect(spyLogInfo).toHaveBeenCalledWith('Light type: %s', 'Unknown');
144
+ });
145
+
146
+ test('Normal light type when only on schema is provided', () => {
147
+ const onSchema = { code: 'on', type: TuyaDeviceSchemaType.Boolean } as any;
148
+
149
+ configureLight(accessoryMock, serviceMock, onSchema);
150
+ expect(spyLogInfo).toHaveBeenCalledWith('Light type: %s', 'Normal');
151
+ });
152
+
153
+ test('CW light type when on and temp schemas are provided', () => {
154
+ const onSchema = { code: 'on', type: TuyaDeviceSchemaType.Boolean } as any;
155
+ const brightSchema = { code: 'bright', type: TuyaDeviceSchemaType.Integer } as any;
156
+ const tempSchema = { code: 'temp', type: TuyaDeviceSchemaType.Integer } as any;
157
+
158
+ configureLight(accessoryMock, serviceMock, onSchema, brightSchema, tempSchema);
159
+ expect(spyLogInfo).toHaveBeenCalledWith('Light type: %s', 'CW');
160
+ });
161
+
162
+ test('RGB light type when on and color schemas are provided', () => {
163
+ const onSchema = { code: 'on', type: TuyaDeviceSchemaType.Boolean } as any;
164
+ const colorSchema = {
165
+ code: 'color',
166
+ type: TuyaDeviceSchemaType.Json,
167
+ property: {
168
+ h: { type: TuyaDeviceSchemaType.Integer, min: 0, max: 360, scale: 0 },
169
+ s: { type: TuyaDeviceSchemaType.Integer, min: 0, max: 1000, scale: 0 },
170
+ v: { type: TuyaDeviceSchemaType.Integer, min: 0, max: 1000, scale: 0 },
171
+ },
172
+ } as any;
173
+
174
+ configureLight(accessoryMock, serviceMock, onSchema, undefined, undefined, colorSchema);
175
+ expect(spyLogInfo).toHaveBeenCalledWith('Light type: %s', 'RGB');
176
+ });
177
+
178
+ test('RGBC light type when on, color, and mode schemas are provided with mode including colour', () => {
179
+ const onSchema = { code: 'on', type: TuyaDeviceSchemaType.Boolean } as any;
180
+ const brightSchema = { code: 'bright', type: TuyaDeviceSchemaType.Integer } as any;
181
+ const colorSchema = {
182
+ code: 'color',
183
+ type: TuyaDeviceSchemaType.Json,
184
+ property: {
185
+ h: { type: TuyaDeviceSchemaType.Integer, min: 0, max: 360, scale: 0 },
186
+ s: { type: TuyaDeviceSchemaType.Integer, min: 0, max: 1000, scale: 0 },
187
+ v: { type: TuyaDeviceSchemaType.Integer, min: 0, max: 1000, scale: 0 },
188
+ },
189
+ } as any;
190
+ const modeSchema = { code: 'mode', type: TuyaDeviceSchemaType.Enum, property: { range: ['colour', 'white'] } } as any;
191
+
192
+ configureLight(accessoryMock, serviceMock, onSchema, brightSchema, undefined, colorSchema, modeSchema);
193
+ expect(spyLogInfo).toHaveBeenCalledWith('Light type: %s', 'RGBC');
194
+ });
195
+
196
+ test('RGBCW light type', () => {
197
+ const onSchema = { code: 'on', type: TuyaDeviceSchemaType.Boolean } as any;
198
+ const brightSchema = { code: 'bright', type: TuyaDeviceSchemaType.Integer } as any;
199
+ const tempSchema = { code: 'temp', type: TuyaDeviceSchemaType.Integer } as any;
200
+ const colorSchema = { code: 'color', type: TuyaDeviceSchemaType.Json, property: { h: {}, s: {}, v: {} } } as any;
201
+ const modeSchema = { code: 'mode', type: TuyaDeviceSchemaType.Enum, property: { range: ['colour', 'white'] } } as any;
202
+
203
+ configureLight(accessoryMock, serviceMock, onSchema, brightSchema, tempSchema, colorSchema, modeSchema);
204
+ expect(spyLogInfo).toHaveBeenCalledWith('Light type: %s', 'RGBCW');
205
+ });
206
+
207
+ test('RGBCW light type with JSON color schema without property but mode includes colour', () => {
208
+ const onSchema = { code: 'on', type: TuyaDeviceSchemaType.Boolean } as any;
209
+ const brightSchema = { code: 'bright', type: TuyaDeviceSchemaType.Integer } as any;
210
+ const tempSchema = { code: 'temp', type: TuyaDeviceSchemaType.Integer } as any;
211
+ const colorSchema = { code: 'color', type: TuyaDeviceSchemaType.Json } as any; // No property
212
+ const modeSchema = { code: 'mode', type: TuyaDeviceSchemaType.Enum, property: { range: ['colour', 'white'] } } as any;
213
+
214
+ configureLight(accessoryMock, serviceMock, onSchema, brightSchema, tempSchema, colorSchema, modeSchema);
215
+ expect(spyLogInfo).toHaveBeenCalledWith('Light type: %s', 'RGBCW');
216
+ });
217
+
218
+ test('RGBCW light type with JSON color schema without property and mode does not include colour', () => {
219
+ const onSchema = { code: 'on', type: TuyaDeviceSchemaType.Boolean } as any;
220
+ const brightSchema = { code: 'bright', type: TuyaDeviceSchemaType.Integer } as any;
221
+ const tempSchema = { code: 'temp', type: TuyaDeviceSchemaType.Integer } as any;
222
+ const colorSchema = { code: 'color', type: TuyaDeviceSchemaType.Json } as any; // No property
223
+ const modeSchema = { code: 'mode', type: TuyaDeviceSchemaType.Enum, property: { range: ['white'] } } as any;
224
+
225
+ configureLight(accessoryMock, serviceMock, onSchema, brightSchema, tempSchema, colorSchema, modeSchema);
226
+ expect(spyLogInfo).toHaveBeenCalledWith('Light type: %s', 'CW');
227
+ });
228
+
229
+ test('RGBCW light type with non JSON color schema', () => {
230
+ const onSchema = { code: 'on', type: TuyaDeviceSchemaType.Boolean } as any;
231
+ const brightSchema = { code: 'bright', type: TuyaDeviceSchemaType.Integer } as any;
232
+ const tempSchema = { code: 'temp', type: TuyaDeviceSchemaType.Integer } as any;
233
+ const colorSchema = { code: 'color', type: 'unsupported' } as any; // Unsupported type
234
+ const modeSchema = { code: 'mode', type: TuyaDeviceSchemaType.Enum, property: { range: ['colour', 'white'] } } as any;
235
+
236
+ configureLight(accessoryMock, serviceMock, onSchema, brightSchema, tempSchema, colorSchema, modeSchema);
237
+ expect(spyLogInfo).toHaveBeenCalledWith('Light type: %s', 'CW');
238
+ });
239
+
240
+ test('RGBCW light type with non JSON with property color schema', () => {
241
+ const onSchema = { code: 'on', type: TuyaDeviceSchemaType.Boolean } as any;
242
+ const brightSchema = { code: 'bright', type: TuyaDeviceSchemaType.Integer } as any;
243
+ const tempSchema = { code: 'temp', type: TuyaDeviceSchemaType.Integer } as any;
244
+ const colorSchema = { code: 'color', type: 'unsupported', property: { h: {}, s: {}, v: {} } } as any; // Unsupported type but has property
245
+ const modeSchema = { code: 'mode', type: TuyaDeviceSchemaType.Enum, property: { range: ['colour', 'white'] } } as any;
246
+
247
+ configureLight(accessoryMock, serviceMock, onSchema, brightSchema, tempSchema, colorSchema, modeSchema);
248
+ expect(spyLogInfo).toHaveBeenCalledWith('Light type: %s', 'RGBCW');
249
+ });
250
+
251
+ });
252
+
253
+ describe('configureLight - ON handler bundles brightness', () => {
254
+ let mockAccessory: any;
255
+ let mockService: any;
256
+ let handlers: Record<string, { onGet?: Function; onSet?: Function }>;
257
+
258
+ beforeEach(() => {
259
+ handlers = {};
260
+
261
+ const makeCharChain = (name: string) => ({
262
+ onGet: jest.fn(function (this: any, handler: Function) {
263
+ handlers[name] = handlers[name] || {};
264
+ handlers[name].onGet = handler;
265
+ return this;
266
+ }),
267
+ onSet: jest.fn(function (this: any, handler: Function) {
268
+ handlers[name] = handlers[name] || {};
269
+ handlers[name].onSet = handler;
270
+ return this;
271
+ }),
272
+ setProps: jest.fn().mockReturnThis(),
273
+ updateValue: jest.fn().mockReturnThis(),
274
+ });
275
+
276
+ const onChar = makeCharChain('On');
277
+ const brightChar = makeCharChain('Brightness');
278
+
279
+ mockService = {
280
+ getCharacteristic: jest.fn((charType: any) => {
281
+ if (charType === 'MockOn') return onChar;
282
+ if (charType === 'MockBrightness') return brightChar;
283
+ return makeCharChain('other');
284
+ }),
285
+ };
286
+
287
+ mockAccessory = {
288
+ Characteristic: { On: 'MockOn', Brightness: 'MockBrightness' },
289
+ Service: { Lightbulb: 'MockLightbulb' },
290
+ accessory: {
291
+ displayName: 'Test Light',
292
+ getService: jest.fn(() => null),
293
+ addService: jest.fn(() => mockService),
294
+ },
295
+ log: { info: jest.fn(), debug: jest.fn(), warn: jest.fn() },
296
+ platform: { getDeviceConfig: jest.fn(() => undefined) },
297
+ deviceManager: { enableAdaptiveLighting: jest.fn(() => false)},
298
+ checkOnlineStatus: jest.fn(),
299
+ getStatus: jest.fn((code: string) => {
300
+ if (code === 'light') return { code: 'light', value: true };
301
+ if (code === 'bright_value') return { code: 'bright_value', value: 420 };
302
+ if (code === 'switch_led') return { code: 'switch_led', value: false };
303
+ if (code === 'bright_value_1') return { code: 'bright_value_1', value: 100 };
304
+ return undefined;
305
+ }),
306
+ sendCommands: jest.fn(),
307
+ };
308
+ });
309
+
310
+ function makeSchema(code: string, type = 'Boolean', property: any = {}) {
311
+ return { code, mode: 'rw', type, property };
312
+ }
313
+
314
+ function brightSchema(code = 'bright_value') {
315
+ return makeSchema(code, 'Integer', { min: 10, max: 1000, scale: 0, step: 1 });
316
+ }
317
+
318
+ test('LightType.C: ON sends both on + cached brightness', async () => {
319
+ configureLight(
320
+ mockAccessory,
321
+ mockService,
322
+ makeSchema('light') as any,
323
+ brightSchema() as any,
324
+ );
325
+
326
+ expect(handlers['On']?.onSet).toBeDefined();
327
+ await handlers['On'].onSet!(true);
328
+
329
+ expect(mockAccessory.sendCommands).toHaveBeenCalledWith(
330
+ [
331
+ { code: 'light', value: true },
332
+ { code: 'bright_value', value: 420 },
333
+ ],
334
+ true,
335
+ );
336
+ });
337
+
338
+ test('LightType.C: OFF sends only the on command (no brightness)', async () => {
339
+ configureLight(
340
+ mockAccessory,
341
+ mockService,
342
+ makeSchema('light') as any,
343
+ brightSchema() as any,
344
+ );
345
+
346
+ await handlers['On'].onSet!(false);
347
+
348
+ expect(mockAccessory.sendCommands).toHaveBeenCalledWith(
349
+ [{ code: 'light', value: false }],
350
+ true,
351
+ );
352
+ });
353
+
354
+ test('dual-light warm channel: ON bundles warm brightness', async () => {
355
+ configureLight(
356
+ mockAccessory,
357
+ mockService,
358
+ makeSchema('light') as any,
359
+ brightSchema('bright_value') as any,
360
+ );
361
+
362
+ await handlers['On'].onSet!(true);
363
+
364
+ expect(mockAccessory.sendCommands).toHaveBeenCalledWith(
365
+ [
366
+ { code: 'light', value: true },
367
+ { code: 'bright_value', value: 420 },
368
+ ],
369
+ true,
370
+ );
371
+ });
372
+
373
+ test('dual-light white channel: ON bundles white brightness', async () => {
374
+ configureLight(
375
+ mockAccessory,
376
+ mockService,
377
+ makeSchema('switch_led') as any,
378
+ brightSchema('bright_value_1') as any,
379
+ );
380
+
381
+ await handlers['On'].onSet!(true);
382
+
383
+ expect(mockAccessory.sendCommands).toHaveBeenCalledWith(
384
+ [
385
+ { code: 'switch_led', value: true },
386
+ { code: 'bright_value_1', value: 100 },
387
+ ],
388
+ true,
389
+ );
390
+ });
391
+
392
+ test('brightness-only set does not include on command', async () => {
393
+ configureLight(
394
+ mockAccessory,
395
+ mockService,
396
+ makeSchema('light') as any,
397
+ brightSchema() as any,
398
+ );
399
+
400
+ await handlers['Brightness'].onSet!(42);
401
+
402
+ expect(mockAccessory.sendCommands).toHaveBeenCalledWith(
403
+ [{ code: 'bright_value', value: 420 }],
404
+ true,
405
+ );
406
+ });
407
+
408
+ test('ON without brightness schema does not crash', async () => {
409
+ configureLight(
410
+ mockAccessory,
411
+ mockService,
412
+ makeSchema('light') as any,
413
+ );
414
+
415
+ expect(handlers['On']?.onSet).toBeDefined();
416
+ await handlers['On'].onSet!(true);
417
+
418
+ expect(mockAccessory.sendCommands).toHaveBeenCalledWith(
419
+ [{ code: 'light', value: true }],
420
+ true,
421
+ );
422
+ });
423
+ });
424
+ });