Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sensors dynamically based on available device state #425

Merged
merged 37 commits into from
Aug 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
3b92c4e
Add temporary state sensor
iMicknl Mar 12, 2021
f5d1470
Add extra sensors
iMicknl Apr 18, 2021
47afb76
Add more states
iMicknl Jul 14, 2021
f959364
Add more sensors
iMicknl Jul 14, 2021
503908b
Create supported_platforms variable
tetienne Aug 3, 2021
84be0be
Use Overkiz label as device name
tetienne Aug 3, 2021
8db4070
Suffix state sensor name with device index
tetienne Aug 3, 2021
668a1d8
Avoid to duplicate state key
tetienne Aug 4, 2021
600f30a
Remove now usless rssi level attribute
tetienne Aug 4, 2021
e2e1ac9
Migrate LightSensor to TahomaStateSensor
tetienne Aug 4, 2021
e3a55d0
Apply linters
tetienne Aug 4, 2021
4c3745f
Add PriorityLockOriginatorState sensor
tetienne Aug 4, 2021
eb59d2c
Bump minimum version to 2021.8
iMicknl Aug 4, 2021
dcb9ee0
Remove unneeded value key
iMicknl Aug 4, 2021
0441fae
Migrate to SensorEntityDescription
iMicknl Aug 4, 2021
92b0131
Small tweaks
iMicknl Aug 4, 2021
9b05722
Add battery level
iMicknl Aug 4, 2021
d9eb35d
Remove unused state keys
iMicknl Aug 4, 2021
a9fc25a
Test electricity sensor
iMicknl Aug 4, 2021
f6ba184
Add extra sensors
iMicknl Aug 4, 2021
d30727a
Add sensor
iMicknl Aug 4, 2021
513411d
Add all sensors from sensor.py
iMicknl Aug 4, 2021
814e22a
Add smoke text sensor
iMicknl Aug 4, 2021
56ef6f9
Make optional
iMicknl Aug 4, 2021
ad3d400
Change all sensor to new structure
iMicknl Aug 4, 2021
2558988
Improve sensor definitions
iMicknl Aug 4, 2021
3ab2a66
Ease state
tetienne Aug 5, 2021
2500780
Ease retrieve of the index
tetienne Aug 5, 2021
d16f11d
Rollback device_state_attributes
tetienne Aug 5, 2021
ee567a3
Revert battery changes
iMicknl Aug 9, 2021
44f9215
Remove const
iMicknl Aug 9, 2021
49e66d8
Add LightSensor
iMicknl Aug 10, 2021
2b8a4ca
Rollback icon logic in cover
iMicknl Aug 10, 2021
dedfcb4
Bugfixes
iMicknl Aug 10, 2021
4bdad73
Merge branch 'master' into feature/add_secondary_sensors
iMicknl Aug 10, 2021
4a51335
Add round for RSSI value
iMicknl Aug 10, 2021
a9c5fa7
Merge branch 'master' into feature/add_secondary_sensors
iMicknl Aug 10, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions custom_components/tahoma/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from aiohttp import ClientError, ServerDisconnectedError
from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR
from homeassistant.components.scene import DOMAIN as SCENE
from homeassistant.components.sensor import DOMAIN as SENSOR
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.const import CONF_EXCLUDE, CONF_PASSWORD, CONF_SOURCE, CONF_USERNAME
from homeassistant.core import HomeAssistant, ServiceCall
Expand Down Expand Up @@ -208,6 +209,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

# Sensor and Binary Sensor will be added dynamically, based on the device states
supported_platforms.add(BINARY_SENSOR)
supported_platforms.add(SENSOR)

