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

Fix HomeMatic availability detection #17341

Merged
merged 4 commits into from
Oct 15, 2018
Merged

Fix HomeMatic availability detection #17341

merged 4 commits into from
Oct 15, 2018

Conversation

danielperna84
Copy link
Contributor

@danielperna84 danielperna84 commented Oct 11, 2018

Description:

Currently the transition from unavailable to available for devices that are offline during startup doesn't work reliably. pyhomematic handles the availability state internally though, and this change makes use of that. This should have been fixed with #16202, but for some reason it still didn't work.

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass

@pvizeli
Copy link
Member

pvizeli commented Oct 12, 2018

That was my origin code. The problem is, that the library don't update this flag internal. I never found out why. Do you test that local?

This current code work also only if the device send data otherwise it stay unavailability.

If that now work, it would be the best solution instead my workaround

@danielperna84
Copy link
Contributor Author

danielperna84 commented Oct 12, 2018

The problem is, that the library don't update this flag internal

It actually does. At least in the following scenario the change in this PR works as intended:

  1. Stop HASS
  2. Remove Battery from Wall Thermostat
  3. Control Thermostat from CCU (the generates the Kommunikationsstörung message -> unreachable)
  4. Start HASS
  5. Entity gets created, but as unavailable
  6. Plug in Battery into device
  7. Event: UNREACH: False gets distributed
  8. pyhomematics internal callback sets hmdevice._unreach to False
  9. Any event for that device leads to comparing the HASS-availability to the pyhomematic-state, which turns the HASS entity to available.

Before my change this did not work. I can't easily test the opposite direction. Removing the battery doesn't send the UNREACH event (at least not within the 2 minutes I have waited). But in another issue at pyhomematic a user reports his IP device turning unavailable when switching it (because of exhausted duty cycle). So I assume he will actually see the UNREACH: True event. So the test would be, if for him this also sets the HASS entity to not available.

In any case this is an improvement (for me) because devices that were unavailble at startup eventually go online later on. Until now they would stay offline until I restart HASS.

@danielperna84 danielperna84 merged commit 9718a17 into home-assistant:dev Oct 15, 2018
@ghost ghost removed the in progress label Oct 15, 2018
@danielperna84 danielperna84 deleted the homematic_availability branch October 15, 2018 18:34
@balloob balloob mentioned this pull request Oct 26, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Feb 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants