silveradept: A librarian wearing a futuristic-looking visor with text squiggles on them. (Librarian Techno-Visor)
Silver Adept ([personal profile] silveradept) wrote2024-05-12 10:15 pm

Adventures in Home Automation #12: Source Data Switching

At the moment, most of the automations and controls that have been put in place for the Home Assistant are stable. There's a fair amount more of things to teach to the remotes so they can do more control matters in the rooms they're in, but for the most part, there hasn't been a whole lot of need to add more functions or figure out a method to do a thing that has been requested of me. (Which just means that a new thing hasn't caught our attention at this point and I haven't been tasked with figuring out how to make it work.)

What that does mean, however, is making sure that the things that are in place, the duct tape and string holding it all together, is still strong and properly reinforced. Sometimes that means making sure the glue script for turning a TV on and off over the MQTT/CEC bridge still works and has been put properly into place when the attached SBC changes to a different operating system. (And finding out, delightfully, that a different method of controlling the screen works just fine even if one of the libraries is tied up in the bridge.) Sometimes it means shuffling some methods over to make sure that there's still good remote access for when you want to do work on one of the other computers without disturbing the person who is in the room that's there. (Because the library you had been relying on to do that upgraded itself and the program that worked with it didn't upgrade to the new version.)

For this particular situation, though, it was the announcement from one of the API providers that I've been using for weather and other data saying "We're shutting down the always-free, needs no payment methods on file API access and moving all of you over to the still free for a limited amount of calls, but after that we charge you access instead." At which point I said, "Well, that's a service that I'm no longer going to be using." What that means, though, is that the one service that I was pulling weather, Air Quality Index, and Ultraviolet Index data from needed replacements. I was about to find out how good I had gotten, and how good my design of automations was, because I had to do some wholesale data source replacements.

Weather turned out to be a fairly easy replacement. There's a National Oceanic and Atmospheric Administration (NOAA) integration present for Home Assistant, and that gave me most of the weather things I needed, like temperature, heat index, wind speed, and current weather condition. Being United States Government data, it was available for free and, presumably, will not suddenly start disappearing behind a paywall. I needed to provide some latitude and longitude, and what my closest reporting station identification was, both of which are fairly easy to find.

The U.S. Government also has an API for AQI, administered through the Environmental Protection Agency, and that explicitly mentions several partner agencies and entities that are feeding them live data. Unfortunately, those partner agencies, like my local clean air agency, do not have a clearly-accessible API, nor a method for getting an account or key with them to pull their data. And the EPA has a form for you to fill out to request access to the API, and I got the feeling, true or not, that if I said "Well, I want it so my home automation device will change lights when things are bad outside or play a clip from 1776 about how it would be a good idea to circulate fresh air into our house," that the EPA would say "Your scale is too small for access to this data." and deny the request.

Luckily for me, a different integration, the World Air Quality Index, helped me out. I had to register an API key with them, but once that was plugged in, and again, I indicated which of my local stations was the one I wanted to pull data from, that also integrated into my flows pretty easily. I did lose some fidelity in the switch, as the new integration only seems to track particulate matter as their measure of pollutants, and the previous one had created an index value that measured particulates, ozone, and other such things. This was an acceptable loss to me.

The last thing to find a replacement for was the Ultraviolet Index, and that did not have a convenient integration to work with. But being an information professional, that means going about in the world and finding somewhere that is providing this data and using their API to do it with. Which I did, and then integrated it into the flow, using the templates that I had already learned about in creating REST sensors and the bits I had learned about how to traverse JSON paths to get to the right places so I could pull in the information I wanted. This is the one I'm the least confident in its continued success and availability, but if I have to hop from one to another, that'll be fine, as I'm sure there are plenty of places that will provide this data for my location.

Having found new sources, then I just had to rewire all the appropriate automations and commands to use the new data sources, which didn't take long, just repeatedly having to change from one source to another in all the places where it had been. And within the last two days, all of the automations that were running on new sources fired correctly, did their actions, and informed us about what was going on in the world and what might be a good action to take for us. So it's good to know that the things I have set up were set up correctly so that I could plug new and different sources into them and still have them work correctly. It gives me confidence both in the way the Home Assistant is set up and in my own abilities to get it to do what I want that this kind of source change was the work of a day to find, add, and rewire everything to run on different sources. This seems like another one of those situations where it looked easy to me and that may have involved more skill than I think it did.

Post a comment in response:

If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org