Overview of options for custom sensors

I have a few ideas for custom things I want to hook up to Home Assistant so I’m looking for an overview of the available options.

One is an USB based sensor (TFA Dostmann CO2 sensor) that I want to hook up to HA in some way. Either directly on the Raspberry Pi, or possibly connected to some other PC or Arduino. This obviously requires direct hardware access.

Another is an ESP32 with significant local functionality like a display and buttons with a complete menu interface. ESPHome seems to be a common suggestion for connecting these to HA, but this project doesn’t fit neatly within the paradigm of yaml configuration files and sensors.

Another need is the ability to do a somewhat nontrivial analysis on several different sensors to compute a derived value (vapour-pressure deficit) that is used for further automatons. It’d probably have to be some kind of helper script (Python, JS, etc) that takes in multiple entities and produces a new sensor value.

Options I’ve found

  • If I duck around it seems like a lot of people go straight for MQTT, which requires a broker addon.
  • It appears you can also just directly make HTTP requests to create a HTTP sensor.
  • There is also a REST sensor which seems similar but poll rather than push
  • For the ESP32 it might be possible to stuff the entire local functionality in an external component
  • There is some support for sandboxed Python scripts that could maybe be used for computing a derived sensor value, but I’m not sure how.
  • A custom component seems to be the most versatile and complicated solution.

But it’s kind of hard to find the pros and cons of each approach, and if there are any other approaches I’ve missed. In particular:

It’d be nice to be able to do automatic discovery of my ESP32 without using ESPHome, but it’s not clear to me which technologies and APIs this uses.

I don’t really understand how to compute a derived value of some other entities.

CO2 specific options

Actually it turns out someone already wrote a custom airco2ntrol component which uses hidraw directly connected to the raspi.

Further research indicates this is probably a rebranded ZyAura device, which has ESPHome support if you’re willing to open it up and hook up the wires.