Private GIT

Skip to content
Snippets Groups Projects
Commit 28c2ed9d authored by Sean Rees's avatar Sean Rees
Browse files

Add support for Pure Cool Formaldehyde fans and bump to 0.3.1

parent 65102bdb
Branches
No related tags found
No related merge requests found
......@@ -112,5 +112,5 @@ pkg_deb(
package = "prometheus-dyson",
postrm = "debian/postrm",
prerm = "debian/prerm",
version = "0.3.0",
version = "0.3.1",
)
......@@ -54,6 +54,7 @@ dyson_volatile_organic_compounds_units | gauge | all | volatile organic compound
dyson_dust_units | gauge | V1 fans only | dust level (range 0-10)
dyson_pm25_units | gauge | V2 fans only | PM2.5 units (µg/m^3 ?)
dyson_pm10_units | gauge | V2 fans only | PM10 units (µg/m^3 ?)
dyson_formaldehyde_units | gauge | Formaldehyde units only | Formaldehyde/H-CHO units
dyson_nitrogen_oxide_units | gauge | V2 fans only | Nitrogen Oxide (NOx) levels (range 0-10)
......
......@@ -122,6 +122,8 @@ class Metrics:
'dyson_pm10_units', 'Level of PM10 particulate matter (V2 units only)')
self.nox = make_gauge('dyson_nitrogen_oxide_units',
'Level of nitrogen oxides (NOx, V2 units only)')
self.formaldehyde = make_gauge(
'dyson_formaldehyde_units', 'Level of formaldehyde/H-CHO (Formaldehyde unit only)')
# Operational State (v1 & v2 common)
# Not included: tilt (known values: "OK", others?), standby_monitoring.
......@@ -235,6 +237,9 @@ class Metrics:
update_env_gauge(self.voc, name, device.serial, voc)
update_env_gauge(self.nox, name, device.serial, nox)
if isinstance(device, libdyson.DysonPureCoolFormaldehyde):
update_env_gauge(self.formaldehyde, name, device.serial, device.formaldehyde)
def update_common_environmental(self, name: str, device) -> None:
update_gauge(self.last_update_environmental,
name, device.serial, timestamp())
......
......@@ -84,6 +84,29 @@ class TestMetrics(unittest.TestCase):
got = self.registry.get_sample_value(metric, labels)
self.assertEqual(got, want, f'metric {metric}')
def test_update_formaldehyde_environmental(self):
device = libdyson.DysonPureCoolFormaldehyde(
SERIAL, CREDENTIALS, libdyson.DEVICE_TYPE_PURE_COOL_FORMALDEHYDE)
payload = {
'msg': 'ENVIRONMENTAL-CURRENT-SENSOR-DATA',
'time': '2021-03-17T15:09:23.000Z',
'data': {'tact': '2956', 'hact': '0047', 'pm10': '3', 'pm25': 'INIT',
'noxl': 30, 'va10': 'INIT', 'hcho': '0002', 'hchr': '0003',
'sltm': 'OFF'}
}
device._handle_message(payload)
labels = {'name': NAME, 'serial': SERIAL}
self.metrics.update(NAME, device, is_state=False,
is_environmental=True)
cases = {
'dyson_formaldehyde_units': 2,
}
for metric, want in cases.items():
got = self.registry.get_sample_value(metric, labels)
self.assertEqual(got, want, f'metric {metric}')
def test_update_v1_state(self):
device = libdyson.DysonPureHotCoolLink(
SERIAL, CREDENTIALS, libdyson.DEVICE_TYPE_PURE_HOT_COOL_LINK)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment