Skip to content

Commit

Permalink
Merge pull request #64 from Necroneco/tvoc
Browse files Browse the repository at this point in the history
Change unit of tvoc to µg/m³
  • Loading branch information
mypal authored Oct 29, 2023
2 parents 21c8dbd + 1ed3dc3 commit 359ef35
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion custom_components/ds_air/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"humidity": [PERCENTAGE, None, SensorDeviceClass.HUMIDITY, 10],
"pm25": [CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, None, SensorDeviceClass.PM25, 1],
"co2": [CONCENTRATION_PARTS_PER_MILLION, None, SensorDeviceClass.CO2, 1],
"tvoc": [CONCENTRATION_MILLIGRAMS_PER_CUBIC_METER, None, SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS_PARTS, 100],
"tvoc": [CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, None, SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS, 0.1],
"voc": [None, None, SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS_PARTS, EnumSensor.Voc],
"hcho": [CONCENTRATION_MILLIGRAMS_PER_CUBIC_METER, None, None, 100],
}
5 changes: 3 additions & 2 deletions custom_components/ds_air/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,11 @@ def parse_data(self, device: Sensor, not_update: bool = False):
"""Parse data sent by gateway."""
self._is_available = device.connected
if UNINITIALIZED_VALUE != getattr(device, self._data_key):
if type(SENSOR_TYPES.get(self._data_key)[3]) != int:
scaling = SENSOR_TYPES.get(self._data_key)[3]
if type(scaling) != int and type(scaling) != float:
self._state = str(getattr(device, self._data_key))
else:
self._state = getattr(device, self._data_key) / SENSOR_TYPES.get(self._data_key)[3]
self._state = getattr(device, self._data_key) / scaling

if not not_update:
self.schedule_update_ha_state()
Expand Down
5 changes: 5 additions & 0 deletions hacs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "DS-AIR",
"render_readme": true,
"homeassistant": "2023.7.0"
}

1 comment on commit 359ef35

@bwsgp
Copy link

@bwsgp bwsgp commented on 359ef35 Jun 12, 2024

Choose a reason for hiding this comment

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

"version": "1.3.3",

Please sign in to comment.