Dylan's blog

How I improved my automated apartment

The last time I made a post here, I talked about my Home Assistant setup and the activities I began to automate with it. I also spoke about the data I had readily available at the time. Since that time almost two months ago, I’ve made some significant changes, including some I’m still working on.

Where do I begin? I think it’s most fitting to start with my most recent project. I wanted a way to track and view my energy data from my utility provider. Now, I know what you’re thinking - I could have bought a module to stick to my meter or breaker box panel; however, when I tried to get maintenance to hang up my smart thermostat, it took them over a week. I wasn’t interested in paying for a module like that either.

Getting energy usage from my provider

Please don’t sue me.

As a result, I ended up writing city-utilities-restful-wrapper, a Python project that exposes a RESTful web service. This web service is accessed by Home Assistant (HA). HA proceeds to ‘scan’ or reach out to the exposed /get endpoint every 24 hours. To sum up what this service does in a few steps:

The response coming back is super informative. Not only can I look at my statistics for the month, but I can also have an idea if my usage on the previous day was higher than average.

Energy usage Fun graphs

The gauges I put together while writing this. I also noticed the usage page on the CU website now has more data than before.

My plan is to use this data to make informed decisions about my water and electric usage for a given day or month. If I’m high in water usage, I’ll take shorter showers. And so on. Automations can give me suggestions based on my previous day’s usage each morning.

While writing this blog post, I worked on cleaning up the response coming back from City Utilities and returning half-hour and hour-by-hour data. Using this data I’ll be able to determine what time of the day I use the most electric.

Here’s an example of some of the data I’m receiving: image

If you’re curious to learn how this works, you can check out the project on GitHub: https://github.com/dbolger/city-utilities-restful-wrapper

Integrating my car

It’s probably too late to ask… but am I going too far?

Next up, I made a pretty big investment back in September and bought a new car. My car is a 2020 Hyundai Santa Fe and supports Hyundai’s BlueLink features, which allow for remote starts, remote locking and unlocking, and shows general information about your vehicle.

I quickly learned about how to interface with my device. On some of my first days of exploration, I was looking at hyundai_kia_connect_api, a wrapper library similar to that of my CU RESTful API, except without REST. The library is built in Python and users can start their car using Python (weird to think that’s where tech has brought us today).

I was able to start my car remotely after configuring the library to use my BlueLink account. The next thing on the agenda was including it in Home Assistant, and sure enough, the kia_uvo integration was exactly the solution I was looking for. After providing my credentials to the integration, I was provided a plethora of information about my car.

I recently started working on tracking my vehicle mileage. Rather than try to do that with trip meter inside the vehicle, I can watch my vehicle’s range decrease over time and get an idea of how many miles were driven in the past day, week, and month.

Neat, right?

I don’t drive very often since I work from home. Ideally if I were daily driving, I’d have some sort of sweet automation to start my car each morning before leaving.

I’d like to put more statistics about my driving and vehicle usage habits into HA. One implementation I’ve thought about is trying to report how many times I’ve filled up my tank each month. Some of these measurements could also be calculated for the year.

Organizing the configurable things

It’s great to have all of your configurations available in front of your controls. That is, until there’s too many things you can configure.

I’ve built my HA functionality with configurable helpers so if I need to make changes, I don’t have to find the hard-coded value somewhere. For example, if I start going into work at 7:00AM instead of 8:00AM, I have a “Work Start Time” helper, which allows me to provide a time to start work. Once I change this value, any automation or entity deriving information from this helper will use the new value.

I have a lot of these helpers. Probably too many. At a point they were starting to make understanding what I could control on HA much more difficult.

I opted for creating a new Dashboard for just helpers I use for configurations:

While a bit empty at the moment, this provides a base location for everything I could want to change on the fly:


One configuration I spun up was for my thermostat temperatures. As we’ve moved from summer into fall, my ideal thermostat settings changed. I decided to create some helpers to specify the exact temperatures I’d like to run throughout a year:


When we officially enter the Winter season on December 21, 2023, fall temperatures will automatically hide and I will be able to configure my winter temperatures. The same for all other seasons - the active season is the only one shown. I decided to make the sleep temperature as a sort of ‘global’ value for now, but helpers could be made to specify each season’s sleep temperature.

Talking about my thermostat is a great way to segue into the next improvement:

Adding Matter to my apartment

I currently only have one device that supports Matter; that is my Nest Thermostat, which had a software update earlier this year to enable the functionality.

Adding Matter to my home was a bit painful. I use a Raspberry Pi to run all of this magic. I was hit with a nasty blocker that prevented me from installing the python-matter-server package to my stack. Specifically that the architecture I was running on the Pi didn’t have a supported docker image. As a result, I had to make a backup of my Pi and reinstall the OS with the correct architecture. This was a good learning process on how to back things up and restore them. Also in the process, I learned a lot about Docker. In a future blog post, I’ll go into detail about my the architecture of my services and some things I learned along the way.

Once I had the correct OS, python-matter-server installed with no hesitation, and setting up the thermostat was pretty easy. All I had to do was open the Matter menu on the thermostat, scan the QR code through the HA companion app, and I had my thermostat configured through Matter.

There were and still are some caveats to this. The Nest Thermostat by Google doesn’t support sending humidity information over Matter just yet. I’ve ran into some user interface bugs that took some research into HA’s frontend and core implementations. I’ve opened some bug reports and plan on implementing some fixes.

Finally controlling my thermostat on my LAN

Why move to Matter if everything already works? The main reason is to make my system more responsive. To dissect how requests were originally being made, these are the general steps:

  1. I press some buttons that change the thermostat’s operating temperature
  2. A request is sent to Google/Nest’s servers to change my thermostat temperature
  3. The Google/Nest cloud service sends a response saying, yes, change the temperature
  4. The thermostat receives the response and changes the temperature

This works until you start getting rate-limited by Google because you’ve been debugging automations for the past thirty minutes. You also have a small amount of latency you’re waiting on while Google is replying to your request to change your thermostat’s temperature.

By implementing Matter, the steps look like this:

  1. I press some buttons that change the thermostat’s operating temperature
  2. A request is sent on my LAN without requiring an active internet connection
  3. The thermostat immediately gets the request and changes the temperature

And just like that, we reduce the number of hops needed to change my apartment’s temperature and we also no longer need to have an outside network connection to do so.

Adding a Matter server to my network also introduces support for any future home devices I add that support Matter.

Going forward

What’s next?

Ideally, I’d like to start parsing my electric and water usage in an understandable form. I’d like to set up a morning push notification that makes suggestions on how much energy to use based on the previous day. In example:

I’ve got some ideas on integrating vehicle data, but some of the helper logic and automation should be cleaned up before progressing.

Since I recently moved to a new operating system on my desktop, in my next post I’ll talk about the architecture of my services and how I host things on my LAN.

Until then, thanks for reading - I appreciate you taking the time to check this out!