home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.11k stars 29.79k forks source link

Mysensors integration stops updating entities #82783

Closed Jordan-Szwejda closed 8 months ago

Jordan-Szwejda commented 1 year ago

The problem

I have HomeAssistant OS installed which connects to raspberrypi with installed MySensors Ethernet Gateway. HomeAssistant is in the same LAN but on different machine. After Raspberry Pi restart MySensors integration stops working. It does not update any entities. Manual reload of integration is necessary to make it working again. I grabbed some debug logs from mysensors (attached). MySensors integration also stops logging after last entry about saving sensors .

What version of Home Assistant Core has the issue?

2022.11.4

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

mysensors

Link to integration documentation on our website

https://www.home-assistant.io/integrations/mysensors

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2022-11-27 11:18:32.283 DEBUG (MainThread) [mysensors.transport] Receiving 0;255;3;0;2;0.0.1
2022-11-27 11:18:32.285 DEBUG (MainThread) [mysensors.transport] Receiving 0;255;3;0;12;0.0.1
2022-11-27 11:18:32.286 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 0 child 255
2022-11-27 11:18:32.287 DEBUG (MainThread) [mysensors.transport] Receiving 0;255;0;0;18;2.3.0
2022-11-27 11:18:32.288 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 0 child 255
2022-11-27 11:18:32.289 DEBUG (MainThread) [mysensors.gateway_tcp] Connection lost with <_SelectorSocketTransport closing fd=52 read=idle write=<idle, bufsize=0>>
2022-11-27 11:18:33.206 DEBUG (MainThread) [mysensors.gateway_tcp] Connection lost with <_SelectorSocketTransport closing fd=47 read=idle write=<idle, bufsize=0>>
2022-11-27 11:18:42.163 DEBUG (SyncWorker_6) [mysensors.persistence] Saving sensors to persistence file /config/mysensors_69478a2845889930e4b5b400b737372c.json

Additional information

No response

home-assistant[bot] commented 1 year ago

