bachya / ecowitt2mqtt

Send data from Fine Offset weather stations (Ecowitt, Ambient Weather, Froggit, etc.) to MQTT!
MIT License
210 stars 44 forks source link

Additional Calculated Values for Auxiliary Sensors #1073

Open nanderson97651 opened 3 weeks ago

nanderson97651 commented 3 weeks ago

Is your feature request related to a problem? Please describe. No, additional functionality.

Describe the solution you'd like I'm using this with home assistant and loving it so far, especially the calculated values. My station (WS3800) has temp and humidity for inside too. Is it possible to add the (optional) function of calculated values for auxiliary sensors? e.g. Calculate dew point at the location of my base station or location of additional WN31 sensors.

Additional context Could be an optional feature as to not clutter with too many additional entities.

wolfgangr commented 2 weeks ago

Just hit the same question, relating to WH31 sensors.
My station found 4 of them lingering around, 8 were possible.

It boils down to the question where in the pipeline were the best point to "blow up" data by e.g calculated values.

Digging down the rabitt hole
https://github.com/bachya/ecowitt2mqtt/blob/dev/ecowitt2mqtt/util/meteo.py
we find that ecowitt2mqtt uses this library function
https://github.com/malexer/meteocalc/blob/master/meteocalc/dewpoint.py

    const = CONSTANTS['positive'] if T > 0 else CONSTANTS['negative']
    pa = RH / 100. * math.exp(const['b'] * T / (const['c'] + T))
    dp = const['c'] * math.log(pa) / (const['b'] - math.log(pa))

Sure, a bit cumbersome, but this can be implemented anywhere you have access to some basic math.

For my case, I think I'll drop calculated values from the raw log any 16s in my database.
May be I'll add it back by SQL calculation in 5 min or 60 min aggregates.

I agree with you that a configurable option would be great -
offloading our work to the ecowitt2mqtt maintainer ;-)

There's a nice piece of "MQTT-philosophy" in the German wiki (did not find it in the English version, unfortunately)
https://de.wikipedia.org/wiki/MQTT

In this view, I'd think ecowitt2mqtt is a sensor interface and thus might better be kept simple and lightweight?
Isn't home assistant capable of doing the calculations?