Skip to content

Commit

Permalink
Fixes environmental data reporting (#17)
Browse files Browse the repository at this point in the history
- Improves the display of Formaldehyde data to show a graph
- Sets the VOC and NO2 to their correct index scales instead of
  the incorrect mass measurements.
- Creates new sensor entities for the above to avoid conversion errors
  in Home Assistant
  • Loading branch information
dotvezz committed May 5, 2023
1 parent b9d8272 commit d118a07
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions custom_components/dyson_local/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,9 @@ def native_value(self) -> int:

class DysonParticulatesSensor(DysonSensorEnvironmental):
"""Dyson sensor for particulate matters for "Link" devices."""

_SENSOR_TYPE = "pm1"
_SENSOR_NAME = "Air Quality"
_attr_device_class = SensorDeviceClass.PM1
_SENSOR_TYPE = "aqi"
_SENSOR_NAME = "Air Quality Index"
_attr_device_class = SensorDeviceClass.AQI
_attr_state_class = SensorStateClass.MEASUREMENT

@environmental_property
Expand All @@ -296,9 +295,9 @@ def native_value(self) -> int:
class DysonVOCSensor(DysonSensorEnvironmental):
"""Dyson sensor for volatile organic compounds."""

_SENSOR_TYPE = "voc"
_SENSOR_NAME = "Volatile Organic Compounds"
_attr_device_class = SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS
_SENSOR_TYPE = "voc-index"
_SENSOR_NAME = "Volatile Organic Compounds Index"
_attr_device_class = SensorDeviceClass.AQI
_attr_state_class = SensorStateClass.MEASUREMENT

@environmental_property
Expand All @@ -310,9 +309,9 @@ def native_value(self) -> float:
class DysonNO2Sensor(DysonSensorEnvironmental):
"""Dyson sensor for Nitrogen Dioxide."""

_SENSOR_TYPE = "no2"
_SENSOR_NAME = "Nitrogen Dioxide"
_attr_device_class = SensorDeviceClass.NITROGEN_DIOXIDE
_SENSOR_TYPE = "no2-index"
_SENSOR_NAME = "Nitrogen Dioxide Index"
_attr_device_class = SensorDeviceClass.AQI
_attr_state_class = SensorStateClass.MEASUREMENT

@environmental_property
Expand Down

0 comments on commit d118a07

Please sign in to comment.