marcolivierarsenault / moonraker-home-assistant

Home Assistant integration for Moonraker, Klipper and Mainsail
https://moonraker-home-assistant.readthedocs.io
MIT License
231 stars 25 forks source link

Add support for other BME680 measurements #277

Closed BenBergman closed 5 months ago

BenBergman commented 7 months ago

Is your feature request related to a problem? Please describe.

Currently this integration pulls the temperature from BME280-style sensors. My sensor is a BME680 (uses the BME280 class in Moonraker) which also provides air pressure, humidity, and "air quality". It would be great to get these into Home Assistant for logging and automating (eg. track when humidity has gotten too high, notify when air quality is poor).

Describe your setup

My printer is an Artillery Sidewinder X1 running Klipper, Moonraker, Mainsail, Klipper Screen Raspberry Pi

Describe the solution you'd like

When a BME280 device is found on the Moonraker instance, this integration should check if it provides each of pressure, humidity, and air quality. If so, it should add them to Home Assistant.

Additional context

image
marcolivierarsenault commented 7 months ago

@BenBergman we don't have these sensors so we can't really tests and implement. We will need someone with this sensor willing to implement

BenBergman commented 6 months ago

I'll poke around in it and see what I can do.

BenBergman commented 6 months ago

I'll try to put some more time in later, but for posterity, making a query to the Moonraker API for "method": "printer.objects.query", "params": {"objects": {"bme280 enclosure": null}} got me

{
  "jsonrpc": "2.0",
  "result": {
    "eventtime": 542200.418648897,
    "status": {
      "bme280 enclosure": {
        "temperature": 21.79,
        "pressure": 985.6027570024027,
        "humidity": 21.03908186195813,
        "gas": 54177.11558804064
      }
    }
  },
  "id": 5153
}

I could create 3 more sensors here at all times, but I'm not sure if that would give garbage sensors for people with the simpler bme280s. If so, I'll have to see if there is a way to make the above API call to get a list of the available sensors.

Edit: I see from other parts of the code how to query that manually, so I should be able to implement this tonight or tomorrow.