TelldusLive config flow (#18758)

* update TelldusLive to use config flow

* fixes from Martin

* Update homeassistant/components/tellduslive/config_flow.py

Co-Authored-By: fredrike <fredrik.e@gmail.com>

* revert changes in entry.py

* tox tests

* tox fixes

* woof woof (fix for hound)

* lint ignore

* unload entry

* coverall toxtests

* fix some toxtests
This commit is contained in:
Fredrik Erlandsson authored and Martin Hjelmare committed 2018-12-10 18:44:45 +01:00
1 parent f4f42176bd
commit 92e19f6001
14 files changed
+685 -235

No files matched your search

+21 -7
View File
@@ -6,11 +6,12 @@ https://home-assistant.io/components/sensor.tellduslive/
"""
import logging
from homeassistant.components import tellduslive
from homeassistant.components import sensor, tellduslive
from homeassistant.components.tellduslive.entry import TelldusLiveEntity
from homeassistant.const import (
DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_ILLUMINANCE, DEVICE_CLASS_TEMPERATURE,
TEMP_CELSIUS)
from homeassistant.helpers.dispatcher import async_dispatcher_connect
_LOGGER = logging.getLogger(__name__)
@@ -46,12 +47,25 @@ SENSOR_TYPES = {
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Tellstick sensors."""
if discovery_info is None:
return
client = hass.data[tellduslive.DOMAIN]
add_entities(
TelldusLiveSensor(client, sensor) for sensor in discovery_info)
"""Old way of setting up TelldusLive.
Can only be called when a user accidentally mentions the platform in their
config. But even in that case it would have been ignored.
"""
pass
async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up tellduslive sensors dynamically."""
async def async_discover_sensor(device_id):
"""Discover and add a discovered sensor."""
client = hass.data[tellduslive.DOMAIN]
async_add_entities([TelldusLiveSensor(client, device_id)])
async_dispatcher_connect(
hass,
tellduslive.TELLDUS_DISCOVERY_NEW.format(
sensor.DOMAIN, tellduslive.DOMAIN), async_discover_sensor)
class TelldusLiveSensor(TelldusLiveEntity):