for platform in supported_platforms:
hass.async_create_task(
Expand Down
30 changes: 15 additions & 15 deletions custom_components/tahoma/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from homeassistant.components.cover import DOMAIN as COVER
from homeassistant.components.light import DOMAIN as LIGHT
from homeassistant.components.lock import DOMAIN as LOCK
from homeassistant.components.sensor import DOMAIN as SENSOR
from homeassistant.components.switch import DOMAIN as SWITCH
from homeassistant.components.water_heater import DOMAIN as WATER_HEATER

Expand All @@ -19,6 +18,21 @@
IGNORED_TAHOMA_DEVICES = [
"ProtocolGateway",
"Pod",
# entries mapped to Sensor based on available states
"AirSensor",
"ConsumptionSensor",
"ElectricitySensor",
"GasSensor",
"GenericSensor",
"HumiditySensor",
"LightSensor",
"SunIntensitySensor",
"SunSensor",
"TemperatureSensor",
"ThermalEnergySensor",
"WaterSensor",
"WeatherSensor",
"WindSensor",
iMicknl marked this conversation as resolved.
Show resolved Hide resolved
# entries mapped to Binary Sensor based on available states
"AirFlowSensor", # widgetName, uiClass is AirSensor (sensor)
"ContactSensor",
Expand All @@ -32,7 +46,6 @@
# Used to map the Somfy widget and ui_class to the Home Assistant platform
TAHOMA_DEVICE_TO_PLATFORM = {
"AdjustableSlatsRollerShutter": COVER,
"AirSensor": SENSOR,
"Alarm": ALARM_CONTROL_PANEL,
"AtlanticElectricalHeater": CLIMATE, # widgetName, uiClass is HeatingSystem (not supported)
"AtlanticElectricalHeaterWithAdjustableTemperatureSetpoint": CLIMATE, # widgetName, uiClass is HeatingSystem (not supported)
Expand All @@ -41,27 +54,21 @@
"AtlanticPassAPCHeatingAndCoolingZone": CLIMATE, # widgetName, uiClass is HeatingSystem (not supported)
"AtlanticPassAPCZoneControl": CLIMATE, # widgetName, uiClass is HeatingSystem (not supported)
"Awning": COVER,
"ConsumptionSensor": SENSOR,
"Curtain": COVER,
"DimmerExteriorHeating": CLIMATE, # widgetName, uiClass is ExteriorHeatingSystem (not supported)
"DomesticHotWaterProduction": WATER_HEATER, # widgetName, uiClass is WaterHeatingSystem (not supported)
"DomesticHotWaterTank": SWITCH, # widgetName, uiClass is WaterHeatingSystem (not supported)
"DoorLock": LOCK,
"ElectricitySensor": SENSOR,
"EvoHomeController": CLIMATE, # widgetName, uiClass is EvoHome (not supported)
"ExteriorScreen": COVER,
"ExteriorVenetianBlind": COVER,
"GarageDoor": COVER,
"GasSensor": SENSOR,
"Gate": COVER,
"GenericSensor": SENSOR,
"HeatingSetPoint": CLIMATE, # widgetName, uiClass is EvoHome (not supported)
"HitachiDHW": WATER_HEATER, # widgetName, uiClass is HitachiHeatingSystem (not supported)
"HitachiAirToWaterHeatingZone": CLIMATE, # widgetName, uiClass is HitachiHeatingSystem (not supported)
"HitachiAirToAirHeatPump": CLIMATE, # widgetName, uiClass is HitachiHeatingSystem (not supported)
"HumiditySensor": SENSOR,
"Light": LIGHT,
"LightSensor": SENSOR,
iMicknl marked this conversation as resolved.
Show resolved Hide resolved
iMicknl marked this conversation as resolved.
Show resolved Hide resolved
"MyFoxSecurityCamera": COVER, # widgetName, uiClass is Camera (not supported)
"OnOff": SWITCH,
"Pergola": COVER,
Expand All @@ -73,16 +80,9 @@
"SirenStatus": None, # widgetName, uiClass is Siren (switch)
"SomfyThermostat": CLIMATE, # widgetName, uiClass is HeatingSystem (not supported)
"StatelessExteriorHeating": CLIMATE, # widgetName, uiClass is ExteriorHeatingSystem.
"SunIntensitySensor": SENSOR,
"SunSensor": SENSOR,
"SwimmingPool": SWITCH,
"SwingingShutter": COVER,
"TemperatureSensor": SENSOR,
"ThermalEnergySensor": SENSOR,
"VenetianBlind": COVER,
"WaterSensor": SENSOR,
"WeatherSensor": SENSOR,
"WindSensor": SENSOR,
"Window": COVER,
}

Expand Down
32 changes: 16 additions & 16 deletions custom_components/tahoma/cover_devices/tahoma_cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@
CORE_TARGET_CLOSURE_STATE = "core:TargetClosureState"
MYFOX_SHUTTER_STATUS_STATE = "myfox:ShutterStatusState"

ICON_LOCK_ALERT = "mdi:lock-alert"
ICON_WEATHER_WINDY = "mdi:weather-windy"

IO_PRIORITY_LOCK_LEVEL_STATE = "io:PriorityLockLevelState"
IO_PRIORITY_LOCK_ORIGINATOR_STATE = "io:PriorityLockOriginatorState"

ICON_LOCK_ALERT = "mdi:lock-alert"
iMicknl marked this conversation as resolved.
Show resolved Hide resolved
ICON_WEATHER_WINDY = "mdi:weather-windy"

STATE_CLOSED = "closed"

SERVICE_COVER_MY_POSITION = "set_cover_my_position"
Expand Down Expand Up @@ -128,19 +128,6 @@ def is_closed(self):

return None

@property
def icon(self):
iMicknl marked this conversation as resolved.
Show resolved Hide resolved
"""Return the icon to use in the frontend, if any."""
if (
self.has_state(CORE_PRIORITY_LOCK_TIMER_STATE)
and self.select_state(CORE_PRIORITY_LOCK_TIMER_STATE) > 0
):
if self.select_state(IO_PRIORITY_LOCK_ORIGINATOR_STATE) == "wind":
return ICON_WEATHER_WINDY
return ICON_LOCK_ALERT

return None

async def async_open_cover_tilt(self, **_):
"""Open the cover tilt."""
await self.async_execute_command(self.select_command(*COMMANDS_OPEN_TILT))
Expand Down Expand Up @@ -292,3 +279,16 @@ def supported_features(self):
supported_features |= SUPPORT_MY

return supported_features

@property
def icon(self):
"""Return the icon to use in the frontend, if any."""
if (
self.has_state(CORE_PRIORITY_LOCK_TIMER_STATE)
and self.select_state(CORE_PRIORITY_LOCK_TIMER_STATE) > 0
):
if self.select_state(IO_PRIORITY_LOCK_ORIGINATOR_STATE) == "wind":
return ICON_WEATHER_WINDY
return ICON_LOCK_ALERT

return None
Loading