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.14k stars 29.82k forks source link

Shelly motion sensor not responding in HA after 10 min. #47947

Closed ned786 closed 2 years ago

ned786 commented 3 years ago

The problem

Hi,

I am having problems with the Shelly integration and the new Shelly motion. I have added the homeassistant ip to the shelly COIOT and I have added the device to my homeassistant. For the first 15-20 minutes it works perfect, very responsive but after a few minutes of inactivity if fails to pick up updates anymore and becomes unavailable. The detector is still showing in the Shelly app and responds as it should do but it does not update home assistant.

I have tried removing and reinstalling the intervention (which was very painful), I have done several factory resets with no luck. I currently have my Shelley’s on a IOT network and my home assistant on the main network, not sure if that makes a difference but thought I would mention it. Also maybe a little off topic, I have just started the transfer of my devices to my new IOT network and I have realised there is a 7-9 second delay when using a IOT network in comparison to when it was all on the same network. Has any one else experienced this and is there anything I can do to rectify? It seems to me when I use home assistant to turn on a light for example it works instant but when I use the light switch to turn on the light it does not update home assistant like it did when they were all on the same network. Should I maybe do some port forwarding? Sorry if that is a silly question I am new to all of this and everything so far has been self taught.

What is version of Home Assistant Core has the issue?

2021.3.4

What was the last working version of Home Assistant Core?

2021.3.4

What type of installation are you running?

Home Assistant Core

Integration causing the issue

Shelly intergration

Link to integration documentation on our website

No response

Example YAML snippet

# Put your YAML below this line

Anything in the logs that might be useful for us?

# Put your logs below this line

Logger: homeassistant.components.shelly
Source: helpers/update_coordinator.py:173 
Integration: Shelly (documentation, issues) 
First occurred: 13:43:47 (1 occurrences) 
Last logged: 13:43:47

Error fetching shellymotionsensor-60A423937420 data: Sleeping device did not update

ABC0C71B-D78B-485C-86DA-AC9545DD6A2A

thecode commented 3 years ago

Note that for motion sensor if you leave the web open device does not go to sleep and have high battery drain. If you see the action in the Web but not in HA you might have a network issue.

Add the following to configuration.yaml , restart HA, and post the logs near the error:

logger:
  default: warning
  logs:
    homeassistant.components.shelly: debug
    aioshelly: debug

Note: logs may be to be to read in github, it is better to use a service such as https://pastebin.com/ for uploading the logs

cigas4 commented 3 years ago

I only get shelly motion unavailable after restarting Home Assistant. Every time I do a restart of HA some of my shelly motion sensors (sometimes all of them - 6 pcs) goes unavailable and never recovers. I have to restart every sensor manually to get it online again. Any ideas?

chemelli74 commented 3 years ago

I have to restart every sensor manually to get it online again. Any ideas?

Wait a few days for new firmware and your issue will be fixed

Simone

biocoder-frodo commented 3 years ago

I've had this happen to me twice. I started using the Docker image on my Synology NAS with a Shelly Motion and a Shelly Plug S. The motion device went missing not after 10 minutes after HA startup, but several hours. My shellymotionsensor connected to HA on Aug 29, 00:23 and went missing some 15 hours later.

Logger: homeassistant.components.shelly
Source: helpers/update_coordinator.py:219
Integration: Shelly (documentation, issues)
First occurred: August 29, 2021, 3:17:41 PM (2 occurrences)
Last logged: August 29, 2021, 9:52:00 PM

Error fetching shellymotionsensor-******* data: Sleeping device did not update

I've enabled Wifi logging on my repeater to see what goes on there if this reoccurs, My repeater and accesspoint are configured to pick the Wifi channel automatically.

Shelly Motion FW 20210725-085052/v1.1.3-rc16@4899605c

