I’m trying to create an item (Number or Switch) in order to receive the status of a D1 Relay.
I’m using ESP8266 to control the delay and to check the status of it:
Topics:
Hall/D1Relay/TRIGGER - to receive messages from openhab
Hall/D1Relay/STATUS - to send the status to openhab.
MQTT inbound message works like a charm. Below is the configuration of the item for outbound messages :
In this way when the ESP will receive “CLOSE” or “OPEN” messages it will close or open the Relay.
Now I’m trying to get the status of the Relay that is published by the ESP controller:
if (relay_status == 1 ) {
client.publish(D1RelaySTATUS,"CLOSE",true);
Serial.println("D1RelaySTATUS = CLOSE ");
}
else if (relay_status == 0) {
client.publish(D1RelaySTATUS, "OPEN",true);
Serial.println("D1RelaySTATUS = OPEN");
}