Additional ZWave coverage (#7024)

* Additional ZWave coverage

* setup_platform tests
This commit is contained in:
Adam Mills authored and GitHub committed 2017-04-10 16:11:39 -04:00
1 parent 05eb73a0e3
commit ee988dc884
2 files changed
+105 -11

No files matched your search

+9 -7
View File
@@ -13,6 +13,7 @@ from pprint import pprint
import voluptuous as vol
from homeassistant.core import CoreState
from homeassistant.loader import get_platform
from homeassistant.helpers import discovery
from homeassistant.helpers.entity_component import EntityComponent
@@ -201,14 +202,15 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Generic Z-Wave platform setup."""
if discovery_info is None or NETWORK is None:
return False
device = hass.data[DATA_ZWAVE_DICT].pop(
discovery_info[const.DISCOVERY_DEVICE])
if device:
async_add_devices([device])
return True
else:
discovery_info[const.DISCOVERY_DEVICE], None)
if device is None:
return False
async_add_devices([device])
return True
# pylint: disable=R0914
def setup(hass, config):
@@ -258,7 +260,7 @@ def setup(hass, config):
NETWORK = ZWaveNetwork(options, autostart=False)
hass.data[DATA_ZWAVE_DICT] = {}
if use_debug:
if use_debug: # pragma: no cover
def log_all(signal, value=None):
"""Log all the signals."""
print("")
@@ -388,7 +390,7 @@ def setup(hass, config):
"""Stop Z-Wave network."""
_LOGGER.info("Stopping ZWave network.")
NETWORK.stop()
if hass.state == 'RUNNING':
if hass.state == CoreState.running:
hass.bus.fire(const.EVENT_NETWORK_STOP)
def rename_node(service):