@switchbot/homebridge-switchbot 5.0.0-beta.9 → 5.0.0-beta.90
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/.github/ISSUE_TEMPLATE/e2e-verification.md +36 -0
- package/.github/workflows/ci.yml +32 -0
- package/.github/workflows/manual-e2e.yml +115 -0
- package/.github/workflows/release.yml +0 -4
- package/CHANGELOG.md +35 -0
- package/E2E-VERIFICATION.md +121 -0
- package/MIGRATION.md +44 -0
- package/README.md +56 -3
- package/config.schema.json +91 -14787
- package/dist/deviceFactory.d.ts +13 -0
- package/dist/deviceFactory.d.ts.map +1 -0
- package/dist/deviceFactory.js +81 -0
- package/dist/deviceFactory.js.map +1 -0
- package/dist/devices/deviceBase.d.ts +50 -0
- package/dist/devices/deviceBase.d.ts.map +1 -0
- package/dist/devices/deviceBase.js +119 -0
- package/dist/devices/deviceBase.js.map +1 -0
- package/dist/devices/genericDevice.d.ts +283 -0
- package/dist/devices/genericDevice.d.ts.map +1 -0
- package/dist/devices/genericDevice.js +1035 -0
- package/dist/devices/genericDevice.js.map +1 -0
- package/dist/homebridge-ui/public/index.html +630 -246
- package/dist/homebridge-ui/server.d.ts +3 -1
- package/dist/homebridge-ui/server.d.ts.map +1 -1
- package/dist/homebridge-ui/server.js +367 -36
- package/dist/homebridge-ui/server.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -32
- package/dist/index.js.map +1 -1
- package/dist/platform.d.ts +35 -0
- package/dist/platform.d.ts.map +1 -0
- package/dist/platform.js +514 -0
- package/dist/platform.js.map +1 -0
- package/dist/settings.d.ts +10 -249
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +5 -30
- package/dist/settings.js.map +1 -1
- package/dist/switchbotClient.d.ts +32 -0
- package/dist/switchbotClient.d.ts.map +1 -0
- package/dist/switchbotClient.js +194 -0
- package/dist/switchbotClient.js.map +1 -0
- package/dist/utils.d.ts +39 -50
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +39 -688
- package/dist/utils.js.map +1 -1
- package/docs/assets/highlight.css +14 -0
- package/docs/assets/icons.js +1 -1
- package/docs/assets/icons.svg +1 -1
- package/docs/assets/main.js +2 -2
- package/docs/assets/style.css +3 -3
- package/docs/index.html +77 -13
- package/docs/variables/default.html +1 -1
- package/eslint.config.js +2 -8
- package/package.json +21 -28
- package/scripts/e2e/README.md +25 -0
- package/scripts/e2e/curtain-e2e.sh +70 -0
- package/scripts/e2e/fan-e2e.sh +75 -0
- package/scripts/e2e/light-advanced-e2e.sh +97 -0
- package/scripts/e2e/light-e2e.sh +75 -0
- package/scripts/e2e/list-accessories.sh +19 -0
- package/scripts/e2e/lock-e2e.sh +65 -0
- package/scripts/generate-matter-maps.js +60 -0
- package/scripts/run-e2e-local.sh +14 -0
- package/src/deviceFactory.ts +122 -0
- package/src/devices/deviceBase.ts +141 -0
- package/src/devices/genericDevice.ts +965 -0
- package/src/homebridge-ui/public/index.html +630 -246
- package/src/homebridge-ui/server.ts +434 -41
- package/src/index.ts +4 -33
- package/src/platform.ts +515 -0
- package/src/settings.ts +12 -277
- package/src/switchbotClient.ts +203 -0
- package/src/utils.ts +45 -713
- package/test/accessory-restore.spec.ts +73 -0
- package/test/device-mapping.spec.ts +37 -0
- package/test/deviceFactory.spec.ts +18 -0
- package/test/e2e/run-e2e.spec.ts +50 -0
- package/test/fan-swing.spec.ts +29 -0
- package/test/helpers/matter-harness.ts +53 -0
- package/test/lock-users.spec.ts +44 -0
- package/test/matter-childbridge.spec.ts +55 -0
- package/test/matter-descriptors.spec.ts +97 -0
- package/test/matter-device-state.spec.ts +101 -0
- package/test/matter-integration.spec.ts +70 -0
- package/test/platform.integration.spec.ts +55 -0
- package/test/switchbot-client-debounce.spec.ts +131 -0
- package/test/switchbot-client-openapi.spec.ts +56 -0
- package/test/switchbotClient.spec.ts +10 -0
- package/test/utils.spec.ts +20 -0
- package/vitest.config.ts +7 -0
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/clover.xml +0 -15847
- package/coverage/coverage-final.json +0 -42
- package/coverage/docs/assets/dmt/dmt-component-data.js.html +0 -85
- package/coverage/docs/assets/dmt/dmt-components.js.html +0 -286
- package/coverage/docs/assets/dmt/index.html +0 -131
- package/coverage/docs/assets/hierarchy.js.html +0 -85
- package/coverage/docs/assets/icons.js.html +0 -136
- package/coverage/docs/assets/index.html +0 -146
- package/coverage/docs/assets/main.js.html +0 -265
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +0 -191
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -196
- package/coverage/src/device/blindtilt.ts.html +0 -3238
- package/coverage/src/device/bot.ts.html +0 -2803
- package/coverage/src/device/ceilinglight.ts.html +0 -2338
- package/coverage/src/device/colorbulb.ts.html +0 -2824
- package/coverage/src/device/contact.ts.html +0 -1465
- package/coverage/src/device/curtain.ts.html +0 -2869
- package/coverage/src/device/device.ts.html +0 -2500
- package/coverage/src/device/fan.ts.html +0 -2242
- package/coverage/src/device/hub.ts.html +0 -1408
- package/coverage/src/device/humidifier.ts.html +0 -2116
- package/coverage/src/device/index.html +0 -416
- package/coverage/src/device/iosensor.ts.html +0 -1375
- package/coverage/src/device/lightstrip.ts.html +0 -2617
- package/coverage/src/device/lock.ts.html +0 -1963
- package/coverage/src/device/meter.ts.html +0 -1372
- package/coverage/src/device/meterplus.ts.html +0 -1384
- package/coverage/src/device/meterpro.ts.html +0 -1618
- package/coverage/src/device/motion.ts.html +0 -1264
- package/coverage/src/device/plug.ts.html +0 -1372
- package/coverage/src/device/relayswitch.ts.html +0 -2284
- package/coverage/src/device/robotvacuumcleaner.ts.html +0 -1810
- package/coverage/src/device/waterdetector.ts.html +0 -1294
- package/coverage/src/homebridge-ui/index.html +0 -116
- package/coverage/src/homebridge-ui/server.ts.html +0 -229
- package/coverage/src/index.html +0 -161
- package/coverage/src/index.ts.html +0 -124
- package/coverage/src/irdevice/airconditioner.ts.html +0 -1687
- package/coverage/src/irdevice/airpurifier.ts.html +0 -844
- package/coverage/src/irdevice/camera.ts.html +0 -475
- package/coverage/src/irdevice/fan.ts.html +0 -766
- package/coverage/src/irdevice/index.html +0 -251
- package/coverage/src/irdevice/irdevice.ts.html +0 -1117
- package/coverage/src/irdevice/light.ts.html +0 -826
- package/coverage/src/irdevice/other.ts.html +0 -2458
- package/coverage/src/irdevice/tv.ts.html +0 -1222
- package/coverage/src/irdevice/vacuumcleaner.ts.html +0 -466
- package/coverage/src/irdevice/waterheater.ts.html +0 -469
- package/coverage/src/platform.ts.html +0 -8776
- package/coverage/src/settings.ts.html +0 -934
- package/coverage/src/utils.ts.html +0 -2092
- package/dist/devices-hap/airpurifier.d.ts +0 -54
- package/dist/devices-hap/airpurifier.d.ts.map +0 -1
- package/dist/devices-hap/airpurifier.js +0 -527
- package/dist/devices-hap/airpurifier.js.map +0 -1
- package/dist/devices-hap/blindtilt.d.ts +0 -90
- package/dist/devices-hap/blindtilt.d.ts.map +0 -1
- package/dist/devices-hap/blindtilt.js +0 -974
- package/dist/devices-hap/blindtilt.js.map +0 -1
- package/dist/devices-hap/bot.d.ts +0 -102
- package/dist/devices-hap/bot.d.ts.map +0 -1
- package/dist/devices-hap/bot.js +0 -811
- package/dist/devices-hap/bot.js.map +0 -1
- package/dist/devices-hap/ceilinglight.d.ts +0 -85
- package/dist/devices-hap/ceilinglight.d.ts.map +0 -1
- package/dist/devices-hap/ceilinglight.js +0 -701
- package/dist/devices-hap/ceilinglight.js.map +0 -1
- package/dist/devices-hap/colorbulb.d.ts +0 -88
- package/dist/devices-hap/colorbulb.d.ts.map +0 -1
- package/dist/devices-hap/colorbulb.js +0 -881
- package/dist/devices-hap/colorbulb.js.map +0 -1
- package/dist/devices-hap/contact.d.ts +0 -44
- package/dist/devices-hap/contact.d.ts.map +0 -1
- package/dist/devices-hap/contact.js +0 -409
- package/dist/devices-hap/contact.js.map +0 -1
- package/dist/devices-hap/curtain.d.ts +0 -73
- package/dist/devices-hap/curtain.d.ts.map +0 -1
- package/dist/devices-hap/curtain.js +0 -869
- package/dist/devices-hap/curtain.js.map +0 -1
- package/dist/devices-hap/device.d.ts +0 -98
- package/dist/devices-hap/device.d.ts.map +0 -1
- package/dist/devices-hap/device.js +0 -749
- package/dist/devices-hap/device.js.map +0 -1
- package/dist/devices-hap/fan.d.ts +0 -69
- package/dist/devices-hap/fan.d.ts.map +0 -1
- package/dist/devices-hap/fan.js +0 -649
- package/dist/devices-hap/fan.js.map +0 -1
- package/dist/devices-hap/hub.d.ts +0 -37
- package/dist/devices-hap/hub.d.ts.map +0 -1
- package/dist/devices-hap/hub.js +0 -392
- package/dist/devices-hap/hub.js.map +0 -1
- package/dist/devices-hap/humidifier.d.ts +0 -68
- package/dist/devices-hap/humidifier.d.ts.map +0 -1
- package/dist/devices-hap/humidifier.js +0 -628
- package/dist/devices-hap/humidifier.js.map +0 -1
- package/dist/devices-hap/iosensor.d.ts +0 -42
- package/dist/devices-hap/iosensor.d.ts.map +0 -1
- package/dist/devices-hap/iosensor.js +0 -382
- package/dist/devices-hap/iosensor.js.map +0 -1
- package/dist/devices-hap/lightstrip.d.ts +0 -79
- package/dist/devices-hap/lightstrip.d.ts.map +0 -1
- package/dist/devices-hap/lightstrip.js +0 -797
- package/dist/devices-hap/lightstrip.js.map +0 -1
- package/dist/devices-hap/lock.d.ts +0 -53
- package/dist/devices-hap/lock.d.ts.map +0 -1
- package/dist/devices-hap/lock.js +0 -561
- package/dist/devices-hap/lock.js.map +0 -1
- package/dist/devices-hap/meter.d.ts +0 -37
- package/dist/devices-hap/meter.d.ts.map +0 -1
- package/dist/devices-hap/meter.js +0 -379
- package/dist/devices-hap/meter.js.map +0 -1
- package/dist/devices-hap/meterplus.d.ts +0 -42
- package/dist/devices-hap/meterplus.d.ts.map +0 -1
- package/dist/devices-hap/meterplus.js +0 -384
- package/dist/devices-hap/meterplus.js.map +0 -1
- package/dist/devices-hap/meterpro.d.ts +0 -43
- package/dist/devices-hap/meterpro.d.ts.map +0 -1
- package/dist/devices-hap/meterpro.js +0 -468
- package/dist/devices-hap/meterpro.js.map +0 -1
- package/dist/devices-hap/motion.d.ts +0 -42
- package/dist/devices-hap/motion.d.ts.map +0 -1
- package/dist/devices-hap/motion.js +0 -345
- package/dist/devices-hap/motion.js.map +0 -1
- package/dist/devices-hap/plug.d.ts +0 -49
- package/dist/devices-hap/plug.d.ts.map +0 -1
- package/dist/devices-hap/plug.js +0 -395
- package/dist/devices-hap/plug.js.map +0 -1
- package/dist/devices-hap/relayswitch.d.ts +0 -96
- package/dist/devices-hap/relayswitch.d.ts.map +0 -1
- package/dist/devices-hap/relayswitch.js +0 -642
- package/dist/devices-hap/relayswitch.js.map +0 -1
- package/dist/devices-hap/robotvacuumcleaner.d.ts +0 -54
- package/dist/devices-hap/robotvacuumcleaner.d.ts.map +0 -1
- package/dist/devices-hap/robotvacuumcleaner.js +0 -523
- package/dist/devices-hap/robotvacuumcleaner.js.map +0 -1
- package/dist/devices-hap/waterdetector.d.ts +0 -41
- package/dist/devices-hap/waterdetector.d.ts.map +0 -1
- package/dist/devices-hap/waterdetector.js +0 -356
- package/dist/devices-hap/waterdetector.js.map +0 -1
- package/dist/devices-matter/BaseMatterAccessory.d.ts +0 -63
- package/dist/devices-matter/BaseMatterAccessory.d.ts.map +0 -1
- package/dist/devices-matter/BaseMatterAccessory.js +0 -100
- package/dist/devices-matter/BaseMatterAccessory.js.map +0 -1
- package/dist/devices-matter/ColorLightAccessory.d.ts +0 -20
- package/dist/devices-matter/ColorLightAccessory.d.ts.map +0 -1
- package/dist/devices-matter/ColorLightAccessory.js +0 -95
- package/dist/devices-matter/ColorLightAccessory.js.map +0 -1
- package/dist/devices-matter/ColorTemperatureLightAccessory.d.ts +0 -18
- package/dist/devices-matter/ColorTemperatureLightAccessory.d.ts.map +0 -1
- package/dist/devices-matter/ColorTemperatureLightAccessory.js +0 -78
- package/dist/devices-matter/ColorTemperatureLightAccessory.js.map +0 -1
- package/dist/devices-matter/ContactSensorAccessory.d.ts +0 -12
- package/dist/devices-matter/ContactSensorAccessory.d.ts.map +0 -1
- package/dist/devices-matter/ContactSensorAccessory.js +0 -34
- package/dist/devices-matter/ContactSensorAccessory.js.map +0 -1
- package/dist/devices-matter/DimmableLightAccessory.d.ts +0 -58
- package/dist/devices-matter/DimmableLightAccessory.d.ts.map +0 -1
- package/dist/devices-matter/DimmableLightAccessory.js +0 -167
- package/dist/devices-matter/DimmableLightAccessory.js.map +0 -1
- package/dist/devices-matter/DoorLockAccessory.d.ts +0 -14
- package/dist/devices-matter/DoorLockAccessory.d.ts.map +0 -1
- package/dist/devices-matter/DoorLockAccessory.js +0 -50
- package/dist/devices-matter/DoorLockAccessory.js.map +0 -1
- package/dist/devices-matter/ExtendedColorLightAccessory.d.ts +0 -21
- package/dist/devices-matter/ExtendedColorLightAccessory.d.ts.map +0 -1
- package/dist/devices-matter/ExtendedColorLightAccessory.js +0 -107
- package/dist/devices-matter/ExtendedColorLightAccessory.js.map +0 -1
- package/dist/devices-matter/FanAccessory.d.ts +0 -16
- package/dist/devices-matter/FanAccessory.d.ts.map +0 -1
- package/dist/devices-matter/FanAccessory.js +0 -81
- package/dist/devices-matter/FanAccessory.js.map +0 -1
- package/dist/devices-matter/HumiditySensorAccessory.d.ts +0 -12
- package/dist/devices-matter/HumiditySensorAccessory.d.ts.map +0 -1
- package/dist/devices-matter/HumiditySensorAccessory.js +0 -34
- package/dist/devices-matter/HumiditySensorAccessory.js.map +0 -1
- package/dist/devices-matter/LeakSensorAccessory.d.ts +0 -12
- package/dist/devices-matter/LeakSensorAccessory.d.ts.map +0 -1
- package/dist/devices-matter/LeakSensorAccessory.js +0 -33
- package/dist/devices-matter/LeakSensorAccessory.js.map +0 -1
- package/dist/devices-matter/LightSensorAccessory.d.ts +0 -12
- package/dist/devices-matter/LightSensorAccessory.d.ts.map +0 -1
- package/dist/devices-matter/LightSensorAccessory.js +0 -34
- package/dist/devices-matter/LightSensorAccessory.js.map +0 -1
- package/dist/devices-matter/OccupancySensorAccessory.d.ts +0 -12
- package/dist/devices-matter/OccupancySensorAccessory.d.ts.map +0 -1
- package/dist/devices-matter/OccupancySensorAccessory.js +0 -39
- package/dist/devices-matter/OccupancySensorAccessory.js.map +0 -1
- package/dist/devices-matter/OnOffLightAccessory.d.ts +0 -38
- package/dist/devices-matter/OnOffLightAccessory.d.ts.map +0 -1
- package/dist/devices-matter/OnOffLightAccessory.js +0 -118
- package/dist/devices-matter/OnOffLightAccessory.js.map +0 -1
- package/dist/devices-matter/OnOffOutletAccessory.d.ts +0 -12
- package/dist/devices-matter/OnOffOutletAccessory.d.ts.map +0 -1
- package/dist/devices-matter/OnOffOutletAccessory.js +0 -40
- package/dist/devices-matter/OnOffOutletAccessory.js.map +0 -1
- package/dist/devices-matter/OnOffSwitchAccessory.d.ts +0 -14
- package/dist/devices-matter/OnOffSwitchAccessory.d.ts.map +0 -1
- package/dist/devices-matter/OnOffSwitchAccessory.js +0 -42
- package/dist/devices-matter/OnOffSwitchAccessory.js.map +0 -1
- package/dist/devices-matter/RoboticVacuumAccessory.d.ts +0 -68
- package/dist/devices-matter/RoboticVacuumAccessory.d.ts.map +0 -1
- package/dist/devices-matter/RoboticVacuumAccessory.js +0 -334
- package/dist/devices-matter/RoboticVacuumAccessory.js.map +0 -1
- package/dist/devices-matter/SmokeCOAlarmAccessory.d.ts +0 -11
- package/dist/devices-matter/SmokeCOAlarmAccessory.d.ts.map +0 -1
- package/dist/devices-matter/SmokeCOAlarmAccessory.js +0 -49
- package/dist/devices-matter/SmokeCOAlarmAccessory.js.map +0 -1
- package/dist/devices-matter/TemperatureSensorAccessory.d.ts +0 -12
- package/dist/devices-matter/TemperatureSensorAccessory.d.ts.map +0 -1
- package/dist/devices-matter/TemperatureSensorAccessory.js +0 -36
- package/dist/devices-matter/TemperatureSensorAccessory.js.map +0 -1
- package/dist/devices-matter/ThermostatAccessory.d.ts +0 -19
- package/dist/devices-matter/ThermostatAccessory.d.ts.map +0 -1
- package/dist/devices-matter/ThermostatAccessory.js +0 -95
- package/dist/devices-matter/ThermostatAccessory.js.map +0 -1
- package/dist/devices-matter/VenetianBlindAccessory.d.ts +0 -19
- package/dist/devices-matter/VenetianBlindAccessory.d.ts.map +0 -1
- package/dist/devices-matter/VenetianBlindAccessory.js +0 -99
- package/dist/devices-matter/VenetianBlindAccessory.js.map +0 -1
- package/dist/devices-matter/WindowBlindAccessory.d.ts +0 -17
- package/dist/devices-matter/WindowBlindAccessory.d.ts.map +0 -1
- package/dist/devices-matter/WindowBlindAccessory.js +0 -80
- package/dist/devices-matter/WindowBlindAccessory.js.map +0 -1
- package/dist/devices-matter/custom/PowerStripAccessory.d.ts +0 -97
- package/dist/devices-matter/custom/PowerStripAccessory.d.ts.map +0 -1
- package/dist/devices-matter/custom/PowerStripAccessory.js +0 -265
- package/dist/devices-matter/custom/PowerStripAccessory.js.map +0 -1
- package/dist/devices-matter/custom/index.d.ts +0 -8
- package/dist/devices-matter/custom/index.d.ts.map +0 -1
- package/dist/devices-matter/custom/index.js +0 -8
- package/dist/devices-matter/custom/index.js.map +0 -1
- package/dist/devices-matter/index.d.ts +0 -29
- package/dist/devices-matter/index.d.ts.map +0 -1
- package/dist/devices-matter/index.js +0 -28
- package/dist/devices-matter/index.js.map +0 -1
- package/dist/index.test.d.ts +0 -2
- package/dist/index.test.d.ts.map +0 -1
- package/dist/index.test.js +0 -14
- package/dist/index.test.js.map +0 -1
- package/dist/irdevice/airconditioner.d.ts +0 -61
- package/dist/irdevice/airconditioner.d.ts.map +0 -1
- package/dist/irdevice/airconditioner.js +0 -472
- package/dist/irdevice/airconditioner.js.map +0 -1
- package/dist/irdevice/airpurifier.d.ts +0 -50
- package/dist/irdevice/airpurifier.d.ts.map +0 -1
- package/dist/irdevice/airpurifier.js +0 -213
- package/dist/irdevice/airpurifier.js.map +0 -1
- package/dist/irdevice/camera.d.ts +0 -32
- package/dist/irdevice/camera.d.ts.map +0 -1
- package/dist/irdevice/camera.js +0 -107
- package/dist/irdevice/camera.js.map +0 -1
- package/dist/irdevice/fan.d.ts +0 -36
- package/dist/irdevice/fan.d.ts.map +0 -1
- package/dist/irdevice/fan.js +0 -200
- package/dist/irdevice/fan.js.map +0 -1
- package/dist/irdevice/irdevice.d.ts +0 -68
- package/dist/irdevice/irdevice.d.ts.map +0 -1
- package/dist/irdevice/irdevice.js +0 -298
- package/dist/irdevice/irdevice.js.map +0 -1
- package/dist/irdevice/light.d.ts +0 -36
- package/dist/irdevice/light.d.ts.map +0 -1
- package/dist/irdevice/light.js +0 -206
- package/dist/irdevice/light.js.map +0 -1
- package/dist/irdevice/other.d.ts +0 -57
- package/dist/irdevice/other.d.ts.map +0 -1
- package/dist/irdevice/other.js +0 -778
- package/dist/irdevice/other.js.map +0 -1
- package/dist/irdevice/tv.d.ts +0 -45
- package/dist/irdevice/tv.d.ts.map +0 -1
- package/dist/irdevice/tv.js +0 -327
- package/dist/irdevice/tv.js.map +0 -1
- package/dist/irdevice/vacuumcleaner.d.ts +0 -28
- package/dist/irdevice/vacuumcleaner.d.ts.map +0 -1
- package/dist/irdevice/vacuumcleaner.js +0 -104
- package/dist/irdevice/vacuumcleaner.js.map +0 -1
- package/dist/irdevice/waterheater.d.ts +0 -30
- package/dist/irdevice/waterheater.d.ts.map +0 -1
- package/dist/irdevice/waterheater.js +0 -105
- package/dist/irdevice/waterheater.js.map +0 -1
- package/dist/platform-hap.d.ts +0 -149
- package/dist/platform-hap.d.ts.map +0 -1
- package/dist/platform-hap.js +0 -2861
- package/dist/platform-hap.js.map +0 -1
- package/dist/platform-matter.d.ts +0 -120
- package/dist/platform-matter.d.ts.map +0 -1
- package/dist/platform-matter.js +0 -966
- package/dist/platform-matter.js.map +0 -1
- package/dist/verifyconfig.test.d.ts +0 -2
- package/dist/verifyconfig.test.d.ts.map +0 -1
- package/dist/verifyconfig.test.js +0 -167
- package/dist/verifyconfig.test.js.map +0 -1
- package/src/custom.d.ts +0 -7
- package/src/devices-hap/airpurifier.ts +0 -563
- package/src/devices-hap/blindtilt.ts +0 -1049
- package/src/devices-hap/bot.ts +0 -900
- package/src/devices-hap/ceilinglight.ts +0 -742
- package/src/devices-hap/colorbulb.ts +0 -904
- package/src/devices-hap/contact.ts +0 -457
- package/src/devices-hap/curtain.ts +0 -944
- package/src/devices-hap/device.ts +0 -811
- package/src/devices-hap/fan.ts +0 -711
- package/src/devices-hap/hub.ts +0 -439
- package/src/devices-hap/humidifier.ts +0 -669
- package/src/devices-hap/iosensor.ts +0 -427
- package/src/devices-hap/lightstrip.ts +0 -836
- package/src/devices-hap/lock.ts +0 -620
- package/src/devices-hap/meter.ts +0 -426
- package/src/devices-hap/meterplus.ts +0 -430
- package/src/devices-hap/meterpro.ts +0 -522
- package/src/devices-hap/motion.ts +0 -390
- package/src/devices-hap/plug.ts +0 -423
- package/src/devices-hap/relayswitch.ts +0 -727
- package/src/devices-hap/robotvacuumcleaner.ts +0 -568
- package/src/devices-hap/waterdetector.ts +0 -400
- package/src/devices-matter/BaseMatterAccessory.ts +0 -131
- package/src/devices-matter/ColorLightAccessory.ts +0 -110
- package/src/devices-matter/ColorTemperatureLightAccessory.ts +0 -92
- package/src/devices-matter/ContactSensorAccessory.ts +0 -41
- package/src/devices-matter/DimmableLightAccessory.ts +0 -192
- package/src/devices-matter/DoorLockAccessory.ts +0 -60
- package/src/devices-matter/ExtendedColorLightAccessory.ts +0 -123
- package/src/devices-matter/FanAccessory.ts +0 -95
- package/src/devices-matter/HumiditySensorAccessory.ts +0 -41
- package/src/devices-matter/LeakSensorAccessory.ts +0 -40
- package/src/devices-matter/LightSensorAccessory.ts +0 -41
- package/src/devices-matter/OccupancySensorAccessory.ts +0 -48
- package/src/devices-matter/OnOffLightAccessory.ts +0 -133
- package/src/devices-matter/OnOffOutletAccessory.ts +0 -46
- package/src/devices-matter/OnOffSwitchAccessory.ts +0 -51
- package/src/devices-matter/RoboticVacuumAccessory.ts +0 -407
- package/src/devices-matter/SmokeCOAlarmAccessory.ts +0 -59
- package/src/devices-matter/TemperatureSensorAccessory.ts +0 -43
- package/src/devices-matter/ThermostatAccessory.ts +0 -110
- package/src/devices-matter/VenetianBlindAccessory.ts +0 -115
- package/src/devices-matter/WindowBlindAccessory.ts +0 -92
- package/src/devices-matter/custom/PowerStripAccessory.ts +0 -309
- package/src/devices-matter/custom/index.ts +0 -8
- package/src/devices-matter/index.ts +0 -29
- package/src/index.test.ts +0 -19
- package/src/irdevice/airconditioner.ts +0 -533
- package/src/irdevice/airpurifier.ts +0 -252
- package/src/irdevice/camera.ts +0 -129
- package/src/irdevice/fan.ts +0 -226
- package/src/irdevice/irdevice.ts +0 -344
- package/src/irdevice/light.ts +0 -246
- package/src/irdevice/other.ts +0 -790
- package/src/irdevice/tv.ts +0 -378
- package/src/irdevice/vacuumcleaner.ts +0 -126
- package/src/irdevice/waterheater.ts +0 -127
- package/src/platform-hap.ts +0 -2997
- package/src/platform-matter.ts +0 -1092
- package/src/verifyconfig.test.ts +0 -197
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import { irdeviceBase } from './irdevice.js';
|
|
2
|
-
/**
|
|
3
|
-
* Platform Accessory
|
|
4
|
-
* An instance of this class is created for each accessory your platform registers
|
|
5
|
-
* Each accessory may expose multiple services of different service types.
|
|
6
|
-
*/
|
|
7
|
-
export class AirPurifierIR extends irdeviceBase {
|
|
8
|
-
platform;
|
|
9
|
-
// Services
|
|
10
|
-
AirPurifier;
|
|
11
|
-
TemperatureSensor;
|
|
12
|
-
// Characteristic Values
|
|
13
|
-
APActive;
|
|
14
|
-
CurrentAPTemp;
|
|
15
|
-
CurrentAPMode;
|
|
16
|
-
CurrentAPFanSpeed;
|
|
17
|
-
// Others
|
|
18
|
-
Busy;
|
|
19
|
-
Timeout = null;
|
|
20
|
-
static IDLE;
|
|
21
|
-
CurrentMode;
|
|
22
|
-
static INACTIVE;
|
|
23
|
-
LastTemperature;
|
|
24
|
-
CurrentFanSpeed;
|
|
25
|
-
static PURIFYING_AIR;
|
|
26
|
-
constructor(platform, accessory, device) {
|
|
27
|
-
super(platform, accessory, device);
|
|
28
|
-
this.platform = platform;
|
|
29
|
-
// Set category
|
|
30
|
-
accessory.category = 19 /* this.hap.Categories.AIR_PURIFIER */;
|
|
31
|
-
// Initialize AirPurifier Service
|
|
32
|
-
accessory.context.AirPurifier = accessory.context.AirPurifier ?? {};
|
|
33
|
-
this.AirPurifier = {
|
|
34
|
-
Name: accessory.displayName,
|
|
35
|
-
Service: accessory.getService(this.hap.Service.AirPurifier) ?? accessory.addService(this.hap.Service.AirPurifier),
|
|
36
|
-
Active: accessory.context.Active ?? this.hap.Characteristic.Active.INACTIVE,
|
|
37
|
-
RotationSpeed: accessory.context.RotationSpeed ?? 0,
|
|
38
|
-
CurrentAirPurifierState: accessory.context.CurrentAirPurifierState ?? this.hap.Characteristic.CurrentAirPurifierState.INACTIVE,
|
|
39
|
-
TargetAirPurifierState: accessory.context.TargetAirPurifierState ?? this.hap.Characteristic.TargetAirPurifierState.AUTO,
|
|
40
|
-
CurrentHeaterCoolerState: accessory.context.CurrentHeaterCoolerState ?? this.hap.Characteristic.CurrentHeaterCoolerState.INACTIVE,
|
|
41
|
-
};
|
|
42
|
-
accessory.context.AirPurifier = this.AirPurifier;
|
|
43
|
-
this.AirPurifier.Service.setCharacteristic(this.hap.Characteristic.Name, this.AirPurifier.Name).getCharacteristic(this.hap.Characteristic.Active).onGet(() => {
|
|
44
|
-
return this.AirPurifier.Active;
|
|
45
|
-
}).onSet(this.ActiveSet.bind(this));
|
|
46
|
-
this.AirPurifier.Service.getCharacteristic(this.hap.Characteristic.CurrentAirPurifierState).onGet(() => {
|
|
47
|
-
return this.CurrentAirPurifierStateGet();
|
|
48
|
-
});
|
|
49
|
-
this.AirPurifier.Service.getCharacteristic(this.hap.Characteristic.TargetAirPurifierState).onGet(() => {
|
|
50
|
-
return this.AirPurifier.TargetAirPurifierState;
|
|
51
|
-
}).onSet(this.TargetAirPurifierStateSet.bind(this));
|
|
52
|
-
// Initialize TemperatureSensor Service
|
|
53
|
-
accessory.context.TemperatureSensor = accessory.context.TemperatureSensor ?? {};
|
|
54
|
-
this.TemperatureSensor = {
|
|
55
|
-
Name: `${accessory.displayName} Temperature Sensor`,
|
|
56
|
-
Service: accessory.getService(this.hap.Service.TemperatureSensor) ?? accessory.addService(this.hap.Service.TemperatureSensor),
|
|
57
|
-
CurrentTemperature: accessory.context.CurrentTemperature || 24,
|
|
58
|
-
};
|
|
59
|
-
accessory.context.TemperatureSensor = this.TemperatureSensor;
|
|
60
|
-
this.TemperatureSensor.Service.setCharacteristic(this.hap.Characteristic.Name, this.TemperatureSensor.Name).getCharacteristic(this.hap.Characteristic.CurrentTemperature).onGet(() => {
|
|
61
|
-
return this.TemperatureSensor.CurrentTemperature;
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
async ActiveSet(value) {
|
|
65
|
-
this.debugLog(`Set Active: ${value}`);
|
|
66
|
-
this.AirPurifier.Active = value;
|
|
67
|
-
if (this.AirPurifier.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
68
|
-
this.pushAirPurifierOnChanges();
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
this.pushAirPurifierOffChanges();
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
async TargetAirPurifierStateSet(value) {
|
|
75
|
-
switch (value) {
|
|
76
|
-
case this.hap.Characteristic.CurrentAirPurifierState.PURIFYING_AIR:
|
|
77
|
-
this.CurrentMode = AirPurifierIR.PURIFYING_AIR;
|
|
78
|
-
break;
|
|
79
|
-
case this.hap.Characteristic.CurrentAirPurifierState.IDLE:
|
|
80
|
-
this.CurrentMode = AirPurifierIR.IDLE;
|
|
81
|
-
break;
|
|
82
|
-
case this.hap.Characteristic.CurrentAirPurifierState.INACTIVE:
|
|
83
|
-
this.CurrentMode = AirPurifierIR.INACTIVE;
|
|
84
|
-
break;
|
|
85
|
-
default:
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
async CurrentAirPurifierStateGet() {
|
|
90
|
-
if (this.AirPurifier.Active === 1) {
|
|
91
|
-
this.AirPurifier.CurrentAirPurifierState = this.hap.Characteristic.CurrentAirPurifierState.PURIFYING_AIR;
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
this.AirPurifier.CurrentAirPurifierState = this.hap.Characteristic.CurrentAirPurifierState.INACTIVE;
|
|
95
|
-
}
|
|
96
|
-
return this.AirPurifier.CurrentAirPurifierState;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Pushes the requested changes to the SwitchBot API
|
|
100
|
-
* deviceType commandType Command command parameter Description
|
|
101
|
-
* AirPurifier: "command" "turnOn" "default" = every home appliance can be turned on by default
|
|
102
|
-
* AirPurifier: "command" "turnOff" "default" = every home appliance can be turned off by default
|
|
103
|
-
* AirPurifier: "command" "swing" "default" = swing
|
|
104
|
-
* AirPurifier: "command" "timer" "default" = timer
|
|
105
|
-
* AirPurifier: "command" "lowSpeed" "default" = fan speed to low
|
|
106
|
-
* AirPurifier: "command" "middleSpeed" "default" = fan speed to medium
|
|
107
|
-
* AirPurifier: "command" "highSpeed" "default" = fan speed to high
|
|
108
|
-
*/
|
|
109
|
-
async pushAirPurifierOnChanges() {
|
|
110
|
-
this.debugLog(`pushAirPurifierOnChanges Active: ${this.AirPurifier.Active}, disablePushOn: ${this.deviceDisablePushOn}`);
|
|
111
|
-
if (this.AirPurifier.Active === this.hap.Characteristic.Active.ACTIVE && !this.deviceDisablePushOn) {
|
|
112
|
-
const commandType = await this.commandType();
|
|
113
|
-
const command = await this.commandOn();
|
|
114
|
-
const bodyChange = {
|
|
115
|
-
command,
|
|
116
|
-
parameter: 'default',
|
|
117
|
-
commandType,
|
|
118
|
-
};
|
|
119
|
-
await this.pushChanges(bodyChange);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
async pushAirPurifierOffChanges() {
|
|
123
|
-
this.debugLog(`pushAirPurifierOffChanges Active: ${this.AirPurifier.Active}, disablePushOff: ${this.deviceDisablePushOff}`);
|
|
124
|
-
if (this.AirPurifier.Active === this.hap.Characteristic.Active.INACTIVE && !this.deviceDisablePushOn) {
|
|
125
|
-
const commandType = await this.commandType();
|
|
126
|
-
const command = await this.commandOff();
|
|
127
|
-
const bodyChange = {
|
|
128
|
-
command,
|
|
129
|
-
parameter: 'default',
|
|
130
|
-
commandType,
|
|
131
|
-
};
|
|
132
|
-
await this.pushChanges(bodyChange);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
async pushAirPurifierStatusChanges() {
|
|
136
|
-
this.debugLog(`pushAirPurifierStatusChanges Active: ${this.AirPurifier.Active}, disablePushOff: ${this.deviceDisablePushOff}, disablePushOn: ${this.deviceDisablePushOn}`);
|
|
137
|
-
if (!this.Busy) {
|
|
138
|
-
this.Busy = true;
|
|
139
|
-
this.AirPurifier.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.IDLE;
|
|
140
|
-
}
|
|
141
|
-
clearTimeout(this.Timeout);
|
|
142
|
-
// Make a new Timeout set to go off in 1000ms (1 second)
|
|
143
|
-
this.Timeout = setTimeout(this.pushAirPurifierDetailsChanges.bind(this), 1500);
|
|
144
|
-
}
|
|
145
|
-
async pushAirPurifierDetailsChanges() {
|
|
146
|
-
this.debugLog(`pushAirPurifierDetailsChanges Active: ${this.AirPurifier.Active}, disablePushOff: ${this.deviceDisablePushOff}, disablePushOn: ${this.deviceDisablePushOn}`);
|
|
147
|
-
this.CurrentAPTemp = this.TemperatureSensor.CurrentTemperature ?? 24;
|
|
148
|
-
this.CurrentAPMode = this.CurrentMode ?? 1;
|
|
149
|
-
this.CurrentAPFanSpeed = this.CurrentFanSpeed ?? 1;
|
|
150
|
-
this.APActive = this.AirPurifier.Active === 1 ? 'on' : 'off';
|
|
151
|
-
const parameter = `${this.CurrentAPTemp},${this.CurrentAPMode},${this.CurrentAPFanSpeed},${this.APActive}`;
|
|
152
|
-
const bodyChange = {
|
|
153
|
-
command: 'setAll',
|
|
154
|
-
parameter: `${parameter}`,
|
|
155
|
-
commandType: 'command',
|
|
156
|
-
};
|
|
157
|
-
if (this.AirPurifier.Active === 1) {
|
|
158
|
-
if ((Number(this.TemperatureSensor.CurrentTemperature) || 24) < (this.LastTemperature || 30)) {
|
|
159
|
-
this.AirPurifier.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.COOLING;
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
this.AirPurifier.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
this.AirPurifier.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.INACTIVE;
|
|
167
|
-
}
|
|
168
|
-
await this.pushChanges(bodyChange);
|
|
169
|
-
}
|
|
170
|
-
async pushChanges(bodyChange) {
|
|
171
|
-
this.debugLog('pushChanges');
|
|
172
|
-
if (this.device.connectionType === 'OpenAPI') {
|
|
173
|
-
this.infoLog(`Sending request to SwitchBot API, body: ${JSON.stringify(bodyChange)}`);
|
|
174
|
-
try {
|
|
175
|
-
const deviceStatus = await this.pushChangeRequest(bodyChange);
|
|
176
|
-
await this.pushStatusCodes(deviceStatus);
|
|
177
|
-
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
178
|
-
await this.successfulPushChange(deviceStatus, bodyChange);
|
|
179
|
-
await this.updateHomeKitCharacteristics();
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
await this.statusCode(deviceStatus.statusCode);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
catch (e) {
|
|
186
|
-
await this.apiError(e);
|
|
187
|
-
await this.pushChangeError(e);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
this.warnLog(`Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
async updateHomeKitCharacteristics() {
|
|
195
|
-
this.debugLog('updateHomeKitCharacteristics');
|
|
196
|
-
// Active
|
|
197
|
-
await this.updateCharacteristic(this.AirPurifier.Service, this.hap.Characteristic.Active, this.AirPurifier.Active, 'Active');
|
|
198
|
-
// CurrentAirPurifierState
|
|
199
|
-
await this.updateCharacteristic(this.AirPurifier.Service, this.hap.Characteristic.CurrentAirPurifierState, this.AirPurifier.CurrentAirPurifierState, 'CurrentAirPurifierState');
|
|
200
|
-
// CurrentHeaterCoolerState
|
|
201
|
-
await this.updateCharacteristic(this.AirPurifier.Service, this.hap.Characteristic.CurrentHeaterCoolerState, this.AirPurifier.CurrentHeaterCoolerState, 'CurrentHeaterCoolerState');
|
|
202
|
-
// CurrentTemperature
|
|
203
|
-
await this.updateCharacteristic(this.TemperatureSensor.Service, this.hap.Characteristic.CurrentTemperature, this.TemperatureSensor.CurrentTemperature, 'CurrentTemperature');
|
|
204
|
-
}
|
|
205
|
-
async apiError(e) {
|
|
206
|
-
this.AirPurifier.Service.updateCharacteristic(this.hap.Characteristic.Active, e);
|
|
207
|
-
this.AirPurifier.Service.updateCharacteristic(this.hap.Characteristic.TargetAirPurifierState, e);
|
|
208
|
-
this.AirPurifier.Service.updateCharacteristic(this.hap.Characteristic.CurrentAirPurifierState, e);
|
|
209
|
-
this.AirPurifier.Service.updateCharacteristic(this.hap.Characteristic.CurrentHeaterCoolerState, e);
|
|
210
|
-
this.TemperatureSensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, e);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
//# sourceMappingURL=airpurifier.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"airpurifier.js","sourceRoot":"","sources":["../../src/irdevice/airpurifier.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAE5C;;;;GAIG;A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AC,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,sBAAsB,EAAE,CAAC,CAAC,CAAA;QAChG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,uBAAuB,EAAE,CAAC,CAAC,CAAA;QACjG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,wBAAwB,EAAE,CAAC,CAAC,CAAA;QAClG,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAA;IACpG,CAAC;CACF"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { CharacteristicValue, PlatformAccessory } from 'homebridge';
|
|
2
|
-
import type { irdevice } from 'node-switchbot';
|
|
3
|
-
import type { SwitchBotHAPPlatform } from '../platform-hap.js';
|
|
4
|
-
import type { irDevicesConfig } from '../settings.js';
|
|
5
|
-
import { irdeviceBase } from './irdevice.js';
|
|
6
|
-
/**
|
|
7
|
-
* Platform Accessory
|
|
8
|
-
* An instance of this class is created for each accessory your platform registers
|
|
9
|
-
* Each accessory may expose multiple services of different service types.
|
|
10
|
-
*/
|
|
11
|
-
export declare class Camera extends irdeviceBase {
|
|
12
|
-
readonly platform: SwitchBotHAPPlatform;
|
|
13
|
-
private Switch;
|
|
14
|
-
constructor(platform: SwitchBotHAPPlatform, accessory: PlatformAccessory, device: irdevice & irDevicesConfig);
|
|
15
|
-
OnSet(value: CharacteristicValue): Promise<void>;
|
|
16
|
-
/**
|
|
17
|
-
* Pushes the requested changes to the SwitchBot API
|
|
18
|
-
* deviceType commandType Command command parameter Description
|
|
19
|
-
* Camera - "command" "turnOff" "default" = set to OFF state
|
|
20
|
-
* Camera - "command" "turnOn" "default" = set to ON state
|
|
21
|
-
* Camera - "command" "volumeAdd" "default" = volume up
|
|
22
|
-
* Camera - "command" "volumeSub" "default" = volume down
|
|
23
|
-
* Camera - "command" "channelAdd" "default" = next channel
|
|
24
|
-
* Camera - "command" "channelSub" "default" = previous channel
|
|
25
|
-
*/
|
|
26
|
-
pushOnChanges(): Promise<void>;
|
|
27
|
-
pushOffChanges(): Promise<void>;
|
|
28
|
-
pushChanges(bodyChange: any): Promise<void>;
|
|
29
|
-
updateHomeKitCharacteristics(): Promise<void>;
|
|
30
|
-
apiError(e: any): Promise<void>;
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=camera.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"camera.d.ts","sourceRoot":"","sources":["../../src/irdevice/camera.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAW,MAAM,YAAY,CAAA;AACjF,OAAO,KAAK,EAAc,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAE1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAE5C;;;;GAIG;AACH,qBAAa,MAAO,SAAQ,YAAY;IASpC,QAAQ,CAAC,QAAQ,EAAE,oBAAoB;IAPzC,OAAO,CAAC,MAAM,CAIb;gBAGU,QAAQ,EAAE,oBAAoB,EACvC,SAAS,EAAE,iBAAiB,EAC5B,MAAM,EAAE,QAAQ,GAAG,eAAe;IAoB9B,KAAK,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAWtD;;;;;;;;;OASG;IACG,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAc9B,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAc/B,WAAW,CAAC,UAAU,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAsB3C,4BAA4B,IAAI,OAAO,CAAC,IAAI,CAAC;IAM7C,QAAQ,CAAC,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;CAGtC"}
|
package/dist/irdevice/camera.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { irdeviceBase } from './irdevice.js';
|
|
2
|
-
/**
|
|
3
|
-
* Platform Accessory
|
|
4
|
-
* An instance of this class is created for each accessory your platform registers
|
|
5
|
-
* Each accessory may expose multiple services of different service types.
|
|
6
|
-
*/
|
|
7
|
-
export class Camera extends irdeviceBase {
|
|
8
|
-
platform;
|
|
9
|
-
// Services
|
|
10
|
-
Switch;
|
|
11
|
-
constructor(platform, accessory, device) {
|
|
12
|
-
super(platform, accessory, device);
|
|
13
|
-
this.platform = platform;
|
|
14
|
-
// Set category
|
|
15
|
-
accessory.category = 17 /* this.hap.Categories.CAMERA */;
|
|
16
|
-
// Initialize Switch Service
|
|
17
|
-
accessory.context.Switch = accessory.context.Switch ?? {};
|
|
18
|
-
this.Switch = {
|
|
19
|
-
Name: accessory.displayName,
|
|
20
|
-
Service: accessory.getService(this.hap.Service.Switch) ?? accessory.addService(this.hap.Service.Switch),
|
|
21
|
-
On: accessory.context.On ?? false,
|
|
22
|
-
};
|
|
23
|
-
accessory.context.Switch = this.Switch;
|
|
24
|
-
this.Switch.Service.setCharacteristic(this.hap.Characteristic.Name, this.Switch.Name).getCharacteristic(this.hap.Characteristic.On).onGet(() => {
|
|
25
|
-
return this.Switch.On;
|
|
26
|
-
}).onSet(this.OnSet.bind(this));
|
|
27
|
-
}
|
|
28
|
-
async OnSet(value) {
|
|
29
|
-
this.debugLog(`On: ${value}`);
|
|
30
|
-
this.Switch.On = value;
|
|
31
|
-
if (this.Switch.On) {
|
|
32
|
-
this.pushOnChanges();
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
this.pushOffChanges();
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Pushes the requested changes to the SwitchBot API
|
|
40
|
-
* deviceType commandType Command command parameter Description
|
|
41
|
-
* Camera - "command" "turnOff" "default" = set to OFF state
|
|
42
|
-
* Camera - "command" "turnOn" "default" = set to ON state
|
|
43
|
-
* Camera - "command" "volumeAdd" "default" = volume up
|
|
44
|
-
* Camera - "command" "volumeSub" "default" = volume down
|
|
45
|
-
* Camera - "command" "channelAdd" "default" = next channel
|
|
46
|
-
* Camera - "command" "channelSub" "default" = previous channel
|
|
47
|
-
*/
|
|
48
|
-
async pushOnChanges() {
|
|
49
|
-
this.debugLog(`pushOnChanges On: ${this.Switch.On}, disablePushOn: ${this.deviceDisablePushOn}`);
|
|
50
|
-
if (this.Switch.On && !this.deviceDisablePushOn) {
|
|
51
|
-
const commandType = await this.commandType();
|
|
52
|
-
const command = await this.commandOn();
|
|
53
|
-
const bodyChange = {
|
|
54
|
-
command,
|
|
55
|
-
parameter: 'default',
|
|
56
|
-
commandType,
|
|
57
|
-
};
|
|
58
|
-
await this.pushChanges(bodyChange);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
async pushOffChanges() {
|
|
62
|
-
this.debugLog(`pushOffChanges On: ${this.Switch.On}, disablePushOff: ${this.deviceDisablePushOff}`);
|
|
63
|
-
if (!this.Switch.On && !this.deviceDisablePushOff) {
|
|
64
|
-
const commandType = await this.commandType();
|
|
65
|
-
const command = await this.commandOff();
|
|
66
|
-
const bodyChange = {
|
|
67
|
-
command,
|
|
68
|
-
parameter: 'default',
|
|
69
|
-
commandType,
|
|
70
|
-
};
|
|
71
|
-
await this.pushChanges(bodyChange);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
async pushChanges(bodyChange) {
|
|
75
|
-
this.debugLog('pushChanges');
|
|
76
|
-
if (this.device.connectionType === 'OpenAPI') {
|
|
77
|
-
this.infoLog(`Sending request to SwitchBot API, body: ${JSON.stringify(bodyChange)}`);
|
|
78
|
-
try {
|
|
79
|
-
const deviceStatus = await this.pushChangeRequest(bodyChange);
|
|
80
|
-
await this.pushStatusCodes(deviceStatus);
|
|
81
|
-
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
82
|
-
await this.successfulPushChange(deviceStatus, bodyChange);
|
|
83
|
-
await this.updateHomeKitCharacteristics();
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
await this.statusCode(deviceStatus.statusCode);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
catch (e) {
|
|
90
|
-
await this.apiError(e);
|
|
91
|
-
await this.pushChangeError(e);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
this.warnLog(`Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
async updateHomeKitCharacteristics() {
|
|
99
|
-
this.debugLog('updateHomeKitCharacteristics');
|
|
100
|
-
// Active
|
|
101
|
-
await this.updateCharacteristic(this.Switch.Service, this.hap.Characteristic.On, this.Switch.On, 'On');
|
|
102
|
-
}
|
|
103
|
-
async apiError(e) {
|
|
104
|
-
this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, e);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
//# sourceMappingURL=camera.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"camera.js","sourceRoot":"","sources":["../../src/irdevice/camera.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAE5C;;;;GAIG;AACH,MAAM,OAAO,MAAO,SAAQ,YAAY;IAS3B;IARX,WAAW;IACH,MAAM,CAIb;IAED,YACW,QAA8B,EACvC,SAA4B,EAC5B,MAAkC;QAElC,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CAAA;QAJzB,aAAQ,GAAR,QAAQ,CAAsB;QAKvC,eAAe;QACf,SAAS,CAAC,QAAQ,sCAA6B,CAAA;QAE/C,4BA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evice/fan.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { CharacteristicValue, PlatformAccessory } from 'homebridge';
|
|
2
|
-
import type { irdevice } from 'node-switchbot';
|
|
3
|
-
import type { SwitchBotHAPPlatform } from '../platform-hap.js';
|
|
4
|
-
import type { irDevicesConfig } from '../settings.js';
|
|
5
|
-
import { irdeviceBase } from './irdevice.js';
|
|
6
|
-
/**
|
|
7
|
-
* Platform Accessory
|
|
8
|
-
* An instance of this class is created for each accessory your platform registers
|
|
9
|
-
* Each accessory may expose multiple services of different service types.
|
|
10
|
-
*/
|
|
11
|
-
export declare class IRFan extends irdeviceBase {
|
|
12
|
-
readonly platform: SwitchBotHAPPlatform;
|
|
13
|
-
private Fan;
|
|
14
|
-
constructor(platform: SwitchBotHAPPlatform, accessory: PlatformAccessory, device: irdevice & irDevicesConfig);
|
|
15
|
-
SwingModeSet(value: CharacteristicValue): Promise<void>;
|
|
16
|
-
RotationSpeedSet(value: CharacteristicValue): Promise<void>;
|
|
17
|
-
ActiveSet(value: CharacteristicValue): Promise<void>;
|
|
18
|
-
/**
|
|
19
|
-
* Pushes the requested changes to the SwitchBot API
|
|
20
|
-
* deviceType commandType Command command parameter Description
|
|
21
|
-
* Fan - "command" "swing" "default" = swing
|
|
22
|
-
* Fan - "command" "timer" "default" = timer
|
|
23
|
-
* Fan - "command" "lowSpeed" "default" = fan speed to low
|
|
24
|
-
* Fan - "command" "middleSpeed" "default" = fan speed to medium
|
|
25
|
-
* Fan - "command" "highSpeed" "default" = fan speed to high
|
|
26
|
-
*/
|
|
27
|
-
pushFanOnChanges(): Promise<void>;
|
|
28
|
-
pushFanOffChanges(): Promise<void>;
|
|
29
|
-
pushFanSpeedUpChanges(): Promise<void>;
|
|
30
|
-
pushFanSpeedDownChanges(): Promise<void>;
|
|
31
|
-
pushFanSwingChanges(): Promise<void>;
|
|
32
|
-
pushChanges(bodyChange: any): Promise<void>;
|
|
33
|
-
updateHomeKitCharacteristics(): Promise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3C,4BAA4B,IAAI,OAAO,CAAC,IAAI,CAAC;IAU7C,QAAQ,CAAC,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;CAKtC"}
|
package/dist/irdevice/fan.js
DELETED
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import { irdeviceBase } from './irdevice.js';
|
|
2
|
-
/**
|
|
3
|
-
* Platform Accessory
|
|
4
|
-
* An instance of this class is created for each accessory your platform registers
|
|
5
|
-
* Each accessory may expose multiple services of different service types.
|
|
6
|
-
*/
|
|
7
|
-
export class IRFan extends irdeviceBase {
|
|
8
|
-
platform;
|
|
9
|
-
// Services
|
|
10
|
-
Fan;
|
|
11
|
-
constructor(platform, accessory, device) {
|
|
12
|
-
super(platform, accessory, device);
|
|
13
|
-
this.platform = platform;
|
|
14
|
-
// Set category
|
|
15
|
-
accessory.category = 3 /* this.hap.Categories.FAN */;
|
|
16
|
-
// Initialize Switch Service
|
|
17
|
-
accessory.context.Fan = accessory.context.Fan ?? {};
|
|
18
|
-
this.Fan = {
|
|
19
|
-
Name: accessory.displayName,
|
|
20
|
-
Service: accessory.getService(this.hap.Service.Fanv2) ?? accessory.addService(this.hap.Service.Fanv2),
|
|
21
|
-
Active: accessory.context.Active ?? this.hap.Characteristic.Active.INACTIVE,
|
|
22
|
-
SwingMode: accessory.context.SwingMode ?? this.hap.Characteristic.SwingMode.SWING_DISABLED,
|
|
23
|
-
RotationSpeed: accessory.context.RotationSpeed ?? 0,
|
|
24
|
-
RotationDirection: accessory.context.RotationDirection ?? this.hap.Characteristic.RotationDirection.CLOCKWISE,
|
|
25
|
-
};
|
|
26
|
-
accessory.context.Fan = this.Fan;
|
|
27
|
-
this.Fan.Service.setCharacteristic(this.hap.Characteristic.Name, this.Fan.Name).getCharacteristic(this.hap.Characteristic.Active).onGet(() => {
|
|
28
|
-
return this.Fan.Active;
|
|
29
|
-
}).onSet(this.ActiveSet.bind(this));
|
|
30
|
-
if (device.rotation_speed) {
|
|
31
|
-
// handle Rotation Speed events using the RotationSpeed characteristic
|
|
32
|
-
this.Fan.Service.getCharacteristic(this.hap.Characteristic.RotationSpeed).setProps({
|
|
33
|
-
minStep: device.set_minStep ?? 1,
|
|
34
|
-
minValue: device.set_min ?? 1,
|
|
35
|
-
maxValue: device.set_max ?? 100,
|
|
36
|
-
}).onGet(() => {
|
|
37
|
-
return this.Fan.RotationSpeed;
|
|
38
|
-
}).onSet(this.RotationSpeedSet.bind(this));
|
|
39
|
-
}
|
|
40
|
-
else if (this.Fan.Service.testCharacteristic(this.hap.Characteristic.RotationSpeed) && !device.swing_mode) {
|
|
41
|
-
const characteristic = this.Fan.Service.getCharacteristic(this.hap.Characteristic.RotationSpeed);
|
|
42
|
-
this.Fan.Service.removeCharacteristic(characteristic);
|
|
43
|
-
this.debugLog('Rotation Speed Characteristic was removed.');
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
this.debugLog(`RotationSpeed Characteristic was not removed/added, Clear Cache on ${this.accessory.displayName} to remove Chracteristic`);
|
|
47
|
-
}
|
|
48
|
-
if (device.swing_mode) {
|
|
49
|
-
// handle Osolcation events using the SwingMode characteristic
|
|
50
|
-
this.Fan.Service.getCharacteristic(this.hap.Characteristic.SwingMode).onGet(() => {
|
|
51
|
-
return this.Fan.SwingMode;
|
|
52
|
-
}).onSet(this.SwingModeSet.bind(this));
|
|
53
|
-
}
|
|
54
|
-
else if (this.Fan.Service.testCharacteristic(this.hap.Characteristic.SwingMode) && !device.swing_mode) {
|
|
55
|
-
const characteristic = this.Fan.Service.getCharacteristic(this.hap.Characteristic.SwingMode);
|
|
56
|
-
this.Fan.Service.removeCharacteristic(characteristic);
|
|
57
|
-
this.debugLog('Swing Mode Characteristic was removed.');
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
this.debugLog(`Swing Mode Characteristic was not removed/added, Clear Cache on ${this.accessory.displayName} To Remove Chracteristic`);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
async SwingModeSet(value) {
|
|
64
|
-
this.debugLog(`SwingMode: ${value}`);
|
|
65
|
-
if (value > this.Fan.SwingMode) {
|
|
66
|
-
this.Fan.SwingMode = 1;
|
|
67
|
-
await this.pushFanOnChanges();
|
|
68
|
-
await this.pushFanSwingChanges();
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
this.Fan.SwingMode = 0;
|
|
72
|
-
await this.pushFanOnChanges();
|
|
73
|
-
await this.pushFanSwingChanges();
|
|
74
|
-
}
|
|
75
|
-
this.Fan.SwingMode = value;
|
|
76
|
-
this.accessory.context.SwingMode = this.Fan.SwingMode;
|
|
77
|
-
}
|
|
78
|
-
async RotationSpeedSet(value) {
|
|
79
|
-
this.debugLog(`RotationSpeed: ${value}`);
|
|
80
|
-
if (value > this.Fan.RotationSpeed) {
|
|
81
|
-
this.Fan.RotationSpeed = 1;
|
|
82
|
-
this.pushFanSpeedUpChanges();
|
|
83
|
-
this.pushFanOnChanges();
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
this.Fan.RotationSpeed = 0;
|
|
87
|
-
this.pushFanSpeedDownChanges();
|
|
88
|
-
}
|
|
89
|
-
this.Fan.RotationSpeed = value;
|
|
90
|
-
this.accessory.context.RotationSpeed = this.Fan.RotationSpeed;
|
|
91
|
-
}
|
|
92
|
-
async ActiveSet(value) {
|
|
93
|
-
this.debugLog(`Active: ${value}`);
|
|
94
|
-
this.Fan.Active = value;
|
|
95
|
-
if (this.Fan.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
96
|
-
this.pushFanOnChanges();
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
this.pushFanOffChanges();
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Pushes the requested changes to the SwitchBot API
|
|
104
|
-
* deviceType commandType Command command parameter Description
|
|
105
|
-
* Fan - "command" "swing" "default" = swing
|
|
106
|
-
* Fan - "command" "timer" "default" = timer
|
|
107
|
-
* Fan - "command" "lowSpeed" "default" = fan speed to low
|
|
108
|
-
* Fan - "command" "middleSpeed" "default" = fan speed to medium
|
|
109
|
-
* Fan - "command" "highSpeed" "default" = fan speed to high
|
|
110
|
-
*/
|
|
111
|
-
async pushFanOnChanges() {
|
|
112
|
-
this.debugLog(`pushFanOnChanges Active: ${this.Fan.Active}, disablePushOn: ${this.deviceDisablePushOn}`);
|
|
113
|
-
if (this.Fan.Active === this.hap.Characteristic.Active.ACTIVE && !this.deviceDisablePushOn) {
|
|
114
|
-
const commandType = await this.commandType();
|
|
115
|
-
const command = await this.commandOn();
|
|
116
|
-
const bodyChange = {
|
|
117
|
-
command,
|
|
118
|
-
parameter: 'default',
|
|
119
|
-
commandType,
|
|
120
|
-
};
|
|
121
|
-
await this.pushChanges(bodyChange);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
async pushFanOffChanges() {
|
|
125
|
-
this.debugLog(`pushLightOffChanges Active: ${this.Fan.Active}, disablePushOff: ${this.deviceDisablePushOff}`);
|
|
126
|
-
if (this.Fan.Active === this.hap.Characteristic.Active.INACTIVE && !this.deviceDisablePushOff) {
|
|
127
|
-
const commandType = await this.commandType();
|
|
128
|
-
const command = await this.commandOff();
|
|
129
|
-
const bodyChange = {
|
|
130
|
-
command,
|
|
131
|
-
parameter: 'default',
|
|
132
|
-
commandType,
|
|
133
|
-
};
|
|
134
|
-
await this.pushChanges(bodyChange);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
async pushFanSpeedUpChanges() {
|
|
138
|
-
const bodyChange = {
|
|
139
|
-
command: 'highSpeed',
|
|
140
|
-
parameter: 'default',
|
|
141
|
-
commandType: 'command',
|
|
142
|
-
};
|
|
143
|
-
await this.pushChanges(bodyChange);
|
|
144
|
-
}
|
|
145
|
-
async pushFanSpeedDownChanges() {
|
|
146
|
-
const bodyChange = {
|
|
147
|
-
command: 'lowSpeed',
|
|
148
|
-
parameter: 'default',
|
|
149
|
-
commandType: 'command',
|
|
150
|
-
};
|
|
151
|
-
await this.pushChanges(bodyChange);
|
|
152
|
-
}
|
|
153
|
-
async pushFanSwingChanges() {
|
|
154
|
-
const bodyChange = {
|
|
155
|
-
command: 'swing',
|
|
156
|
-
parameter: 'default',
|
|
157
|
-
commandType: 'command',
|
|
158
|
-
};
|
|
159
|
-
await this.pushChanges(bodyChange);
|
|
160
|
-
}
|
|
161
|
-
async pushChanges(bodyChange) {
|
|
162
|
-
this.debugLog('pushChanges');
|
|
163
|
-
if (this.device.connectionType === 'OpenAPI') {
|
|
164
|
-
this.infoLog(`Sending request to SwitchBot API, body: ${JSON.stringify(bodyChange)}`);
|
|
165
|
-
try {
|
|
166
|
-
const deviceStatus = await this.pushChangeRequest(bodyChange);
|
|
167
|
-
await this.pushStatusCodes(deviceStatus);
|
|
168
|
-
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
169
|
-
await this.successfulPushChange(deviceStatus, bodyChange);
|
|
170
|
-
await this.updateHomeKitCharacteristics();
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
await this.statusCode(deviceStatus.statusCode);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
catch (e) {
|
|
177
|
-
await this.apiError(e);
|
|
178
|
-
await this.pushChangeError(e);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
this.warnLog(`Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
async updateHomeKitCharacteristics() {
|
|
186
|
-
this.debugLog('updateHomeKitCharacteristics');
|
|
187
|
-
// Active
|
|
188
|
-
await this.updateCharacteristic(this.Fan.Service, this.hap.Characteristic.Active, this.Fan.Active, 'Active');
|
|
189
|
-
// SwingMode
|
|
190
|
-
await this.updateCharacteristic(this.Fan.Service, this.hap.Characteristic.SwingMode, this.Fan.SwingMode, 'SwingMode');
|
|
191
|
-
// RotationSpeed
|
|
192
|
-
await this.updateCharacteristic(this.Fan.Service, this.hap.Characteristic.RotationSpeed, this.Fan.RotationSpeed, 'RotationSpeed');
|
|
193
|
-
}
|
|
194
|
-
async apiError(e) {
|
|
195
|
-
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.Active, e);
|
|
196
|
-
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.RotationSpeed, e);
|
|
197
|
-
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.SwingMode, e);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
//# sourceMappingURL=fan.js.map
|
package/dist/irdevice/fan.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fan.js","sourceRoot":"","sources":["../../src/irdevice/fan.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAE5C;;;;GAIG;AACH,MAAM,OAAO,KAAM,SAAQ,YAAY;IAY1B;IAXX,WAAW;IACH,GAAG,CAOV;IAED,YACW,QAA8B,EACvC,SAA4B,EAC5B,MAAkC;QAElC,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CAAA;QAJzB,aAAQ,GAAR,QAAQ,CAAsB;QAKvC,eAAe;QACf,SAAS,CAAC,QAAQ,kCAA0B,CAAA;QAE5C,4BAA4B;QAC5B,SAAS,CAAC,OAAO,CAAC,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,IAAI,EAAE,CAAA;QACnD,IAAI,CAAC,GAAG,GAAG;YACT,IAAI,EAAE,SAAS,CAAC,WAAW;YAC3B,OAAO,EAAE,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAY;YAChH,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC,QAAQ;YAC3E,SA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