Z-Wave Device Registry Support (#17291)

* Add device_registry support for sensor and switch domains

* Add device_registry support for light

* Add device registry to binary_sensor, climate, cover

* Add device registry to zwave fan

* Fix test for config entry loading

* lint

* revert erroneous modification

* Revert device_registry.py change
This commit is contained in:
Charles Garwood authored and Paulus Schoutsen committed 2018-10-16 14:58:25 +02:00
1 parent c6d9ceca63
commit 9c52a3ce22
10 files changed
+189 -31

No files matched your search

+20 -3
View File
@@ -6,13 +6,30 @@ https://home-assistant.io/components/switch.zwave/
"""
import logging
import time
from homeassistant.core import callback
from homeassistant.components.switch import DOMAIN, SwitchDevice
from homeassistant.components import zwave
from homeassistant.components.zwave import workaround, async_setup_platform # noqa pylint: disable=unused-import
from homeassistant.helpers.dispatcher import async_dispatcher_connect
_LOGGER = logging.getLogger(__name__)
async def async_setup_platform(hass, config, async_add_entities,
discovery_info=None):
"""Old method of setting up Z-Wave switches."""
pass
async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up Z-Wave Switch from Config Entry."""
@callback
def async_add_switch(switch):
"""Add Z-Wave Switch."""
async_add_entities([switch])
async_dispatcher_connect(hass, 'zwave_new_switch', async_add_switch)
def get_device(values, **kwargs):
"""Create zwave entity device."""
return ZwaveSwitch(values)
@@ -25,8 +42,8 @@ class ZwaveSwitch(zwave.ZWaveDeviceEntity, SwitchDevice):
"""Initialize the Z-Wave switch device."""
zwave.ZWaveDeviceEntity.__init__(self, values, DOMAIN)
self.refresh_on_update = (
workaround.get_device_mapping(values.primary) ==
workaround.WORKAROUND_REFRESH_NODE_ON_UPDATE)
zwave.workaround.get_device_mapping(values.primary) ==
zwave.workaround.WORKAROUND_REFRESH_NODE_ON_UPDATE)
self.last_update = time.perf_counter()
self._state = self.values.primary.data