Zwave import fixes for stability (#1845)

This commit is contained in:
John Arild Berentsen 2016-04-17 23:46:51 +02:00 committed by Paulus Schoutsen
parent ea38742067
commit b45c0cd735
5 changed files with 43 additions and 55 deletions

View file

@ -9,25 +9,23 @@ https://home-assistant.io/components/light.zwave/
from threading import Timer
from homeassistant.components.light import ATTR_BRIGHTNESS, DOMAIN, Light
from homeassistant.components.zwave import (
ATTR_NODE_ID, ATTR_VALUE_ID, COMMAND_CLASS_SWITCH_MULTILEVEL, GENRE_USER,
NETWORK, TYPE_BYTE, ZWaveDeviceEntity)
from homeassistant.components import zwave
from homeassistant.const import STATE_OFF, STATE_ON
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Find and add Z-Wave lights."""
if discovery_info is None or NETWORK is None:
if discovery_info is None or zwave.NETWORK is None:
return
node = NETWORK.nodes[discovery_info[ATTR_NODE_ID]]
value = node.values[discovery_info[ATTR_VALUE_ID]]
node = zwave.NETWORK.nodes[discovery_info[zwave.ATTR_NODE_ID]]
value = node.values[discovery_info[zwave.ATTR_VALUE_ID]]
if value.command_class != COMMAND_CLASS_SWITCH_MULTILEVEL:
if value.command_class != zwave.COMMAND_CLASS_SWITCH_MULTILEVEL:
return
if value.type != TYPE_BYTE:
if value.type != zwave.TYPE_BYTE:
return
if value.genre != GENRE_USER:
if value.genre != zwave.GENRE_USER:
return
value.set_change_verified(False)
@ -42,7 +40,7 @@ def brightness_state(value):
return 255, STATE_OFF
class ZwaveDimmer(ZWaveDeviceEntity, Light):
class ZwaveDimmer(zwave.ZWaveDeviceEntity, Light):
"""Representation of a Z-Wave dimmer."""
# pylint: disable=too-many-arguments
@ -51,7 +49,7 @@ class ZwaveDimmer(ZWaveDeviceEntity, Light):
from openzwave.network import ZWaveNetwork
from pydispatch import dispatcher
ZWaveDeviceEntity.__init__(self, value, DOMAIN)
zwave.ZWaveDeviceEntity.__init__(self, value, DOMAIN)
self._brightness, self._state = brightness_state(value)