Skip to main content
Home
The Baheyeldin Dynasty
The journey for wisdom starts with knowledge
  • Home
  • About
  • Site Map
  • Contact

Visualizing Thermostat/HVAC In Home Assistant With InfluxDB and Grafana

  1. Home

By Khalid on 2022/11/12 - 12:09, last updated 2022/11/14 - 14:50

If you already use Home Assistant, using the InfluxDB integration, coupled with Grafana will allow you to create very useful data visualizations that offers insight into your home over time. This includes things like: what are the humidity level fluctuations? What is the temperature indoors compared to outdoors? And much more ...

The Problem: Home Assistant Climate Integration

One question that took me many months of searching, is how to make a graph for the thermostat/HVAC, in order to see how long heating or cooling is running, versus indoor temperature and various other data points. The reason this is hard is that the thermostat uses the Climate integration in Home Assistant, which actually combines lots of data points into a single one entity, and making those data points attributes. As a result, it is not obvious how to get the data into InfluxDB. The Home Assistant forums have several questions on the topic that are either unanswered or involve convoluted partial solutions, such as using template sensors (example 1, example 2).

The rest of this article outlines how to solve the above problem, and get everything from Home Assistant to InfluxDB/Grafana.

Configure InfluxDB in Home Assistant

A minimal InfluxDB configuration in Home Assistant would not send an entity's attributes, or convert an entity into an InfluxDB measurement automatically.

To get over this limitation, you need to add the last four lines from the configuration snippet below:

influxdb:
  host: 127.0.0.1
  max_retries: 3
  tags_attributes:
    - entity_id
    - friendly_name
    - device_class

What this does is have each entity as a measurement and put the attributes as fields in there.

Side note: While you are at it, add the following, in order to get InfluxDB to better compress historical data:

  precision: ms

Once you add the above, and restart Home Assistant, you should be able to have queries like the ones below.

Create The Grafana Queries

Now you need to know what your thermostat entity name in Home Assistant, for example "climate.my_thermostat".

The following will show what desired temperature you have set the thermostat to.

SELECT last("temperature") 
FROM "climate.my_thermostat"
WHERE $timeFilter
GROUP BY time($__interval)
fill(previous)

And the following will show what actual temperature the thermostat is measuring from your indoor air.

SELECT last("current_temperature") 
FROM "climate.my_thermostat"
WHERE $timeFilter
GROUP BY time($__interval)
fill(previous)

And finally, you can create a graph of how long the thermostat is heating or cooling, per the following query.
Since the value for the hvac_action in Home Assistant is a string, the graph has to be a State Timeline in Grafana.

And while you are there, you may want to use the Value mapping option to assign colours to the various values (off, heating, cooling).

SELECT last("hvac_action_str") 
FROM "climate.my_thermostat"
WHERE $timeFilter
GROUP BY time($__interval)
fill(previous)

The Result: Everything Visualized

When you have completed all of the above steps, you can now see a graph like this one:

Acknowledgements

Thanks to Andrew Berry for his advice on the tag_attributes setting in Home Assistant YAML. Without this advice, this article would not have been possible.

Contents: 
Software
Tags: 
InfluxDB
Grafana
Home Assistant
HVAC
  • Add comment

Current

Pandemic

  • COVID-19
  • Coronavirus

Search

Site map

Contents

  • Family
    • Khalid
    • Ancestry
    • Extended
  • Friends
  • Nokat نكت
  • Writings
    • Cooking
    • Culture
    • Science
    • History
    • Linguistics
    • Media
    • Literature
    • Politics
    • Humor
    • Terrorism
    • Business
    • Philosophy
    • Religion
    • Children
  • Technology
    • Linux
    • Arabization
    • Drupal
      • Association
    • Software
    • Internet
    • Technology in Society
    • Digital Archeology
    • NCR History
    • MidEast Internet
    • Programming
    • Saudi ISPs
    • Miscellaneous
  • Places
    • Canada
      • Weather
    • Egypt
      • Cuisine
      • Alexandria
      • E.G.C.
    • USA
    • Saudi Arabia
  • Interests
    • Astronomy
    • Fishing
    • Photography
    • Snorkeling
    • Nature
    • Photomicroscopy
  • Miscellany

In Depth

  • al-Hakim bi Amr Allah: Fatimid Caliph of Egypt الحاكم بأمر الله
  • Alexandria, Egypt
  • Arabic on the Internet
  • Articles on the history of Muslims and Arabs in the Iberian Peninsula تاريخ المسلمين و العرب في الأند
  • DIY GOTO Telescope Controller With Autoguiding and Periodic Error Correction
  • E.G.C. English Girls College in Alexandria, Egypt
  • Egyptian Cuisine, Food and Recipes مأكولات مصرية
  • George Saliba: Seeking the Origins of Modern Science?
  • Internet Scams and Fraud
  • Mistaken for an Arab or Muslim: Absurdities of being a victim in the War on Terror
  • Mistaken Identity: How some people confuse my site for others
  • One People's Terrorist Is Another People's Freedom Fighter
  • Overview of Google's Technologies
  • Photomicroscopy
  • Pseudoscience: Lots of it around ...
  • Resources for using Google Adsense with Drupal
  • Rockwood Conservation Area, Southern Ontario
  • Selected Symbolic Novels And Movies
  • Snorkeling the Red Sea near Jeddah
  • Updates and Thoughts on the Egyptian Revolution of 2011

Recent Content

Most recent articles on the site.

  • FYSETC S6 3D Printer Board for OnStep Telescope Controller
  • The Rise Of Right Wing Violence And Terrorism In The USA And The West
  • Evidence Against Ivermectin Efficacy For COVID-19
  • Alazraqui: an Arab family name from Argentina
  • Ubuntu Pro Annoying Ads When Executing The apt Command
more

Most Comments

Most commented on articles ...

  • Another scam via Craigslist: offering more than asking price
  • Warning to female tourists thinking of marrying Egyptians
  • Craigslist classified for used car: Cheque fraud scam
  • Winning the lottery scam email: World Cup South African lottery
  • Email Scam: BMW 5 Series car and lottery winning
more

About Khalid

Various little bits of information ...

  • Khalid Baheyeldin: brief biography
  • Presentations and Talks
  • Youtube Videos
  • GitHub Projects
  • Drupal.org Profile
  • Astrophotography @ Flickr

Sponsored Links

Your Link Ad Here

Tags

Android Mobile Ubuntu OnStep Sony OpenWRT Ericsson Router Arabic COVID-19 Rogers Coronavirus GSM Kubuntu 419 Home Assistant Spectrum tablet Telescope Scam App backup Balkanization Comet Conspiracy CPU DIY Firefox Laptop Malta
More

© Copyright 1999-2023 The Baheyeldin Dynasty. All rights reserved.
You can use our content under the Terms of Use.
Please read our privacy policy before you post any information on this site.
All posted articles and comments are copyright by their owner, and reflect their own views and opinions, which may not necessarily be consistent with the views and opinions of the owners of The Baheyeldin Dynasty.

Web site developed by 2bits.com Inc.