Bugfixes random (#2270)
* Fix Z-Wave autoheal network * Make config_per_platform handle bad config betterpull/2281/head
parent
35dd3b8d0d
commit
bc78997bbd
|
@ -214,12 +214,6 @@ def setup(hass, config):
|
||||||
config_path=config[DOMAIN].get('config_path',
|
config_path=config[DOMAIN].get('config_path',
|
||||||
default_zwave_config_path),)
|
default_zwave_config_path),)
|
||||||
|
|
||||||
# Setup autoheal
|
|
||||||
if autoheal:
|
|
||||||
_LOGGER.info("ZWave network autoheal is enabled.")
|
|
||||||
track_time_change(hass, lambda: heal_network(None),
|
|
||||||
hour=0, minute=0, second=0)
|
|
||||||
|
|
||||||
options.set_console_output(use_debug)
|
options.set_console_output(use_debug)
|
||||||
options.lock()
|
options.lock()
|
||||||
|
|
||||||
|
@ -291,24 +285,24 @@ def setup(hass, config):
|
||||||
dispatcher.connect(
|
dispatcher.connect(
|
||||||
scene_activated, ZWaveNetwork.SIGNAL_SCENE_EVENT, weak=False)
|
scene_activated, ZWaveNetwork.SIGNAL_SCENE_EVENT, weak=False)
|
||||||
|
|
||||||
def add_node(event):
|
def add_node(service):
|
||||||
"""Switch into inclusion mode."""
|
"""Switch into inclusion mode."""
|
||||||
NETWORK.controller.begin_command_add_device()
|
NETWORK.controller.begin_command_add_device()
|
||||||
|
|
||||||
def remove_node(event):
|
def remove_node(service):
|
||||||
"""Switch into exclusion mode."""
|
"""Switch into exclusion mode."""
|
||||||
NETWORK.controller.begin_command_remove_device()
|
NETWORK.controller.begin_command_remove_device()
|
||||||
|
|
||||||
def heal_network(event):
|
def heal_network(service):
|
||||||
"""Heal the network."""
|
"""Heal the network."""
|
||||||
_LOGGER.info("ZWave heal running.")
|
_LOGGER.info("ZWave heal running.")
|
||||||
NETWORK.heal()
|
NETWORK.heal()
|
||||||
|
|
||||||
def soft_reset(event):
|
def soft_reset(service):
|
||||||
"""Soft reset the controller."""
|
"""Soft reset the controller."""
|
||||||
NETWORK.controller.soft_reset()
|
NETWORK.controller.soft_reset()
|
||||||
|
|
||||||
def test_network(event):
|
def test_network(service):
|
||||||
"""Test the network by sending commands to all the nodes."""
|
"""Test the network by sending commands to all the nodes."""
|
||||||
NETWORK.test()
|
NETWORK.test()
|
||||||
|
|
||||||
|
@ -324,7 +318,7 @@ def setup(hass, config):
|
||||||
# Wait up to NETWORK_READY_WAIT_SECS seconds for the zwave network
|
# Wait up to NETWORK_READY_WAIT_SECS seconds for the zwave network
|
||||||
# to be ready.
|
# to be ready.
|
||||||
for i in range(NETWORK_READY_WAIT_SECS):
|
for i in range(NETWORK_READY_WAIT_SECS):
|
||||||
_LOGGER.info(
|
_LOGGER.debug(
|
||||||
"network state: %d %s", NETWORK.state, NETWORK.state_str)
|
"network state: %d %s", NETWORK.state, NETWORK.state_str)
|
||||||
if NETWORK.state >= NETWORK.STATE_AWAKED:
|
if NETWORK.state >= NETWORK.STATE_AWAKED:
|
||||||
_LOGGER.info("zwave ready after %d seconds", i)
|
_LOGGER.info("zwave ready after %d seconds", i)
|
||||||
|
@ -355,6 +349,11 @@ def setup(hass, config):
|
||||||
hass.services.register(DOMAIN, SERVICE_SOFT_RESET, soft_reset)
|
hass.services.register(DOMAIN, SERVICE_SOFT_RESET, soft_reset)
|
||||||
hass.services.register(DOMAIN, SERVICE_TEST_NETWORK, test_network)
|
hass.services.register(DOMAIN, SERVICE_TEST_NETWORK, test_network)
|
||||||
|
|
||||||
|
# Setup autoheal
|
||||||
|
if autoheal:
|
||||||
|
_LOGGER.info("ZWave network autoheal is enabled.")
|
||||||
|
track_time_change(hass, heal_network, hour=0, minute=0, second=0)
|
||||||
|
|
||||||
hass.bus.listen_once(EVENT_HOMEASSISTANT_START, start_zwave)
|
hass.bus.listen_once(EVENT_HOMEASSISTANT_START, start_zwave)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -40,7 +40,11 @@ def config_per_platform(config, domain):
|
||||||
platform_config = [platform_config]
|
platform_config = [platform_config]
|
||||||
|
|
||||||
for item in platform_config:
|
for item in platform_config:
|
||||||
platform = None if item is None else item.get(CONF_PLATFORM)
|
try:
|
||||||
|
platform = item.get(CONF_PLATFORM)
|
||||||
|
except AttributeError:
|
||||||
|
platform = None
|
||||||
|
|
||||||
yield platform, item
|
yield platform, item
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
"""Test component helpers."""
|
"""Test component helpers."""
|
||||||
# pylint: disable=protected-access,too-many-public-methods
|
# pylint: disable=protected-access,too-many-public-methods
|
||||||
|
from collections import OrderedDict
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from homeassistant import helpers
|
from homeassistant import helpers
|
||||||
|
@ -30,3 +31,19 @@ class TestHelpers(unittest.TestCase):
|
||||||
|
|
||||||
self.assertEqual(set(['zone', 'zone Hallo', 'zone 100']),
|
self.assertEqual(set(['zone', 'zone Hallo', 'zone 100']),
|
||||||
set(helpers.extract_domain_configs(config, 'zone')))
|
set(helpers.extract_domain_configs(config, 'zone')))
|
||||||
|
|
||||||
|
def test_config_per_platform(self):
|
||||||
|
"""Test config per platform method."""
|
||||||
|
config = OrderedDict([
|
||||||
|
('zone', {'platform': 'hello'}),
|
||||||
|
('zoner', None),
|
||||||
|
('zone Hallo', [1, {'platform': 'hello 2'}]),
|
||||||
|
('zone 100', None),
|
||||||
|
])
|
||||||
|
|
||||||
|
assert [
|
||||||
|
('hello', config['zone']),
|
||||||
|
(None, 1),
|
||||||
|
('hello 2', config['zone Hallo'][1]),
|
||||||
|
(None, None)
|
||||||
|
] == list(helpers.config_per_platform(config, 'zone'))
|
||||||
|
|
Loading…
Reference in New Issue