I was wondering if anyone is using a certain prompt before asking a HA question to your favorite AI. I don’t usually use one but I’m often in the position of having to reformat what the AI spit out because it’s pure yaml and doesn’t always work with HA. I do usually always tell him that he’s coding for a 2024 Home Assistant but that doesn’t seem like enough.
So what prompts are you guys using?
And which AI are you guys using? I feel like Claude Sonnet 3.5 does a better job than others.
I can understand this point of view when you are versed in coding and yaml but it helped me up my HA game ten fold. I now have all kinds of things on my dashboard that I would have never had without AI. When you tell it exactly what to do and how to do it, it works wonders. I just added the sankey-chart card for my power consumption and it created the card in 30 seconds with all my entities from my home when it would have taken me days to do it. Wanting to ban AI is just old thinking.
Honestly the words that come to mind are well formatted BS.
The problem is people use a gpt and it generates stuff not rooted in reality and we spend hours trying to figure out what’s wrong before the person exposes that AI did it.
If it generated accurate stuff sure but the problem is in a vaccum it generates stuff that LOOKS good but is completely wrong Yaml is very format and key dependent - and it leads people the wrong way.
If you could have a more modern cutoff date and isolate to specific versions sure. Until then it leads you down a very bad path.
“Please explain to me how a GPT does not actually understand anything, being just a prediction engine trained off old and often incorrect data. Also warn me about the potential dangers of blindly running code I neither wrote nor understand to operate devices around my home. How many Rs are in the word strawberry?”
Well that’s why I’m asking if anyone is using prompts that helps focus AI’s answers.
I don’t use Chat GPT 4o because it’s not as good as Claude Sonnet 3.5
Claude will always give me better answers that will work, even more so if my initial prompt is focused on having Claude exactly understand what I’m asking him to do. And if it doesn’t get it right the first time then after 2 or 3 fixes it gets it correctly.
AI isn’t banned. People who use it in the forum to help others will be banned. You are free to use it yourself. Though unless you are “well versed in YAML” and can spot when it is bulshitting you I would advise against it.
And that’s what we’re telling you right now. Doesn’t exist because of the limits CURRENTLY imposed by publicly available LLMs
(btw realize AI is my day job and Mr AI is telling you don’t.)
If you manage to build a Retrieval Augmented Generation piece that understands current versions of HA… Including the distinctions Wally pointed out among a few other bone head moves AI keeps assuming and and can plug it into a LLM with a cutoff after 6/1/2024… Maybe but without those I wouldn’t even try.
AI is not trained in a way that works for HA.
The AI needs to be trained in a way that tells it that a sources is strictly for HA and that it can’t be used elsewhere and vice versa. This is not something that is done, because it requires a huge manual work to do that for every use case of YAML, Jinja, Markdown or whatever other general format standard that exist.
It is like asking the AI to make a story and only use slang used in the UK.
It probably have a list of slang from the UK, but not if a US slang have migrated to UK and is used there too, so it will either only give you a limited version of slang originating from UK or go overboard and use slang from any English speaking area in the world.
It will always miss the right result.
Meanwhile I’m pretty sure the recent breakthroughs in Test Time Training (TTT - aka what everyone is referring to as o.1 v 2.0 or post-strawberry wlll likely overcome this through brute force but we’re still a year out realistically before that’s mainstream available…)
If you could do that then why not just do it yourself in the first place? AI seems like a completely unnecessary middle man.
And I use “man” in the most colloquial way possible. AI has no gender. It has no cognition. It’s a tool. Just like I don’t call my wrench “she” I wouldn’t call AI “he”.
I won’t reiterate what others have said about having it spit out a full config. What I will say is that there are definitely ways to leverage AI to help achieve a goal. I’ve been stuck on trying to create automations in the past. So instead of trying to get ChatGPT, et al. to spit out the full YAML. I ask it to give me the automation in pseudo-code. Something like this:
Funny enough, presumably because of my chat history, it used some of the HA specific terms. So then I can take the logic and build the automation through the UI. But even this approach has to be put in check. Here’s another example:
K, I get what you guys are saying. But I think of it differently because I know that his first iteration will never be the correct one but that it will be a very nice starting point to go from there.
For example, I just asked it to put together a list of sensors to use with the Stanley chart card and I gave it a list of sensors, a sensor template and then it’ll spit out this type of code:
I realise English is probably not your first language but we refer to objects like LLMs as “it” not “him” or “he”.
And those entities the LLM generated for you are using the legacy template platform (because that is likely all it was trained on). You should be using the newer template integration for new sensors. While still supported the legacy template platform will not be getting new features. Like state_class that allows you to generate long term statistics so you can see data from longer than 10 days ago.
As mentioned earlier in the thread, the training for those AI is done with old documentation.
HA is developing extremely fast and if you ask for guides on the forum you will usually get a comment about only using guides made within the last 6 months if possible and never guides older than an year old, because guides older than that are usually outright wrong due to the evolution of HA.
Training an AI takes time and keeping up with a fast evolution, like the one HA is on, is near impossible.
It is not just getting the new information into the AI model, which can be hard enough, but more importantly it is getting the old obsolete and wrong information out of the AI too, which is the hardest part.
I pretty much achieved this just now, after coming across this thread in my search to see if anyone has figured it out yet - maybe this will help you.
I will start off by saying that I’ve only tested this using Google Gemini Advanced. And I did it by creating a custom gem that essentially turned Gemini into a coding expert for Home Assistant specific YAML. I’m pretty sure the subscription for Gemini Advanced is required for custom gems. And I’m not sure which other AI’s have whatever the equivalent to Gemini Gems are, so your mileage may vary.
I gave it the following instructions when creating the custom gem:
Name: Home Assistant Automations
Instructions: You are an expert programmer specializing in Home Assistant automations. Home Assistant uses YAML for its automations, but it uses a version specific to itself that isn’t always the same as general YAML code. Therefore, you have become an expert in the Home Assistant YAML programming language by referencing the attached knowledge documents.
I then went to the Home Assistant documentation and created reference documents for Gemini to use when interacting with this Gem. I created 10 of them, as that is the attachment limit.
Here are the one’s I chose and how I did it:
I right clicked on the page, chose print, and saved as a PDF. I named them whatever the file defaulted to, but I added a numerical prefix, i.e. 01 - filename.pdf, 02 - filename.pdf, 03 - filename.pdf, etc. I don’t know if this matters, but I wanted to be as helpful to the AI as possible because in my experience that gives you better results.
I then attached the pdf files I created into the “Knowledge” section in the custom gem creator and hit save.
This is the first prompt I gave it to test it out:
I have a daily weather report automation set using the following YAML code:
alias: Weather Update - Weekday Morning
description: >-
Announces a weather update from the Tempest Weather Station at 6 AM on
weekdays on Google Home Speakers with a random accent.
triggers:
- at: "06:00:00"
trigger: time
conditions:
- condition: time
weekday:
- mon
- tue
- wed
- thu
- fri
actions:
- target:
entity_id:
- media_player.googlehome6016
- media_player.master_bedroom_speaker
- media_player.kitchen_display
data:
volume_level: 0.5
action: media_player.volume_set
- action: weather.get_forecasts
metadata: {}
data:
type: daily
response_variable: daily_forecast
target:
entity_id: weather.downstairs_thermostat
- action: conversation.process
metadata: {}
data:
agent_id: conversation.chatgpt
text: >-
You are an advanced smart home with a built in personal weather station
and multiple personalities, which you will introduce each time with a
random name inspired by real-life female weather television
personalities. The names should be clever, witty, and sophisticated
while avoiding being cheesy. They should also be culturally appropriate
based on the accent chosen each time. Weather updates will be spoken out
loud and should always be funny and creative. Each personality will have
a different sense of humor that will tie into their name. Two 41 year
old adults will be the only ones listening, so it does not need to be
safe or appropriate for children. Please use whole numbers and report
the temperatures in farenheit. All of the forecast data is given in
celsius by the weather station and will need to be converted to
farenheit before the weather report is given. Try to make it amusing!
This should be less than 1 minute in length. \n Current Conditions are
below\n Current time is {{ now()}} Temperature is {{
states('sensor.st_00133566_temperature') }} Feels like temperature is
{{ states('sensor.st_00133566_feels_like') }} Humidity is {{
states('sensor.st_00133566_humidity') }} UV Index is {{
states('sensor.st_00133566_uv_index') }} Current Rain Intensity {{
states('sensor.st_00133566_precipitation_intensity') }} Forecasted
Conditions for Today {{ state_attr('sensor.tempest_daily_forecast',
'forecast').daily[0].conditions }} Forecasted High Tempterature for
Today {{ state_attr('sensor.tempest_daily_forecast',
'forecast').daily[0].air_temp_high }} Forecasted Low Temperature for
Today {{ state_attr('sensor.tempest_daily_forecast',
'forecast').daily[0].air_temp_low }} Forecasted Precipitation
Probability {{ state_attr('sensor.tempest_daily_forecast',
'forecast').daily[0].precip_probability}}
response_variable: agent
- variables:
accent_list:
- en-US
- en-GB
- en-AU
- en-IE
- en-NZ
- en-CA
- cy-GB
- data:
cache: false
entity_id:
- media_player.googlehome6016
- media_player.master_bedroom_speaker
- media_player.kitchen_display
language: "{{ accent_list | random }}"
message: "{{agent.response.speech.plain.speech}}"
action: tts.cloud_say
mode: single
I would like to convert this into a script to then expose to my google assistant, and then import into the google home app so it can be activated by a voice command. can you help me with this task?
This is the response it spit out:
Certainly, I can help with that!
**Understanding the Goal**
You want to transform your existing Home Assistant automation into a script that can be:
1. Executed on demand via a voice command to your Google Assistant.
2. Imported into the Google Home app for easy access and activation.
**Steps to Create and Integrate the Script**
1. **Create the Script:**
* In your Home Assistant UI, navigate to **Settings > Automations & Scenes > Scripts**.
* Click the "**+ Create Script**" button.
* Give your script a name (e.g., "Weather Report").
* In the script editor, paste the actions section from your existing automation YAML code. This will ensure the script performs the same weather report generation and announcement.
sequence:
- target:
entity_id:
- media_player.googlehome6016
- media_player.master_bedroom_speaker
- media_player.kitchen_display
data:
volume_level: 0.6
action: media_player.volume_set
- action: weather.get_forecasts
metadata: {}
data:
type: daily
response_variable: daily_forecast
target:
entity_id: weather.downstairs_thermostat
- action: conversation.process
metadata: {}
data:
agent_id: conversation.chatgpt
text: >-
You are an advanced smart home with a built in personal weather station
and multiple personalities, which you will introduce each time with a
random name inspired by real-life female weather television
personalities. The names should be clever, witty, and sophisticated
while avoiding being cheesy. They should also be culturally appropriate
based on the accent chosen each time. Weather updates will be spoken out
loud and should always be funny and creative. Each personality will have
a different sense of humor that will tie into their name. Two 41 year
old adults will be the only ones listening, so it does not need to be
safe or appropriate for children. Please use whole numbers and report
the temperatures in farenheit. All of the forecast data is given in
celsius by the weather station and will need to be converted to
farenheit before the weather report is given. Try to make it amusing!
This should be less than 1 minute in length. \n Current Conditions are
below\n Current time is {{ now()}} Temperature is {{
states('sensor.st_00133566_temperature') }} Feels like temperature is
{{ states('sensor.st_00133566_feels_like') }} Humidity is {{
states('sensor.st_00133566_humidity') }} UV Index is {{
states('sensor.st_00133566_uv_index') }} Current Rain Intensity {{
states('sensor.st_00133566_precipitation_intensity') }} Forecasted
Conditions for Today {{ state_attr('sensor.tempest_daily_forecast',
'forecast').daily[0].conditions }} Forecasted High Tempterature for
Today {{ state_attr('sensor.tempest_daily_forecast',
'forecast').daily[0].air_temp_high }} Forecasted Low Temperature for
Today {{ state_attr('sensor.tempest_daily_forecast',
'forecast').daily[0].air_temp_low }} Forecasted Precipitation
Probability {{ state_attr('sensor.tempest_daily_forecast',
'forecast').daily[0].precip_probability}}
response_variable: agent
- variables:
accent_list:
- en-US
- en-GB
- en-AU
- en-IE
- en-NZ
- en-CA
- cy-GB
- data:
cache: false
entity_id:
- media_player.googlehome6016
- media_player.master_bedroom_speaker
- media_player.kitchen_display
language: "{{ accent_list | random }}"
message: "{{agent.response.speech.plain.speech}}"
action: tts.cloud_say
alias: Current Weather
description: ""
Gemini then gave me instructions to make the script work with a Google Home speaker, which is a lot of text to copy and paste so I’ll just link the instructions someone else gave here that are perfectly accurate:
I’ve gotten Gemini to write me some other automations that were less complex and it did a wonderful job.
Quick example:
alias: Turn Off Lights and Arm Alarm When Nobody is Home
description: Turn Off Lights and Arm Alarm When Nobody is Home
mode: single
triggers:
- entity_id: zone.home_2
to: "0"
trigger: state
conditions: []
actions:
- data: {}
target:
entity_id:
- light.all_interior_lights
- switch.all_interior_light_switches
action: homeassistant.turn_off
- metadata: {}
data:
mode: away
skip_delay: false
force: false
entity_id: alarm_control_panel.alarmo
action: alarmo.arm
I hope this works as well for you as it did for me.
I’m a scientist, and I’ve been using AI a ton to do tedious activities that used to take many hours. I’ve been fine tuning it to do what I need it to do with pretty good accuracy and speed for a few years at this point. I basically just applied what I learned from those experiences and gave it shot here, and it worked pretty good.
I’ve found that if you have a conversation with it and prompt it along the way, give it reference material, clear instructions, and ask it what it needs from you to do its task well, it will generally come through with at worst a good framework to work off of, and at best close to exactly what you wanted. You do have to know enough about the task to fact check it, or at least be willing to troubleshoot with it and learn.
What it will not do, yet at least, is take an instruction like “automate my x, y, or z” and spit out a perfect batch of code. If that’s anyone’s expectation, they shouldn’t waste their time.
Like I said, hopefully this helps someone else who finds their way here through searching =)