wonderslug / MMM-HomeAssistantDisplay

A Magic Mirror Module to display information from Home Assistant.
MIT License
83 stars 6 forks source link

Loosing connection, no updates after certain time #21

Closed Mugga6315 closed 6 months ago

Mugga6315 commented 10 months ago

I've got the issue that after sometime the homeassistant entities are not updating anymore. I've looked into the logs but couldn't find any log entry. I just suddelny stops receiving updates.

Any clue how I can debug this?

rjfendricks commented 8 months ago

I have a bit of information to add, but no real solutions.

For my setup, I have the MMM server running on a local computer and the client running on my Magic Mirror. After a few hours, I also notice that the homeassistant entities stop updating. However, if I connect to the MMM Server's IP address/port through a web browser from a third device, the client on the magic mirror magically recovers.

I still don't know all of the details, but I think that MMM-HomeAssistantDisplay.js runs as an instance on the client(s) while node_helper.js runs on the server. My theory is that by connecting a new MMM-HomesassistantDisplay instance, the node_helper script is being forced to reconnect back to Home Assistant and gets everything moving again.

Looking further into it, when I observe the logs I see that the statement here stops printing when the issue manifests. Tracing it backwards in the code, my best guess is that the state_changed event is no longer getting fired from the hassWs object (which is bound here).

I have no clue yet why this stops firing events or why connecting a new instance to the MMM server seems to fix this. If I have time/motivation later I'll continue to look into it, but with any luck someone more versed in this architecture than me can make more sense of my findings :)

rjfendricks commented 8 months ago

After looking into it some more, it probably has something to do with this 3rd party Node module. Either it isn't being configured correctly or there's a bug in the linked module, but at this point I don't have enough expertise/motivation to figure it out.

Instead, I'll propose a hacky workaround, which I pushed up as PR #22. It's definitely not solving the issue at hand, but it will at least make the module functional until someone fixes it properly. Plus, I can think of at least 1 legitimate use case that might make this helpful regardless.

wonderslug commented 6 months ago

should be closed by PR #22