openLuup: Tasmota MQTT Bridge
-
@archers said in openLuup: Tasmota MQTT Bridge:
I think the Zway bridge is costing a bit of cpu actually, it is quite active.
Do you have it running in asynchronous mode? Do you have CJson installed yet?
@archers said in openLuup: Tasmota MQTT Bridge:
I do however get the following errors in the log:
OK, I'll take a look. Do you have an example of the message posted which causes the error?
Otherwise, things seem to be going fairly well...
@archers said in openLuup: Tasmota MQTT Bridge:
Combined with the GUI in the Virtual Sensor plugin from @toggledbits it is now really easy to link the desired variables to a virtual sensor.
In total a really user friendly setup without any coding required.This is really good news, and perhaps means that I don't need to refine the variables further or create any child devices?
-
@akbooer I have "AsyncPoll" true on the Zway Bridge, I assume that means that it is in asynchronuous mode? Or should I check something else?
No, I have yet to install cjson. This was actually intentional since I wanted to test it without this first and see if it works. On my main OpenLuup server that has experienced crashes I have cjson installed so I wanted to test without cjson first. But I should test this later on and see what happens to the cpu load.
Regarding cpu load it has not gone up that much when comparing running one Tasmota vs running seven which is promising.I am not sure what message that causes the error, do you have any ideas what I should look for in the log or elsewhere? It mentions "TasmotaBridge.Lua:188 table index is nil" in all errors for the devices.
The errors always says:
2021-04-14 21:19:10.214 openLuup.context_switch:: ERROR: [dev #14] openLuup/L_TasmotaBridge.lua:188: table index is nil 2021-04-14 21:19:10.214 openLuup.mqtt:: ERROR publishing application message for mqtt:tele/TasmotaTest/STATE : openLuup/L_TasmotaBridge.lua:188: table index is nil
and it seems to cycle through my Tasmota devices reporting the same two rows but for each device:
2021-04-14 21:35:10.064 openLuup.context_switch:: ERROR: [dev #14] openLuup/L_TasmotaBridge.lua:188: table index is nil 2021-04-14 21:35:10.065 openLuup.mqtt:: ERROR publishing application message for mqtt:tele/TasmotaTest/STATE : openLuup/L_TasmotaBridge.lua:188: table index is nil ... 2021-04-14 21:35:42.864 openLuup.context_switch:: ERROR: [dev #14] openLuup/L_TasmotaBridge.lua:188: table index is nil 2021-04-14 21:35:42.865 openLuup.mqtt:: ERROR publishing application message for mqtt:tele/TasmotaUterum/STATE : openLuup/L_TasmotaBridge.lua:188: table index is nil ... 2021-04-14 21:35:44.637 openLuup.context_switch:: ERROR: [dev #14] openLuup/L_TasmotaBridge.lua:188: table index is nil 2021-04-14 21:35:44.637 openLuup.mqtt:: ERROR publishing application message for mqtt:tele/TasmotaCO2An/STATE : openLuup/L_TasmotaBridge.lua:188: table index is nil ... 2021-04-14 21:35:44.844 openLuup.context_switch:: ERROR: [dev #14] openLuup/L_TasmotaBridge.lua:188: table index is nil 2021-04-14 21:35:44.844 openLuup.mqtt:: ERROR publishing application message for mqtt:tele/TasmotaCO2Ax/STATE : openLuup/L_TasmotaBridge.lua:188: table index is nil
Yes I agree, it seems to be going well.
No, I think it is quite good the way it is, creating Virtual Sensors and then linking them to the devices/variables is very easy. It only takes a few minutes to add a new Tasmota device from scratch without any coding at all.
In fact I think it is better this way since typically you do not want all of the reported values as a child device, e.g. you do not want "Dew point" or "Time", the useless MHZ19B temperature etc. This way you can select only what you want, not getting OpenLuup cluttered by a lot of "useless" child devices. -
@akbooer, I have bridged the 2 brokers but not seeing any Tasmota bridge I see the mosquitto bridge in the openluup log no errors. My topics are
tasmota/stat/devicename/POWER
The devices are sonoff mini's flashed with tasmota-lite.bin. Any ideas? -
@elcid said in openLuup: Tasmota MQTT Bridge:
My topics are tasmota/stat/devicename/POWER
So, at the moment, I have only subscribed to
tele/#
, so that's why you're not seeing anything.I can make this configurable, but what does a message look like with this topic?
-
@akbooer
Ask the device for statuscmnd/tasmota_switch/Power ← // an empty message/payload sends a status query ↳ stat/tasmota_switch/RESULT → {"POWER":"OFF"} ↳ stat/tasmota_switch/POWER → OFF We can see that the switch (devices relay) is turned off. Send a command to toggle the relay~ cmnd/tasmota_switch/Power ← "TOGGLE" ↳ // Power for relay 1 is toggled ↳ stat/tasmota_switch/RESULT → {"POWER":"ON"} ↳ stat/tasmota_switch/POWER → ON
I have appended th tasmota at the start of the topic in my tasmota device settings.
-
ATM the bridge doesn't solicit any response from the devices. Indeed, it would have to discover them first in order to do so. So at this time, if the device does not sent regular tele/ updates, then it won't be seen. This is early days for the bridge.
-
OK, well that will work if I add configuration for your optional ‘Tasmota’ prefix.
-
I added the prefix for future use so i could group devices by type (sensor/switch/dimmer/etc) as i will filter topics by type of device i want to subscribe to. So it would be nice to have a list of prefixes, if it is possible.
-
@akbooer Good start on my end. Here's a pic of one device that shows three Bluetooth temp/humidity sensors (LYWSD...) that connect to a Tasmota relay:
You may need to decode a layer deeper for the "table" entries....
I do have a bunch of error messages in the log, but I will have to get into that on the weekend as I'm currently buried with work work....
Here's a snippet though:
2021-04-14 20:11:13.634 openLuup.context_switch:: ERROR: [dev #262] openLuup/L_TasmotaBridge.lua:188: table index is nil 2021-04-14 20:11:13.634 openLuup.mqtt:: ERROR publishing application message for mqtt:tele/power_BedroomTV/BLE : openLuup/L_TasmotaBridge.lua:188: table index is nil 2021-04-14 20:11:14.044 openLuup.server:: request completed (1490 bytes, 1 chunks, 1280 ms) tcp{client}: 0x5619338130b8 2021-04-14 20:11:14.642 openLuup.context_switch:: ERROR: [dev #262] openLuup/L_TasmotaBridge.lua:188: table index is nil 2021-04-14 20:11:14.642 openLuup.mqtt:: ERROR publishing application message for mqtt:tele/power_BedroomTV/STATE : openLuup/L_TasmotaBridge.lua:188: table index is nil 2021-04-14 20:11:14.662 openLuup.context_switch:: ERROR: [dev #0] attempt to call a string value 2021-04-14 20:11:14.663 openLuup.mqtt:: ERROR publishing application message for mqtt:tele/power_BedroomTV/SENSOR : attempt to call a string value 2021-04-14 20:11:14.701 openLuup.context_switch:: ERROR: [dev #262] openLuup/L_TasmotaBridge.lua:188: table index is nil
-
Ok, I've added support for command based on MQTT in version 3.0-beta1.
Variable updated on messages coming soon. Feedback much appreciated!
-
@akbooer I did some debug on the error messages above and came up with the following. I placed some debug entries in the "L_TasmotaBridge.lua" to try to see what was causing the errors. First the code: under function _G.Tasmota_MQTT_Handler (topic, message)
local myMessage = "" if message == nil then myMessage = "Message is null" else if message == "" then myMessage = "Message is empty" else myMessage = message end end _log ("JSON error info " .. myMessage)
Which produced the following log errors and their context:
2021-04-16 20:48:01.335 openLuup.io.server:: MQTT:1882 connection from 10.17.2.28 tcp{client}: 0x55fac42317b8 2021-04-16 20:48:01.355 luup.tasmota:262: JSON error info Online 2021-04-16 20:48:01.356 luup.tasmota:262: JSON error: ? 2021-04-16 20:48:01.366 luup.tasmota:262: JSON error info Message is empty 2021-04-16 20:48:01.367 luup.tasmota:262: JSON error: ? 2021-04-16 20:48:01.423 openLuup.mqtt:: BedroomTV SUBSCRIBE to cmnd/power_BedroomTV/# tcp{client}: 0x55fac42317b8 2021-04-16 20:48:01.432 openLuup.mqtt:: BedroomTV SUBSCRIBE to cmnd/tasmotas/# tcp{client}: 0x55fac42317b8 2021-04-16 20:48:01.433 openLuup.mqtt:: BedroomTV SUBSCRIBE to cmnd/BedroomTV_fb/# tcp{client}: 0x55fac42317b8
-
@akbooer Then further down the log file I was getting errors in the "function init_device (altid, info)" function. Error code is:
local myaltid = "" local myinfo = "" if altid == nil then myaltid = "altid is null" else myaltid = altid end if info == nil then myinfo = "info is null" else if info == " " then myinfo = "info is empty" else myinfo = unpack(info) end end _log ("Find info " .. myinfo ) _log ("Find altid " .. myaltid ) local dno = luup.openLuup.find_device {altid = altid} or create_device (altid, info) _log ("Find DNO " .. dno)
Which yields:
2021-04-16 21:37:06.773 openLuup.io.server:: MQTT:1882 connection closed tcp{client}: 0x556c246bb0f8 2021-04-16 21:37:06.773 openLuup.mqtt:: RECEIVE ERROR: closed tcp{client}: 0x556c246bb0f8 2021-04-16 21:37:06.815 luup.io.incoming:: bytes received: 51, status: OK tcp{client}: 0x556c24620fb8 2021-04-16 21:37:09.516 luup.tasmota:262: JSON error info {"Time":"2021-04-17T05:37:09","Uptime":"0T02:24:57","UptimeSec":8697,"Heap":125,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":13,"POWER1":"OFF","POWER2":"OFF","Wifi":{"AP":1,"SSId":"CD","BSSId":"FE:9F:DB:F5:A0:11","Channel":1,"RSSI":94,"Signal":-53,"LinkCount":1,"Downtime":"0T00:00:06"}} 2021-04-16 21:37:09.517 luup.tasmota:262: Find info info is null 2021-04-16 21:37:09.517 luup.tasmota:262: Find altid altid is null 2021-04-16 21:37:09.517 luup.tasmota:262: Find DNO 1 2021-04-16 21:37:09.518 openLuup.context_switch:: ERROR: [dev #262] openLuup/L_TasmotaBridge.lua:215: table index is nil 2021-04-16 21:37:09.518 openLuup.mqtt:: ERROR publishing application message for mqtt:tele/power_BedroomTV/STATE : openLuup/L_TasmotaBridge.lua:215: table index is nil 2021-04-16 21:37:09.605 openLuup.context_switch:: ERROR: [dev #0] attempt to call a string value 2021-04-16 21:37:09.605 openLuup.mqtt:: ERROR publishing application message for mqtt:tele/power_BedroomTV/SENSOR : attempt to call a string value 2021-04-16 21:37:09.605 luup.tasmota:262: JSON error info {"Time":"2021-04-17T05:37:09","Switch1":"ON","Switch2":"ON","ENERGY":{"TotalStartTime":"2021-04-04T05:29:11","Total":0.000,"Yesterday":0.000,"Today":0.000,"Period":0,"Power":[0,0],"ApparentPower":[0,0],"ReactivePower":[0,0],"Factor":[0.00,0.00],"Frequency":60,"Voltage":121,"Current":[0.000,0.000]}} 2021-04-16 21:37:09.606 luup.tasmota:262: Find info info is null 2021-04-16 21:37:09.606 luup.tasmota:262: Find altid power_BedroomTV 2021-04-16 21:37:09.606 luup.tasmota:262: Find DNO 30001 2021-04-16 21:37:09.618 luup.tasmota:262: JSON error info {"Time":"2021-04-17T05:37:09","BLEDevices":{"total":3,"A4C138EB4F4F":{"i":0,"r":-73},"A4C13838EB2E":{"i":1,"r":-87},"A4C138A59E0C":{"i":2,"r":-92}}} 2021-04-16 21:37:09.619 luup.tasmota:262: Find info info is null 2021-04-16 21:37:09.619 luup.tasmota:262: Find altid altid is null 2021-04-16 21:37:09.619 luup.tasmota:262: Find DNO 1 2021-04-16 21:37:09.619 openLuup.context_switch:: ERROR: [dev #262] openLuup/L_TasmotaBridge.lua:215: table index is nil 2021-04-16 21:37:09.619 openLuup.mqtt:: ERROR publishing application message for mqtt:tele/power_BedroomTV/BLE : openLuup/L_TasmotaBridge.lua:215: table index is nil 2021-04-16 21:37:09.620 luup.tasmota:262: JSON error info {"Time":"2021-04-17T05:37:09","BLE":{"scans":483,"adverts":23232,"devices":3,"resets":0}} 2021-04-16 21:37:09.620 luup.tasmota:262: Find info info is null 2021-04-16 21:37:09.620 luup.tasmota:262: Find altid altid is null 2021-04-16 21:37:09.620 luup.tasmota:262: Find DNO 1
Hope that's of some use.
-
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...
24/127