I’ve been using OpenHab since version 2 and never had any major problems - actually I am using openHAB 4.2.0 as a Docker image on my Linux server.
Most of my devices run with KNX, now I have added some lightbulbs with MQTT and ESPHome. I can switch them on and off and the state is also updated when I reload the browser.
However, the new state is not displayed directly when switching. Even if I control the devices via Alexa / HomeKit, for example, I see the following in the item log:
[openhab.event.ItemCommandEvent ] - Item ‘LEDStripPower’ received command ON
[openhab.event.ItemStateChangedEvent ] - Item ‘LEDStripPower’ changed from OFF to ON
but the UI remains unchanged.
Sitemap:
Switch item=LEDStripPower label="HRW Passiv"
Item looks like:
Switch LEDStripPower "LED Power" { channel="esphome:device:esp1:led_strip_relay" }
I tried also something like this:
rule "Force UI Refresh with Longer Delay"
when
Item LEDStripPower received command
then
// Delay for 1 second to allow the command to be processed by ESPHome
createTimer(now.plusSeconds(1), [|
LEDStripPower.postUpdate(receivedCommand.toString)
])
end
and autoupdate="true"
or refresh in the items file.
After all I tried it with MQTT but with the same result:
Type switch : eg_hwr_ledlight_esp8266 [ stateTopic="ledlight/switch/led_light/state", commandTopic="ledlight/switch/led_light/command" ]
Switch LEDStripPower2 "HWR Passiv2" <light> (Licht) { channel="mqtt:topic:allnew:eg_hwr_ledlight_esp8266" }
As I mentioned, after F5 reload of the Basic UI the state will be shown correctly. And for my other Items such as KNX and others the state is being immediately shown.
Any ideas? I thought that it could be related to the ESP8266 itself, but as the items log is updated correctly I guess this could not be the case.
ESPHome Config:
esphome:
name: ledlight
esp8266:
board: huzzah
# Enable logging
logger:
# Enable Home Assistant API
api:
password: ""
ota:
- platform: esphome
password: ""
mqtt:
broker: 192.168.2.30
web_server:
port: 80
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
captive_portal:
remote_transmitter:
pin: GPIO12
carrier_duty_percent: 50%
switch:
- platform: gpio
pin: GPIO13
name: "LED Light"
id: led_strip_relay
retain: true