diff --git a/custom_components/dirigera_platform/binary_sensor.py b/custom_components/dirigera_platform/binary_sensor.py index c9b3952..867050b 100644 --- a/custom_components/dirigera_platform/binary_sensor.py +++ b/custom_components/dirigera_platform/binary_sensor.py @@ -104,6 +104,7 @@ def device_info(self) -> DeviceInfo: manufacturer=self._json_data.attributes.manufacturer, model=self._json_data.attributes.model, sw_version=self._json_data.attributes.firmware_version, + suggested_area=self._json_data.room.name if self._json_data.room is not None else None, ) @property @@ -142,6 +143,7 @@ def device_info(self) -> DeviceInfo: manufacturer=self._json_data.attributes.manufacturer, model=self._json_data.attributes.model, sw_version=self._json_data.attributes.firmware_version, + suggested_area=self._json_data.room.name if self._json_data.room is not None else None, ) @property @@ -220,6 +222,7 @@ def device_info(self) -> DeviceInfo: manufacturer=self._json_data.attributes.manufacturer, model=self._json_data.attributes.model, sw_version=self._json_data.attributes.firmware_version, + suggested_area=self._json_data.room.name if self._json_data.room is not None else None, ) @property diff --git a/custom_components/dirigera_platform/cover.py b/custom_components/dirigera_platform/cover.py index efe269a..fb236c7 100644 --- a/custom_components/dirigera_platform/cover.py +++ b/custom_components/dirigera_platform/cover.py @@ -68,6 +68,7 @@ def device_info(self) -> DeviceInfo: manufacturer=self._json_data.attributes.manufacturer, model=self._json_data.attributes.model, sw_version=self._json_data.attributes.firmware_version, + suggested_area=self._json_data.room.name if self._json_data.room is not None else None, ) @property diff --git a/custom_components/dirigera_platform/fan.py b/custom_components/dirigera_platform/fan.py index a7b3414..f971513 100644 --- a/custom_components/dirigera_platform/fan.py +++ b/custom_components/dirigera_platform/fan.py @@ -193,6 +193,7 @@ def device_info(self) -> DeviceInfo: manufacturer=self._json_data.attributes.manufacturer, model=self._json_data.attributes.model, sw_version=self._json_data.attributes.firmware_version, + suggested_area=self._json_data.room.name if self._json_data.room is not None else None, ) @property diff --git a/custom_components/dirigera_platform/light.py b/custom_components/dirigera_platform/light.py index d2483ae..da27673 100644 --- a/custom_components/dirigera_platform/light.py +++ b/custom_components/dirigera_platform/light.py @@ -1,7 +1,9 @@ import logging +from typing import Optional import dirigera from dirigera import Hub +from dirigera.devices.device import Room from homeassistant import config_entries, core from homeassistant.components.light import ( ATTR_BRIGHTNESS, @@ -59,11 +61,13 @@ async def async_setup_entry( for one_set in light._json_data.device_set: id = one_set['id'] name = one_set['name'] + # Use the room of the first light encountered in the set as the 'suggested area' for HA + suggested_room = light._json_data.room target_device_set = None if id not in device_sets: logger.debug(f"Found new device set {name}") - device_sets[id] = device_set_model(id, name) + device_sets[id] = device_set_model(id, name, suggested_room) target_device_set = device_sets[id] target_device_set.add_light(light) @@ -81,11 +85,12 @@ async def async_setup_entry( logger.debug("LIGHT Complete async_setup_entry") class device_set_model: - def __init__(self, id, name): + def __init__(self, id, name, suggested_room: Optional[Room]): logger.debug(f"device_set ctor {id} : {name}") self._lights = [] self._name = name - self._id = id + self._id = id + self._suggested_room = suggested_room @property def id(self): @@ -93,7 +98,11 @@ def id(self): @property def name(self): - return self._name + return self._name + + @property + def suggested_room(self) -> Optional[Room]: + return self._suggested_room def get_lights(self) -> list: return self._lights @@ -172,6 +181,7 @@ def device_info(self) -> DeviceInfo: manufacturer=self._json_data.attributes.manufacturer, model=self._json_data.attributes.model, sw_version=self._json_data.attributes.firmware_version, + suggested_area=self._json_data.room.name if self._json_data.room is not None else None, ) @property @@ -326,6 +336,7 @@ def device_info(self) -> DeviceInfo: manufacturer="IKEA", model="Device Set", sw_version="1.0", + suggested_area=self._device_set.suggested_room.name if self._device_set.suggested_room is not None else None, ) @property diff --git a/custom_components/dirigera_platform/mocks/ikea_air_purifier_mock.py b/custom_components/dirigera_platform/mocks/ikea_air_purifier_mock.py index f522ec7..388e95c 100644 --- a/custom_components/dirigera_platform/mocks/ikea_air_purifier_mock.py +++ b/custom_components/dirigera_platform/mocks/ikea_air_purifier_mock.py @@ -67,6 +67,7 @@ def device_info(self) -> DeviceInfo: manufacturer="MOCK", model="Mock 1.0", sw_version="Mock SW 1.0", + suggested_area="Kitchen", ) @property diff --git a/custom_components/dirigera_platform/mocks/ikea_blinds_mock.py b/custom_components/dirigera_platform/mocks/ikea_blinds_mock.py index 6dc0a5d..7fa64d8 100644 --- a/custom_components/dirigera_platform/mocks/ikea_blinds_mock.py +++ b/custom_components/dirigera_platform/mocks/ikea_blinds_mock.py @@ -46,6 +46,7 @@ def device_info(self) -> DeviceInfo: manufacturer=self._manufacturer, model=self._model, sw_version=self._sw_version, + suggested_area="Bedroom", ) @property diff --git a/custom_components/dirigera_platform/mocks/ikea_open_close_mock.py b/custom_components/dirigera_platform/mocks/ikea_open_close_mock.py index 6cf37b2..dafa903 100644 --- a/custom_components/dirigera_platform/mocks/ikea_open_close_mock.py +++ b/custom_components/dirigera_platform/mocks/ikea_open_close_mock.py @@ -33,6 +33,7 @@ def device_info(self) -> DeviceInfo: manufacturer=self._manufacturer, model=self._model, sw_version=self._sw_version, + suggested_area="Living room", ) @property diff --git a/custom_components/dirigera_platform/sensor.py b/custom_components/dirigera_platform/sensor.py index 2940cf8..d07ec7e 100644 --- a/custom_components/dirigera_platform/sensor.py +++ b/custom_components/dirigera_platform/sensor.py @@ -147,6 +147,7 @@ def device_info(self) -> DeviceInfo: manufacturer=self._json_data.attributes.manufacturer, model=self._json_data.attributes.model, sw_version=self._json_data.attributes.firmware_version, + suggested_area=self._json_data.room.name if self._json_data.room is not None else None, ) @property @@ -308,6 +309,7 @@ def device_info(self) -> DeviceInfo: manufacturer=self._json_data.attributes.manufacturer, model=self._json_data.attributes.model, sw_version=self._json_data.attributes.firmware_version, + suggested_area=self._json_data.room.name if self._json_data.room is not None else None, ) @property diff --git a/custom_components/dirigera_platform/switch.py b/custom_components/dirigera_platform/switch.py index 88561e0..5159e55 100644 --- a/custom_components/dirigera_platform/switch.py +++ b/custom_components/dirigera_platform/switch.py @@ -65,6 +65,7 @@ def device_info(self) -> DeviceInfo: manufacturer=self._json_data.attributes.manufacturer, model=self._json_data.attributes.model, sw_version=self._json_data.attributes.firmware_version, + suggested_area=self._json_data.room.name if self._json_data.room is not None else None, ) @property