ComfoAir Binding and HIH6131 Sensor

After discovering OpenHAB and playing around with it for a bit, I have it now “in production” with my ComfoAir 350. Thank you for all the effort that went into this platform, especially Holger for the ComfoAir binding. (I hope you’re reading this :grinning:)
I would like to share my insights, maybe it is an inspiration to someone or some help while setting it up.

Motivation for my setup
I wanted to add more intelligence to my ventilation system since out of the ComfoAir 350 it is not very intelligent. It offers a time based profile which is very difficult to enter using the CCEase head unit. I wanted something that takes into account time, temperature and humidity.
My flat is set up such, that air is pushed into all rooms except for the bathrooms, where it is sucked out. Since the bathrooms don’t have a window or any other means but the ventilation to get moist air out, it would be nice to accelerate ventilation automatically if someone is having a shower. Therefore I added a humidity sensor.

I used a RaspberryPi A (the rather old Model B) and added a MAX2323 level shifter for the serial port, and a Honeywell HIH6131 humidity and temperature sensor. (I also tried stealing the 12V power with a LF50C voltage regulator from the ComfoAir, but there is not enough power, so it is now back on an external power supply.)
The HIH6131 “breakout board” is now installed next to the bypass inside the ComfoAir. (I might have lost my warranty here.)

Some hardware pictures

RaspberryPi connected via serial port to Comfoair and via I2C to HIH6131.

(Please go to my GitHub page for the other pictures)
HIH6131 next to the bypass. Please ignore the duct tape and maybe the next revision of the sensor breakout board will feature proper SMD soldering pads.

(Please go to my GitHub page for the other pictures)
RaspberryPi internals. (MAX2323 level shifter and GPIO-Pins, once more duct tape is very useful for insulation :grin: .)

HIH6131 script
Adafruit has a good tutorial for setting up I2C on the RaspberryPi. As you can see in my configuration, I used a simple python script to read the values from the HIH6131 and placed it in /usr/local/bin/

#!/usr/bin/env python
import smbus
import time
b = smbus.SMBus(1)
d = []
addr = 0x27
d = b.read_i2c_block_data(addr, 0, 4)
print ((d[0]<<24) + (d[1]<<16) + (d[2]<<8) + d[3])

For testing purposes it can be helpful to print add these lines

# don't forget to remove before accessing this with OpenHAB!
status = (d[0] & 0xc0) >> 6
humidity = float(((d[0] & 0x3f) << 8) + d[1])*100/16383
tempC = (d[2] << 8) + d[3]
tempC = float(tempC >> 2) * 165 / 16383 - 40
print "%i, %.2f%%rH, %.2f°C" % (status,humidity,tempC)

My status is always “1” indicating “stale”. I don’t fully understand why, maybe I have to get my osci out and examine the protocol on the wire. For now, I don’t bother.

I placed my OpenHAB configuration on GitHub.

This really got me excited :smile:! I’m thinking of integrating my blinds and add some presence detection through my router.

Citation of relevant work
Most of my code and configuration is based on the work of the Samples Comfo Air Binding and this RaspberryPi forum thread. Links are on my GitHub page.

1 Like

3.5 years later…

I decided to update to openhab2 and a RaspberryPi Zero. Due to some problems with the execution of the phython skript, I created a binding for the hih6131. If anyone is interested, here it is:
The sensor is discovered by PaperUI.

Of course some updates to items

Number HIH6131Temperature	"Raumabluft (HIH6131) [%.1f °C]"	<temperature>{channel="hih6131:sensor:667b0c7f:temperature"}
Number HIH6131Humidity		"Luftfeuchtigkeit [%.1f %%rH]"		<humidity>		{channel="hih6131:sensor:667b0c7f:humidity"}
Number HIH6131Status		"Status (HIH6131) [%d]"			<selfError>{channel="hih6131:sensor:667b0c7f:status"}
Number HumidityFanOn				"Schwellwert An [%.1f %%rH]"		<humidity>
Number HumidityFanOff				"Schwellwert Aus [%.1f %%rH]"		<humidity>
Number HumidityAvg				"Ø-Luftfeuchtigkeit [%.1f %%rH]"	<humidity>
Number HumidityAvgHi				"Obergrenze [%.1f %%rH]"		<humidity>
Number HumidityAvgLo				"Untergrenze [%.1f %%rH]"		<humidity>
Switch HumidityHigh				"Hohe Luftfeuchtigkeit"			<humidity>

Of course make sure the channel is correct. For some reason {hih6131=“temperature”} works but humidity and status not. If someone knows why, please reply here.

And one rule

rule "Honeywell sensor"
    Item HIH6131Humidity changed
    var averageHumidity = HumidityAvg.state as DecimalType
    var humidity = HIH6131Humidity.state as DecimalType
    var humidityOn = HumidityFanOn.state as DecimalType
    var humidityOff = HumidityFanOff.state as DecimalType
    var averageHumidityNew = (averageHumidity * 999 + humidity) / 1000
    postUpdate(HumidityAvg, averageHumidityNew)
    postUpdate(HumidityAvgHi, averageHumidityNew + humidityOn)
    postUpdate(HumidityAvgLo, averageHumidityNew + humidityOff)
    if (humidity &gt; HumidityAvgHi.state) {
        logInfo("Humidity", "High humidity detected: " + humidity.toString + " %rH &gt; " + HumidityAvgHi.state.toString + " %rH")
        postUpdate(HumidityHigh, "ON");
    } else if (humidity &lt; HumidityAvgLo.state) {
        logInfo("Humidity", "Lower humidity level reached: " + humidity.toString + " %rH &lt; " + HumidityAvgLo.state.toString + " %rH")
        postUpdate(HumidityHigh, "OFF");

If someone considers this binding relevant enough, I’ll invest some more time into documentation and create a PR. But so far I think it is only relevant to few. :slight_smile: