Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem after restart host computer #1182

Open
rafalolb opened this issue Apr 16, 2024 · 10 comments
Open

Problem after restart host computer #1182

rafalolb opened this issue Apr 16, 2024 · 10 comments
Labels
bug Something isn't working

Comments

@rafalolb
Copy link

Hello,

I have 5 switch with installed OpenBK firmware. I using Home assistant with MQTT installed in Dockers on my RPI. All switches works perfect, but I found 1 problem.

If I restart my host (my RPI), all my switches are unavaible. I must go to Config->Home Assistant Configuration and click Home assistant discovery. If I do this everything works great.

Why I must click discovery if I restart my host computer? Can I do something (for example set some flag)?

Please help.

@openshwprojects openshwprojects added the bug Something isn't working label Apr 16, 2024
@openshwprojects
Copy link
Owner

Hello, do you have set "publish self state every N seconds" or how it was called, flag?

If you restart your host (RPI), and then toggle value of a switch, does it also gets discovered?

Or, to be clear, are they removed from config (so you have to rediscover) or maybe it's just that they are shown as unavailable?

@rafalolb
Copy link
Author

rafalolb commented Apr 17, 2024

Hello, do you have set "publish self state every N seconds" or how it was called, flag?

Yes, I have check checkbox Flag 2 - [MQTT] Broadcast self state every N (def: 60) seconds (delay configurable by 'mqtt_broadcastInterval' and 'mqtt_broadcastItemsPerSec' commands)

If you restart your host (RPI), and then toggle value of a switch, does it also gets discovered?

If I toogle value of state on switch UI, the state of switch will be unavailable on Home Assistant.

Or, to be clear, are they removed from config (so you have to rediscover) or maybe it's just that they are shown as unavailable?

I don't understand. I don't have configuration in configuration.yml, but the switches exists in Settings -> Integration -> MQTT, but all switches are unavailable.

@rafalolb
Copy link
Author

rafalolb commented Apr 17, 2024

I have installed MQTT on RPI host. I think that, if MQTT server is available for some time (restart time), after restart the switch not reconnect to mqtt, but on switch UI I see connected to MQTT.

@rafalolb
Copy link
Author

I have additional info. If I turn off my router and next turn on for some minutes, switches works. Problem only exists when host (RPI) is restarted.

@pikpok
Copy link

pikpok commented May 2, 2024

I had a similar issue, and setting flag 21 did the trick for me:

Flag 21 - [MQTT] Retain power channels (Relay channels, etc)

@rafalolb
Copy link
Author

rafalolb commented May 2, 2024

Doesn't works for me 😒

I set the Flag 21, restart switch, restart host, problem exists.

@jonny190
Copy link

I'm facing the same issue, currently looking at a Home assistant automation that restarts the devices when they show as "unavailable" if the system uptime is less then 5 mins. Its more of a work around as i'm not sure what else to do at present

@slo617
Copy link

slo617 commented May 19, 2024

I have had the same problem, Flag 27 - [HASS] Invoke HomeAssistant discovery on change to ip address, configuration helped me.

Once published discovery information is stored on the MQTT-broker, if the MQTT-broker (and Home-Assistant) restarts this information is lost.
So we need to re-send discovery information every time we reconnect to the MQTT-broker.

Actually, change to ip address, configuration and reconnect to the MQTT-broker is not exactly the same, so either flag 27 might not help in all cases or documentation should be improved.

@rafalolb
Copy link
Author

This Flag helped me, but not solved the problem.

I set 27 Flag on my switches. Now if I restart host, I must restart switches (but I don't have to go to Config->Home Assistant Configuration and click Home assistant Discovery).

@slo617
Copy link

slo617 commented May 19, 2024

I guess flag 27 worked for me because I got home assistant running on my router. Restarting MQTT broker and home assistant usually means restarting the whole router for me.
So this is not a generic solution.

As a workaround you could start home assistant discovery from time to time by a script, e.g. in autoexec.bat. You could try something like this:

addRepeatingEvent 10 -1 scheduleHADiscovery 5

Be warned, I have not tested it. It should schedule a discovery every 10 seconds with a delay of 5 seconds.
If it works, it will also add a very little bit of traffic to your WLAN. And there will be a delay of up to 10 seconds.
See also: https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands.md

Better solution would be an event that is fired by the MQTT driver, or a modification of flag 27, so it sends discovery information on re-connection to the MQTT broker.
So this issue can still be considered as a bug, or at least as a feature request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants