Skip to content

Commit

Permalink
Use skip_configuration flag to skip requests in ZHA (home-assistant#4…
Browse files Browse the repository at this point in the history
…1554)

* Remove duplicated attribute request from ZHA

The on_off attribute is on the REPORT_CONFIG, so
super().async_initialize already requests it from the device.
No need to request it twice.

* Use skip_configuration flag to skip requests in ZHA

* Fix loading from cache

* Fix loading from cache condition
  • Loading branch information
abmantis authored Oct 17, 2020
1 parent c29f613 commit 28fb761
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 4 additions & 0 deletions homeassistant/components/zha/core/channels/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ async def async_configure(self):

async def async_initialize(self, from_cache):
"""Initialize channel."""
if not from_cache and self._ch_pool.skip_configuration:
self._status = ChannelStatus.INITIALIZED
return

self.debug("initializing channel: from_cache: %s", from_cache)
attributes = []
for report_config in self._report_config:
Expand Down
11 changes: 6 additions & 5 deletions homeassistant/components/zha/core/channels/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,12 @@ async def async_configure(self):

async def async_initialize(self, from_cache):
"""Initialize channel."""
power_source = await self.get_attribute_value(
"power_source", from_cache=from_cache
)
if power_source is not None:
self._power_source = power_source
if not self._ch_pool.skip_configuration or from_cache:
power_source = await self.get_attribute_value(
"power_source", from_cache=from_cache
)
if power_source is not None:
self._power_source = power_source
await super().async_initialize(from_cache)

def get_power_source(self):
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/zha/core/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ async def async_configure(self):
entry = self.gateway.zha_storage.async_create_or_update_device(self)
self.debug("stored in registry: %s", entry)

if self._channels.identify_ch is not None:
if self._channels.identify_ch is not None and not self.skip_configuration:
await self._channels.identify_ch.trigger_effect(
EFFECT_OKAY, EFFECT_DEFAULT_VARIANT
)
Expand Down

0 comments on commit 28fb761

Please sign in to comment.