biocoder-frodo commented 3 years ago
Logger: homeassistant.components.shelly
Source: helpers/update_coordinator.py:219
Integration: Shelly (documentation, issues)
First occurred: September 3, 2021, 19:29:46 (3 occurrences)
Last logged: 05:17:11
Error fetching shellymotionsensor-***** data: Sleeping device did not update

It happened again. This time from 5:17 till 6:06 this morning. I found the device re-registers to Wi-Fi every hour or so, but the 49 minute duration of unavailable status does not match the timestamps of the Wi-Fi registration?

    Line 3: 05.09.21 13:56:14 Wireless device registered (2,4 GHz), 72 Mbit/s, PC-192-168-178-202, IP 192.168.178.202, MAC shelly-sensor.
    Line 4: 05.09.21 13:56:12 Wireless device deregistered itself (2,4 GHz), PC-192-168-178-202, IP 192.168.178.202, MAC shelly-sensor.
    Line 12: 05.09.21 12:46:26 Wireless device registered (2,4 GHz), 72 Mbit/s, PC-192-168-178-202, IP 192.168.178.202, MAC shelly-sensor.
    Line 13: 05.09.21 12:46:16 Wireless device deregistered itself (2,4 GHz), PC-192-168-178-202, IP 192.168.178.202, MAC shelly-sensor.
    Line 14: 05.09.21 12:46:16 Wireless device registered (2,4 GHz), 72 Mbit/s, PC-192-168-178-202, IP 192.168.178.202, MAC shelly-sensor.
    Line 15: 05.09.21 12:46:12 Wireless device deregistered itself (2,4 GHz), PC-192-168-178-202, IP 192.168.178.202, MAC shelly-sensor.
    Line 18: 05.09.21 11:36:14 Wireless device registered (2,4 GHz), 72 Mbit/s, PC-192-168-178-202, IP 192.168.178.202, MAC shelly-sensor.
    Line 19: 05.09.21 11:36:12 Wireless device deregistered itself (2,4 GHz), PC-192-168-178-202, IP 192.168.178.202, MAC shelly-sensor.
    Line 30: 05.09.21 10:26:14 Wireless device registered (2,4 GHz), 72 Mbit/s, PC-192-168-178-202, IP 192.168.178.202, MAC shelly-sensor.
    Line 31: 05.09.21 10:26:12 Wireless device deregistered itself (2,4 GHz), PC-192-168-178-202, IP 192.168.178.202, MAC shelly-sensor.
    Line 35: 05.09.21 09:16:14 Wireless device registered (2,4 GHz), 72 Mbit/s, PC-192-168-178-202, IP 192.168.178.202, MAC shelly-sensor.
    Line 36: 05.09.21 09:16:12 Wireless device deregistered itself (2,4 GHz), PC-192-168-178-202, IP 192.168.178.202, MAC shelly-sensor.
    Line 39: 05.09.21 08:06:16 Wireless device registered (2,4 GHz), 72 Mbit/s, PC-192-168-178-202, IP 192.168.178.202, MAC shelly-sensor.
    Line 40: 05.09.21 08:06:12 Wireless device deregistered itself (2,4 GHz), PC-192-168-178-202, IP 192.168.178.202, MAC shelly-sensor.
    Line 43: 05.09.21 06:56:40 Wireless device registered (2,4 GHz), 72 Mbit/s, PC-192-168-178-202, IP 192.168.178.202, MAC shelly-sensor.
    Line 44: 05.09.21 06:54:12 Wireless device deregistered itself (2,4 GHz), PC-192-168-178-202, IP 192.168.178.202, MAC shelly-sensor.
    Line 53: 05.09.21 05:44:22 Wireless device registered (2,4 GHz), 72 Mbit/s, PC-192-168-178-202, IP 192.168.178.202, MAC shelly-sensor.
    Line 54: 05.09.21 05:44:18 Wireless device deregistered itself (2,4 GHz), PC-192-168-178-202, IP 192.168.178.202, MAC shelly-sensor. [3 messages since 05.09.21 05:44:12]
    Line 61: 05.09.21 04:34:14 Wireless device registered (2,4 GHz), 72 Mbit/s, PC-192-168-178-202, IP 192.168.178.202, MAC shelly-sensor.
    Line 62: 05.09.21 04:34:12 Wireless device deregistered itself (2,4 GHz), PC-192-168-178-202, IP 192.168.178.202, MAC shelly-sensor. [2 messages since 05.09.21 04:34:08]
    Line 63: 05.09.21 04:31:18 Wireless device registered (2,4 GHz), 72 Mbit/s, PC-192-168-178-202, IP 192.168.178.202, MAC shelly-sensor.
    Line 64: 05.09.21 04:31:16 Wireless device deregistered itself (2,4 GHz), PC-192-168-178-202, IP 192.168.178.202, MAC shelly-sensor. [2 messages since 05.09.21 04:31:12]
