Am I correct in assuming that this should allow me to send a command using MQTT to turn on/off the light and the last subscription command to update the status. Switching the light works using the OpenHAB2 interface, however, if I switch the light using a different source, OpenHAB2 receives the status update but does not change the GUI to reflect this.
The OpenHAB2 log shows the following:
[ItemCommandEvent ] - Item ‘Light_Bedroom’ received command OFF
[ItemStateChangedEvent ] - Light_Bedroom changed from ON to OFF
So OpenHAB2 is receiving the update but this is not reflected in the GUI. What am I missing? Do I have to define a rule?
Both actually. I’ve done another test since posting, It looks like the log entries I posted were for the ones I instigated through the interface. I checked again after doing it from the other source, i.e. the built-in button and nothing registered in the log.
Using the MQTT client software I subscribed to the switch topic and I get the following:
mosquitto_sub -u user -P pass -t stat/BSwitch/1/LIGHT/
On
Off
On
Off
The only thing that stands out is in mosquitto_sub you subscribed to stat/BSwitch/1/LIGHT/ but in the binding config you subscribe to stat/BSwitch/1/LIGHT/state.
I removed the /state and now the openhab.log file shows
[b.core.events.EventPublisherDelegate] - given new state is NULL, couldn’t post update for ‘Light_Bedroom’
But i think there is an issue with the Basic UI, i would like someone to confirm.
i am using proper mapping, i am using the read state as well in case the command did not reach the node (i.e if the node receives the command and turns on the light, it sends a feedback on a different topic path).
i was able to generate a radio comm loss (i.e command did not reach node), logically, after the i hit the switch, it turns on momentarily and should jump back to OFF since it did not receive the ON value on the feed back topic.
this works on a mobile app (android), but i needed to refresh the page on Basic UI in order to get the correct status of the switch