Skip to content

Commit 007c79a

Browse files
committed
Add CO2 support for Alpstuga Air Quality Sensor (PR sanjoyg#182)
Cherry-picked from sanjoyg#182 by stirante
1 parent b35f933 commit 007c79a

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

custom_components/dirigera_platform/base_classes.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from typing import Optional
12
from homeassistant import core
23
from homeassistant.core import HomeAssistantError
34

@@ -20,6 +21,7 @@
2021
UnitOfPower,
2122
UnitOfTemperature,
2223
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
24+
CONCENTRATION_PARTS_PER_MILLION,
2325
)
2426

2527
from dirigera import Hub
@@ -454,6 +456,20 @@ def __init__(self, device: ikea_vindstyrka_device) -> None:
454456
def native_value(self) -> int:
455457
return self._device.voc_index
456458

459+
class ikea_alpstuga_co2(ikea_base_device_sensor, SensorEntity):
460+
def __init__(self, device: ikea_vindstyrka_device) -> None:
461+
logger.debug("ikea_alpstuga_co2 ctor...")
462+
super().__init__(
463+
device,
464+
id_suffix="CO2",
465+
name="CO2",
466+
device_class=SensorDeviceClass.CO2,
467+
native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION)
468+
469+
@property
470+
def native_value(self) -> int:
471+
return self._device.current_c_o2
472+
457473
# SOMRIG Controllers act differently in the gateway Hub
458474
# While its one device but two id's are sent back each
459475
# representing the two buttons on the controler. The id is

custom_components/dirigera_platform/hub_event_listener.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"environmentSensor": [ "currentTemperature",
3636
"currentRH",
3737
"currentPM25",
38+
"currentCO2",
3839
"vocIndex",
3940
"batteryPercentage"]
4041
}

custom_components/dirigera_platform/sensor.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from .base_classes import (
66
battery_percentage_sensor,
7+
ikea_alpstuga_co2,
78
ikea_vindstyrka_temperature,
89
ikea_vindstyrka_humidity,
910
ikea_vindstyrka_pm25,
@@ -85,6 +86,8 @@ async def add_environment_sensors(async_add_entities, env_devices):
8586
env_sensors.append(ikea_vindstyrka_pm25(env_device, WhichPM25.MIN))
8687
if getattr(env_device,"voc_index") is not None:
8788
env_sensors.append(ikea_vindstyrka_voc_index(env_device))
89+
if getattr(env_device,"current_c_o2") is not None:
90+
env_sensors.append(ikea_alpstuga_co2(env_device))
8891

8992
logger.debug("Found {} env entities to setup...".format(len(env_sensors)))
9093

0 commit comments

Comments
 (0)