Skip to content

Commit

Permalink
support for floor temp
Browse files Browse the repository at this point in the history
  • Loading branch information
karlblum committed Oct 14, 2024
1 parent 68124a2 commit d33440a
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 2 deletions.
Binary file modified .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
custom_components/.DS_Store
.DS_Store
.DS_Store
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This custom integration allows you to integrate **Airobot thermostats** with Hom
## Requirements

- Airobot thermostat that supports the API.
- Static IP address must be assigned to each thermostat.
- Home Assistant 2023.1 or later.

## Installation Instructions (via HACS)
Expand Down
3 changes: 3 additions & 0 deletions custom_components/airobot_thermostat/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ def preset_mode(self):

@property
def current_temperature(self):
if self.coordinator.data.get("floor_temperature_available"):
return self.coordinator.data["floor_temperature"]

return self.coordinator.data["temperature"]

@property
Expand Down
6 changes: 6 additions & 0 deletions custom_components/airobot_thermostat/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,14 @@ async def _async_update_data(self):
if co2_value == 65535:
co2_value = None # Set to None to indicate no valid CO2 reading

floor_temperature = status_data.get("TEMP_FLOOR", 0)
floor_temperature_available = 0 < floor_temperature < 32767


return {
"temperature": status_data.get("TEMP_AIR", 0) / 10,
"floor_temperature": status_data.get("TEMP_FLOOR", 0) / 10,
"floor_temperature_available": floor_temperature_available,
"humidity": status_data.get("HUM_AIR", 0) / 10,
"co2": co2_value,
"aqi": status_data.get("AQI", 0),
Expand Down
44 changes: 42 additions & 2 deletions custom_components/airobot_thermostat/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up sensor entities from a config entry."""
coordinator = hass.data[DOMAIN][config_entry.entry_id]["coordinator"]

entities = [AirobotTemperatureSensor(coordinator)]
entities.append(AirobotHumiditySensor(coordinator))
entities = [
AirobotTemperatureSensor(coordinator),
AirobotHumiditySensor(coordinator),
AirobotHeatingStatusSensor(coordinator)
]

if coordinator.data.get("co2") is not None:
entities.append(AirobotCO2Sensor(coordinator))

if coordinator.data.get("floor_temperature_available"):
entities.append(AirobotFloorTemperatureSensor(coordinator))

async_add_entities(entities, update_before_add=True)

class AirobotTemperatureSensor(CoordinatorEntity, SensorEntity):
Expand Down Expand Up @@ -56,3 +62,37 @@ def __init__(self, coordinator):
@property
def state(self):
return self.coordinator.data["co2"]

class AirobotHeatingStatusSensor(CoordinatorEntity, SensorEntity):
"""Representation of the heating status sensor."""

def __init__(self, coordinator):
super().__init__(coordinator)
self._attr_name = f"Airobot {coordinator._room} Heating Status"
self._attr_unique_id = f"{DOMAIN}_{coordinator._username}_{coordinator._room}_heating_status"

@property
def state(self):
"""Return the state of the sensor."""
heating_on = self.coordinator.data.get("heating_on")
return "On" if heating_on else "Off"

@property
def icon(self):
"""Return an icon based on the heating status."""
return "mdi:radiator" if self.state == "On" else "mdi:radiator-off"

class AirobotFloorTemperatureSensor(CoordinatorEntity, SensorEntity):
"""Representation of the floor temperature sensor."""

def __init__(self, coordinator):
super().__init__(coordinator)
self._attr_name = f"Airobot {coordinator._room} Floor Temperature"
self._attr_unique_id = f"{DOMAIN}_{coordinator._username}_{coordinator._room}_floor_temp"
self._attr_native_unit_of_measurement = UnitOfTemperature.CELSIUS
self._attr_device_class = "temperature"

@property
def state(self):
"""Return the state of the sensor."""
return self.coordinator.data.get("floor_temperature")

0 comments on commit d33440a

Please sign in to comment.