Any chance we can also control from rest commands or from the web interface?
that is probably possible but youâre the first to ask for it. I personnaly wouldnt use it, but I can maybe look into it once I get some free time
certain features (like simulated ON/OFF) wouldnât work without some extra thought. I am using retained MQTT messages for the âassumed stateâ in case the esp32 loses power
Is there a specific reason why you would want that? just wondering. So u can control it independently from HA? or just so you dont use MQTT?
Hi devWaves. Any luck with the humidifier? I have one if you want to play
@andremain Is the humidier using bluetooth or WIFI?
There is currently no documentation I can reference for humidifier so figuring out the control commands wouldnât be easy
If it uses BLE, if you want you can try pretending the humidifier is a bot and send the ON/OFF commands and see what happens but that might be a long shot. If that works, I could figure out the state information from a couple screenshots of the BLE service data
Can you send a screenshot of what it looks like in the switchbot app? what values would be worth capturing?
@andremain according to this the humidifier uses WIFI (not BLE).
https://support.switch-bot.com/hc/en-us/articles/360039939573-How-to-set-up-your-Humidifier
I would imagine because it is plugged into the wall and doesnât need the benefits of BLE low energy usage
so without some documentation from switchbot I wonât be able to support it and unless it supports both BLE and wifi, but I donât think so
for the humidifier it would make more sense to do the connection directly from HA instead of using an ESP32 if it uses WIFI. The intention of the esp32 is for the BLE stuff
Hi and thank you for your response. There is actually both ble and wifi on the device. But i am not sure it uses ble after the initial setup. Here are some screenshots.
Oh ok cool. I do actually see BLE Mac in the switchbot link now. I didnât see it before. It only talked about WIFI
If you have an android or iphone can you download a BLE service data scanner app? the one I use is called ânRF connect for mobileâ
If you can change the state from ON to OFF and send a screenshot of the service data at each step, I should be able to figure out how to at least get the current state
I would need multiple pics like thisâŚ
If you can use my ESP32 code and pretend the humidifier is a bot and call ON/OFF that is a first attempt at control. If that works awesome, if not, figuring out the exact command may be tricky with switchbot documentation
also let me know if humidifier supports password like the bots do
edit: To see if BLE works, maybe try turning the WIFI on your phone off then use the switchbot app to see if you can still control the humidifier
Can you please give me some more step by step instructions on how to do that?
In the screenshot I sent I would need the line that says âService dataâ
if humidifier works with BLE, the service data should show the current state of the device in hexidecimal format
Steps
- Install ânRF connect for mobileâ on android. (If you have an iphone there are similar apps that provide the service data)
- Scan for devices
- Find the MAC address for the humidifier
- Click on the humidifier device to expand it and see its data
- Take a screenshot as a baseline of where you started
- Now open the switchbot app, send the ON command to the humidifier
- Open the nRF connect app again and scan again. Take a new screenshot
- open the switchbot again, send the OFF command
- Open the nRF connect app again and scan again. Take a new screenshot
if the humidifer has more commands then just ON/OFF, do the the steps 8,9 again but with those commands
A separate test I was going to get you to try pretending the humidifier MAC was a bot in the esp32 code. And seeing if the existing ON/OFF commands would work for bot, but I realise now it wonât work without me making some minor adjustments
So if you can please provide the screenshots of the service data, we can first see if its even worth going any further
@devWaves, now that @RenierM26 has updated the integration. I was wondering if there are any plans to setup MQTT discovery like zwavejstomqtt does with zwavejs? The reason I ask is because I have bt single issues and this great project fix it
@asucrews sorry, not sure I understand. This ESP32 project already supports MQTT discovery and has for quite some time now. This is completely separate from the other integrations also. Is there something specific you are looking for that isnât already there?
if you meant, making it so you donât need to edit the code to auto MQTT discover devices, then I wasnât really planning on making changes like that. It adds quite a bit of complexity for little benefit. Also bluetooth broadcasts to everyone around. So although it is probably rare, if you had a neighbour that also had a switchbot you wouldnât want to discover their device. The app does that and although it doesnât affect me personally, it is kind of annoying.
Let me know though. Always up for new ideas
so let see if i can explain this betterâŚ
i was thinking like the zwavejs intergration dsicover devies added by zwavejstomqtt.
so like switchbo intergration would discover devies added by your procject
@asucrews so I think I get what you are saying now and although technically possible⌠No this probably wonât happen. A main reason is that this means the HA component would need to be maintained in order to work with the ESP32 stuff and it somewhat defeats the purpose of what I was trying to achieve with using an ESP32
Using the ESP32 and MQTT only means that this âintegrationâ will just continue to work âforeverâ without the need to mess around with HA integrations. As long as you have an MQTT broker working and HA doesnât change how MQTT discovery works this will continue to work 10+ years from now. With an HA integration, this means that an HA update can break things unless the code is maintained.
If I understand correctly, are you using both the Switchbot integration for some switchbots and you are also using my EPS32 code for a couple other switchbots that are too far from your smarthub?
If so, is there any reason why you arenât using only the ESP32 for all your switchbots? Why mix the two?
if someone else wants to go through the effort of maintaining an HA component to work with my ESP32 then all the power to them, but I personally see no point. Why mess with something that works and will continue to always work
a basic example of this is for those people still using version 1.0 of my ESP32 code, it still works for them (although with bug fixes and improvements added along the way), they arenât forced to update to v6.4 if they donât want to, and 10+ years from now they can still be using v1.0. If you tied in an HA integration with that, it could break at any point with an HA update
Iâm glad this project solves some bluetooth signal issues youâve had though! That was my initial main purpose. It comes with the added benefit of a âset it and forget itâ solution
MQTT discovery already creates all the HA devices for you automatically, so I donât see the benefit in tying this together with the Switchbot integration
Cheers
Itâs been few days now that I have an issue with this integration. When I trigger my button after a long time (all night for example) it doesnât work the first time but I have to trigger it 3 or 4 times. Than it starts working fine.
Iâm on version 5.2 and I donât know if the previous version was working fine. Iâm gonna try to update to the latest version but in the meantime do you know why this is happening?
@viciovb you would have to watch the mqtt messages or have it plugged into pc and watch serial output
my main esp32 is still running v5.2 and has been for weeks now making my coffee every morning without issue, so I am not aware of any issues with v5.2
what board type are u using? how many switchbot devices?
Iâm using a WeMos board with 2 switchbot devices. One seems to be working fine, the other one struggles a bit.
what is the linkquality rssi of the one that struggles? when u said 3-4 tries is that only for the one that struggles or both? If only one is acting up then it is a signal from bot to esp32 issue
also make sure also not to just wrap the board in electrical tape. I know the esp32s are not a fan of that and it can cause reboots from overheating
Itâs just one that struggles, the other seems to be working fine.
RSSI from the one thatâs working is -88
RSSI from tha one that struggles is -77
At the moment the esp32 is inside a small plastic enclosure. Iâm gonna remove it from it and see how it goes.
are you sure 88 works? thats a bad signal. you want under 80 at a minimum.
-77 is alright but you kind of want a better signal then that for it to work fast
the closer to zero, the better the signal
removing the enclosure would help possibly
if one works fine then it isnât a code issue. Just a connection with the bot issue. If you place the esp32 closer to the one having issues you should notice the issues go away. You may just have to find the sweet spot as to where to place the esp32 if you are only using one
you can increase the number of retries, but that wont help speed with a bad signal. Spaming the retry calls more than default retries Iâve
if you say it works with 3-4 attempts this is basically the equivalent of increasing the retries by a multiplier of 3-4. Not what I would suggest as a solution but it would technically work because it will still take longer