Axis discovery updates host address (#22632)

* Discovery can update host on existing entries

* Add support in device to update host on entry update

* Fix tests and listener

* Fix hound comment

* Fix failing tests from cleanup
This commit is contained in:
Robert Svensson authored and Paulus Schoutsen committed 2019-04-02 11:13:11 -07:00
1 parent 6c14e7afa7
commit 8a0b210f87
7 files changed
+104 -49

No files matched your search

+7 -9
View File
@@ -4,11 +4,10 @@ import voluptuous as vol
from homeassistant import config_entries
from homeassistant.const import (
CONF_DEVICE, CONF_HOST, CONF_NAME, CONF_TRIGGER_TIME,
EVENT_HOMEASSISTANT_STOP)
CONF_DEVICE, CONF_NAME, CONF_TRIGGER_TIME, EVENT_HOMEASSISTANT_STOP)
from homeassistant.helpers import config_validation as cv
from .config_flow import configured_devices, DEVICE_SCHEMA
from .config_flow import DEVICE_SCHEMA
from .const import CONF_CAMERA, CONF_EVENTS, DEFAULT_TRIGGER_TIME, DOMAIN
from .device import AxisNetworkDevice, get_device
@@ -21,18 +20,17 @@ CONFIG_SCHEMA = vol.Schema({
async def async_setup(hass, config):
"""Set up for Axis devices."""
if DOMAIN in config:
if not hass.config_entries.async_entries(DOMAIN) and DOMAIN in config:
for device_name, device_config in config[DOMAIN].items():
if CONF_NAME not in device_config:
device_config[CONF_NAME] = device_name
if device_config[CONF_HOST] not in configured_devices(hass):
hass.async_create_task(hass.config_entries.flow.async_init(
DOMAIN, context={'source': config_entries.SOURCE_IMPORT},
data=device_config
))
hass.async_create_task(hass.config_entries.flow.async_init(
DOMAIN, context={'source': config_entries.SOURCE_IMPORT},
data=device_config
))
return True