-
Notifications
You must be signed in to change notification settings - Fork 804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Switchbot support and discovery. #995
Conversation
Just received 4 MagicSwitchbot units and can try this. Already compiled and uploaded the firmware in the pr but cannot figure out the command I have to send to trigger the switch. Im guessing its a write command like the one in ble.md mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoBT/config -m '{ but with the correct mac and payload. |
@darkjavi That should be working, I do not know what value / value type the switchbot needs to receive but you may need to change that as well. |
been looking to this python lib to manage the switchbot:
Looks like it needs a handle+fixed command , don't know yet how to generate that and the char-write-cmd |
@darkjavi I used this https://github.com/devWaves/SwitchBot-MQTT-BLE-ESP32/blob/main/SwitchBot-BLE2MQTT-ESP32.ino as a reference for the basic implementation. Maybe that will help. |
I have 2 SwitchBot curtains which I want to integrate with Home Assistant. |
Thanks for the feedback and the link. I am looking for specifics on the commands to interface with the switchbots as I do not have any. This is just a base framework to expand on. If you know the data and commands to read/write for your application please post the info and I'll be glad to write docs and or update the code for support. |
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. |
Bump, not stale. |
73bc96f
to
a416ef8
Compare
Hi @h2zero @1technophile I'm wondering how this project for SwitchBot connectivity is planned for the future? Like with the recent SwitchBot S1 status decoder this could allow for all READ commands info to be substituted by the advertised broadcast information through status decoders, while WRITE commands are issued through this connectivity implementation through a encoder-like substitution in place of the raw hex commands?!? I'm just wondering if a split implementation like this is planned, or if all WRITE and READ will be implemented here? If the former, and with the detailed SwitchBot APIs, which @1technophile linked to and the S1 decoder is based on, I'd be happy to work on the other SwitchBot devices' status decoder implementations, like @nielsfaber's SwitchBot curtains etc. With the API info the WRITE commands should also be clearly defined. Thanks |
Hi @DigiH, I'm planning to integrate the new version of the decoder and leverage it for identifying the SwitchBot S1, once identified we will auto-discover those as a switch or press button depending on the mode. So yes you can go ahead and implement the Switchbot devices that you want, it will be a great contribution to the decoder! |
Hi @1technophile sounds great, thanks for the info. I already created a Curtain status decoder at https://github.com/DigiH/decoder/tree/switchbot-curtain So @nielsfaber or anyone else with the SwitchBot Curtain if you could test this version, as the test cases I included are only based on the API documentation, but no real world device testing. Currently the decoder contains the status for motionstate, position, calibrated (only gets published if state is false, i.e. calibration is needed), lightlevel and battery.
is not currently implemented, but might actually be needed/helpful for WRITE connections. Probably best to move any further discussions of SwitchBot devices' status decoders here and leave this for further control implementation exchange. Thanks |
Rebased now to latest development branch, needed to bump decoder version also. |
50ebe6c
to
da4c942
Compare
* Use a task to process immediate BLE actions to prevent MQTT disconnection if the action takes too long to complete. * Add state_on and state_off parameters to createDiscovery
@nielsfaber @darkjavi This PR adds Switchbot S1 (button) autodiscovery and control, would you like to test it? |
@1technophile thanks for your efforts, sounds great! As said in my previous comment, at this point I do not know how to send (or request) the open/closed state of these modules, so I would need some help regarding the topic/payload data that is used (unless they are automatically added as cover entities in HA). |
Hi @nielsfaber, did you ever get a chance to test the SwitchBot curtain status decoder I mentioned above? While it doesn't allow you to send commands to the SwitchBot curtain modules, it shows you their current status (motion state, position, calibration status, light level and battery) and status changes which you might have initiated through the SwitchBot app so far, and similarly to the current SwitchBot S1 implementation is part of getting a full SwitchBot curtain OMG inclusion ready. If you feel like testing the status decoder and giving some feedback please use the SwitchBot decoder discussion Thanks |
Adds Switchbot support and automatic discovery for Home Assistant and OpenHAB.
Improves BLE command support by using a one-shot task to process immediate BLE actions, this prevents MQTT disconnections if the action takes too long to complete.
Adds state_on and state_off parameters to createDiscovery().