Radon Project: Looking for someone to convert using already made python script into HAOS - any takers?

Hi all,

I’m running this script here on a RPi4

It basically measures radon levels (Airthings Wave Plus) and adjust the radon fan speed using the mcp4725 based on the level of radon. The radon fan uses a DAC (digital to analogue controller) and accepts values from 0.00 to10.00, which corresponds to fan speed of 0 to 100%. It also logs pressure from a Honeywell AMBP Sensor and sends alerts (via gmail) when any of the values are out of range. Here’s my actual setup, you can see the components:

Here’s what I did to try and get this into HA via HAOS. I created 2 custom addons

  1. For reading the Honeywell Pressure sensor using this code only:
Summary
if __name__ == '__main__':
    print("Press CTRL+C to exit...")

    try:
        abp = SensorHnyAbp("060MG2")    # 0 to 60 mbar gage I2C
        # abp = SensorHnyAbp("001PDS")    # -1 to +1 psi diff SPI

        while True:
            """
            result = abp.readAbp()
            print('Press: {0:7.3f} {1:s} {2:7.2f} in.wc'.
                     format(round(result,3), abp.PRES_UNITS, round(abp.pres2inwc(result),2)) )

            status, result = abp.readAbpStatus()
            print('Status: {0:d}  Press: {1:7.3f} {2:s} {3:7.2f} in.wc'.
                   format(status, round(result,3), abp.PRES_UNITS, round(abp.pres2inwc(result),2)) )
            """

            status, result, tempC = abp.readAbpStatusTemp()
            if 0 :    # mbar
                print('Status: {0:d}  Press: {1:7.3f} {2:s} {3:7.2f} in.wc {4:5.1f} degF'.
                   format(status, round(result,3), abp.PRES_UNITS, round(abp.pres2inwc(result),2), round(abp.c2f(tempC),1)) )
            else :    # psi
                print('Status: {0:d}  Press: {1:7.3f} {2:s} {3:7.2f} in.wc {4:5.1f} degF'.
                   format(status, round(result,3), abp.PRES_UNITS, round(abp.pres2inwc(result),2), round(abp.c2f(tempC),1)) )

            time.sleep(1)            # Print out every second

    except KeyboardInterrupt:
        sys.exit(" Exit")
  1. For setting the value for the DAC fan speed
Summary
if __name__ == '__main__':
    print("Press CTRL+C to exit...")

    try:
        dac = mcp4725()

        # initialize bus
        i2c_ch = 1                    # i2c channel
        dac.bus=smbus.SMBus(i2c_ch)   # Initialize I2C (SMBus)

        while True:
            print("Enter value (0.0 - 1.0): ")
            value = float(input())
            dac.writeDAC(value)

    except KeyboardInterrupt:
        print(" Keyboard interrupt caught, exiting.")

    dac.bus.close()

By creating these 2 addons, I was able to see the pressure being logged every few seconds and I was able to control the fan speed, but there was a couple of issues:

  1. I was not able to get the pressure data into HA, it was just being shown/logged in the addon logs and not like an entity with a history date/time etc.

  2. I had to publish a new version of the addon to change the value of the DAC it was not like a number input, for example

I believe there needs to be an integration that has to be created to bring these two features into HA.

The rest of the script is extra because I can use for example the Airthings, Gmail integrations to take care of the rest.

If I can get these two into HA, it would basically be all that I need to replace the script.

Any takers? Perhaps fee for service?

thanks

Interesting project.

From my experience and seeing the tools you have (hardware and software) I would think integrating this device with Home Assistant would be best done using MQTT.

You have a powerful and reliable MCU in the RPi4. (I would add either hardware or RPi OS based watchdog timer)

Your ‘radonMaster’ program already seems to have a MQTT publishing loop built in, you just need to add the sensor in the softwares publishing loop.

Get your sensors values into MQTT messages via the ‘radonMaster’ publishing loop. And then debug the format the the message values in MQTT tools such as MQTT Explorer. You can then adjust the MQTT value formats either in the ‘radonMaster’ publishing loop or on the receiving end (in this case a Home Assistant MQTT sensor.

You appear to have already hacked the radon Fan and created software on the Pi to adjust the fan. I am guessing this is running in parallel and outside to the ‘radonMaster’ code, probably the best idea to minimize any fault injection and code changes to the ‘radonMaster’ code. If I am correct in this ASSumption, you just need to add some type of async MQTT message receiver in your DAC code to override the setting received from the radon reading (though I would default to radon sensor reading, or to max fan level for ‘fail safe’ mode). I would add the publishing a ‘heartbeat’ time, say every 30 seconds, in MQTT message. This would allow HA to check that your control process is running (it could probably also monitor the radonMaster code some how to check it is operating properly.

IMHO by forking the ‘radonMaster’ code or adding to it, and doing all your work via MQTT you open your solution to more folks, those that might not use Home Assistant but rather say HomeKit, OpenHab, Tasmota Matter, etc. And as result you get more testing and feedback.

Good hunting!

thanks, @dproffer

going the mqtt route could be an alternative here. You’re right, there is some basic mqtt code written there but as you said, it does not work in HA as written due to the missing sensor information.

Please see @firstof9 forked branch for complete re-write of mqtt feature along with mqtt with Home Assistant discovery of pressure, fan value and airthings sensors to mqtt.

Thanks, Chris!

1 Like

Might need the branch linked:

1 Like