Using ChatGPT In Your Smart Home for $0.01 a MONTH?! #homeassistant #chatgpt #openai

98.3k views3574 WordsCopy TextShare
Future Smart Home
This video shows you how to use OpenAI and ChatGPT in Home Assistant. For less than $0.01 a month, ...
Video Transcript:
today I'm going to show you some amazing ways I use AI in my smart home I'll show you how to set everything up in just a few minutes and how all of this cost me less than 1 cent per month Welcome Back to Future smart home my name is Ben and this channel is all about simplifying your life with smart home technology so if you like all things smart home consider subscribing in today's episode we're exploring how you can use open aai which is the company that developed chat GPT to transform your smart home into an even smarter home smart smart home the smartest home a more smart a smartest smart none of this is working integrating your home with open Ai and chat GPT is actually not that hard I'll walk you through a step-by step of how to do it but before I do that let me show you some of the really cool ways that this comes to life I have a lot of sensors in this house and it's difficult at times to keep track of everything checking different dashboards apps that's where AI tools can be really cool our house experiences some pretty big temperature and weather fluctuations and it has been so wet lately so every morning my smart home checks the values for the current temperature and humidity both indoors and Outdoors and make some suggestions this AI driven system looks up our external weather conditions from our Tempest weather station and Compares it to the temperature sensors I have from aara or the air things air quality Monitor and on top of that it also looks at what what our heating system is doing and provide some advice on whether or not we should open the windows it's kind of like having a personal weather HVAC forecaster all in one another thing that I like to keep an eye on is our daily energy and water usage for energy I only keep track of our electrical usage but if I had a way to monitor our natural gas I'd throw that in there too but for this example you could take any of the utilities in your house that you have data for and send it up to open AI to provide you with an update every morning I wake up to a friendly update on my energy and water usage that actually makes me laugh out loud sometimes and to give you a sense of the kind of messages I'm getting here's one that I got earlier today wo were you training for a water drinking contest we gushed through 85. 6 gallons much more than usual stay indoors today the weather's likely to go all Thor on [Music] us that's hilarious in the morning I send the amounts of water and electricity that we used yesterday as well as the previous 7 days and I instruct chat GPT that I want a briefing on my consumption but I also ask it to keep things light-hearted and fun because no one wants a dull AI smart home one day it told me to knock it off with all the water usage because I must have had a pool party inside our house the previous day this isn't just fun it's about making Energy Management engaging and accessible and it has brought to my attention times when our energy or water usage spiked for some reason at the end of the day this kind of notification could help you save on bills and reduce your environmental footprint without a lot of hassle of checking different dashboards and different apps but most importantly it's varied enough and always unexpected that I pay attention to these notifications maybe I'm the only one who enjoys getting roasted by AI large language model but some of you might like it too enough about things that are better for me what about the Next Generation my kids are going to grow up in a very different world than I did so I figured I might as well introduce them to an artificial intelligence that I have some control over for now our Tempest personal weather station at the house just has a metric ton of data coming off of it if you're interested in weather stations I've got a whole video on how this thing works it's really quite cool but my daughter was really interested in how it works so I thought it might be fun to hook up the weather station to chat GPT and then to our Google Nest Hub so that's what I did I used the same process as the other use cases I take data from the house or in this case the weather station send it up to chat jpt press it with some specifics about how it's a forecaster for children give it some parameters to make it fun and age appropriate and voila a talking AI weather station that my kids love it's your friendly weather forecaster here ready to give you the scoop on the weather let's start with the current conditions it's a lovely day outside with a temperature how cool is that so now that you've seen some of these examples how do you actually do this and for only 1 cent a month for my usage this really is no exaggeration but your usage is going to vary based on Which models you choose and how frequently you're using it I have experimented with more recent models from open AI it costs a little bit more but it's only 30 cents a month so in both cases it's really quite inexpensive so let's jump into home assistant and I'll show you how to set things up with open Ai and with your smart home here we are in home assistant and the way you want to get started is you want to look for an integration called open aai conversation you can do that hit the blue button in the bottom right type in open AI conversation what you're going to be prompted for is an API key the way you get an API key is you go to openai you do platform. open.
com you need to sign up for an account once you sign up for an account you put a credit card on file you can then see on the left side this section called API Keys once you go to API Keys you want to create a new secret key so this is going to be test home assistant key leave it default project it's owned by you you don't necessarily need to worry about those things right now create our secret Pro secret key copy that key and now we'll head back to home assistant put that key in okay so now that you're in home home assistant you're going to see a couple of these I've already created some open AI Keys before and this this is a way to compartmentalize different conversational systems and I prep the different conversational assistants in different ways but you're going to just see one of these for now and what you do is you'll hit configure you're going to see there's a ton of information here now what home assistant does by default is it says hey we're going to as a preamble to any message that you or any conversation you have with open AI we're just going to do you a favor and we have all this information here it's going to send all the statuses of your devices up to open aai and this is so that you could have a dialogue with open AI about your house which is useful but for our purposes I want a little bit more focused and so don't necessarily need all this text now this is what's called Ginga uh it's a templating language if you aren't familiar with it I'm not going to have have time to go over how it works in this video but you should definitely uh search around there's a lot of great templates and tutorials on how to use gja you will likely need gja to pass data to open AI in a easy way so something to look into definitely worth checking out it's really not too hard you can definitely get a handle of it there's a lot of great tutorials out there so this is what comes by default we're just going to get rid of that and then you can put in your own prompt template now what I'll show you really quickly is one example from the kids weather forecasting station that I just talked about so the prompt is important because sort of sets the scene for the conversational assistant so here's what I say and you can put whatever you want say you're a weather forecaster for kids you love the weather you're a sentient being inside of a smart home two children are your audience be creative and fun instead of emojis please use words as your response because it's being read out loud uh that has seemed to work for me produces some fun and interesting light-hearted results but you could tweak and change it however you want the next thing is you want to specify the model so this is the model GPT 3. 5 it's an older model from open AI but it's also a really cheap model and that's how I can do all of this for literally 1 cent a month and I'll show you that in a second but you can also specify more recent models like GPT 4 which you may or may not be familiar with let's jump into an automation to show you how this works specifically so if we go in into our automations and look at the weather update here's how this works the most important animportant and the biggest part of this automation is this section called conversation process and I'll talk through that in a second but just to give you a sense of how I get data first I do take the forecast I call a service called weather get forecast and that's specific again to the weather station if you have data in other parts of Home assistant already weather forecast you have to actually query for this is how it works so I have our weather station set here I select the forecast type I want is dat daily and the response variable is how that's going to be stored which is daily forecast so show you how that why that matters in just a second here the conversation process action is actually what's going to give you this agent ID now to figure out how to get the agent ID what you would do is when you're adding your action here so we'll do conversation process you're going to jump down here to agent and then you'll select whichever agent you want so that's the first step you want to actually go through this process to uh select the agent you put in basic text and then you'll hit save and then when you want to edit it you can edit it in yaml and now you've got your agent ID which is quite valuable oh one thing that I did actually just forget you do want to have a response variable for anything that is going to text to speech um you're going to send it along in a push notification so as you can see here in this yaml I've got response variable agent so I just write response variable agent again if I was to edit this in yaml you would see that's the response variable agent okay so that's how you get the agent ID specific to the one that you just created this is again the meat of this automation so I again this is genja templating it pulls in some specific values I'll roughly talk you through how it works so I say you're an advanced smart home and again I have some of this in the prel but I found that saying it twice didn't necessarily hurt so that might be a little bit redundant but here's what I have put in here uh what I then also do is I pipe in some of the values so I say hey this is current time this is the temperature so this is pulling from our Tempest so it's the state sensor. tempest temperature here's the feels like here's the humidity UV index I sent all that information now this is the forecast part so forecast conditions for today you can see daily forecast was that variable that I just stored and you can query the first uh section of that variable so the first um it's actually a Json array so it's the first item and say that's you know I want to I want to pull the conditions so this is the forecasting conditions you can pull the temperature temperature low uh precipitation probability Etc to find these values I highly suggest you look in the developer tools because you can look around and see what the different lower level names of these items are within your home assistant so you're going to want to become pretty familiar with the developer tools one really nice thing is there is this template section where you can start writing out and and home assistant does give you some examples of how to use Ginga uh you can write these things out and you kind of learn the syntax and some of the partic the particular variables that you're going to be looking for like sun.
sun or above Horizon the last part of our smart weather station kids forecaster update is that after I do get this information up to chat GPT it will then respond back with that variable agent okay so that's just the text that was included next I do a service called text of speech call service text of speech and specifically what I passed through here is this message which includes the agent. response. speech.
play. speech I ended up I think I looked that up to figure out that that was actually what I wanted to grab from the response um and that's that's what works that's what sends up to you can see our entity here is a media player Nest Hub Max so it sends that up I chose a British accent cuz that's a better accent I think shout out to the Brits uh and that's it pretty simple plays on The Nest tuub Max takes the info from chat GPT and it works like a charm all right let's jump into another example specifically on energy so this is the energy example that I showed you before the trigger is time of day so I choose 8:00 a. m.
I get the weather forecast as you can see here here okay so again the meat of this automation is is in this conversation process step and you can see down here I've pulled my agent ID and now I'm sending it some various different states the first is a number an input number which I used to save our energy usage at any given time so input number yesterday's energy usage uh then there's a text which is weekly energy usage Json I'm going to show you how that works in a second that's for the historical work do the same thing for water usage and water usage Json which again is a historical array of our energy usage for the past 7 Days uh and then I also send the weather outlook you can see right here and the high for the day that's what I send up I will say that for this automation I have started playing with using GPT 4 GPT 3. 5 actually did pretty well with it GPD 4 has been kind of interesting to see has maybe a little bit more character and uh humor again it's a little bit more expensive more like 1 cent a day so 30 cents uh a month nothing crazy I get the response and we send out uh a notification to um to the devices in the house let me jump over really quickly show you some of these helper items so these there's two here that are the input numbers are pretty straightforward it's just at the end of the day I capture what is the current energy usage it's like 11:58 at night I say hey what was the current energy usage I st save it in this input number this one's a little bit more complicated the way that this works is I actually have uh a text field and it's formatted in a sense as a Json array which can be a really straightforward array the way that it calculates so that's the the item that's used to save and by the way there's probably a better way to do this but this is how I figured out how to do but let me jump over to automations there is a stats collection and here is how I'm storing that energy usage in that Json array every single day I taking the value for the current for yes the current day which is going to be yesterday's usage and I put that in the first uh position of the Json array there's a lot of code here I'll try to post a snapshot of how this code Works to do some concatenation and storing but ended up finding this on a forum uh worked really well to pipe in new data to the Json preserve the old data and just kind of always have seven days worth of stats so I'll post how this works again it St saves down this quote unquote Json array which I created in home assistant as a Helper and then that's what I send up to chat gbt as a piece of text which works pretty well last automation that I didn't show you was the automation specifically around weather and the temperatures in the house outside of the house humidity all those sorts of things I trigger this three times a day again it's using the GPT 35 uh model which is very cheap so it doesn't really cost me anything for this and it works again same way get the weather forecast call conversation process this one uh I will say formatting yaml in this uh in the visual editor can be a little bit tricky sometimes but it's the best way that I can show it to you again I do a little bit of a preamble here I send the time I send uh the states of the thermostat I send the average temperature cross our sensors that's a helper function um I do the status of all downstairs Windows which again is another helper function that I created and you can send really whatever you want up and that's how it gets its data and then when it's done the uh conversation spits back out a response and here is what um here's what we do send same thing notification call service notification agent. response.
speech. plain.
Copyright © 2025. Made with ♥ in London by YTScribe.com