Good afternoon everybody,
First of all, sorry for my rusty English …
my system is as follows:
Raspberry PI3
Openhab 2.5
MQTT: mosquito
I use the binding-mqtt1 - 1.14.0 version (waiting to migrate to the binding-mqtt - 2.5.4 version)
I looked at some documentation but I just can’t get a maintenance rule for devices that use tasmota to work.
the device uses the following topic to go on power off: openhabianpi-mqtt:tasmota/ingresso/luci/luce_ingresso/cmnd/power:command:*:default
I created, as suggested by a guide I found, the following code:
`val tasmota_device_ids = newArrayList(
“tasmota-A00EEA”,
//… add all your modules here!
“tasmota-E8A6E4”
)
// OR
// Work with the grouptopic, addressing ALL modules at once
//val tasmota_device_ids = newArrayList(“tasmotas”)
rule “Tasmota Maintenance”
when
Item Sonoff_Action received command
then
logInfo(“tasmota.rules”, "TasmotaMaintenance on all devices: " + receivedCommand)
for (String device_id : tasmota_device_ids) {
switch (receivedCommand) {
case “restart” :
publish(“broker”, “cmnd/” + device_id + “/restart”, “1”)
case “queryFW” :
publish(“broker”, “cmnd/” + device_id + “/status”, “2”)
case “upgrade” : {
publish(“broker”, “cmnd/” + device_id + “/otaurl”, “http://thehackbox.org/tasmota/tasmota.bin”)
publish(“broker”, “cmnd/” + device_id + “/upgrade”, “1”)
}
}
}
Sonoff_Action.postUpdate(NULL)
end`
But I can’t understand exactly how to enter the values that I set in tasmota …
Could you please give me a hand?
I thank you in advance
hank you for the answer,
sorry for the code but it is one of the first posts that I send. The MQTT action is installed [MQTT Action (1.x) action-mqtt - 1.14.0].
Regardless of the tutorial what I would like to do is send via mqtt to the device openhabianpi-mqtt:tasmota/ingresso/luci/luce_ingresso/
he restart 1 command.
I can easily create the button to insert it in the sitemap and send the command to start a rule, but I can not build the rule that contains the command …
Thanks again for the help
If your mqtt binding and mqtt action are working ( which migth not be if loaded in a false sequence) and you add your tasmota items to the above posted rule (either seperatly or via the group ) that should be all you need.
Putting in random parameters won’t help; you haven’t seen that as an example anywhere.
Looks a bit better …but …
Is your broker actually named “broker”?
This is something you defined in your mqtt.cfg file, like broker.url = xxxx
You can’t, that’s to say, in MQTT you can only publish to broker using a topic, which your remote device needs to subscribe to.
I think you are actually allowed to have a colon in your topic like openhabianpi-mqtt:tasmota
but is that really what your tasmota device subscribes to? It’s unusual.
It’s not at all like the topics in your first post involving device-id.
I think you’ll find a tool like mqtt.fx very useful, you can ask the broker what messages it actually sees.
Okay, so your defined broker is named “mosquitto”
You’d use that with publish() like so -
publish("mosquitto",...
Next, you need to put the topic you want to publish to.
If I’m reading your example properly was tasmota/ingresso/luci/luce_ingresso/cmnd/restart
so you’d put that in
It works perfectly !! I just couldn’t understand what to enter in the broker field! as often happens the solution was under the eyes and I didn’t see it !!
Thanks so much for the help!