Skip to content

Commit

Permalink
Merge pull request #15 from iMicknl/add_occupancy_and_async
Browse files Browse the repository at this point in the history
  • Loading branch information
iMicknl authored Jun 4, 2020
2 parents 1a9bfc0 + 5f2b138 commit 14d94f9
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

Expand All @@ -52,4 +52,3 @@ If your device is not supported, it will show the following message in the loggi
| RemoteController |
| Alarm |
| HeatingSystem |

10 changes: 5 additions & 5 deletions custom_components/tahoma/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -61,10 +61,10 @@ 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()
scenes = controller.get_action_groups()
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 = await hass.async_add_executor_job(controller.get_action_groups)

# TODO Add better exception handling
except RequestException:
Expand Down
5 changes: 3 additions & 2 deletions custom_components/tahoma/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions custom_components/tahoma/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from homeassistant.components.binary_sensor import (
DEVICE_CLASS_SMOKE,
DEVICE_CLASS_MOTION,
DEVICE_CLASS_OCCUPANCY,
DEVICE_CLASS_OPENING
)

Expand All @@ -34,7 +34,7 @@
"GarageDoor": "cover",
"ContactSensor": "binary_sensor",
"SmokeSensor": "binary_sensor",
"MotionSensor": "binary_sensor",
"OccupancySensor": "binary_sensor",
"ExteriorVenetianBlind": "cover",
"Awning": "cover"
}
Expand All @@ -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
}

Expand Down
1 change: 1 addition & 0 deletions custom_components/tahoma/tahoma_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 14d94f9

Please sign in to comment.