@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
package/dist/settings.d.ts
CHANGED
|
@@ -1,251 +1,12 @@
|
|
|
1
|
-
import type { IClientOptions } from 'async-mqtt';
|
|
2
|
-
import type { PlatformConfig } from 'homebridge';
|
|
3
|
-
import type { device, irdevice, SwitchBotBLEModel, SwitchBotBLEModelFriendlyName, SwitchBotBLEModelName, SwitchBotModel } from 'node-switchbot';
|
|
4
|
-
/**
|
|
5
|
-
* This is the name of the platform that users will use to register the plugin in the Homebridge config.json
|
|
6
|
-
*/
|
|
7
|
-
export declare const PLATFORM_NAME = "SwitchBot";
|
|
8
|
-
/**
|
|
9
|
-
* This must match the name of your plugin as defined the package.json
|
|
10
|
-
*/
|
|
11
1
|
export declare const PLUGIN_NAME = "@switchbot/homebridge-switchbot";
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export
|
|
22
|
-
devices?: devicesConfig[];
|
|
23
|
-
deviceConfig?: {
|
|
24
|
-
[deviceType: string]: devicesConfig;
|
|
25
|
-
};
|
|
26
|
-
irdevices?: irDevicesConfig[];
|
|
27
|
-
irdeviceConfig?: {
|
|
28
|
-
[remoteType: string]: irDevicesConfig;
|
|
29
|
-
};
|
|
30
|
-
allowInvalidCharacters?: boolean;
|
|
31
|
-
mqttURL?: string;
|
|
32
|
-
mqttOptions?: IClientOptions;
|
|
33
|
-
mqttPubOptions?: IClientOptions;
|
|
34
|
-
BLE?: boolean;
|
|
35
|
-
discoverBLE?: boolean;
|
|
36
|
-
disableLogsforBLE?: boolean;
|
|
37
|
-
disableLogsforOpenAPI?: boolean;
|
|
38
|
-
hostname?: string;
|
|
39
|
-
webhookURL?: string;
|
|
40
|
-
maxRetries?: number;
|
|
41
|
-
delayBetweenRetries?: number;
|
|
42
|
-
refreshRate?: number;
|
|
43
|
-
updateRate?: number;
|
|
44
|
-
pushRate?: number;
|
|
45
|
-
logging?: string;
|
|
46
|
-
}
|
|
47
|
-
export type devicesConfig = botConfig | relaySwitch1Config | relaySwitch1PMConfig | meterConfig | meterProConfig | indoorOutdoorSensorConfig | humidifierConfig | curtainConfig | blindTiltConfig | contactConfig | motionConfig | waterDetectorConfig | plugConfig | colorBulbConfig | stripLightConfig | ceilingLightConfig | lockConfig | hubConfig;
|
|
48
|
-
export interface BaseDeviceConfig extends device {
|
|
49
|
-
bleMac?: string;
|
|
50
|
-
model: SwitchBotModel;
|
|
51
|
-
bleModel: SwitchBotBLEModel;
|
|
52
|
-
bleModelName: SwitchBotBLEModelName;
|
|
53
|
-
bleModelFriednlyName: SwitchBotBLEModelFriendlyName;
|
|
54
|
-
configDeviceType: string;
|
|
55
|
-
configDeviceName?: string;
|
|
56
|
-
deviceId: string;
|
|
57
|
-
external?: boolean;
|
|
58
|
-
refreshRate?: number;
|
|
59
|
-
updateRate?: number;
|
|
60
|
-
pushRate?: number;
|
|
61
|
-
firmware?: string;
|
|
62
|
-
logging?: string;
|
|
63
|
-
connectionType?: string;
|
|
64
|
-
customBLEaddress?: string;
|
|
65
|
-
scanDuration?: number;
|
|
66
|
-
hide_device?: boolean;
|
|
67
|
-
offline?: boolean;
|
|
68
|
-
maxRetry?: number;
|
|
69
|
-
maxRetries?: number;
|
|
70
|
-
delayBetweenRetries?: number;
|
|
71
|
-
disableCaching?: boolean;
|
|
72
|
-
disablePlatformBLE?: boolean;
|
|
73
|
-
mqttURL?: string;
|
|
74
|
-
mqttOptions?: IClientOptions;
|
|
75
|
-
mqttPubOptions?: IClientOptions;
|
|
76
|
-
history?: boolean;
|
|
77
|
-
webhook?: boolean;
|
|
78
|
-
}
|
|
79
|
-
export interface botConfig extends BaseDeviceConfig {
|
|
80
|
-
configDeviceType: 'Bot';
|
|
81
|
-
mode?: string;
|
|
82
|
-
type: string;
|
|
83
|
-
doublePress?: number;
|
|
84
|
-
pushRatePress?: number;
|
|
85
|
-
allowPush?: boolean;
|
|
86
|
-
multiPress?: boolean;
|
|
87
|
-
}
|
|
88
|
-
export interface relaySwitch1Config extends BaseDeviceConfig {
|
|
89
|
-
configDeviceType: 'Relay Switch 1';
|
|
90
|
-
type: string;
|
|
91
|
-
allowPush?: boolean;
|
|
92
|
-
}
|
|
93
|
-
export interface relaySwitch1PMConfig extends BaseDeviceConfig {
|
|
94
|
-
configDeviceType: 'Relay Switch 1PM';
|
|
95
|
-
type: string;
|
|
96
|
-
allowPush?: boolean;
|
|
97
|
-
}
|
|
98
|
-
export interface meterConfig extends BaseDeviceConfig {
|
|
99
|
-
configDeviceType: 'Meter' | 'MeterPlus';
|
|
100
|
-
hide_temperature?: boolean;
|
|
101
|
-
convertUnitTo?: string;
|
|
102
|
-
hide_humidity?: boolean;
|
|
103
|
-
}
|
|
104
|
-
export interface meterProConfig extends BaseDeviceConfig {
|
|
105
|
-
configDeviceType: 'Meter Pro' | 'MeterPro(CO2)';
|
|
106
|
-
hide_temperature?: boolean;
|
|
107
|
-
convertUnitTo?: string;
|
|
108
|
-
hide_humidity?: boolean;
|
|
109
|
-
hide_co2?: boolean;
|
|
110
|
-
}
|
|
111
|
-
export interface indoorOutdoorSensorConfig extends BaseDeviceConfig {
|
|
112
|
-
configDeviceType: 'WoIOSensor';
|
|
113
|
-
hide_temperature?: boolean;
|
|
114
|
-
convertUnitTo?: string;
|
|
115
|
-
hide_humidity?: boolean;
|
|
116
|
-
}
|
|
117
|
-
export interface humidifierConfig extends BaseDeviceConfig {
|
|
118
|
-
configDeviceType: 'Humidifier' | 'Humidifier2';
|
|
119
|
-
hide_temperature?: boolean;
|
|
120
|
-
convertUnitTo?: string;
|
|
121
|
-
set_minStep?: number;
|
|
122
|
-
}
|
|
123
|
-
export interface curtainConfig extends BaseDeviceConfig {
|
|
124
|
-
configDeviceType: 'Curtain' | 'Curtain3' | 'WoRollerShade' | 'Roller Shade';
|
|
125
|
-
disable_group?: boolean;
|
|
126
|
-
hide_lightsensor?: boolean;
|
|
127
|
-
set_minLux?: number;
|
|
128
|
-
set_maxLux?: number;
|
|
129
|
-
set_max?: number;
|
|
130
|
-
set_min?: number;
|
|
131
|
-
set_minStep?: number;
|
|
132
|
-
setCloseMode?: string;
|
|
133
|
-
setOpenMode?: string;
|
|
134
|
-
silentModeSwitch?: boolean;
|
|
135
|
-
}
|
|
136
|
-
export interface blindTiltConfig extends BaseDeviceConfig {
|
|
137
|
-
configDeviceType: 'Blind Tilt';
|
|
138
|
-
disable_group?: boolean;
|
|
139
|
-
mapping?: string;
|
|
140
|
-
hide_lightsensor?: boolean;
|
|
141
|
-
set_minLux?: number;
|
|
142
|
-
set_maxLux?: number;
|
|
143
|
-
set_max?: number;
|
|
144
|
-
set_min?: number;
|
|
145
|
-
set_minStep?: number;
|
|
146
|
-
setCloseMode?: string;
|
|
147
|
-
setOpenMode?: string;
|
|
148
|
-
silentModeSwitch?: boolean;
|
|
149
|
-
}
|
|
150
|
-
export interface contactConfig extends BaseDeviceConfig {
|
|
151
|
-
configDeviceType: 'Contact Sensor';
|
|
152
|
-
hide_lightsensor?: boolean;
|
|
153
|
-
set_minLux?: number;
|
|
154
|
-
set_maxLux?: number;
|
|
155
|
-
hide_motionsensor?: boolean;
|
|
156
|
-
}
|
|
157
|
-
export interface motionConfig extends BaseDeviceConfig {
|
|
158
|
-
configDeviceType: 'Motion Sensor';
|
|
159
|
-
hide_lightsensor?: boolean;
|
|
160
|
-
set_minLux?: number;
|
|
161
|
-
set_maxLux?: number;
|
|
162
|
-
}
|
|
163
|
-
export interface waterDetectorConfig extends BaseDeviceConfig {
|
|
164
|
-
configDeviceType: 'Water Detector';
|
|
165
|
-
hide_leak?: boolean;
|
|
166
|
-
dry?: boolean;
|
|
167
|
-
}
|
|
168
|
-
export interface plugConfig extends BaseDeviceConfig {
|
|
169
|
-
configDeviceType: 'Plug' | 'Plug Mini (US)' | 'Plug Mini (JP)';
|
|
170
|
-
}
|
|
171
|
-
export interface colorBulbConfig extends BaseDeviceConfig {
|
|
172
|
-
configDeviceType: 'Color Bulb';
|
|
173
|
-
set_minStep?: number;
|
|
174
|
-
adaptiveLightingShift?: number;
|
|
175
|
-
}
|
|
176
|
-
export interface stripLightConfig extends BaseDeviceConfig {
|
|
177
|
-
configDeviceType: 'Strip Light';
|
|
178
|
-
set_minStep?: number;
|
|
179
|
-
adaptiveLightingShift?: number;
|
|
180
|
-
}
|
|
181
|
-
export interface ceilingLightConfig extends BaseDeviceConfig {
|
|
182
|
-
configDeviceType: 'Ceiling Light' | 'Ceiling Light Pro';
|
|
183
|
-
set_minStep?: number;
|
|
184
|
-
adaptiveLightingShift?: number;
|
|
185
|
-
}
|
|
186
|
-
export interface lockConfig extends BaseDeviceConfig {
|
|
187
|
-
configDeviceType: 'Smart Lock' | 'Smart Lock Pro';
|
|
188
|
-
hide_contactsensor?: boolean;
|
|
189
|
-
activate_latchbutton?: boolean;
|
|
190
|
-
}
|
|
191
|
-
export interface hubConfig extends BaseDeviceConfig {
|
|
192
|
-
configDeviceType: 'Hub 2';
|
|
193
|
-
hide_temperature?: boolean;
|
|
194
|
-
convertUnitTo?: string;
|
|
195
|
-
hide_humidity?: boolean;
|
|
196
|
-
hide_lightsensor?: boolean;
|
|
197
|
-
set_minLux?: number;
|
|
198
|
-
set_maxLux?: number;
|
|
199
|
-
}
|
|
200
|
-
export type irDevicesConfig = irFanConfig | irLightConfig | irAirConfig | irOtherConfig;
|
|
201
|
-
export interface irBaseDeviceConfig extends irdevice {
|
|
202
|
-
configDeviceName?: string;
|
|
203
|
-
configRemoteType?: string;
|
|
204
|
-
connectionType?: string;
|
|
205
|
-
hide_device?: boolean;
|
|
206
|
-
external?: boolean;
|
|
207
|
-
refreshRate?: number;
|
|
208
|
-
updateRate?: number;
|
|
209
|
-
pushRate?: number;
|
|
210
|
-
maxRetries?: number;
|
|
211
|
-
delayBetweenRetries?: number;
|
|
212
|
-
firmware?: string;
|
|
213
|
-
deviceId: string;
|
|
214
|
-
logging?: string;
|
|
215
|
-
customOn?: string;
|
|
216
|
-
customOff?: string;
|
|
217
|
-
customize?: boolean;
|
|
218
|
-
commandType?: string;
|
|
219
|
-
disablePushOn?: boolean;
|
|
220
|
-
disablePushOff?: boolean;
|
|
221
|
-
disablePushDetail?: boolean;
|
|
222
|
-
}
|
|
223
|
-
export interface irFanConfig extends irBaseDeviceConfig {
|
|
224
|
-
configRemoteType?: 'Fan' | 'DIY Fan';
|
|
225
|
-
swing_mode?: boolean;
|
|
226
|
-
rotation_speed?: boolean;
|
|
227
|
-
set_minStep?: number;
|
|
228
|
-
set_max?: number;
|
|
229
|
-
set_min?: number;
|
|
230
|
-
}
|
|
231
|
-
export interface irLightConfig extends irBaseDeviceConfig {
|
|
232
|
-
configRemoteType?: 'Light' | 'DIY Light';
|
|
233
|
-
stateless?: boolean;
|
|
234
|
-
}
|
|
235
|
-
export interface irAirConfig extends irBaseDeviceConfig {
|
|
236
|
-
configRemoteType?: 'Air Conditioner' | 'DIY Air Conditioner';
|
|
237
|
-
hide_automode?: boolean;
|
|
238
|
-
set_max_heat?: number;
|
|
239
|
-
set_min_heat?: number;
|
|
240
|
-
set_max_cool?: number;
|
|
241
|
-
set_min_cool?: number;
|
|
242
|
-
meterType?: string;
|
|
243
|
-
meterId?: string;
|
|
244
|
-
meterUuid?: string;
|
|
245
|
-
}
|
|
246
|
-
export interface irOtherConfig extends irBaseDeviceConfig {
|
|
247
|
-
configRemoteType?: 'Others';
|
|
248
|
-
type?: string;
|
|
249
|
-
}
|
|
250
|
-
export {};
|
|
2
|
+
export declare const PLATFORM_NAME = "SwitchBot";
|
|
3
|
+
export interface SwitchBotPluginConfig {
|
|
4
|
+
openApiToken?: string;
|
|
5
|
+
openApiSecret?: string;
|
|
6
|
+
preferMatter?: boolean;
|
|
7
|
+
enableMatter?: boolean;
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
}
|
|
10
|
+
export declare const DEFAULT_CONFIG: Partial<SwitchBotPluginConfig>;
|
|
11
|
+
export type DeviceType = string;
|
|
251
12
|
//# sourceMappingURL=settings.d.ts.map
|
package/dist/settings.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,oCAAoC,CAAA;AAC5D,eAAO,MAAM,aAAa,cAAc,CAAA;AAExC,MAAM,WAAW,qBAAqB;IACpC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,YAAY,CAAC,EAAE,OAAO,CAAA;IAEtB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACnB;AAED,eAAO,MAAM,cAAc,EAAE,OAAO,CAAC,qBAAqB,CAGzD,CAAA;AAED,MAAM,MAAM,UAAU,GAAG,MAAM,CAAA"}
|
package/dist/settings.js
CHANGED
|
@@ -1,32 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This is the name of the platform that users will use to register the plugin in the Homebridge config.json
|
|
3
|
-
*/
|
|
4
|
-
export const PLATFORM_NAME = 'SwitchBot';
|
|
5
|
-
/**
|
|
6
|
-
* This must match the name of your plugin as defined the package.json
|
|
7
|
-
*/
|
|
8
1
|
export const PLUGIN_NAME = '@switchbot/homebridge-switchbot';
|
|
9
|
-
;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
;
|
|
14
|
-
;
|
|
15
|
-
;
|
|
16
|
-
;
|
|
17
|
-
;
|
|
18
|
-
;
|
|
19
|
-
;
|
|
20
|
-
;
|
|
21
|
-
;
|
|
22
|
-
;
|
|
23
|
-
;
|
|
24
|
-
;
|
|
25
|
-
;
|
|
26
|
-
;
|
|
27
|
-
;
|
|
28
|
-
;
|
|
29
|
-
;
|
|
30
|
-
;
|
|
31
|
-
;
|
|
2
|
+
export const PLATFORM_NAME = 'SwitchBot';
|
|
3
|
+
export const DEFAULT_CONFIG = {
|
|
4
|
+
preferMatter: true,
|
|
5
|
+
enableMatter: true,
|
|
6
|
+
};
|
|
32
7
|
//# sourceMappingURL=settings.js.map
|
package/dist/settings.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,iCAAiC,CAAA;AAC5D,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CAAA;AAWxC,MAAM,CAAC,MAAM,cAAc,GAAmC;IAC5D,YAAY,EAAE,IAAI;IAClB,YAAY,EAAE,IAAI;CACnB,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { SwitchBotPluginConfig } from './settings.js';
|
|
2
|
+
export interface ISwitchBotClient {
|
|
3
|
+
init(): Promise<void>;
|
|
4
|
+
getDevice(id: string): Promise<any>;
|
|
5
|
+
getDevices(): Promise<any[]>;
|
|
6
|
+
setDeviceState(id: string, body: any): Promise<any>;
|
|
7
|
+
destroy(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Thin wrapper around node-switchbot v4.0.0-beta.2+
|
|
11
|
+
* Leverages upstream resilience features (retry, circuit breaker, connection intelligence)
|
|
12
|
+
* while maintaining plugin-specific features like write debouncing and OpenAPI fallback.
|
|
13
|
+
*/
|
|
14
|
+
export declare class SwitchBotClient implements ISwitchBotClient {
|
|
15
|
+
private cfg;
|
|
16
|
+
private client;
|
|
17
|
+
private baseUrl;
|
|
18
|
+
private requestTimeout;
|
|
19
|
+
private maxRetries;
|
|
20
|
+
private writeDebounceMs;
|
|
21
|
+
private logger;
|
|
22
|
+
private pendingWrites;
|
|
23
|
+
constructor(cfg: SwitchBotPluginConfig);
|
|
24
|
+
init(): Promise<void>;
|
|
25
|
+
private fetchWithTimeoutAndRetry;
|
|
26
|
+
getDevice(id: string): Promise<any>;
|
|
27
|
+
getDevices(): Promise<any[]>;
|
|
28
|
+
setDeviceState(id: string, body: any): Promise<any>;
|
|
29
|
+
private _doSetDeviceState;
|
|
30
|
+
destroy(): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=switchbotClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"switchbotClient.d.ts","sourceRoot":"","sources":["../src/switchbotClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAE1D,MAAM,WAAW,gBAAgB;IAC/B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACrB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;IACnC,UAAU,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;IAC5B,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;IACnD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACzB;AAED;;;;GAIG;AACH,qBAAa,eAAgB,YAAW,gBAAgB;IACtD,OAAO,CAAC,GAAG,CAAuB;IAClC,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,OAAO,CAAoC;IACnD,OAAO,CAAC,cAAc,CAAO;IAC7B,OAAO,CAAC,UAAU,CAAI;IACtB,OAAO,CAAC,eAAe,CAAM;IAC7B,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,aAAa,CAA0H;gBAEnI,GAAG,EAAE,qBAAqB;IAQhC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;YAqBb,wBAAwB;IAkChC,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAmBnC,UAAU,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAoB5B,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;YA+B3C,iBAAiB;IAqCzB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAM/B"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin wrapper around node-switchbot v4.0.0-beta.2+
|
|
3
|
+
* Leverages upstream resilience features (retry, circuit breaker, connection intelligence)
|
|
4
|
+
* while maintaining plugin-specific features like write debouncing and OpenAPI fallback.
|
|
5
|
+
*/
|
|
6
|
+
export class SwitchBotClient {
|
|
7
|
+
cfg;
|
|
8
|
+
client = null;
|
|
9
|
+
baseUrl = 'https://api.switch-bot.com/v1.0';
|
|
10
|
+
requestTimeout = 5000;
|
|
11
|
+
maxRetries = 2;
|
|
12
|
+
writeDebounceMs = 100;
|
|
13
|
+
logger;
|
|
14
|
+
pendingWrites = new Map();
|
|
15
|
+
constructor(cfg) {
|
|
16
|
+
this.cfg = cfg;
|
|
17
|
+
this.logger = cfg?.logger ?? console;
|
|
18
|
+
if (typeof cfg?.requestTimeout === 'number')
|
|
19
|
+
this.requestTimeout = cfg.requestTimeout;
|
|
20
|
+
if (typeof cfg?.maxRetries === 'number')
|
|
21
|
+
this.maxRetries = cfg.maxRetries;
|
|
22
|
+
if (typeof cfg?.writeDebounceMs === 'number')
|
|
23
|
+
this.writeDebounceMs = cfg.writeDebounceMs;
|
|
24
|
+
}
|
|
25
|
+
async init() {
|
|
26
|
+
try {
|
|
27
|
+
// Dynamic import of node-switchbot v4 with native resilience features
|
|
28
|
+
const { SwitchBot } = await import('node-switchbot');
|
|
29
|
+
this.client = new SwitchBot({
|
|
30
|
+
token: this.cfg.openApiToken,
|
|
31
|
+
secret: this.cfg.openApiSecret,
|
|
32
|
+
// Enable all built-in resilience features from node-switchbot v4
|
|
33
|
+
enableFallback: true, // Auto-fallback from BLE to API
|
|
34
|
+
enableRetry: true, // Retry with exponential backoff
|
|
35
|
+
enableCircuitBreaker: true, // Circuit breaker per connection type
|
|
36
|
+
enableMetrics: true, // Connection tracking and statistics
|
|
37
|
+
...(typeof this.cfg?.nodeClientConfig === 'object' && this.cfg.nodeClientConfig),
|
|
38
|
+
});
|
|
39
|
+
this.logger?.info?.('SwitchBot client initialized with native resilience features');
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
this.logger?.warn?.('Failed to load node-switchbot; will use OpenAPI fallback:', e);
|
|
43
|
+
this.client = null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async fetchWithTimeoutAndRetry(url, opts = {}, timeoutMs, retries) {
|
|
47
|
+
const to = typeof timeoutMs === 'number' ? timeoutMs : this.requestTimeout;
|
|
48
|
+
const max = typeof retries === 'number' ? retries : this.maxRetries;
|
|
49
|
+
let attempt = 0;
|
|
50
|
+
while (true) {
|
|
51
|
+
attempt += 1;
|
|
52
|
+
const controller = new AbortController();
|
|
53
|
+
const timer = setTimeout(() => controller.abort(), to);
|
|
54
|
+
try {
|
|
55
|
+
const fetchOpts = Object.assign({}, opts);
|
|
56
|
+
try {
|
|
57
|
+
Object.defineProperty(fetchOpts, 'signal', { value: controller.signal, enumerable: false, configurable: true });
|
|
58
|
+
}
|
|
59
|
+
catch (_e) {
|
|
60
|
+
// ignore
|
|
61
|
+
}
|
|
62
|
+
const resp = await fetch(url, fetchOpts);
|
|
63
|
+
clearTimeout(timer);
|
|
64
|
+
if (resp.ok)
|
|
65
|
+
return resp;
|
|
66
|
+
// server error / rate limit: retry
|
|
67
|
+
if (resp.status >= 500 || resp.status === 429) {
|
|
68
|
+
throw new Error(`retriable response: ${resp.status}`);
|
|
69
|
+
}
|
|
70
|
+
return resp;
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
clearTimeout(timer);
|
|
74
|
+
if (attempt > max)
|
|
75
|
+
throw err;
|
|
76
|
+
// exponential backoff
|
|
77
|
+
const backoff = Math.min(100 * Math.pow(2, attempt - 1), 2000);
|
|
78
|
+
await new Promise((r) => setTimeout(r, backoff));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async getDevice(id) {
|
|
83
|
+
// Try client API first (with node-switchbot's smart fallback and retry)
|
|
84
|
+
if (this.client?.getDevice) {
|
|
85
|
+
try {
|
|
86
|
+
return await this.client.getDevice(id);
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
this.logger?.warn?.(`Client getDevice failed for ${id}, trying OpenAPI fallback:`, e);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// Fallback: call OpenAPI via HTTP
|
|
93
|
+
if (this.cfg.openApiToken) {
|
|
94
|
+
const url = `${this.baseUrl}/devices/${id}`;
|
|
95
|
+
const opts = { headers: { Authorization: this.cfg.openApiToken } };
|
|
96
|
+
const resp = await this.fetchWithTimeoutAndRetry(url, opts);
|
|
97
|
+
return resp.json();
|
|
98
|
+
}
|
|
99
|
+
throw new Error('No SwitchBot client available');
|
|
100
|
+
}
|
|
101
|
+
async getDevices() {
|
|
102
|
+
// Try client API first
|
|
103
|
+
if (this.client?.getDevices) {
|
|
104
|
+
try {
|
|
105
|
+
return await this.client.getDevices();
|
|
106
|
+
}
|
|
107
|
+
catch (e) {
|
|
108
|
+
this.logger?.warn?.('Client getDevices failed, trying OpenAPI fallback:', e);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// Fallback: call OpenAPI
|
|
112
|
+
if (this.cfg.openApiToken) {
|
|
113
|
+
const url = `${this.baseUrl}/devices`;
|
|
114
|
+
const opts = { headers: { Authorization: this.cfg.openApiToken } };
|
|
115
|
+
const resp = await this.fetchWithTimeoutAndRetry(url, opts);
|
|
116
|
+
const data = await resp.json();
|
|
117
|
+
return (data?.body || data);
|
|
118
|
+
}
|
|
119
|
+
return [];
|
|
120
|
+
}
|
|
121
|
+
async setDeviceState(id, body) {
|
|
122
|
+
// Plugin-level debounce: coalesce rapid writes per device
|
|
123
|
+
if (!this.writeDebounceMs || this.writeDebounceMs <= 0) {
|
|
124
|
+
return this._doSetDeviceState(id, body);
|
|
125
|
+
}
|
|
126
|
+
return new Promise((resolve, reject) => {
|
|
127
|
+
const existing = this.pendingWrites.get(id);
|
|
128
|
+
if (existing) {
|
|
129
|
+
existing.body = body;
|
|
130
|
+
existing.resolvers.push({ resolve, reject });
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
const resolvers = [{ resolve, reject }];
|
|
134
|
+
const timer = setTimeout(async () => {
|
|
135
|
+
const entry = this.pendingWrites.get(id);
|
|
136
|
+
if (!entry)
|
|
137
|
+
return;
|
|
138
|
+
this.pendingWrites.delete(id);
|
|
139
|
+
try {
|
|
140
|
+
const out = await this._doSetDeviceState(id, entry.body);
|
|
141
|
+
for (const r of entry.resolvers)
|
|
142
|
+
r.resolve(out);
|
|
143
|
+
}
|
|
144
|
+
catch (e) {
|
|
145
|
+
for (const r of entry.resolvers)
|
|
146
|
+
r.reject(e);
|
|
147
|
+
}
|
|
148
|
+
}, this.writeDebounceMs);
|
|
149
|
+
this.pendingWrites.set(id, { timer, body, resolvers });
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
async _doSetDeviceState(id, body) {
|
|
153
|
+
// Prefer client API (which has node-switchbot's native resilience)
|
|
154
|
+
if (this.client?.setDeviceState) {
|
|
155
|
+
try {
|
|
156
|
+
return await this.client.setDeviceState(id, body);
|
|
157
|
+
}
|
|
158
|
+
catch (e) {
|
|
159
|
+
this.logger?.warn?.(`Client setDeviceState failed for ${id}, trying fallback:`, e);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// Try generic sendCommand if available
|
|
163
|
+
if (this.client?.sendCommand) {
|
|
164
|
+
try {
|
|
165
|
+
return await this.client.sendCommand(id, body);
|
|
166
|
+
}
|
|
167
|
+
catch (e) {
|
|
168
|
+
this.logger?.warn?.(`Client sendCommand failed for ${id}, trying OpenAPI:`, e);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
// OpenAPI fallback
|
|
172
|
+
if (this.cfg.openApiToken) {
|
|
173
|
+
const url = `${this.baseUrl}/devices/${id}/commands`;
|
|
174
|
+
const opts = {
|
|
175
|
+
method: 'POST',
|
|
176
|
+
headers: {
|
|
177
|
+
Authorization: this.cfg.openApiToken,
|
|
178
|
+
'Content-Type': 'application/json',
|
|
179
|
+
},
|
|
180
|
+
body: JSON.stringify(body),
|
|
181
|
+
};
|
|
182
|
+
const resp = await this.fetchWithTimeoutAndRetry(url, opts);
|
|
183
|
+
return resp.json();
|
|
184
|
+
}
|
|
185
|
+
throw new Error('No SwitchBot client available for setDeviceState');
|
|
186
|
+
}
|
|
187
|
+
async destroy() {
|
|
188
|
+
if (this.client?.destroy) {
|
|
189
|
+
await this.client.destroy();
|
|
190
|
+
}
|
|
191
|
+
this.client = null;
|
|
192
|
+
}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;gBACX,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACP,aAAa,EAAE,IAAI,CAAC,GAAG,CAAC,YAAY;oBACpC,cAAc,EAAE,kBAAkB;iBACnC;gBACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;aAC3B,CAAA;YACD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,wBAAwB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;YAC3D,OAAO,IAAI,CAAC,IAAI,EAAE,CAAA;QACpB,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAA;IACrE,CAAC;IAED,KAAK,CAAC,OAAO;QACX,IAAI,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;YACzB,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAA;QAC7B,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;IACpB,CAAC;CACF"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,51 +1,40 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
export declare
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export declare
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
*/
|
|
41
|
-
export declare function formatDeviceIdAsMac(deviceId: string, cassSensative?: boolean): string;
|
|
42
|
-
export declare function rgb2hs(r: any, g: any, b: any): number[];
|
|
43
|
-
export declare function hs2rgb(h: any, s: any): number[];
|
|
44
|
-
export declare function k2rgb(k: number): any;
|
|
45
|
-
export declare function m2hs(m: any): number[];
|
|
46
|
-
/**
|
|
47
|
-
* Remove deviceConfig entries that contain only default/empty values.
|
|
48
|
-
* Returns undefined if nothing meaningful remains.
|
|
49
|
-
*/
|
|
50
|
-
export declare function cleanDeviceConfig(deviceConfig?: Record<string, Record<string, any>>): Record<string, Record<string, any>> | undefined;
|
|
1
|
+
import type { PlatformConfig } from 'homebridge';
|
|
2
|
+
import type { SwitchBotPluginConfig } from './settings.js';
|
|
3
|
+
export declare const MATTER_CLUSTER_IDS: {
|
|
4
|
+
readonly OnOff: 6;
|
|
5
|
+
readonly LevelControl: 8;
|
|
6
|
+
readonly ColorControl: 768;
|
|
7
|
+
readonly WindowCovering: 258;
|
|
8
|
+
readonly DoorLock: 257;
|
|
9
|
+
readonly FanControl: 514;
|
|
10
|
+
readonly RelativeHumidityMeasurement: 1029;
|
|
11
|
+
};
|
|
12
|
+
export declare const MATTER_ATTRIBUTE_IDS: {
|
|
13
|
+
readonly OnOff: {
|
|
14
|
+
readonly OnOff: 0;
|
|
15
|
+
};
|
|
16
|
+
readonly LevelControl: {
|
|
17
|
+
readonly CurrentLevel: 0;
|
|
18
|
+
};
|
|
19
|
+
readonly ColorControl: {
|
|
20
|
+
readonly CurrentHue: 0;
|
|
21
|
+
readonly CurrentSaturation: 1;
|
|
22
|
+
readonly ColorTemperatureMireds: 2;
|
|
23
|
+
};
|
|
24
|
+
readonly WindowCovering: {
|
|
25
|
+
readonly CurrentPosition: 0;
|
|
26
|
+
readonly TargetPosition: 1;
|
|
27
|
+
};
|
|
28
|
+
readonly FanControl: {
|
|
29
|
+
readonly SpeedCurrent: 0;
|
|
30
|
+
};
|
|
31
|
+
readonly DoorLock: {
|
|
32
|
+
readonly LockState: 0;
|
|
33
|
+
};
|
|
34
|
+
readonly RelativeHumidityMeasurement: {
|
|
35
|
+
readonly MeasuredValue: 0;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export declare function normalizeConfig(raw?: PlatformConfig): SwitchBotPluginConfig;
|
|
39
|
+
export declare function createPlatformProxy(HAPPlatform: any, MatterPlatform: any): any;
|
|
51
40
|
//# sourceMappingURL=utils.d.ts.map
|