Skip to content

Commit

Permalink
Use skip_configuration flag to skip requests in ZHA
Browse files Browse the repository at this point in the history
  • Loading branch information
abmantis committed Oct 7, 2020
1 parent 85e541b commit 77f9e5e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
7 changes: 5 additions & 2 deletions homeassistant/components/zha/core/channels/base.py
Expand Up @@ -6,9 +6,8 @@
import logging
from typing import Any, Union

import zigpy.exceptions

from homeassistant.core import callback
import zigpy.exceptions

from .. import typing as zha_typing
from ..const import (
Expand Down Expand Up @@ -200,6 +199,10 @@ async def async_configure(self):

async def async_initialize(self, from_cache):
"""Initialize channel."""
if 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
Expand Up @@ -88,11 +88,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:
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
15 changes: 7 additions & 8 deletions homeassistant/components/zha/core/device.py
Expand Up @@ -7,20 +7,19 @@
import time
from typing import Any, Dict

from zigpy import types
import zigpy.exceptions
from zigpy.profiles import PROFILES
import zigpy.quirks
from zigpy.zcl.clusters.general import Groups
import zigpy.zdo.types as zdo_types

from homeassistant.core import callback
from homeassistant.helpers.dispatcher import (
async_dispatcher_connect,
async_dispatcher_send,
)
from homeassistant.helpers.event import async_track_time_interval
from homeassistant.helpers.typing import HomeAssistantType
from zigpy import types
import zigpy.exceptions
from zigpy.profiles import PROFILES
import zigpy.quirks
from zigpy.zcl.clusters.general import Groups
import zigpy.zdo.types as zdo_types

from . import channels, typing as zha_typing
from .const import (
Expand Down Expand Up @@ -401,7 +400,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 77f9e5e

Please sign in to comment.