I recently replaced my old thermostat with a smart thermostat I can control through Home Assistant. I chose the Zen thermostat because it uses Zigbee, doesn’t require a common wire (c-wire), and they were available for under $30 on ebay. When I paired the new thermostat using the Zigbee Home Automation integration in Home Assistant, it appeared as a generic thermostat that I could control using Automations.
The generic thermostat device creates a new sensor Entity called hvac_action. This sensor shows when the thermostat is in heating mode. Viewing the history of the generic thermostat shows when the thermostat called for heat and the furnace was running.
Creating the virtual sensors
To make use of this data, we need to create a sensor that will track how long the furnace has run each day. I will create a sensor in configuration.yaml
called Furnace On Time that will track when hvac_action is heating. Then, I need to calculate how much gas the furnace burns while running. Since I’m in Canada and billed in cubic meters, my goal is to determine how many m³ of natural gas my furnace is consuming. My furnace has an input of 80,000 BTU/h. Since 35,300 BTU are in each cubic meter of natural gas, I can divide 35,300 BTU/m³ by 80,000 BTU/h to determine how many cubic meters my furnace consumes per hour. In my case, it’s 0.44125 m³/h. So, we need to create a sensor called Natural Gas Usage
that divides sensor.furnace_on_time
by 0.44125. I added the following code to the configuration.yaml
file:
sensor:
- platform: history_stats
name: Furnace On Time
entity_id: sensor.zen_hvac_action
state: "heating"
type: time
start: "{{ now().replace(hour=0, minute=0, second=0) }}"
duration:
hours: 24
template:
- sensor:
- name: "Natural Gas Usage"
state_class: total_increasing
device_class: gas
unit_of_measurement: "m³"
# 0.44125 m³/h calculated by dividing 35,300 BTU/m³ by 80,000 BTU/h furnace
state: "{{ states('sensor.furnace_on_time') | float / 0.44125 | round(4) }}"
Adding the data to the Energy dashboard
The final step is to add Natural Gas Usage to your Energy dashboard in Home Assistant. You can also add the price of gas to estimate your hourly/daily/monthly/quarterly/yearly costs.
Final thoughts
This is a very simple way to get an estimate of gas usage but in the end, it’s still just an estimate. Your furnace may consume natural gas at a slightly different rate than what the manufacturer intended for a variety of reasons.
Code was modified from this discussion post on the Home Assistant forums.
Estimating natural gas usage with a generic thermostat
byu/rastrillo inhomeassistant