I’m a very new user & on a steep learning curve here so please bear with me.
I have a wifi relay switch (Tuya type flashed with the openBK firmware - https://github.com/openshwprojects/OpenBK7231N). I’ve installed the latest home assistant on a RPi3 & set the device up in configuration.yaml as follows:
I setup a card on the dashboard for this entity and all works OK except on startup of HA or reloading the yaml. When I do this, the switch/relay state is shown as unknown and is not properly showing the switch state as on or off in HA until it the switch is operated either from the dashboard in HA or by pressing the toggle button on the unit.
The results of activating the switch from HA or by the toggle button are:
Clicking the icon on the dashboard card when the relay is in the on state turns the relay off and modifies the displayed state to off.
Clicking the icon on the dashboard card when the relay is in the off state does nothing - Displayed state is still unknown.
When the state shows as unknown, if the pushbutton on the unit is pressed the status in HA is updated correctly.
Any guidance is appreciated. I’ve looked through the forums and manuals, but not yet found anything that seems definitively helpful. I have been assuming that there is a way of querying the on/off status of the device from HA on startup, but maybe this is not possible? Of course thngs are complicated a bit by the openBK firmware, but maybe I’m expecting HA do do something it can’t do. If thats the case, I’ll stop now
In an ideal scenario, the MQTT device will have a state_topic to publish state changes. If these messages are published with a RETAIN flag, the MQTT switch will receive an instant state update after subscription, and will start with the correct state. Otherwise, the initial state of the switch will be unknown.
Take a look in the firmware settings to publish the state with the RETAIN flag.
I found that, but didn’t quite get it at the time. I’ll concentrate on that then.
It seemed to me that this would fail if the switch state changed during the time HA was restarting. Perhaps I missunderstood.
I guess I expected HA to be capable of interrogating the device at will to find the service status.
The guy who wrote the firmware for the switch produced a firmware version with an option which broadcasts the switch status once a minute. This solved things for me at the time.
I did figure out that I could do something using node red to periodically interrogaqte a switch or sensor to get its state. I used that for a home made heater controller I built. Now that returns temperature, humidity and output status when interrogated using a node red flow in HA. I probably have to optimise that, but seems promising.
I’m in the same situation. When I reboot, I have to find the device in settings; and from there I can turn on/off.
Then I go to “home” and its real state appears.
Any solution?
Hi guys, i had the same problem, and searching for a while i found this link that someone had the same problem. If anyone come across here from now on, it seems that Flag 21 in OpenBK App does just that:
Flag 21 - [MQTT] Retain power channels (Relay channels, etc)