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:

image

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:

image

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!