openLuup: Tasmota MQTT Bridge
-
And I've also added handlers to get status from a generic MQTT message. It's done on lights, dimmers, roller shutters and rgb/rgbw.
Just use the format topic/=/payload, where * for payload means "pass the value to the variable".
Color and white temp are supported, but I'll need to write a converter (or link to the existing one). If anyone is still interested, I could port it to alarm, heaters, door locks and sensors.
-
The latest development version v21.4.17 has added and additional subscription to the tasmota/tele/# topic. I will make it configurable later.
I've refactored the bridge a bit, but haven't yet addressed the nested table issue... don't know if this has fixed any of the other errors you've seen, but I didn't do anything explicitly to address those. Still very much work in progress.
-
Has installed tasmota bridge and the child devices have been added with the following varaiables
LastUpdate 17/04/2021, 12:43:57 Switch1 OFF Time 2021-04-17T12:43:57 tasmota/tele {"Time":"2021-04-17T12:43:57","Switch1":"OFF"}
-
I have now updated to v21.4.17 and also installed cjson.
The cpu load on my test Pi went down from 10.5% to 4-4.5%, so that is a good step better.
The server has been running with my Zway bridge with 64 zNodes and 165 vDevs and five Tasmota devices.
Data this morning after 2.5 days run time:I have added one more Tasmota device, in total 6 are now pushing data over Mqtt to OpenLuup.
@akbooer what is changed in v21.4.17, I could not see any changes to be honest.
What I did notice however was that the old error messages I posted above have disappeared. I will see if I get any new, so far I have not seen any.
-
@archers said in openLuup: Tasmota MQTT Bridge:
what is changed in v21.4.17
Well, I think you answered your own question...
@archers said in openLuup: Tasmota MQTT Bridge:
the old error messages I posted above have disappeared
-
@buxton said in openLuup: Tasmota MQTT Bridge:
You may need to decode a layer deeper for the "table" entries....
Version 21.4.17c does just that (I hope.)
Would be interesting in seeing the variables which result...
-
Just reporting that the variables in the tasmota devices are not updating correctly
tasmota/tele {"Time":"2021-04-17T19:28:59","Switch1":"ON"}
The time stamp updates, but not the value of Switch1.
[edit] after deleteing the 4 devices and reloading luup I found these errors in log2021-04-17 19:59:39.142 openLuup.server:: GET /data_request?id=lu_status2&output_format=json&DataVersion=685929357&Timeout=60&MinimumDelay=1500&_=1618685858944 HTTP/1.1 tcp{client}: 0xff56978 2021-04-17 19:59:39.145 openLuup.mqtt:: localhost.bridge-01 SUBSCRIBE to # tcp{client}: 0xff593e0 2021-04-17 19:59:39.147 luup.tasmota:47: JSON error: Expected value but found invalid token at character 1 2021-04-17 19:59:39.148 luup.tasmota:47: JSON error: Expected value but found invalid token at character 1 2021-04-17 19:59:39.153 luup.tasmota:47: JSON error: Expected value but found invalid token at character 1 2021-04-17 19:59:39.154 luup.tasmota:47: JSON error: Expected value but found invalid token at character 1
-
ArcherSreplied to akbooer on Apr 17, 2021, 6:57 PM last edited by ArcherS Apr 17, 2021, 4:13 PM
@akbooer I have now discovered a few new error messages:
2021-04-17 19:52:02.446 openLuup.io.server:: MQTT:1883 connection from 192.168.1.56 tcp{client}: 0x2654a78 2021-04-17 19:52:02.464 luup.tasmota:14: JSON error: Expected value but found invalid token at character 1 2021-04-17 19:52:02.477 openLuup.io.server:: MQTT:1883 connection closed tcp{client}: 0x20aeec0 2021-04-17 19:52:02.477 openLuup.mqtt:: RECEIVE ERROR: closed tcp{client}: 0x20aeec0 2021-04-17 19:52:02.477 openLuup.mqtt:: TasmotaBLE UNSUBSCRIBE from cmnd/tasmotas/# tcp{client}: 0x20aeec0 2021-04-17 19:52:02.478 openLuup.mqtt:: TasmotaBLE UNSUBSCRIBE from cmnd/TasmotaBLE/# tcp{client}: 0x20aeec0 2021-04-17 19:52:02.478 openLuup.mqtt:: TasmotaBLE UNSUBSCRIBE from cmnd/TasmotaBLE_fb/# tcp{client}: 0x20aeec0 2021-04-17 19:52:02.482 openLuup.mqtt:: TasmotaBLE SUBSCRIBE to cmnd/TasmotaBLE/# tcp{client}: 0x2654a78 2021-04-17 19:52:02.561 openLuup.mqtt:: TasmotaBLE SUBSCRIBE to cmnd/tasmotas/# tcp{client}: 0x2654a78 2021-04-17 19:52:02.859 openLuup.mqtt:: TasmotaBLE SUBSCRIBE to cmnd/TasmotaBLE_fb/# tcp{client}: 0x2654a78
I seem to get it on an irregular basis now and then in the log.
It is coming from my ESP32 Tasmota that has three BLE devices connected to it (device #20005). It typically sends the following every 5 minutes:
tele/TasmotaBLE/SENSOR = {"Time":"2021-04-17T19:12:04","ATC-f159bf":{"Temperature":24.0,"Humidity":44.0,"DewPoint":11.0,"Battery":63,"RSSI":-84},"ATC-9446bf":{"Temperature":23.1,"Humidity":62.0,"DewPoint":15.4,"Battery":80,"RSSI":-82},"ATC-6d5d44":{"Temperature":14.8,"Humidity":43.0,"DewPoint":2.3,"Battery":54,"RSSI":-89},"TempUnit":"C"}
I have seen in the log that the device works, i.e. the data for the three devices get updated between the errors.
I tried to capture what is going on and I think it is the device restarting or something when the errors occur. I will check some more on that, perhaps to try and update to a newer firmware.
At the time for the error I got the following in the Tasmota Console:
19:50:09.833 MQT: tele/TasmotaBLE/INFO1 = {"Module":"ESP32-DevKit","Version":"9.2.0.3(tasmota)","FallbackTopic":"cmnd/TasmotaBLE_fb/","GroupTopic":"cmnd/tasmotas/"} 19:50:09.841 MQT: tele/TasmotaBLE/INFO2 = {"WebServerMode":"Admin","Hostname":"TasmotaBLE-0476","IPAddress":"192.168.1.56"} 19:50:09.852 MQT: tele/TasmotaBLE/INFO3 = {"RestartReason":"Software reset CPU"} 19:50:10.911 QPC: Reset 19:50:13.901 MQT: tele/TasmotaBLE/STATE = {"Time":"2021-04-17T19:50:13","Uptime":"0T00:00:10","UptimeSec":10,"Heap":110,"SleepMode":"Normal","Sleep":50,"LoadAvg":37,"MqttCount":1,"Wifi":{"AP":1,"SSId":"BeachAC","BSSId":"FC:EC:DA:D1:7A:64","Channel":11,"RSSI":86,"Signal":-57,"LinkCount":1,"Downtime":"0T00:00:04"}} 19:50:13.924 MQT: tele/TasmotaBLE/SENSOR = {"Time":"2021-04-17T19:50:13","ATC-f159bf":{"Temperature":24.0,"Humidity":43.0,"DewPoint":10.6,"Battery":63,"RSSI":-81},"TempUnit":"C"}
Maybee it is the OpenLuup Mqtt server reacting to the startup messages?Edit: Yes it is an error from when a Tasmota device starts, I restarted one of my other devices and got the same error in the log. It also recovered as it should after rebooted.
2021-04-17 22:01:05.433 openLuup.io.server:: MQTT:1883 connection from 192.168.1.50 tcp{client}: 0x25fcc50 2021-04-17 22:01:05.440 luup.tasmota:14: JSON error: Expected value but found invalid token at character 1 2021-04-17 22:01:05.447 openLuup.mqtt:: TasmotaUterum SUBSCRIBE to cmnd/TasmotaUterum/# tcp{client}: 0x25fcc50 2021-04-17 22:01:05.452 openLuup.mqtt:: TasmotaUterum SUBSCRIBE to cmnd/tasmotas/# tcp{client}: 0x25fcc50 2021-04-17 22:01:05.454 openLuup.mqtt:: TasmotaUterum SUBSCRIBE to cmnd/TasmotaUterum_fb/# tcp{client}: 0x25fcc50 2021-04-17 22:01:05.455 openLuup.io.server:: MQTT:1883 connection closed tcp{client}: 0x24ae758 2021-04-17 22:01:05.455 openLuup.mqtt:: RECEIVE ERROR: closed tcp{client}: 0x24ae758 2021-04-17 22:01:05.456 openLuup.mqtt:: TasmotaUterum UNSUBSCRIBE from cmnd/TasmotaUterum/# tcp{client}: 0x24ae758 2021-04-17 22:01:05.456 openLuup.mqtt:: TasmotaUterum UNSUBSCRIBE from cmnd/tasmotas/# tcp{client}: 0x24ae758 2021-04-17 22:01:05.456 openLuup.mqtt:: TasmotaUterum UNSUBSCRIBE from cmnd/TasmotaUterum_fb/# tcp{client}: 0x24ae758
-
@akbooer My log is much calmer with the oL update. Thanks for that. I still have the following error though:
2021-04-17 13:41:37.079 luup.tasmota:262: JSON error: ? 2021-04-17 13:41:37.080 luup.tasmota:262: Received message causing error was: Online
This happens only on a LUUP reload. If I were to guess, the JSON decoder is seeing a single text string, so it doesn't/can't really decode, but throws an error instead. Maybe trap for strings before being sent to the decoder.... They are valid messages and should not throw receive errors or decode errors.
-
@akbooer And the below error is probably related to the string error:
2021-04-17 13:48:51.407 openLuup.context_switch:: ERROR: [dev #0] attempt to call a string value 2021-04-17 13:48:51.407 openLuup.mqtt:: ERROR publishing application message for mqtt:tele/power_BedroomTV/SENSOR : attempt to call a string value
-
@akbooer The table level decode issue is a byproduct of the type of relay I'm using in the above examples.
This tasmota relay controls two separate outputs (switches), as well as an unlimited number of bluetooth sensors that see/connect to the relay. So for example, I placed the above mentioned relay behind a standard wall power outlet that has its two plug ports separated into two different circuits. One outlet of the relay controls the top plug and the other relay outlet controls the bottom.
This is not uncommon with the tasmota devices as I also have a four relay tasmota device that controls four different circuits of my landscape lights, though there is only a single device with a single IP address.
-
My devices seem to have been discovered OK, albeit as generic. I'm eager to help to map them to child devices. Even with different sensors, the variable name seems to be consistent.
Here's what I have:
- Temperature
- Humidity
- Distance
- DewPoint
- IR
- Illuminance
- Pressure
- Broadband (for light)
I think that if multiple are present, multiple child devices could be created. I could also help with code @akbooer if you need help.
-
akbooerreplied to therealdb on Apr 18, 2021, 10:02 AM last edited by akbooer Apr 18, 2021, 6:16 AM
@therealdb said in openLuup: Tasmota MQTT Bridge:
I'm eager to help to map them to child devices.
Oh, I didn't think that was necessary since you made it so easy to create virtual devices? You want ALL the child devices to be separate? This could become messy.
-
ArcherSreplied to akbooer on Apr 18, 2021, 11:03 AM last edited by ArcherS Apr 18, 2021, 11:22 AM
@akbooer I think it is quite good without the plugin creating a lot of child devices for Tasmota sensor devices.
Instead I create child devices myself with the excellent Virtual Sensor plugin for the ones I want (I typically do not want child devices for all the data from a Tasmota sensor). I then simply map each virtual sensor to the device and variable in the Virtual Sensor plugin:
Super easy and clean without any coding.
For Tasmota switches or similar where you typically want to send Mqtt data to the device it may be a bit different of course. I have not tested any of these yet. Perhaps the Mqtt addition to the Virtual Http plugin from @therealdb is the right path here? I have still to test this.
I have a Tasmota IR tranceiver that I will test for controlling my HVAC, but I have not come that far yet! -
akbooerreplied to ArcherS on Apr 18, 2021, 11:38 AM last edited by akbooer Apr 18, 2021, 7:40 AM
@archers said in openLuup: Tasmota MQTT Bridge:
I typically do not want child devices for all the data from a Tasmota sensor
Yes, that would be my thinking too.
I went through the same issues when creating the Netatmo plugin, and the auto-creation of child devices made it overly complex, handling all the possible options. If I started again (and I may now make a simplified Netatmo 'bridge') I'd just leave that to manually created virtual sensors.
-
therealdbreplied to akbooer on Apr 18, 2021, 3:05 PM last edited by therealdb Apr 18, 2021, 11:06 AM
@akbooer if we want to make it user friendly, I think it’s the easiest thing to do. I could of course do it with my virtual plugin in a future update if you think it’d be better to leave it to each setup.
EDIT: or just don’t implement it, since I forgot about virtual sensor. Ok, I think we’re covered now.
-
ArcherSreplied to akbooer on Apr 18, 2021, 4:19 PM last edited by ArcherS Apr 18, 2021, 12:43 PM
Thought it could be good for future users to give a short write up on how to set up Tasmota devices reporting sensors into OpenLuup with the new Tasmota bridge.
First setup the Tasmota device:
Browse to the Tasmota device IP and then select "Configuration"
Go into Configuration Other
Make sure "Mqtt enable" is set and give a Device Name
Then into Configuration MQTT
Give IP adress and port of OpenLuup Mqtt server
Give a Client name
Set user and password
Set topic name
If you want to change how often the Tasmota device pushes data over Mqtt you can do that in the Console for the Tasmota by using the "TelePeriod" command. By default TelePeriod is set to 300 seconds, e.g. "TelePeriod 60" sets it to once every minute. (Just typing "TelePeriod" shows the current value.)
Second set up OpenLuup:
Paste the following into Lua Startup:luup.attr_set ("openLuup.MQTT.Port", 1883) luup.attr_set ("openLuup.MQTT.Username", "luup") luup.attr_set ("openLuup.MQTT.Password", "password") luup.attr_set ("openLuup.MQTT.PublishVariableUpdates", true) -- Not requred for Tasmota, publish every variable update if wanted
Save and reload Luup engine, you should now get the Tasmota bridge in OpenLuup
You should also get the Tasmota device you setup above
On my OpenLuup it got placed in the room "Tasmota".
Next step is to set up devices for the sensor data you want to get from the Tasmota device. This data is pushed into variables for the Tasmota device (if you hover above a variable name you see the sensor, e.g. "BME280"):
Download the plugin "Virtual Sensor" if you do not have it.
Go into Virtual Sensors, tab "Virtual Sensors" and create the new virtual sensors you need for the data you want to display from the Tasmota device, you want one virtual sensor per value.
Next step is to set the data from the Tasmota variables to the corresponding virtual sensors.
Go into the Virtual Sensor plugin, into the tab "Virtual Sensors"
Select the Tasmota device in the first drop down and then the variable in the second:Job done! Now repeat for all the variables you wish to add into OpenLuup.
-
That’s great, thanks on behalf of all future users!
AFAIK, you don’t need to enable the PublishVariableUpdates MQTT option in order for the Tasmota bridge to work (since it is, itself, only one-way) although you may need it for other purposes.
38/127