What's up, home? part 19

Logo

Can you automatically control the temperature of your home in a time- and room based manner using Zabbix? Of course you can! By day, I am a monitoring technical lead in a global cyber security company. By night, I monitor my home with Zabbix & Grafana and make some weird experiments with them. Welcome to my weekly blog about this project.

Earlier in this blog series I have made Zabbix to read the status of our air conditioner, and have made it possible to use Zabbix as a manual remote control for the device. But we need to take a step further and make Zabbix to control the AC based on the time of day and if I am at home or not.

Forget the sweaty nights

Usually in Finland the nights are not so hot that an AC would be needed. However, that can happen during any rare heat wave we get. It's annoying to wake up in the middle of the night all sweaty and turn on the AC when it's already too late.

Of course, I could just leave the AC on when I go to bed, but let's make Zabbix to do some good for our electricity bill and for the environment by not using the AC when it's not needed.

Detecting if I am at home

Like so many times before in this blog series, Cozify smart home hub is the true star of this story. It detects if anyone is at home based on if a specific phone or for example a smart key fob is present and reachable in Cozify's range. For this case, I will be using my smart key fob in Zabbix, too. This is how it looks in Cozify.

No alt text provided for this image

... and here's the key fob reachability status in Zabbix.

No alt text provided for this image

Surprisingly enough, it shows 1 (or "True") as my status now that I type this blog entry at home and my keys are at home.

A deeper dive to my key fob Zabbix item

To make this all work, I have a set of Python scripts gathering data from Cozify via an unofficial Cozify API Python library. One of the scripts gets the reachability status for all the items, and here's the configuration for my key fob Zabbix item.

No alt text provided for this image

... and some preprocessing ...

No alt text provided for this image

Let's add some triggers

Now that we have the key fob data, let's create some triggers to combine the data about my presence with the temperature information.

I created the triggers by using Zabbix expression constructor:

No alt text provided for this image

.. and when I was done, this is how it looked.

No alt text provided for this image

I made a similar trigger for our living room, too.

Next, some scripts

Next I added some scripts under Zabbix Administration --> Scripts and made them as Action operations.

This one turns on the AC:

No alt text provided for this image

... and this one turns it off.

No alt text provided for this image

Lights, camera, action!

We have our triggers and scripts, great! Next it's time to add some actions.

 

  • During daytime, Zabbix will be interested about the living room temperature and will turn on AC if the temperature goes over 23C for ten consecutive times
  • During nighttime, Zabbix will be reading the temperature of our bedroom and turn on AC if the temperature goes over 23C for ten consecutive times

 

No alt text provided for this image

We will see how well my attempt to this will work. Here's how the operations do look like -- if it's too hot, turn on the AC, and when the temperature comes down enough, turn off AC.

No alt text provided for this image

As I built this thing while I wrote this blog entry, it's possible I will need to fine-tune the thresholds somewhat to not make my automatic AC control too aggressive. Anyway, this now works in theory.

Oh, BTW, Cozify could also do similar rules, but as it does not directly support our air conditioner (but would require a separate Air Patrol device for that), this is again a great example of how I can utilise Cozify, but with Zabbix extend my home's IoT functionality even more for free.

I have been working at Forcepoint since 2014 and always try to find out new ways to automate things.

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
Buy me a coffee

Like these posts? Support the project and Buy me a coffee