Adding Temperature Sensing to Your Home Automation System On the Cheap

Problem

I wanted to be able to measure the temperature and humidity in various parts of my apartment, because the heating and cooling isn’t evenly distributed. My plan was to average those numbers and use it as a baseline to tune the heat and cooling, as opposed to the temperature just at the thermostat.

This is a feature of some thermostats, like the Ecobee, where they acknowledge the issue of one location making decisions for the comfort of the entire house.

I don’t want to solder. This is a personal decision. I burnt out too many components trying to learn that in high school. The best options for hobbyists in this area are to build their own, which I may try again someday.  So, I need a prebuilt solution.

Off the Shelf Options

There are a lack of good inexpensive temperature sensors that can be easily integrated into a Home Automation system. The best inexpensive option I found were some Z-Wave sensors made by Xiaomi(they’ll be here in a few weeks from China and I’ll see how that works).

I have, for a few years, had an Acurite 5 in 1 weather station mounted outside. It measures temperature, humidity, wind speed, wind direction, and rainfall. It broadcasts updates every 36 seconds.

It came with a wireless temperature and humidity sensor that updates every 16 seconds.

Implementing a Solution

So, I had one of these, and after I got this working, I bought several more to cover the areas I wanted to. The system is ultimately expandable without limit.

There are two ways to get this data into a computer. One is with the provided Acurite hardware. They make an Internet bridge..which you cannot get data from so easily. They also make USB devices, which you can interface with. I use this to run a weewx installation(more on this later).

But, the option I chose was based on what I had in house. A software defined radio USB dongle left over from my ADS-B project(more on that another time too).

On Github, you can download a project called RTL_433, which is designed to retrieve data from wireless temperature sensors. It also supports a variety of brands and other types of sensors. And, on a positive note, if you find something that operates on the same frequency, you can probably get it included.

The RTL_433 program supports output in JSON, which I can then feed into something to monitor the data and use it. I originally had planned to pre-process it with a script and then send it into Home Assistant.

I have the output from the sensors being converted to MQTT messages. But the messages from RTL_433 are all merged together, coming from the same source.

Someone in the Home Assistant Discord chat room suggested I use Home Assistant itself for pre-processing.

- alias: rtl433_bedroom_convert
 trigger:
 - platform: mqtt
 topic: sensors/rtl_433
 condition:
 condition: template
 value_template: >
 {% if trigger.payload_json.id %}
 {{ trigger.payload_json.id == 494 }}
 {% else %}
 false
 {% endif %}
 action:
 - service: mqtt.publish
 data_template:
 topic: rtl433/bedroom
 payload: '{ "temperature_F" : {{ trigger.payload_json.temperature_F | round(1) }}, "humidity" : {{ trigger.payload_json.humidity }}, "model" : "{{ trigger.payload_json.model }}" }'

This is triggered when a sensor transmission comes in, and the id number is ‘494’, which is the sensor in my bedroom. It converts the payload into its own specific message that can be picked up not only by Home Assistant, but by anything that is monitoring these messages(dashboard anyone?)

You may notice a few things here. The sensors I have do support humidity for example…I’ll be using that as part of my climate control project. I am also rounding the temperature to a single decimal point, where the system supports 2 decimals. I do pass a few other parameters I am not yet using, such as battery on the sensor, which I’ll likely set up a notification on.

2 thoughts on “Adding Temperature Sensing to Your Home Automation System On the Cheap”

Leave a Comment