diff --git a/homeassistant/components/thinkingcleaner/sensor.py b/homeassistant/components/thinkingcleaner/sensor.py index 26175b5368a..724ed54e4da 100644 --- a/homeassistant/components/thinkingcleaner/sensor.py +++ b/homeassistant/components/thinkingcleaner/sensor.py @@ -2,10 +2,13 @@ from datetime import timedelta import logging -from pythinkingcleaner import Discovery +from pythinkingcleaner import Discovery, ThinkingCleaner +import voluptuous as vol from homeassistant import util -from homeassistant.const import UNIT_PERCENTAGE +from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.const import CONF_HOST, UNIT_PERCENTAGE +import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -46,12 +49,18 @@ STATES = { "st_unknown": "Unknown state", } +PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({vol.Optional(CONF_HOST): cv.string}) + def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the ThinkingCleaner platform.""" - discovery = Discovery() - devices = discovery.discover() + host = config.get(CONF_HOST) + if host: + devices = [ThinkingCleaner(host, "unknown")] + else: + discovery = Discovery() + devices = discovery.discover() @util.Throttle(MIN_TIME_BETWEEN_SCANS, MIN_TIME_BETWEEN_FORCED_SCANS) def update_devices(): diff --git a/homeassistant/components/thinkingcleaner/switch.py b/homeassistant/components/thinkingcleaner/switch.py index 88d87e4e5fe..172951ed1ef 100644 --- a/homeassistant/components/thinkingcleaner/switch.py +++ b/homeassistant/components/thinkingcleaner/switch.py @@ -3,10 +3,13 @@ from datetime import timedelta import logging import time -from pythinkingcleaner import Discovery +from pythinkingcleaner import Discovery, ThinkingCleaner +import voluptuous as vol from homeassistant import util -from homeassistant.const import STATE_OFF, STATE_ON +from homeassistant.components.switch import PLATFORM_SCHEMA +from homeassistant.const import CONF_HOST, STATE_OFF, STATE_ON +import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity import ToggleEntity _LOGGER = logging.getLogger(__name__) @@ -23,12 +26,17 @@ SWITCH_TYPES = { "find": ["Find", None, None], } +PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({vol.Optional(CONF_HOST): cv.string}) + def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the ThinkingCleaner platform.""" - - discovery = Discovery() - devices = discovery.discover() + host = config.get(CONF_HOST) + if host: + devices = [ThinkingCleaner(host, "unknown")] + else: + discovery = Discovery() + devices = discovery.discover() @util.Throttle(MIN_TIME_BETWEEN_SCANS, MIN_TIME_BETWEEN_FORCED_SCANS) def update_devices():