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:
- Authenticates (logs in) with City Utilities to get a login token
- Uses login token to perform RESTful requests to their hosted pages.
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.
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:
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.
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:
- I press some buttons that change the thermostatās operating temperature
- A request is sent to Google/Nestās servers to change my thermostat temperature
- The Google/Nest cloud service sends a response saying, yes, change the temperature
- 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:
- I press some buttons that change the thermostatās operating temperature
- A request is sent on my LAN without requiring an active internet connection
- 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:
- If the previous dayās usage is high, provide a warning to be more mindful of usage
- If the previous dayās usage is average or low, donāt provide any push notification
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!