From c191c13f3acb52126c77872f17e77d4107817cf0 Mon Sep 17 00:00:00 2001 From: Rasmus Date: Thu, 26 Oct 2017 15:54:50 +0200 Subject: [PATCH] Telldus Live: Device without methods is a binary sensor (#10106) Telldus Live reports binary sensors as devices without methods. --- .../components/binary_sensor/tellduslive.py | 34 +++++++++++++++++++ homeassistant/components/tellduslive.py | 2 ++ 2 files changed, 36 insertions(+) create mode 100644 homeassistant/components/binary_sensor/tellduslive.py diff --git a/homeassistant/components/binary_sensor/tellduslive.py b/homeassistant/components/binary_sensor/tellduslive.py new file mode 100644 index 00000000000..e5d2d83fe47 --- /dev/null +++ b/homeassistant/components/binary_sensor/tellduslive.py @@ -0,0 +1,34 @@ +""" +Support for binary sensors using Tellstick Net. + +This platform uses the Telldus Live online service. + +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/binary_sensor.tellduslive/ + +""" +import logging + +from homeassistant.components.tellduslive import TelldusLiveEntity +from homeassistant.components.binary_sensor import BinarySensorDevice + +_LOGGER = logging.getLogger(__name__) + + +def setup_platform(hass, config, add_devices, discovery_info=None): + """Set up Tellstick sensors.""" + if discovery_info is None: + return + add_devices( + TelldusLiveSensor(hass, binary_sensor) + for binary_sensor in discovery_info + ) + + +class TelldusLiveSensor(TelldusLiveEntity, BinarySensorDevice): + """Representation of a Tellstick sensor.""" + + @property + def is_on(self): + """Return true if switch is on.""" + return self.device.is_on diff --git a/homeassistant/components/tellduslive.py b/homeassistant/components/tellduslive.py index 1f2b3720062..a0e1efbd75c 100644 --- a/homeassistant/components/tellduslive.py +++ b/homeassistant/components/tellduslive.py @@ -117,6 +117,8 @@ class TelldusLiveClient(object): return 'cover' elif device.methods & TURNON: return 'switch' + elif device.methods == 0: + return 'binary_sensor' _LOGGER.warning( "Unidentified device type (methods: %d)", device.methods) return 'switch'