Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 16 additions & 0 deletions custom_components/dirigera_platform/base_classes.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from typing import Optional
from homeassistant import core
from homeassistant.core import HomeAssistantError

Expand All @@ -20,6 +21,7 @@
UnitOfPower,
UnitOfTemperature,
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
CONCENTRATION_PARTS_PER_MILLION,
)

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

class ikea_alpstuga_co2(ikea_base_device_sensor, SensorEntity):
def __init__(self, device: ikea_vindstyrka_device) -> None:
logger.debug("ikea_alpstuga_co2 ctor...")
super().__init__(
device,
id_suffix="CO2",
name="CO2",
device_class=SensorDeviceClass.CO2,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To enable long-term statistics for this sensor, and allow the use of the Statistics or Statistics graph cards, can you add this property?

state_class=SensorStateClass.MEASUREMENT

(Just realized this problem is present for a bunch of other IKEA environment sensors as well -- currently the statistics card only shows the temperature sensor but not humidity etc).

@property
def native_value(self) -> int:
return self._device.current_c_o2

# SOMRIG Controllers act differently in the gateway Hub
# While its one device but two id's are sent back each
# representing the two buttons on the controler. The id is
Expand Down
1 change: 1 addition & 0 deletions custom_components/dirigera_platform/hub_event_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"environmentSensor": [ "currentTemperature",
"currentRH",
"currentPM25",
"currentCO2",
"vocIndex",
"batteryPercentage"]
}
Expand Down
2 changes: 1 addition & 1 deletion custom_components/dirigera_platform/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"iot_class": "local_polling",
"issue_tracker": "https://github.com/sanjoyg/dirigera_platform",
"loggers": ["custom_components.dirigera_platform"],
"requirements": ["dirigera==1.2.1"],
"requirements": ["dirigera==1.2.6"],
"version": "0.0.1"
}
2 changes: 1 addition & 1 deletion custom_components/dirigera_platform/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dirigera==1.2.1
dirigera==1.2.6
3 changes: 3 additions & 0 deletions custom_components/dirigera_platform/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from .base_classes import (
battery_percentage_sensor,
ikea_alpstuga_co2,
ikea_vindstyrka_temperature,
ikea_vindstyrka_humidity,
ikea_vindstyrka_pm25,
Expand Down Expand Up @@ -85,6 +86,8 @@ async def add_environment_sensors(async_add_entities, env_devices):
env_sensors.append(ikea_vindstyrka_pm25(env_device, WhichPM25.MIN))
if getattr(env_device,"voc_index") is not None:
env_sensors.append(ikea_vindstyrka_voc_index(env_device))
if getattr(env_device,"current_c_o2") is not None:
env_sensors.append(ikea_alpstuga_co2(env_device))

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

Expand Down