openLuup: Tasmota MQTT Bridge
-
Next question is how to send Mqtt commands from inside OpenLuup to one of the Tasmota devices?
It is probably quite simple, but I have missed how to do that.As far as I have found out the Mqtt command for controlling an HVAC is something like:
cmnd/<device_name>/IRhvac {"Vendor":"LG2", "Power":"On","Mode":"Hot","FanSpeed":3,"Temp":22.5}
So far I have only received messages from the Mqtt/Tasmota devices, so not quite sure how to do that.
-
akbooerreplied to ArcherS on May 8, 2021, 8:32 PM last edited by akbooer May 8, 2021, 4:33 PM
Because there’s infinite variety, I’ve not implemented any command/control from the Tasmota bridge.
I could certainly add a device action to send a generic command with device_name and command parameters, or such like, if that helps.
Edit: the alternative is to publish an MQTT message directly.
-
ArcherSreplied to akbooer on May 8, 2021, 9:58 PM last edited by ArcherS May 8, 2021, 7:08 PM
@akbooer I think that I could try publishing an Mqtt message directly first. A generic command could perhaps also be of use.
The below text is edited after I got it to work by adding \ before the " so that it is passed trough as it should.
I found this:
local mqtt = luup.openLuup.mqtt
mqtt.publish ("My/Topic/Name", "My Application message")
For my simple test this works from Lua Code Test:
cmnd/<device_name>/IrSend/ <rest of the message>
e.g.
luup.openLuup.mqtt.publish ("cmnd/TasmotaIR/IrSend","{\"Protocol\":\"NEC\",\"Bits\":32,\"Data\":\"0x10EF08F7\",\"DataLSB\":\"0x08F710EF\",\"Repeat\":0}")
I will continue to try this for the HVAC, something like this:
cmnd/<device_name>/IRhvac <rest of message>
e.g.
cmnd/TasmotaIR/IrSend/ {\"Vendor\":\"LG2\", \"Power\":\"On\",\"Mode\":\"Hot\",\"FanSpeed\":3,\"Temp\":22.5}
-
Yes, that will work, although two alternatives are available to make the string handling easier...
'{"Vendor":"LG2", "Power":"On", "Mode":"Hot", "FanSpeed":3, "Temp":22.5}'
or
[[{"Vendor":"LG2", "Power":"On", "Mode":"Hot", "FanSpeed":3, "Temp":22.5}]]
-
ArcherSreplied to therealdb on May 9, 2021, 11:57 AM last edited by ArcherS May 9, 2021, 8:24 AM
@therealdb that sounds interesting! I will try that.
Edit: I do not remember; how do I update to the v3 beta for the Virtual Devices plugin? Also I am a bit unsure how I can see the current version.
I typed in "development" in the plugins table and it says "GitHub.development", should that do it? -
@therealdb when looking in github I cannot see the development branch. I can only see the master branch with mqtt, beta2.
Not sure if I am doing something wrong though (quite possible).
In my log it says "VirtualDevices[3.0-beta2@37]".
-
@therealdb I created a simple Virtual Binary Switch and it now has three Mqtt variables:
MQTT_BrightnessValue
MQTT_PowerStatusOff
MQTT_PowerStatusOnI can see the format "topic/=/message" in the instructions, but I am clerarly missing something.
Do I need to define IP address etc in some other variable?I tried to get it to work, but I do not get it right, no reaction in the Tasmota device console. How do I put e.g. the following into "MQTT_PowerStatusOn", i.e. to get the device to send this when it is powered on?
cmnd/TasmotaIR/IRhvac {"Vendor":"FUJITSU_AC","Model":1,"Mode":"Heat","Power":"On","Celsius":"On","Temp":20,"FanSpeed":"Auto","SwingV":"Off","SwingH":"Off","Quiet":"Off","Turbo":"Off","Econo":"Off","Light":"Off","Filter":"Off","Clean":"Off","Beep":"Off","Sleep":-1}
(Where the TasmotaIR has IP 192.168.1.59)
Sorry for the stupid questions.
-
@archers no need to put ip or anything. Just push the mqtt message to the broker. In you case
cmnd/TasmotaIR/IRhvac/=/{"Vendor":"FUJITSU_AC","Model":1,"Mode":"Heat","Power":"On","Celsius":"On","Temp":20,"FanSpeed":"Auto","SwingV":"Off","SwingH":"Off","Quiet":"Off","Turbo":"Off","Econo":"Off","Light":"Off","Filter":"Off","Clean":"Off","Beep":"Off","Sleep":-1}
-
@akbooer I tried to archive several MQTT values from devices by checking the variable's archive box in the historian cache console. When I reloaded the luup engine, the variables disappeared from the console UI. As well, the variables do not show up in the console UI on the historian database page.
-
Not obvious, but answered previously here...
https://smarthome.community/topic/313/historian/4?_=1620559885357
What variables are you trying to archive? From the Tasmota bridge, they’re likely to have special serviceIds. It should be easy enough to set up manually, anyway.
-
Yes, that’s expected. They won’t appear on that display until their value is updated.
-
@akbooer what I have seen is that in the "testing" release it seems as if the checkmarks in the Hstorian disappear, at east for me. When I check a variable the check is gone when I return to the Historian.
Despite this I have historical data when looking at a graph, e.g:
I have not connected my test Pi to Grafana, but I assume that if the graph in Historian contains data so should a graph in Grafana.
@Buxton what I have noticed is that Tasmota for BLE sometimes freezes, at least for me running the beta on an ESP32. It seems that it deliveres the same value every time over Mqtt, I assume that OpenLuup then acts on this and that is why the data is not there in Historian.
In fact when I read you report I checked my data for one of the BLE variables and it was gone. A restart of the Tasmota BLE device fixed that and now data is back. -
@therealdb said in openLuup: Tasmota MQTT Bridge:
@archers no need to put ip or anything. Just push the mqtt message to the broker. In you case
I have tried this, but it seems not to work for some strange reason.
I put the Mqtt message in the "MQTT_PowerStatusOn" variable but I do not get any Mqtt message in either the Tasmota Console or in Mqtt Explorer when toggling the device, I assume that it should react when doing that.Any ideas on what could be wrong?
Just for comparison, when testing this in the Lua Code Test it works, so the messsage should be ok.
luup.openLuup.mqtt.publish ("cmnd/TasmotaIR/IRhvac","{\"Vendor\":\"FUJITSU_AC\",\"Model\":1,\"Mode\":\"Heat\",\"Power\":\"On\",\"Celsius\":\"On\",\"Temp\":20,\"FanSpeed\":\"Auto\",\"SwingV\":\"Off\",\"SwingH\":\"Off\",\"Quiet\":\"Off\",\"Turbo\":\"Off\",\"Econo\":\"Off\",\"Light\":\"Off\",\"Filter\":\"Off\",\"Clean\":\"Off\",\"Beep\":\"Off\",\"Sleep\":-1}")
-
@archers so, to execute something when you turn a device ON, just add this as the SetPowerURL variable's value:
mqtt://cmnd/TasmotaIR/IRhvac/=/{"Vendor":"FUJITSU_AC","Model":1,"Mode":"Heat","Power":"On","Celsius":"On","Temp":20,"FanSpeed":"Auto","SwingV":"Off","SwingH":"Off","Quiet":"Off","Turbo":"Off","Econo":"Off","Light":"Off","Filter":"Off","Clean":"Off","Beep":"Off","Sleep":-1}
(Notice the mqtt:// prefix that I omitted from the docs - my bad).
I've not implemented thermostats yet, but I could do it easily, grabbing some code from the heaters.
68/127