Gen2 Shelly BLE-MQTT Gateway
Moderator: leecollings
-
- Posts: 216
- Joined: Saturday 10 November 2018 18:29
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Hungary
- Contact:
Gen2 Shelly BLE-MQTT Gateway
If anyone has a Gen2 (non battery operated!) device at home, then it can be used as a BLE-MQTT gateway.
I have created a Javascript, which can be added to the Gen2 device Scripting engine and it will collect BLE Temperature sensor data and forward it to the MQTT broker with Autodiscovery topics added. (Domoticz MQTT Autodiscovery compatible)
https://github.com/enesbcs/shelly-scrip ... mqtt-gw.js
Supported non-encrypted protocols: Mijia/ATC/pvvx/BTHome2
I have created a Javascript, which can be added to the Gen2 device Scripting engine and it will collect BLE Temperature sensor data and forward it to the MQTT broker with Autodiscovery topics added. (Domoticz MQTT Autodiscovery compatible)
https://github.com/enesbcs/shelly-scrip ... mqtt-gw.js
Supported non-encrypted protocols: Mijia/ATC/pvvx/BTHome2
-
- Posts: 97
- Joined: Saturday 14 March 2020 13:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Gen2 Shelly BLE-MQTT Gateway
I am running this script on a Shelly Plus i4 device (non battery operated). When I open the magnet contact of a Shelly BLU Door Device (battery operated), it detects the LUX sensor via MQTT Auto Discovery. But only the LUX sensor. Any idea how to get the open/close status as well?
-
- Posts: 216
- Joined: Saturday 10 November 2018 18:29
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Hungary
- Contact:
Re: Gen2 Shelly BLE-MQTT Gateway
Yes i have an idea. You have to add the necessary datatype in "datatypes" variable and have to add support at autodiscovery() function to this.imautohuttraeger wrote: ↑Tuesday 27 February 2024 10:49 I am running this script on a Shelly Plus i4 device (non battery operated). When I open the magnet contact of a Shelly BLU Door Device (battery operated), it detects the LUX sensor via MQTT Auto Discovery. But only the LUX sensor. Any idea how to get the open/close status as well?
As this script is made only for temperature sensors...
-
- Posts: 97
- Joined: Saturday 14 March 2020 13:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Gen2 Shelly BLE-MQTT Gateway
Thank you! The necessary datatype "window" already exists in your script. So at autodiscovery() I have simply copied the snippet of "illuminance" and renamed "params" to "window". Now idea about what to change for the for the rest of the code in order to have it perfectly. Now in Domoticz I get at least a custom sensor that delivers status 0 and 1. So I can work with that in Domoticz and control a virtual device. But of course it would be much nicer to have a switch of type "Door Contact" directly.
-
- Posts: 97
- Joined: Saturday 14 March 2020 13:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Gen2 Shelly BLE-MQTT Gateway
Meanwhile I have experienced, that this script always stops working and is also de-activated after a while (often it runs just 20 minutes) . It is the same with the original code without my customization. It stops (play symbol is shown instead of the pause symbol) and the slide switch for activation is off. See screenshot.
Othe scripts from the Github page do not stop working - I have tested some.
As my programming and debug abilities are close to zero I would appreciate any hint.
Othe scripts from the Github page do not stop working - I have tested some.
As my programming and debug abilities are close to zero I would appreciate any hint.
-
- Posts: 97
- Joined: Saturday 14 March 2020 13:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Gen2 Shelly BLE-MQTT Gateway
Unfortunately I am still not successful. As I have got no reaction on my last post I feel free to bring this thread up, hoping that anyone who could help sees it this time. So if anyone is using this script or another one: Is it unintendently stopping for you as well? If not: Have you done any amendments that I could try to adopt?
-
- Posts: 216
- Joined: Saturday 10 November 2018 18:29
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Hungary
- Contact:
Re: Gen2 Shelly BLE-MQTT Gateway
Than it needs extensive debugging.imautohuttraeger wrote: ↑Monday 04 March 2024 18:15 It stops (play symbol is shown instead of the pause symbol) and the slide switch for activation is off. See screenshot.
I guess those scripts does not use the same BLE functions and passive scanning.imautohuttraeger wrote: ↑Monday 04 March 2024 18:15 Othe scripts from the Github page do not stop working - I have tested some.
Maybe you got some BLE payloads which broke the decoder. However without debug informations, i have no clue.imautohuttraeger wrote: ↑Monday 04 March 2024 18:15 As my programming and debug abilities are close to zero I would appreciate any hint.
-
- Posts: 97
- Joined: Saturday 14 March 2020 13:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Gen2 Shelly BLE-MQTT Gateway
Thank you once again for your feedback. Since I can't provide any more information other than "it stops", I guess I have to accept that this can't work out-of-the-box for my individual needs. Maybe I should just try switching to WiFi door sensors (Shelly D/W 2) and live with having to change the battery more often.
-
- Posts: 216
- Joined: Saturday 10 November 2018 18:29
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Hungary
- Contact:
Re: Gen2 Shelly BLE-MQTT Gateway
There are several console.log() lines in the source, for example in line 270. If you remove // from the front, it will write incoming packages. If you also press an ENTER before "console" in line 321, it will also write detected devices and addresses to the console for debugging purposes.imautohuttraeger wrote: ↑Monday 18 March 2024 17:42 Thank you once again for your feedback. Since I can't provide any more information other than "it stops", I guess I have to accept that this can't work out-of-the-box for my individual needs. Maybe I should just try switching to WiFi door sensors (Shelly D/W 2) and live with having to change the battery more often.
Maybe its a good idea to add a filter by BLE device addresses and return immediately from scanCB() handler in case of unknown devices. See for example https://github.com/ALLTERCO/shelly-scri ... es.js#L189
-
- Posts: 97
- Joined: Saturday 14 March 2020 13:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Gen2 Shelly BLE-MQTT Gateway
After giving up about more than half a year ago, I tried again and first updated the firmware of the BLE device (BLU Window) and the gateway device (PlusI4).
Now the script no longer stops and everything works fine. So it was probably not the script's fault but the firmware had any kind of error or intolerance.
I'm happy now. Thanks @Iwolf!
One question: Can I actually run an identical script on several gateway devices (each on near enough to the BT device) in parallel or does it produce conflicts?
Now the script no longer stops and everything works fine. So it was probably not the script's fault but the firmware had any kind of error or intolerance.
I'm happy now. Thanks @Iwolf!
One question: Can I actually run an identical script on several gateway devices (each on near enough to the BT device) in parallel or does it produce conflicts?
Who is online
Users browsing this forum: No registered users and 0 guests