Hi!
I am experimenting with my new ESP8266 to start applying it to my projects.
I started simply by connecting a led but I had a problem related to the status.
When I change the switch from on to off, the LED turns on but the switch goes back to off, so I have to change the switch back to on, this does not affect the light of the LED, and for the off of the LED the same thing happens.
I’ve been reading that it could be that the status of the item is not updated or something related to that.
I leave you information about my code.
.things
Bridge mqtt:broker:mosquitto "Mosquitto" @ "System" [ host="x.x.x.x", secure=false ]
{
Thing topic prueba "S" {
Channels:
Type switch : verde1 [ commandTopic="esp8266/4", on="1", off="0"]
}
}
.items
Switch Verde {channel="mqtt:topic:mosquitto:prueba:verde1"}
.sitemap
sitemap demo label="Menú"
{
Frame label="Clima" {
Switch item=Verde
}}
And in case you need part of the Arduino code that allows me to publish the status
..........
if(topic=="esp8266/4"){
Serial.print("Changing GPIO 4 to ");
if(messageTemp == "1"){
digitalWrite(ledGPIO4, HIGH);
Serial.print("On");
}
else if(messageTemp == "0"){
digitalWrite(ledGPIO4, LOW);
Serial.print("Off");
}
}
..........
..........
..........
if (client.connect("ESP8266Client")) {
Serial.println("connected");
client.subscribe("esp8266/4");
Any help at all is welcome.
Thanks!