From dedd1aec8c75d1c9c364bdeda3420d4b31a020db Mon Sep 17 00:00:00 2001 From: rhadamantys <46837767+rhadamantys@users.noreply.github.com> Date: Tue, 31 Dec 2019 14:48:31 +0100 Subject: [PATCH] Add support for Somfy RTS power socket and Somfy io Temperature sensor (#30053) * Added support for Somfy RTS wireless power socket and Somfy Temperature Sensore Thermos Wirefree io * Added code formatting fixes for commit 5faaf9c * added support for RollerShutterRTSComponent from Somfy * Added support for RTS roller shutter in set_cover_position * Add support for Somfy RTS power socket and Somfy io temperature sensor * black and isort fixes --- homeassistant/components/tahoma/__init__.py | 2 ++ homeassistant/components/tahoma/sensor.py | 11 ++++++++--- homeassistant/components/tahoma/switch.py | 11 ++++++++--- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/tahoma/__init__.py b/homeassistant/components/tahoma/__init__.py index 640cc6418d0..6bb4fc200af 100644 --- a/homeassistant/components/tahoma/__init__.py +++ b/homeassistant/components/tahoma/__init__.py @@ -45,6 +45,7 @@ TAHOMA_TYPES = { "io:RollerShutterWithLowSpeedManagementIOComponent": "cover", "io:SomfyBasicContactIOSystemSensor": "sensor", "io:SomfyContactIOSystemSensor": "sensor", + "io:TemperatureIOSystemSensor": "sensor", "io:VerticalExteriorAwningIOComponent": "cover", "io:VerticalInteriorBlindVeluxIOComponent": "cover", "io:WindowOpenerVeluxIOComponent": "cover", @@ -59,6 +60,7 @@ TAHOMA_TYPES = { "rts:ExteriorVenetianBlindRTSComponent": "cover", "rts:GarageDoor4TRTSComponent": "switch", "rts:RollerShutterRTSComponent": "cover", + "rts:OnOffRTSComponent": "switch", "rts:VenetianBlindRTSComponent": "cover", } diff --git a/homeassistant/components/tahoma/sensor.py b/homeassistant/components/tahoma/sensor.py index 5279b160d9c..85ccb55761d 100644 --- a/homeassistant/components/tahoma/sensor.py +++ b/homeassistant/components/tahoma/sensor.py @@ -2,7 +2,7 @@ from datetime import timedelta import logging -from homeassistant.const import ATTR_BATTERY_LEVEL +from homeassistant.const import ATTR_BATTERY_LEVEL, TEMP_CELSIUS from homeassistant.helpers.entity import Entity from . import DOMAIN as TAHOMA_DOMAIN, TahomaDevice @@ -40,8 +40,8 @@ class TahomaSensor(TahomaDevice, Entity): @property def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" - if self.tahoma_device.type == "Temperature Sensor": - return None + if self.tahoma_device.type == "io:TemperatureIOSystemSensor": + return TEMP_CELSIUS if self.tahoma_device.type == "io:SomfyContactIOSystemSensor": return None if self.tahoma_device.type == "io:SomfyBasicContactIOSystemSensor": @@ -79,6 +79,11 @@ class TahomaSensor(TahomaDevice, Entity): if self.tahoma_device.type == "rtds:RTDSMotionSensor": self.current_value = self.tahoma_device.active_states["core:OccupancyState"] self._available = True + if self.tahoma_device.type == "io:TemperatureIOSystemSensor": + self.current_value = round( + float(self.tahoma_device.active_states["core:TemperatureState"]), 1 + ) + self._available = True _LOGGER.debug("Update %s, value: %d", self._name, self.current_value) diff --git a/homeassistant/components/tahoma/switch.py b/homeassistant/components/tahoma/switch.py index a0a95ab47ce..1612120f313 100644 --- a/homeassistant/components/tahoma/switch.py +++ b/homeassistant/components/tahoma/switch.py @@ -45,9 +45,14 @@ class TahomaSwitch(TahomaDevice, SwitchDevice): else: self._state = STATE_OFF - self._available = bool( - self.tahoma_device.active_states.get("core:StatusState") == "available" - ) + # A RTS power socket doesn't have a feedback channel, + # so we must assume the socket is available. + if self.tahoma_device.type == "rts:OnOffRTSComponent": + self._available = True + else: + self._available = bool( + self.tahoma_device.active_states.get("core:StatusState") == "available" + ) _LOGGER.debug("Update %s, state: %s", self._name, self._state)