I publish with arduino in mqtt, a sensor that has only two states: on and off. ( “controller_garage / sensor / state”)
how do I configure the parameters on the openhab .things configuration?
//MQTT Binding
Bridge mqtt:systemBroker:embedded-mqtt-broker “MQTT Broker” @ “Garage” [host=“localhost”, secure=false, retain=false ] {
Thing topic mqtt_power “MQTT Power” @ “Garage” {
Channels:
Type number : current “RMS Current” [stateTopic=“controller_garage/sensor/current”]
Type number : voltage “RMS Voltage” [stateTopic=“controller_garage/sensor/voltage”]
Type number : power “RMS Power” [stateTopic=“controller_garage/sensor/power”]
Type switch : state “State” [commandTopic=“controller_garage/sensor/state”]
}
What are the payloads on that topic? You probably want to turn them into ON and OFF, suitable for a Switch type, using the on= off= channel options maybe?
I want to explain that this is not a command.
if it receives an “off” payload the switch must switch to OFF
if it receives an “on” payload the switch must switch to ON
thank you
if you look at the first image (mqqt topic), you can see that the message is off
The topic publishes only two payloads possible “on and off”
I can’t get this payload to read to openhab
I did look at your image, but your string channel appears not to be seeing your topic, you tell us that. If your remote device doesn’t set “retain” on its messages, then your string topic won’t see any messages until one is sent. There’s nothing we can do from here, you have to investigate.
Just to confirm that you are doing it right, make another string channel on one of your other topics that you think is working.
Make sure you give it some new unique name. You seem to have chosen the same name for your new string test channel as the switch channel that doesn’t work, which might be your problem. Have you other channels that you haven’t shown us called “state”?
Yes. It’s a string channel. Now you have found out how to configure, you probably want to change it back to a switch type channel and Item if you want it to look like a switch.
sorry I do not understand
I want a switch, on OpenHab, that switches OFF when the topic sends the payload “off” and that switches ON when the topic sends the payload “on”.
can you write me a sample code?
thank you