thecode commented 3 years ago

It happened again. This time from 5:17 till 6:06 this morning. I found the device re-registers to Wi-Fi every hour or so, but the 49 minute duration of unavailable status does not match the timestamps of the Wi-Fi registration?

This is not a bug, device reports to us what is the maximum interval it must send an update, for Shelly motion it is 1 hour, you can find this under http://device_ip/settings -> "update_period":3600

So that if your device disconnects from WIFI we will only alert it after 1 hour from the last update (and we have an extra buffer time on this), it is by design and there is no way to improve it since we do not know the status of the device unless we get an update. The 1 hour was agreed with the manufacture to be both battery efficient and give an acceptable user experience, FYI for other Shelly battery operated devices this is set to 12 Hours

biocoder-frodo commented 3 years ago

Ok, thanks. I'll see if I can update my automations to cover the transition from Unavailable to Detected, because the blueprint I used only covers the transition from Clear to Detected.

cigas4 commented 3 years ago

Is there any scheduled reboot of Shelly Motion or something like this? I have 6 pcs sensors and all of them becomes unavailable for ~ 1 hour period about 2 times per day. In the mean time they all work fine and detecting motion. I havent tried yet checking if they can detect motion during these blind periods. But clearly there are some periodic things happening, however, not sure it come from HA or Shelly side.

30CA38B8-E637-4E9F-B8F8-91D8DC058B86

biocoder-frodo commented 3 years ago

@cigas4, which firmware version are you using? I bought and updated mine last week.

@thecode I looked at the settings of the device and posted them here

I blocked the device from accessing the internet, but after a week, the internal clock is not too slow or fast, time is accurate.. The JSON response reveals something interesting; there are two update_period settings, one for MQTT and one for CoIOT and a separate sleep_mode setting. The hardware revision is set to dev-prototype. :) ? I get the feeling that having two or three timeout settings might cause this issue? In the meantime I can make a workaround automation.

cigas4 commented 3 years ago

@cigas4, which firmware version are you using? I bought and updated mine last week.

@thecode I looked at the settings of the device and posted them here

I blocked the device from accessing the internet, but after a week, the internal clock is not too slow or fast, time is accurate.. The JSON response reveals something interesting; there are two update_period settings, one for MQTT and one for CoIOT and a separate sleep_mode setting. The hardware revision is set to dev-prototype. :) ? I get the feeling that having two or three timeout settings might cause this issue? In the meantime I can make a workaround automation.

I am using latest stable release. From your configuration I see you have enabled MQTT and also CIOT connections at the same time. I am only using CIOT connection to HA. I have cloud connection disabled also.

thecode commented 3 years ago

@cigas4 @biocoder-frodo as written here https://github.com/home-assistant/core/issues/47947#issuecomment-903335560 we are waiting for a new version to be released. Please be patient and wait, there is no point digging in settings. once there is a new version we will update here.

avegao commented 2 years ago

The new version v2.0.0 was released this week and the problem is resolved for me.

thecode commented 2 years ago

Closing this issue, If someone still has problems please open a new issue with details. v2.0.0 also fixed the timeouts for myself