Haven’t got a clue on sending a command. Kind of thought the whole idea behind items was to abstract the thing but the basic “sendCommand” doesn’t seem to work?
Solution: I was suspicious that an item was created to abstract the physical layer(thing). Indeed, that was the case. The “thing” was working correctly from the control panel and the Basic UI but I couldn’t get a rule to work. Simple, just send it a command and let the thing take care of the correct messaging!
Can you show the complete rule and items? I can not make out what your using for a trigger but you do not need mqtt actions binding to turn ON/OFF a switch.
Using EspEasy firmware but would work same as tasmota for communication:
rule "Garage Door Convert"
when
Item ESP_Easy_Door received update
then
if (ESP_Easy_Door.state as Number == 1){
Garage_Door.sendCommand(ON)
Garage_Status.postUpdate(CLOSED)
}
else {
Garage_Door.sendCommand(OFF)
Garage_Status.postUpdate(OPEN)
}
end
rule "Garage Door Last Updated"
when
Item ESP_Easy_Door changed
then
Garage_update.postUpdate( new DateTimeType() )
end
Turn on/off a light using Cron job as a trigger.
rule "Smart Plug ON"
when
Time cron "0 15 07 ? * MON,TUE,WED,THU,FRI *"
then
Smart_Plug.sendCommand(ON)
end
rule "Smart Plug OFF"
when
Time cron "0 30 18 ? * MON,TUE,WED,THU,FRI *" // OFF at 6:30 Mon-Fri
then
Smart_Plug.sendCommand(OFF)
end
If you need help with your MQTT setup please post what you have already in terms of MQTT Broker ( mosquito or the embedded one), how did you create the things and items ( using PaperUI for both or files for both or one of them/ in case of files, please post the related content), which openHAB version are you using.
Regarding the use of MQTT action in a rule , as posted by @H102 you do not need the action for the purpose you are trying to do. It doesn’t work because you are sending a “stat” message which should be posted by the device. In order to command a switch you would need a “cmnd” message to the topic " cmnd/tasmota_C19E3F/POWER" with the content “ON”.
Thanks, maybe I was not totally clear, my fault. I have the ability to turn on and off the thing with an mqtt message and I can use the control on the paper UI to turn it on and off. I know it is getting the correct message because the MQTT explorer is showing it. What I can’t figure out is how to send the “item” a command like on or off. There is some stuff in the docs about mqtt actions etc but don’t get that to work. Do I simple send the item a command, or must it be in the mymqtt actions format?
cds
Thanks for the info, I’m still confused. How do I send a command message to the topic. If the item is responding to both internal and external mqtt commands I confused about how the rule parts work.
My first thought was since an item is linked to a thing aka abstracted then can’t I send
"myitem.sendCommand(ON) and it translate it to a mqtt message as defined by the thing?
Or is there some special syntax for sending a mqtt message to a topic? stand alone or inside a rule?
That’s it.
An Item has no idea what kind of technology it might be linked to.
Any command sent to an Item gets passed to any channels that you might have linked to the Item.
The channel, and associated Thing “translate” the openHAB command into whatever the technology needs - here, for the MQTT binding, a topic and payload. For some other binding, a stream of hex or a packet of data…