🌦 Weather forecast access for LLM (eg ChatGPT or Gemini)

I bumped into this blueprint while setting up HA Voice PE. Thank you!

For whatever reason, sometimes the assistant says it fails to fetch the weather information, and when I look at the script traces, I see this: Error: UndefinedError: list object has no element 0. I am using the Met.no integration.

Any help would be appreciated.

@badnetmask Can you share the full trace? You can paste it to a code sharing site like https://dpaste.org and share the link. Please share a trace from a script run where it didn’t work.

Which LLM are you using? And are you using the recommended settings?

Hi, i use the OpenAI LLM and added the script. I always get this error:

Something went wrong: unable to call service weather. forecast with data
(day’: ‘2025-01-05’, ‘time’: ‘afternoon’, 'entity_id: None). One of ‘entity_id",
area_id’, or ‘device_id’ is required

How can i fix that? I use met.no and added the entity to the script.

Can you also send the trace of the script run like I requested in my post above

I can’t give you a trace because the script doesn’t seem to be running. If I don’t expose the script for assist, I won’t get this error but then the weather feature dont work.

That I don’t understand, if the error comes from the script, it must be because the script ran, and then there must be a trace

I am using a local OLLAMA instance.
Is there a way to send you a private message with the link?

Thanks for the blueprint! It works great if I ask for today’s or tomorrow’s forecast. But if I ask for the forecast by the day of the week (i.e. Saturday or Sunday) it will give the forecast for the wrong day. I’m using this with the OpenWeatherMap integration.

image

You can click on my profile picture and then press Message

Looks like you’re blocking personal messages:
An error occurred: Sorry, you cannot send a personal message to that user.

Other people can… let me have a look in the settings

@TheFes Thanks for this. Looks great. :slight_smile:
I’m getting an error from Gemini about not knowing the start and end times for Monday! ai_weather is my script, but it looks like it’s never been run. :-/

Using Met.no btw.

Any idea how I can fix that?

Which model are you using for Gemini, are you using the default settings?

“Gemini 1.5 Flash Latest” with default settings.

Don’t know why it doesn’t work for you, it does work here with the same settings

Well if you don’t know, what chance do I have?! :rofl:
It works with OpenAI. Not really sure where to go from here…

I assume you’re using the Google Generative AI integration?
Have you just left the “recommended model settings” box checked?

Yes, but also when I uncheck that, it does work (it selected the model you also mentioned then).

@badnetmask
Your issue should be solved if you update the blueprint (just updated the code on GitHub).
The issue was that your LLM used the exact same datetime string for both start and end. I now add a day if the time of that datetime string was 00:00, otherwise I add an hour.

@undulattice can you check again in Settings > Automations & Scenes > Scripts if the script really didn’t run, and check if there are any traces?

Yes! It worked! Thank you!
I think you can edit your script description to mention it also works with Ollama. :smile: