Use skip_configuration flag to skip requests in ZHA (#41554)

* 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
This commit is contained in:
Abílio Costa 2020-10-17 01:03:35 +01:00 committed by GitHub
parent c29f613b1d
commit 28fb761b01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 6 deletions

View File

@ -200,6 +200,10 @@ class ZigbeeChannel(LogMixin):
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:

View File

@ -89,11 +89,12 @@ class BasicChannel(ZigbeeChannel):
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):

View File

@ -401,7 +401,7 @@ class ZHADevice(LogMixin):
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
)