Skip to content

Update Ring to 0.6.0#30748

Merged
balloob merged 7 commits into
devfrom
update-ring-2
Jan 14, 2020
Merged

Update Ring to 0.6.0#30748
balloob merged 7 commits into
devfrom
update-ring-2

Conversation

@balloob
Copy link
Copy Markdown
Member

@balloob balloob commented Jan 14, 2020

Description:

  • Ring dependency has been updated to 0.6.0 which significantly reduces the number of requests.
  • Tweak update code in Home Assistant to reduce number of requests
  • Support multiple Ring accounts
  • Add device classes to sensors
  • Fix device identifiers and model names

Thanks to @arsaboo for allowing me to use his account for testing.

Added myself as code owner because at this point, well 🤷‍♂

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

@dshokouhi
Copy link
Copy Markdown
Member

Tested this PR and all expected entities get loaded properly including the cameras. I am still facing the issue where binary sensors are not updating but the other sensors for the device is updating. I am willing to share my account as well if it helps to troubleshoot this issue. I know @arsaboo is not experiencing this issue but based on this issue it seems I am not alone: python-ring-doorbell/python-ring-doorbell#177

@dshokouhi
Copy link
Copy Markdown
Member

If it is helpful I am also willing to share my account. I have 4 ring camera devices and also the ring smart lighting system which is not supported by HA yet. Please get in touch with me on discord :)

@tchellomello
Copy link
Copy Markdown
Contributor

@dshokouhi I'm going to test it tonight and report it back.

Comment thread homeassistant/components/ring/__init__.py Outdated
Comment thread homeassistant/components/ring/binary_sensor.py Outdated
Comment thread homeassistant/components/ring/binary_sensor.py Outdated
Comment thread homeassistant/components/ring/camera.py Outdated
Comment thread homeassistant/components/ring/camera.py Outdated
Comment thread homeassistant/components/ring/light.py Outdated
Comment thread homeassistant/components/ring/sensor.py Outdated
Comment thread homeassistant/components/ring/sensor.py Outdated
Comment thread homeassistant/components/ring/sensor.py
Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@balloob balloob requested a review from a team as a code owner January 14, 2020 19:32
logger.warning,
"Setup of platform %s is taking over %s seconds.",
"Setup of %s platform %s is taking over %s seconds.",
self.domain,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this change be included in this PR?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I could open a new PR, but I used it here, so thought I would just include it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. It's not our regular practice, so I wanted to make sure it wasn't a change that was committed by accident.

self.hass = hass
self.cache = {}

async def async_get_history(self, config_entry_id, device):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this better than using a dict cache and our Throttle helper to throttle updating the cache?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, because with the Throttle decorator, if a call is in process, it will return None instead of waiting for the call to finish.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So at worst we would then get 10 second stale data?

What kind of data is this?

Copy link
Copy Markdown
Member Author

@balloob balloob Jan 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last 10 events for a device.

Throttle returns None, not the data. The implementation would become then data.update(); handle(data.data)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that if this approach seems to work, we might want to turn that into a generic asyncio throttle function. We do a similar thing in Hue.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's still not clear to me why a central update and cache with signals telling the entities to update would be worse than this central update with a timed cache where entities pull data, in this situation.

The entities per device that are involved are fixed, except for the camera where only cameras that have subscription are added. So there won't be less or more entities per device pulling data except for the camera case. Maybe the camera entity is the reason?

My point is, that if we know what devices we have and nothing about the features of those devices changes, we should be able to update all devices regardless of platforms.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh my bad. I thought you asked why not use X, instead of how does it work with the existing dispatch update that Ring uses.

So I don't have a good reason. And it is indeed kinda complicated now. We now have a health tracker that has an opt-in signal. We could have used the same approach for history. hmm.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Want to rewrite it ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's ok like this. I mostly want to understand the reasons for the different designs so I know when to recommend what approach. And I like as few choices as possible for my recommendations.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about my last comment tone. I meant to say want ME to rewrite it.

I thought about it more and I'll do one more pass cleaning up data fetching. I can do better here.

@balloob
Copy link
Copy Markdown
Member Author

balloob commented Jan 14, 2020

Going to merge this now so I can cut the beta and go for lunch. I will fix any comments that come up.

@balloob balloob merged commit c4673dd into dev Jan 14, 2020
@delete-merged-branch delete-merged-branch Bot deleted the update-ring-2 branch January 14, 2020 20:54
balloob added a commit that referenced this pull request Jan 14, 2020
* Update Ring to 0.6.0

* Update sensor tests

* update -> async_update

* Delete temp files

* Address comments

* Final tweaks

* Remove stale print
raman325 added a commit to raman325/home-assistant that referenced this pull request Jan 15, 2020
* upstream/dev: (82 commits)
  Add support for vacuums to Alexa. (home-assistant#30764)
  Refactor Ring data handling (home-assistant#30777)
  Restore unit_of_measurement from entity registry (home-assistant#30780)
  Update pyubee to 0.8 (home-assistant#30785)
  Update emulated_roku to 0.1.9 (home-assistant#30791)
  Add Config Flow support, Device Registry support, available property to vizio component (home-assistant#30653)
  Allow input_* and timer component setup without config (home-assistant#30772)
  Search: Add search to default config and don't resolve area (home-assistant#30762)
  [ci skip] Translation update
  Use storage based collections for Timer platform (home-assistant#30765)
  Upgrade youtube_dl to version 2020.01.15 (home-assistant#30767)
  Whitelist Frenck for release
  Hass.io allow to reset password with CLI (home-assistant#30755)
  Revert home-assistant#29701 (home-assistant#30766)
  Add Safe Mode (home-assistant#30723)
  Update Ring to 0.6.0 (home-assistant#30748)
  Add support for the voltage sensor on the greeneye GEM (home-assistant#30484)
  Fix supported_features in MQTT fan (home-assistant#28680)
  Fix small typo in alarmdotcom component (home-assistant#30758)
  bump aiokef to 0.2.5 which uses locks (home-assistant#30753)
  ...
@lock lock Bot locked and limited conversation to collaborators Jan 16, 2020
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.

5 participants