Issue of the topic:
Hello!
I’m new to this OH thing, at least at editing files so sorry if my questions seem dumb.
I want to build an item that reads the state of my sonoff relay but I don’t know what exactly to put in my commands. I tried different codes, but none seems to work. I want to use this state item to work with Webhooks and IFTTT. When someone uses the relay, it triggers a scene through Ifttt.
I already managed to configure a switch button that works very well on this sonoff, but that doesn’t interest me.
sitemap home label="Sonoff Switches" //creez o casa numita Sonoff Switches
{
Frame label="Camera test" //creez camera test
{
Switch item=Sonoff1 //adaug un itemin camera test
//itemele trebuie create in fisierul .item
Text item=State1sonoff
}
}
Which version of the MQTT binding do you have installed? If you are on OH 2.4 or later and just installed MQTT then you are almost definitely running the MQTT 2 binding. Your Item syntax is for the MQTT 1 binding. See Using Sonoff Power Switches with Tasmota firmware and openHAB2 MQTT2 binding which should get you started.
This is the only configuration I made in mqtt.cfg:
# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883
#<broker>.url=tcp://<host>:1883
broker.url=tcp://192.168.1.188:1883
The switch button works ok but I don’t want to publish messages, just to subcribe. I want to know when the state is changed manually on the switch. Also I don’t know where to find the logs.
LE:
I got it working by adding new lines in mqtt.cfg