homebridge-switchbot
homebridge-switchbot copied to clipboard
Support Request: How am I supposed to use a contact sensor via API's 30sec restriction?
Describe Your Problem
30 Seconds refresh rate is far too long for contact or motion sensor
As the installation of @abandonware/noble fails on Raspberry 4B I am unfortunately not be able to use BLE for the contact sensor. But the API version don't want me to refresh faster than every 30 seconds, which seems to be because of the maximum of 10,000 API calls per day.
But with this limitations there is nearly no use of a contact or motion sensor. When I open a door or enter a room, i don't want to wait up to 30 seconds until the lights finally get on. Espacially if I plan to buy more SB sensors.
So i think there is a need to have a 1 second refresh rate or a kind of a push to homebridge. Actually it works with 'Device Refresh Rate' = 1 though the tool tipp says 'must be 30 or more' but I think the plugin will stop working after the first 10,000 seconds of each day, or? I just sat this 1s for testing.
Config for homebridge-switchbot
{
"name": "SwitchBot",
"credentials": {
"openToken": "xxxxx",
"notice": "Keep your token a secret!"
},
"options": {
"devices": [
{
"deviceId": "Fxxxx7",
"configDeviceName": "Door Holger",
"hide_device": false,
"configDeviceType": "Contact Sensor",
"ble": false,
"scanDuration": -5,
"contact": {
"set_maxlux": 500
},
"refreshRate": 1,
"logging": "standard"
}, {....some other devices....}
]
},
"platform": "SwitchBot"
}
Screenshots
No response
Device & Model
contact sensor (and hub mini, bot, meter, meper plus)
Node.js Version
v16.16.0
NPM Version
v8.11.0
Homebridge Version
v1.5.0
Homebridge SwitchBot Plugin Version
v1.14.1
Homebridge Config UI X Plugin Version
v4.50.0
Operating System
Raspbian Bullseye
Check out this page to enable BT on your pi4b. I have a pi4b and use BT for Homebridge devices. I had to do this first though, and you may need to install plugins again after to get BT depends, but I don't remember. I just remeber it was easy & worked the first time (I don't have my bot configured to use BT, but maybe I should, who knows). Good luck!
https://github.com/bwp91/homebridge-govee/wiki/Bluetooth-Control
Edit: I use BT for Govee devices currently.
Thanks Steve, I tried the BLE things with all help- or howto-pages I found. Switchbot itself installs, but fails for noble. On two Raspi 4B I got errors, even when I install by hand.
npm install @abandonware/noble
The logfile is while using this on the browser-console of the homebridge-UI. Homebridge was installed with apt from repo.homebridge.io
2022-08-03T15_06_28_053Z-debug-0.log
I found no differnece when trying this on ssh console with user pi.
But here I asked for people who doesn't even have a BLE-Pi or have one not in BLE-range to the sensor. So the API should have kind of a push or the refresh must be possible at least once per second. Or the device/hub (or cloud service) need to send an mqtt-message imidiately when sensor state changes.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I agree with @HolgerAusB. As the motion detection for contact sensors is not supported by webhook using the API, the refresh rate should be wayyy shorter. (cf: https://github.com/OpenWonderLabs/SwitchBotAPI/issues/94)
I was surprised to see that it takes 30sec for my HUE light to turn on using Homekit automation. I just can’t use it…
I have the same issue with Home Assistant. Probably because of the API limit, as mentioned.
I have 2 Swithbot hubs using Bluetooth. I don’t see why now I have to get another third party device with Bluetooth to control all this… can’t this plugin use the local network (wifi on the hub) to communicate for instance ? And the hub would send the Bluetooth signals.
I use the extremely cheap Aqara zigbee contact sensors with native HomeKit (& Google & Alexa) support and they're super fast and work every time (& did I mention super cheap?).
I highly recommend you don't buy anymore SB sensors unless they implement native HomeKit & you have tested it meets your expectations.
Zigbee or thread is what you want with contact & motion sensors for automation. I've tried almost all of them except the new eve, and Aqara is what I now have 8 of in my house. I couldn't be happier with then.
Sorry for this, but I suggest you cut your losses and switch if the speed is your issue. Good luck folks!
For now I am globally happy with Switchbot's products. The only thing is that issue with motion detection on contact sensors, which is impacting the homebrige plugin too. For now, I use the IFTTT integration which is doing the job. I don't get why IFTTT gets information that we don't have access to using the API... There must be something wrong with the documentation (or the API).
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
customer support said, I should use webhooks instead, they don't count against API calls. But this need to open a port for incoming messages. So I think I will wait for native HomeKit support, which was promised in June 2022 "as comming soon"
@HolgerAusB If you want I can lower the minimum to be lower then 30sec but then you may use up all your api rate
I allready tried that myself, thank you. One can override the 30 Seconds and set 1 sec. But after 2 hours you get errors then.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically closed because it has not had recent activity. Thank you for your contributions.