From f7597f46802b6a5b24c138a3b127aeda2f51b8e8 Mon Sep 17 00:00:00 2001 From: Mick Vleeshouwer Date: Thu, 4 Jun 2020 21:22:05 +0200 Subject: [PATCH 1/3] Add async calls --- custom_components/tahoma/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/custom_components/tahoma/__init__.py b/custom_components/tahoma/__init__.py index 5a06b51cd..8a25bbf78 100644 --- a/custom_components/tahoma/__init__.py +++ b/custom_components/tahoma/__init__.py @@ -21,7 +21,7 @@ _LOGGER = logging.getLogger(__name__) -#TODO Deprecate EXCLUDE for the native method of disabling entities +# TODO Deprecate EXCLUDE for the native method of disabling entities CONFIG_SCHEMA = vol.Schema( { DOMAIN: vol.Schema( @@ -61,9 +61,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): password = entry.data[CONF_PASSWORD] try: - controller = TahomaApi(username, password) - controller.get_setup() - devices = controller.get_devices() + controller = await hass.async_add_executor_job(TahomaApi, username, password) + await hass.async_add_executor_job(controller.get_setup) + devices = await hass.async_add_executor_job(controller.get_devices) # scenes = api.get_action_groups() # TODO Add better exception handling From 487050fa982a69ef17fec8195fb18dcdd0a8f5e5 Mon Sep 17 00:00:00 2001 From: Mick Vleeshouwer Date: Thu, 4 Jun 2020 21:22:35 +0200 Subject: [PATCH 2/3] Change MotionSensor to OccupancySensor --- custom_components/tahoma/binary_sensor.py | 5 +++-- custom_components/tahoma/const.py | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/custom_components/tahoma/binary_sensor.py b/custom_components/tahoma/binary_sensor.py index dd0472ede..9de5080b4 100644 --- a/custom_components/tahoma/binary_sensor.py +++ b/custom_components/tahoma/binary_sensor.py @@ -68,8 +68,9 @@ def update(self): ) if CORE_OCCUPANCY_STATE in self.tahoma_device.active_states: - self.current_value = self.tahoma_device.active_states.get( - CORE_OCCUPANCY_STATE + self.current_value = ( + self.tahoma_device.active_states.get(CORE_OCCUPANCY_STATE) + == "personInside" ) if CORE_SMOKE_STATE in self.tahoma_device.active_states: diff --git a/custom_components/tahoma/const.py b/custom_components/tahoma/const.py index 964a3bf4e..81db505b8 100644 --- a/custom_components/tahoma/const.py +++ b/custom_components/tahoma/const.py @@ -9,7 +9,7 @@ from homeassistant.components.binary_sensor import ( DEVICE_CLASS_SMOKE, - DEVICE_CLASS_MOTION, + DEVICE_CLASS_OCCUPANCY, DEVICE_CLASS_OPENING ) @@ -34,7 +34,7 @@ "GarageDoor": "cover", "ContactSensor": "binary_sensor", "SmokeSensor": "binary_sensor", - "MotionSensor": "binary_sensor", + "OccupancySensor": "binary_sensor", "ExteriorVenetianBlind": "cover", "Awning": "cover" } @@ -53,7 +53,7 @@ TAHOMA_BINARY_SENSOR_DEVICE_CLASSES = { "SmokeSensor": DEVICE_CLASS_SMOKE, - "MotionSensor": DEVICE_CLASS_MOTION, + "OccupancySensor": DEVICE_CLASS_OCCUPANCY, "ContactSensor": DEVICE_CLASS_OPENING } From 1aac669baa760cdbdb2f9d81a78a0d527d937ef3 Mon Sep 17 00:00:00 2001 From: Mick Vleeshouwer Date: Thu, 4 Jun 2020 21:23:59 +0200 Subject: [PATCH 3/3] Update documentation --- README.md | 3 +-- custom_components/tahoma/tahoma_device.py | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 771330913..5852619f9 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ If your device is not supported, it will show the following message in the loggi | GarageDoor | cover | | ContactSensor | binary_sensor | | SmokeSensor | binary_sensor | -| MotionSensor | binary_sensor | +| OccupancySensor | binary_sensor | | Light | light | | Awning | cover | @@ -52,4 +52,3 @@ If your device is not supported, it will show the following message in the loggi | RemoteController | | Alarm | | HeatingSystem | - diff --git a/custom_components/tahoma/tahoma_device.py b/custom_components/tahoma/tahoma_device.py index fbcb7d0e2..4d62ed25e 100644 --- a/custom_components/tahoma/tahoma_device.py +++ b/custom_components/tahoma/tahoma_device.py @@ -73,6 +73,7 @@ def device_state_attributes(self): ] # TODO Parse 'lowBattery' for low battery warning. 'dead' for not available. + # "dead", "lowBattery", "maintenanceRequired", "noDefect" if CORE_SENSOR_DEFECT_STATE in self.tahoma_device.active_states: attr[ATTR_BATTERY_LEVEL] = self.tahoma_device.active_states[ CORE_SENSOR_DEFECT_STATE