Skip to content

Version 4.0 - Move to DataUpdateCoordinator and @property getters.  #250

@scottyphillips

Description

@scottyphillips

The DataUpdateCoordinator model centralizes polling, for our application the preexisting ECHONETConnector class is ideal.

I have started a new branch and I have refactored all entities to use the new DataUpdateCoordinator design pattern.
The big benefit is that it reduces contention, a single Echonetlite Instance is polled at a predictable 30 second interval by the coordinator, which then automatically updates all the entities that rely on data. The same goes for push notifications - as soon as they arrive any sensors that ingest that data will be updated automatically.

I have also updated all entities to use @Property values for returning data; this means as soon as there is new data, whether by polling or by push notifications, Home Assistant should update them in real time. No more stale copies of data being stored here and there, the coordinators job is to look after all that data.

https://developers.home-assistant.io/docs/integration_fetching_data#coordinated-single-api-poll-for-data-for-all-entities

  • All polling per Echonet entity is now centralized to the connector. Thanks to @nao-pon it was easy to maintain the push notification framework, so sensors continue to update in near real time if they are supported by notifications.
  • Update Cover, Fan, Light, Select, Switch, Time, Binary Sensor -> remove async_update() and callbacks from all entities
  • Provide proper @Property methods as necessary.
  • Complex transformations (eg JSON derived sensors that use "dict_key" or "lambda") use _handle_coordinator_update(self)
  • improved error handling for availability tracking of instances.
  • Test Light Entity (NOTE: Partially tested with Moekaden Room emulator)
  • Test Number Entity
  • Test Cover Entity (NOTE: Partially tested with Moekaden Room emulator)
  • Test Time Entity
  • Stretch goal - create a base entity structure to standardize device attributes such as name etc.

If you would like to help out with testing that would be much appreciated!
My goal is to merge and release within the next 2-3 weeks as a beta release.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions