Mqtt datasource command
-
Hi,
I want to send the command below with mqtt with a binary switch. I only get the command correctly executed when I create the item as alphanumeric and manually enter the status. Does anyone know how I send the command off / on through a binary switch with mqtt?
shellies/<model>-<deviceid>/relay/0/command accepts on, off or toggle and applies accordingly
Can anyone help me?
-
set the value with a meta datasource script or scripting datasource point based upon the true or false value of your binary switch point.
Set the binary switch as your context point that fires the script and sets the value of your MQTT point.Fox
-
Do you have a example of this script?
-
1)make a virtual datasource binary datapoint, add it to the script context points. Tick the checkbox that this point triggers the script.
we shall call the context point switch.
Then add your mqtt point to the context. We shall call it toggle. It does not need the checkbox to the right filled. Ensure the mqtt point is settable
This is the script.if(switch.value===true) { toggle.set("on"); } if(switch.value===false) { toggle.set("off"); }
See how you go. I do not use the mqtt client myself, but generally all points can be set - some which send the value back out the data source. I am hoping this is the latter...
Hope this helps
Fox