mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
zwave auto heal at midnight (#2213)
* zwave auto heal at midnight * fix debug to info, running heal, any heal will send a logger event
This commit is contained in:
parent
202a8dba8e
commit
fb2fb5ea73
@ -14,6 +14,7 @@ from homeassistant.const import (
|
|||||||
ATTR_BATTERY_LEVEL, ATTR_DISCOVERED, ATTR_ENTITY_ID, ATTR_LOCATION,
|
ATTR_BATTERY_LEVEL, ATTR_DISCOVERED, ATTR_ENTITY_ID, ATTR_LOCATION,
|
||||||
ATTR_SERVICE, CONF_CUSTOMIZE, EVENT_HOMEASSISTANT_START,
|
ATTR_SERVICE, CONF_CUSTOMIZE, EVENT_HOMEASSISTANT_START,
|
||||||
EVENT_HOMEASSISTANT_STOP, EVENT_PLATFORM_DISCOVERED)
|
EVENT_HOMEASSISTANT_STOP, EVENT_PLATFORM_DISCOVERED)
|
||||||
|
from homeassistant.helpers.event import track_time_change
|
||||||
from homeassistant.util import convert, slugify
|
from homeassistant.util import convert, slugify
|
||||||
|
|
||||||
DOMAIN = "zwave"
|
DOMAIN = "zwave"
|
||||||
@ -24,6 +25,8 @@ DEFAULT_CONF_USB_STICK_PATH = "/zwaveusbstick"
|
|||||||
CONF_DEBUG = "debug"
|
CONF_DEBUG = "debug"
|
||||||
CONF_POLLING_INTERVAL = "polling_interval"
|
CONF_POLLING_INTERVAL = "polling_interval"
|
||||||
CONF_POLLING_INTENSITY = "polling_intensity"
|
CONF_POLLING_INTENSITY = "polling_intensity"
|
||||||
|
CONF_AUTOHEAL = "autoheal"
|
||||||
|
DEFAULT_CONF_AUTOHEAL = True
|
||||||
|
|
||||||
# How long to wait for the zwave network to be ready.
|
# How long to wait for the zwave network to be ready.
|
||||||
NETWORK_READY_WAIT_SECS = 30
|
NETWORK_READY_WAIT_SECS = 30
|
||||||
@ -202,6 +205,7 @@ def setup(hass, config):
|
|||||||
# Load configuration
|
# Load configuration
|
||||||
use_debug = str(config[DOMAIN].get(CONF_DEBUG)) == '1'
|
use_debug = str(config[DOMAIN].get(CONF_DEBUG)) == '1'
|
||||||
customize = config[DOMAIN].get(CONF_CUSTOMIZE, {})
|
customize = config[DOMAIN].get(CONF_CUSTOMIZE, {})
|
||||||
|
autoheal = config[DOMAIN].get(CONF_AUTOHEAL, DEFAULT_CONF_AUTOHEAL)
|
||||||
|
|
||||||
# Setup options
|
# Setup options
|
||||||
options = ZWaveOption(
|
options = ZWaveOption(
|
||||||
@ -210,6 +214,12 @@ 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,6 +301,7 @@ def setup(hass, config):
|
|||||||
|
|
||||||
def heal_network(event):
|
def heal_network(event):
|
||||||
"""Heal the network."""
|
"""Heal the network."""
|
||||||
|
_LOGGER.info("ZWave heal running.")
|
||||||
NETWORK.heal()
|
NETWORK.heal()
|
||||||
|
|
||||||
def soft_reset(event):
|
def soft_reset(event):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user