arachnetech / homebridge-mqttthing

A plugin for Homebridge allowing the integration of many different accessory types using MQTT.
Apache License 2.0
467 stars 104 forks source link

PM2.5, PM10 history for Air Quality Sensor? #162

Closed mrdc closed 5 years ago

mrdc commented 5 years ago

Hello,

Would be nice to add history for PM2.5, PM10 as it's useful for monitoring air quality.

tobekas commented 5 years ago

Unfortunately it’s not possible to implement generic history for any kind of data. Since this feature is based on https://github.com/simont77/fakegato-history, only some types are possible: only types Elgato Eve supports for their own products. It’s up to Eve, which types are supported. The trick is to fake exactly the bahavior of their custom HomeKit characteristic, to offer the graphics also for homebridge-mqttthing accessories.

tobekas commented 5 years ago

For AirQuality sensors, you can just use AirQualityPPM somehow, which is uses by „Eve Room“. You may play around with scaling (apply feature) and just use this topic for your particulate matter (PM) data. If you want to have 2 graphs both for pm2.5 and pm10, you have to configure two separate accessories.

mrdc commented 5 years ago

@tobekas

For AirQuality sensors, you can just use AirQualityPPM somehow

I did the following:

            "topics": {
                "getAirQuality": {
                    "topic": "/ESP_Easy/PMS7003/pm10",
                    "apply": "co2 = JSON.parse(message); return (co2 > 45 ? 'POOR' : co2 > 40 ? 'INFERIOR' : co2 > 35 ? 'FAIR' : co2 > 25 ? 'GOOD' : co2 <= 25 ? 'EXCELLENT' : 'UNKNOWN');"
                },
                "getCarbonDioxideLevel": "/ESP_Easy/PMS7003/pm10",
                "getAirQualityPPM": "/ESP_Easy/PMS7003/pm10"
            },
            "airQualityValues": [
                "UNKNOWN",
                "EXCELLENT",
                "GOOD",
                "FAIR",
                "INFERIOR",
                "POOR"
            ],
            "history": "true"
        },

This is my default AirQuality Sensor: image Here are 2 AirQuality Sensors for PM2.5&PM10. Unfortunately, there is no charts with the above config for PM2.5&PM10, but measurements are saved: image image image image image

Andi1968 commented 5 years ago

Hi, what do the messages look like that you receive under topic /ESP_Easy/PMS7003/pm10 ? Apparently they are not just ppm values but perhaps some value followed by unit ? Your Apply always returns UNKNOWN and I suppose Eve App simply interprets this as no measurement available (for the chart). Also the values in the list are not plausible. Even outside you should not see values below 400ppm CO2. Indoors the value should be higher.

Andreas

mrdc commented 5 years ago

Hi, what do the messages look like that you receive under topic /ESP_Easy/PMS7003/pm10 ?

Hi, image Values are loaded normally from the topic - check the first pic where you can see CO2, PM2.5 and PM10, For PM2.5&PM10 history I've decided to make a trick and connect PM2.5&PM10 to PPM (2 more AirQuality Stations), so history is saved and EVE app reads PPM values which are taken from PM2.5&PM10 topics.

Your Apply always returns UNKNOWN Even outside you should not see values below 400ppm CO2.

That's strange, because I see that on the main screen in EVE app it returns the correct name like excellent, good etc. Picture below. Don't now why in measurements it shows UNKNOWN. I'll play with my config. Yes, EVE app can drop values <400ppm as incorrect. image

tobekas commented 5 years ago

Maybe the values around ~10 are too low. This AirQuality history is originally just for displaying VOC values, which are much higher. Can you just try to scale your values by *100 (apply), just to see if the graph is working. By the way, the named categories (UNKNOWN, ...) in the measurements are not related to the AirQuality category characteristic, but derived from the values. There is a fix relation (from Eve’s side) between ppm values and the category. Nevertheless there is this redundant AirQuality characteristic, because this is a standard HomeKit characteristic, whereas this specific VOC(ppm) characteristic is not.

tobekas commented 5 years ago

Maybe you go better with misusing a temperatureSensor type. Of course this is very unpleasant, because you will get unit °C. But this is just as wrong as ppm instead of μg/m^3.

As a long-term solution I recommend you to take a look at Grafana, a great plattform for MQTT logging and many more. There is a big community and it can also run on a RPi.

mrdc commented 5 years ago

Maybe you go better with misusing a temperatureSensor type. Of course this is very unpleasant, because you will get unit °C. But this is just as wrong as ppm instead of μg/m^3.

As a long-term solution I recommend you to take a look at Grafana, a great plattform for MQTT logging and many more. There is a big community and it can also run on a RPi.

Thanks, I'll try to scale and then will try with the TempSensor. Grafana is great, but there is no iOS app and devs don't plan to release it, additionally my family members like EVE app :)

mrdc commented 5 years ago

Scaling works, so it's EVE app issue.