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

Unavailable Xiaomi Gateway devices are not detected correctly #16274

Open
OleksandrBerchenko opened this issue Aug 29, 2018 · 49 comments
Open

Unavailable Xiaomi Gateway devices are not detected correctly #16274

OleksandrBerchenko opened this issue Aug 29, 2018 · 49 comments

Comments

@OleksandrBerchenko
Copy link
Contributor

Home Assistant release with the issue:

0.77.0

Last working Home Assistant release (if known):

n/a

Operating environment (Hass.io/Docker/Windows/etc.):

Virtualenv on Raspberry Pi

Component/platform:

https://www.home-assistant.io/components/xiaomi_aqara/

Description of problem:

If a device connected to Xiaomi Gateway becomes unavailable (for example, I remove a plug from the socket), it takes a few minutes for my MiHome application to recognize that and a few hours for HA. Even worse, if I restart HA, it starts to think that device is available again and it takes another several hours to realize it doesn't.

Thanks!

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

xiaomi_aqara:
  discovery_retry: 10
  gateways:
    - key: 0wf2zoxhs7zlk28a

Traceback (if applicable):

n/a

Additional information:

n/a

@dshokouhi
Copy link
Member

I have also seen this before. Just an FYI if your devices go to unavailable that means you should consider moving your gateway to a more central location or get some powered nodes to increase the range and stability of the mesh. For me I moved my gateway and I no longer had any device go to the unavailable state. Nonetheless this issue should be fixed too as the restart does show it as available for a few hours.

@syssi
Copy link
Member

syssi commented Jan 3, 2019

The unavailable state of the Mihome App and Home Assistant should be compared with each other. They are independent. The API of the Xiaomi Gateway doesn't expose the unavailable state. The Home Assistant component (xiaomi_aqara) keeps track on it's own. If a device doesn't respond for 150 minutes it's marked as unavailable:

TIME_TILL_UNAVAILABLE = timedelta(minutes=150)
https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/xiaomi_aqara.py#L44

If you reboot Home Assistant all paired zigbee devices are available by default. This line could be changed to swap the default to unavailable:

https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/xiaomi_aqara.py#L211

@OleksandrBerchenko
Copy link
Contributor Author

In #16270 you mentioned that "The gateway receives(?) and publishes a heartbeat every 5 or 10 minutes per sub-device". Why is TIME_TILL_UNAVAILABLE = 150 minutes and not something like 15 minutes? By the way, Mi Home is also not able to detect an unavailable device immediately, but in ~15 minutes or so (never measured exact time period).

Thanks!

@syssi
Copy link
Member

syssi commented Jan 3, 2019

Take a look at: #11631

Average heartbeat time periods
magnet 1 hour
motion/sensor_motion.aq2 55 min
switch 1 hour
sensor_wleak.aq1 50 min
gateway 10 sec
sensor_ht 50 min - 1 hour
plug 7 min

@OleksandrBerchenko
Copy link
Contributor Author

Ah, ok... Then it makes sense.

Well, how do you get states of all devices after HA reboot? Do you just wait for the next heartbeat for each of them separately?

Thanks!

@syssi
Copy link
Member

syssi commented Jan 3, 2019

No. At first a device list is retrieved. Afterwards each devices is polled once.

https://github.com/Danielhiversen/PyXiaomiGateway/blob/master/xiaomi_gateway/__init__.py#L212-L290

@OleksandrBerchenko
Copy link
Contributor Author

Thanks! Yes, you are right: Gateway reports unavailable devices exactly like available ones.

Well... If heartbeat time periods are so different for different device types (from 7 minutes to 1 hour), can we use different TIME_TILL_UNAVAILABLE values for different device types?

It looks like MiHome reports a device us unavailable after about 4 missing heartbeat (~26 minutes for a plug), but 2 missing heartbeats are probably enough.

What do you think?

Thanks!

@OleksandrBerchenko
Copy link
Contributor Author

Regarding restart... Is it possible to use the last known state as the default value? In other words, if a device was unavailable and HA restarted, it continues to be unavailable (until a new heartbeat arrives). That should cover 99% of cases.

What do you think?

Those fixes would be very helpful. At the moment I'm actively developing my smart house, disconnecting and reconnecting devices all the time and restarting my HA 10+ times a day.

Thanks!

@syssi
Copy link
Member

syssi commented Jan 5, 2019

I understand your pain and your idea is possible. I will think about it but the faeture has a low priority on my list.

@OleksandrBerchenko
Copy link
Contributor Author

Ok, thanks in advance!

@balloobbot
Copy link

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 👍

@OleksandrBerchenko
Copy link
Contributor Author

This bug is still actual.

Thanks!

@stale
Copy link

stale bot commented Jul 7, 2019

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 now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 7, 2019
@OleksandrBerchenko
Copy link
Contributor Author

Yes, it's still actual. Thanks!

@stale stale bot removed the stale label Jul 8, 2019
@stale
Copy link

stale bot commented Oct 6, 2019

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 now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 6, 2019
@OleksandrBerchenko
Copy link
Contributor Author

Yes, it's still actual. Thanks!

@caesar1987sk
Copy link

Anything new with this problem?

@stale
Copy link

stale bot commented Mar 23, 2020

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 now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Mar 23, 2020
@OleksandrBerchenko
Copy link
Contributor Author

Yes, it's still actual. Thanks!

@stale stale bot removed the stale label Mar 23, 2020
@stale
Copy link

stale bot commented Jun 21, 2020

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 now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot removed the stale label Feb 28, 2022
@SergeyPomelov

This comment was marked as spam.

@syssi
Copy link
Member

syssi commented Mar 7, 2022

@SergeyPomelov Please don't spam at so much issues. This doesn't help to improve the situation.

@github-actions
Copy link

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.

@github-actions github-actions bot added the stale label Jul 15, 2022
@OleksandrBerchenko
Copy link
Contributor Author

Yes, it's still actual.

@github-actions github-actions bot removed the stale label Jul 15, 2022
@issue-triage-workflows
Copy link

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.

@OleksandrBerchenko
Copy link
Contributor Author

Yes, it's still actual.

@issue-triage-workflows
Copy link

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.

@OleksandrBerchenko
Copy link
Contributor Author

Yes, it's still actual.

@prbreezy
Copy link

I'm having the same issue.

@issue-triage-workflows
Copy link

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.

@OleksandrBerchenko
Copy link
Contributor Author

Yes, it's still actual.

@issue-triage-workflows
Copy link

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.

@OleksandrBerchenko
Copy link
Contributor Author

Yes, it's still actual.

@prbreezy
Copy link

prbreezy commented Dec 12, 2023 via email

@issue-triage-workflows
Copy link

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.

@prbreezy
Copy link

prbreezy commented Mar 11, 2024 via email

@OleksandrBerchenko
Copy link
Contributor Author

Yes, it's still actual.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants