seanrees / prometheus-dyson

Prometheus client for DysonLink fans (Pure Hot+Cool)
MIT License
13 stars 9 forks source link

Formaldehyd metric #13

Closed kaiherzig closed 3 years ago

kaiherzig commented 3 years ago

Hi, is there a way to add formaldehyd sensor? it should be hcho and hchr

I started main.py with debug and i get values. DEBUG New environmental state: {'msg': 'ENVIRONMENTAL-CURRENT-SENSOR-DATA', 'time': '2021-06-17T06:25:40.000Z', 'data': {'tact': '2950', 'hact': '0050', 'pm25': '0005', 'pm10': '0003', 'va10': '0004', 'noxl': '0002', 'p25r': '0007', 'p10r': '0007', 'hcho': '0000', 'hchr': '0000', 'sltm': 'OFF'}}

Sorry I'm not used to python

seanrees commented 3 years ago

Hi there, what model device do you have?

I believe this is possible to add, but it is somewhat complicated because:

  1. I don't have a device that reports this, so I'd need your help to test.
  2. @shenxn 's libdyson doesn't currently support this field, so this needs to be updated first. I can likely help with this as I don't think it's super difficult.

What would be helpful to start would be a full debug log with a few samples of the hcho/hchr fields.

kaiherzig commented 3 years ago

Hi it's a TP-09 https://www.dyson.com/air-treatment/purifiers/dyson-purifier-cool-formaldehyde-tp09/dyson-purifier-cool-formaldehyde-overview-tp09

2021/06/21 08:39:57 [548361592848] INFO Starting up on port=8091 2021/06/21 08:39:57 [548361592848] INFO Reading "config.ini" 2021/06/21 08:39:57 [548361592848] INFO Starting discovery... 2021/06/21 08:39:57 [548361592848] INFO Attempting to discover device "Schlafzimmer" (serial=K3G-EU-PDA2222A) via zeroconf 2021/06/21 08:39:57 [548323983840] INFO Discovered K3G-EU-PDA2222A on 10.... 2021/06/21 08:39:58 [548315591136] DEBUG Connected with result code 0 2021/06/21 08:39:58 [548323983840] INFO Connected to device K3G-EU-PDA2222A 2021/06/21 08:39:58 [548315591136] DEBUG New state: {'msg': 'CURRENT-STATE', 'time': '2021-06-21T06:39:59.000Z', 'mode-reason': 'PRC', 'state-reason': 'MODE', 'rssi': '-46', 'channel': '11', 'fqhp': '90760', 'fghp': '77400', 'product-state': {'fpwr': 'ON', 'auto': 'ON', 'oscs': 'IDLE', 'oson': 'ON', 'nmod': 'OFF', 'rhtm': 'ON', 'fnst': 'OFF', 'ercd': 'NONE', 'wacd': 'NONE', 'nmdv': '0004', 'fnsp': 'AUTO', 'bril': '0002', 'corf': 'ON', 'cflr': 'INV', 'hflr': '0098', 'cflt': 'SCOF', 'hflt': 'GCOM', 'sltm': 'OFF', 'osal': '0152', 'osau': '0242', 'ancp': 'CUST', 'fdir': 'ON'}, 'scheduler': {'srsc': '0000000060ca55de', 'dstv': '0001', 'tzid': '0001'}} 2021/06/21 08:39:58 [548315591136] DEBUG Received update from K3G-EU-PDA2222A: MessageType.STATE 2021/06/21 08:39:58 [548315591136] DEBUG New environmental state: {'msg': 'ENVIRONMENTAL-CURRENT-SENSOR-DATA', 'time': '2021-06-21T06:39:59.000Z', 'data': {'tact': '2951', 'hact': '0053', 'pm25': '0001', 'pm10': '0001', 'va10': '0006', 'noxl': '0002', 'p25r': '0002', 'p10r': '0002', 'hcho': '0000', 'hchr': '0000', 'sltm': 'OFF'}} 2021/06/21 08:39:58 [548315591136] DEBUG Received update from K3G-EU-PDA2222A: MessageType.ENVIRONMENTAL 2021/06/21 08:39:58 [548315591136] DEBUG New environmental state: {'msg': 'ENVIRONMENTAL-CURRENT-SENSOR-DATA', 'time': '2021-06-21T06:39:59.000Z', 'data': {'tact': '2951', 'hact': '0053', 'pm25': '0001', 'pm10': '0001', 'va10': '0006', 'noxl': '0002', 'p25r': '0002', 'p10r': '0002', 'hcho': '0000', 'hchr': '0000', 'sltm': 'OFF'}} 2021/06/21 08:39:58 [548315591136] DEBUG Received update from K3G-EU-PDA2222A: MessageType.ENVIRONMENTAL 2021/06/21 08:40:28 [548306936288] DEBUG Requesting updated environmental data from K3G-EU-PDA2222A 2021/06/21 08:40:28 [548315591136] DEBUG New environmental state: {'msg': 'ENVIRONMENTAL-CURRENT-SENSOR-DATA', 'time': '2021-06-21T06:40:29.000Z', 'data': {'tact': '2951', 'hact': '0053', 'pm25': '0001', 'pm10': '0001', 'va10': '0006', 'noxl': '0002', 'p25r': '0002', 'p10r': '0002', 'hcho': '0000', 'hchr': '0000', 'sltm': 'OFF'}} 2021/06/21 08:40:28 [548315591136] DEBUG Received update from K3G-EU-PDA2222A: MessageType.ENVIRONMENTAL

seanrees commented 3 years ago

Apologies for the delay in responding; I've been pretty busy elsewhere lately. :-)

Thanks for that the log entry. I'm assuming you ran config_builder to generate a config? Can you provide the ProductType it discovered? (from your config.ini)

There was a change to support type 527E here: https://github.com/shenxn/libdyson/pull/9 and I'm wondering if this model differentiates itself by having the Formaldehyde sensors.

crgreenwood commented 3 years ago

Unfortunately not - 527E does not have the formaldehyde sensor. The one with the formaldehyde sensor is yet another model.

seanrees commented 3 years ago

Ping @kaiherzig ?

Can't proceed without the information requested above -- so the other option is to close the issue.

kaiherzig commented 3 years ago

Sorry I’ll send you tomorrow!

Viele Grüße Kai

kaiherzig commented 3 years ago

Sorry for the delay. producttype = 438E

seanrees commented 3 years ago

Thanks @kaiherzig, looks like libdyson has partial support for 438E which is why it sort of works for you.

I created a PR for libdyson to wire through the formaldehyde metrics: https://github.com/shenxn/libdyson/pull/12 which is the first step to support in this code.

seanrees commented 3 years ago

Update: this is ready for testing. I just released 0.3.1 which should plumb through the formaldehyde metric from libdyson.

Will you let me know if it works for you?

kaiherzig commented 3 years ago

Looks good :) It's working.

seanrees commented 3 years ago

Great news :) Thanks for filing the issue & testing the change 👍