Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZHA fixes #21592

Merged
merged 4 commits into from
Mar 2, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add lifeline to lights
  • Loading branch information
dmulcahey committed Mar 2, 2019
commit 4ce772991bd4c3f30995591a1c7402eb67c925d2
7 changes: 7 additions & 0 deletions homeassistant/components/zha/core/channels/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ async def async_initialize(self, from_cache):
await self.get_attribute_value(self.ON_OFF, from_cache=from_cache))
await super().async_initialize(from_cache)

async def async_update(self):
"""Initialize channel."""
_LOGGER.debug("Attempting to update onoff state")
self._state = bool(
await self.get_attribute_value(self.ON_OFF, from_cache=False))
await super().async_update()


class LevelControlChannel(ZigbeeChannel):
"""Channel for the LevelControl Zigbee cluster."""
Expand Down
10 changes: 10 additions & 0 deletions homeassistant/components/zha/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
For more details on this platform, please refer to the documentation
at https://home-assistant.io/components/light.zha/
"""
from datetime import timedelta
import logging

from homeassistant.components import light
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.event import async_track_time_interval
import homeassistant.util.color as color_util
from .const import (
DATA_ZHA, DATA_ZHA_DISPATCHERS, ZHA_DISCOVERY_NEW, COLOR_CHANNEL,
Expand All @@ -26,6 +28,7 @@
CAPABILITIES_COLOR_TEMP = 0x10

UNSUPPORTED_ATTRIBUTE = 0x86
LIFELINE_INTERVAL = timedelta(minutes=10)


async def async_setup_platform(hass, config, async_add_entities,
Expand Down Expand Up @@ -148,6 +151,8 @@ async def async_added_to_hass(self):
if self._level_channel:
await self.async_accept_signal(
self._level_channel, SIGNAL_SET_LEVEL, self.set_level)
async_track_time_interval(
self.hass, self.async_lifeline, LIFELINE_INTERVAL)
Adminiuga marked this conversation as resolved.
Show resolved Hide resolved

async def async_turn_on(self, **kwargs):
"""Turn the entity on."""
Expand Down Expand Up @@ -217,3 +222,8 @@ async def async_turn_off(self, **kwargs):
return
self._state = False
self.async_schedule_update_ha_state()

async def async_lifeline(self, time):
"""Attempt to retrieve on off state from the light."""
if self._on_off_channel:
await self._on_off_channel.async_update()