Skip to content

Commit

Permalink
Added support for device grouping
Browse files Browse the repository at this point in the history
  • Loading branch information
karlblum committed Jan 3, 2025
1 parent 48e762f commit 10b60c1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions custom_components/airobot_thermostat/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ def __init__(self, coordinator):
self._attr_preset_modes = [PRESET_HOME, PRESET_AWAY]
self._attr_preset_mode = None

@property
def device_info(self):
return self.coordinator.device_info

@property
def preset_mode(self):
mode = self.coordinator.data.get("preset_mode", 1) # Default to Home
Expand Down
9 changes: 9 additions & 0 deletions custom_components/airobot_thermostat/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ def __init__(self, hass, room, host, username, password):
update_interval=timedelta(seconds=15),
)

@property
def device_info(self):
return {
"identifiers": {(DOMAIN, self._username)},
"name": f"Airobot {self._room} Thermostat",
"manufacturer": "Airobot",
"model": "Thermostat",
}

def _get_headers(self):
"""Return the headers for REST API with proper Basic Authentication."""
credentials = f"{self._username}:{self._password}"
Expand Down
20 changes: 20 additions & 0 deletions custom_components/airobot_thermostat/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ def __init__(self, coordinator):
self._attr_device_class = "temperature"
self._attr_state_class = "measurement"

@property
def device_info(self):
return self.coordinator.device_info

@property
def state(self):
return self.coordinator.data["temperature"]
Expand All @@ -47,6 +51,10 @@ def __init__(self, coordinator):
self._attr_device_class = "humidity"
self._attr_state_class = "measurement"

@property
def device_info(self):
return self.coordinator.device_info

@property
def state(self):
return self.coordinator.data["humidity"]
Expand All @@ -62,6 +70,10 @@ def __init__(self, coordinator):
self._attr_device_class = "carbon_dioxide"
self._attr_state_class = "measurement"

@property
def device_info(self):
return self.coordinator.device_info

@property
def state(self):
return self.coordinator.data["co2"]
Expand All @@ -74,6 +86,10 @@ def __init__(self, coordinator):
self._attr_name = f"Airobot {coordinator._room} Heating Status"
self._attr_unique_id = f"{DOMAIN}_{coordinator._username}_{coordinator._room}_heating_status"

@property
def device_info(self):
return self.coordinator.device_info

@property
def state(self):
"""Return the state of the sensor."""
Expand All @@ -96,6 +112,10 @@ def __init__(self, coordinator):
self._attr_device_class = "temperature"
self._attr_state_class = "measurement"

@property
def device_info(self):
return self.coordinator.device_info

@property
def state(self):
"""Return the state of the sensor."""
Expand Down

0 comments on commit 10b60c1

Please sign in to comment.