Hey there @martinhjelmare, @functionpointer, mind taking a look at this issue as it has been labeled with an integration (mysensors) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `mysensors` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Change the title of the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign mysensors` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


mysensors documentation mysensors source (message by IssueLinks)

MartinHjelmare commented 1 year ago

It seems there's no exception argument in the connection_lost protocol callback for this case. Currently that doesn't trigger a re-connection attempt. Maybe it should?

Jordan-Szwejda commented 1 year ago

For sure there should be some reconnection implemented. The situation that Ethernet Gateway node is restarted is nothing extraordinary (e.g. periodic node restart to have some OS refresh and to clean up resources). Unfortunately it would be difficult for me to help with fixing this as I have no python experience, but if you need some assistance from my side to perform some additional investigations I would be grateful to help. For now I am going to make a temporary workaround and write an automation to reload integrations if some entity is not updated for a some period of time.

Smittybk1 commented 1 year ago

I too am having the same issue. As far as I know, there is no automation avaliable for the restart of this integration. Further more, as I use temperature sensors, there is no trigger available to sense that the sensor is no longer reporting. I was using a wifi gateway and the problem would occur during a temp loss of the wifi gateway connection. I have switched to an ethernet gateway for now as the connection is more stable. I can provide logs if needed

Jordan-Szwejda commented 1 year ago

@Smittybk1 As a workaround you can create a simple sensor in mysensors which would report a counter value incremented every one minute and write a simple automation for reloading mysensors integration if this counter is not updated for longer than 5 minutes.

Smittybk1 commented 1 year ago

@Smittybk1 As a workaround you can create a simple sensor in mysensors which would report a counter value incremented every one minute and write a simple automation for reloading mysensors integration if this counter is not updated for longer than 5 minutes.

I have yet to find an action in the automations that would reload the mysensors integration. That's the only thing I can't get past in making the automation.

feanor-anglin commented 1 year ago

Hey, I've just upgraded to 2022.12.8 and seem to have similar issue: all MySensors entities are unavailable after restart. They can be brought back by sending a value, so through restart / pressing a button on a module / sending sensor data. The problem is the worst with relay entities, which does not send any values, so only restarting the module can help.

This is really bad for me. Please do something about it as soon as possible.

MartinHjelmare commented 1 year ago

PRs for the pymysensors library that handles the connection are welcome.

Note that this isn't a new problem in recent releases. The logic around connection closed has been the same for years.

feanor-anglin commented 1 year ago

Hmm, that's odd because I've previously used 2022.5.5 and the issue was not there. Also I'm almost 100% certain that it worked as it should in 2022.8.7. Maybe the problem does not lie in pymysensors?

Smittybk1 commented 1 year ago

1 thing I did notice, I switched to an ethernet gateway and I am no longer having issues. It was only when I was using a wifi gateway did this issue persist

d-smes commented 1 year ago

I have Arduino Nano-based ethernet gateway and I always experience MySensors integration closing the integration after a few minutes of operation. Sample log entries below: 2023-02-16 21:59:31.130 DEBUG (MainThread) [mysensors.transport] Receiving 97;1;1;0;0;-0.06 2023-02-16 21:59:31.136 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 97 child 1 2023-02-16 21:59:31.248 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Duck Pen Temp: value_type 0, value = -0.06 2023-02-16 21:59:31.352 DEBUG (SyncWorker_1) [mysensors.persistence] Saving sensors to persistence file /config/mysensors_103f09b3efc84268b05d653beb12662e.json 2023-02-16 21:59:31.518 DEBUG (MainThread) [mysensors.gateway_tcp] Connection lost with <_SelectorSocketTransport closing fd=30 read=idle write=<idle, bufsize=0>>

It usually loses connection just after a SyncWorker saves the persistence file, but not always. Let me know what additional information would be helpful.

CV8R commented 1 year ago

I am suffering the same issue. Using Ethernet Gateway. Sensors work for a few minutes, then fail to update. Need to reload the integration to get the sensors updating, but they fail shortly thereafter.

I am new to HA but have been using MySensors for years, including this particular Genuine Ethernet Shield and Uno on another automation platform. Ported my code to work with HA but this is a showstopper.

I am now using a basic sketch with 2 S_DOOR sensors and having the same failure.

Happy to provide any logging if anyone can point me in the right direction.

Smittybk1 commented 1 year ago

@CV8R I changed to an ethernet gateway and have not had an issue since. Maybe my sketch makes the difference. I am running my gateway with an arduino pro mini 5v 16mhz

korttoma commented 1 year ago

I have a similar issue, from one of the MySensors GWs I only receive sensor updates for a few minutes and then it stops. Disable/Enable integration starts it again but only for a few minutes.

2023-05-30 15:10:01.830 DEBUG (MainThread) [mysensors.gateway_tcp] Connection lost with <_SelectorSocketTransport closing fd=84 read=idle write=<idle, bufsize=0>> 2023-05-30 15:10:05.898 DEBUG (SyncWorker_6) [mysensors.persistence] Saving sensors to persistence file /config/mysensors_95ea7153fb07a8f71ea25910c0426cea.json

issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

d-smes commented 1 year ago

Please don't label this issue as stale, because it is NOT SOLVED. Today, I tested again- I made sure HA and all packages were up to date. Rebooted the Pi HA runs on. When HA was back on line, MySensors was updating sensor values. Within five minutes, it stopped updating. See my Feb 16th comment for example log messages.

I have MYSController (written to view MySensor data) and a Girder Transport Component programs that are able to establish and maintain a connection to the ethernet gateway for months. So this is not a MySensors or gateway issue. Won't someone please take a look at the HA integration?

forexsieno commented 1 year ago

Hello, still have same issues. Home Assistant 2023.8.4, MySensor Serial Gateway 2.3.4. MySensor integration stops working unpredictable, sometimes after some hours, sometimes after some days. Have some temperature sensors which are sending latest values once per minute. There I can see when data updating stops. It's not a problem of MySensors network. I also tested it with MYSController, where this problem doesn't appear.

0uro commented 12 months ago

I have that problem too. Tried to avoid it by switching TCP link to mqtt link but doesn't change anything. Launched domoticz to check : everythings appears fine

issue-triage-workflows[bot] commented 9 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

aneantisor commented 8 months ago

The issue is still present. I have 2 mysensors gateway, identical hardware. Esp32 based. Only one of both have the issue. It randomly stop working. Both gateway are connected to 2 controller. The 2 controller are home assistant and mycontroller.org. both gateway work continously on mycontroller.org. but one gateway randomly stop working on home assistant. Any Idea ?

d-smes commented 7 months ago

There is clearly something wrong in how the plugin maintains a connection. Unfortunately, there are too few people complaining for the HA folks to take an interest in taking a look it this (my speculation). Moreover, the issue bot closed this thread. My suggestion is to open a new issue and reference this thread which has data useful to debug and fix this.

aneantisor commented 7 months ago

Hello, 5 days ago, i've added a 220uf capacitor on 3.3v supply of the esp32. And the fault didnt appear anymore. Clearly, it is a power supply issue. Mycontroller have a more robust way to handle the connexion than hass. But it is not really a hass problem. Thank you for making this soft so good.