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
69.98k stars 29.06k forks source link

Shelly Motion sensors unavailable while CoAP messages are coming in #117734

Closed PimDoos closed 2 weeks ago

PimDoos commented 1 month ago

The problem

My Shelly Motion sensors (gen 1, SHMOS-01 and SHMOS-02) become unavailable within about 1 hour 15 minutes after startup. After restarting Home Assistant or reloading the Shelly integration, the sensors work fine for just over 1 hour. After this, they become unavailable.

I have enabled debug logging (see attached files) for aioshelly and homeassistant.components.shelly. In the logs I see two things happening:

  1. aioshelly shows the devices are sending periodic CoAP messages every 30 minutes, as they should
  2. Roughly 1 hours and 15 minutes after startup, the shelly component logs Error fetching <device name> data: Sleeping device did not update within 3600 seconds interval

What version of Home Assistant Core has the issue?

core-2024.5.4

What was the last working version of Home Assistant Core?

core-2024.4.4

What type of installation are you running?

Home Assistant OS

Integration causing the issue

shelly

Link to integration documentation on our website

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

Diagnostics information

shelly-overloop.log shelly-toilet.log

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

State history for the 'Toilet Motion' and and 'Overloop Motion' sensors during the log snippets. image image

home-assistant[bot] commented 1 month ago

Hey there @balloob, @bieniu, @thecode, @chemelli74, @bdraco, mind taking a look at this issue as it has been labeled with an integration (shelly) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `shelly` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign shelly` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


shelly documentation shelly source (message by IssueLinks)

rhoddan commented 1 month ago

I have similar for almost all my Shellies

Skärmavbild 2024-05-26 kl  22 26 22
thecode commented 1 month ago

@rhoddan by similar I assume you checked the logs and saw that CoAP packets arrive correctly? can you share the log and diagnostics?

@PimDoos can you retest with core 2024.5.5, it should resolve this issue - https://github.com/home-assistant/core/issues/116975#issuecomment-2130359742

logicland commented 1 month ago

Same issue with a Shelly Motion Sensor, deleting and reinstalling this from the integration fixes it for an hour or so, rebooting HA makes it work for around a day.

The sensor uses a fixed IP 192.168.178.xxx:5683, CoLot is enabled, MQTT is Clean Session enabled, Max QoS=1

Rebooting the device has no effect, the device functions normally via http

btw this is with Core 2024.5.5

PimDoos commented 1 month ago

After upgrading to 2024.5.5, the issue persists for me.

Error fetching Overloop Motion data: Sleeping device did not update within 3600 seconds interval
Error fetching Toilet Motion data: Sleeping device did not update within 3600 seconds interval
patriiiiiiiiiick commented 1 month ago

Having similar issue with my TRVs. COAP messages arrive.

2024-06-03 00:43:14.504 DEBUG (MainThread) [aioshelly.block_device.coap] CoapMessage: ip=192.168.0.146, type=CoapType.PERIODIC(30), options={11: b's', 3332: b'SHTRV-01#60A423DCBF4C#2', 3412: b'\x1c!', 3420: b'\x00q'}, payload={'G': [[0, 3101, 18.8], [0, 3102, 65.9], [0, 3103, 8.0], [0, 3104, 46], [0, 3115, 0], [0, 3116, 0], [0, 3117, 0], [0, 3118, 0], [0, 3111, 100], [0, 3121, 0.0], [0, 3122, 0], [0, 9103, 5]]}

PimDoos commented 1 month ago

After upgrading to 2024.5.5, the issue persists for me.

Error fetching Overloop Motion data: Sleeping device did not update within 3600 seconds interval
Error fetching Toilet Motion data: Sleeping device did not update within 3600 seconds interval

Ironically, since I posted this I restarted HA once and did not have any issues with any of my battery powered Shelly devices since. Until today when I upgraded to 2024.06.0: two of my Shelly motion sensors became unavailable again after just over an hour. I'm curious to see if the PR fixes this.

bieniu commented 1 month ago

Today I performed a 12-hour Shelly Motion test. Device entities in HA were available all the time. We suspect that the problem may be caused by blocking the event loop by another integration (probably custom one). The CoIoT packet with status reaches the HA server but cannot be processed correctly. To check this, please enable HA built-in debug mode, restart HA and attach the log file after few hours.

PimDoos commented 1 month ago

I've run HA with debug mode enabled for just over a day, and this one stands out: image

I'll disable entsoe and see if that fixes the issue. Looks like the issue has already been reported with the custom integration. https://github.com/JaccoR/hass-entso-e/issues/156