Unlock the Hidden Weather Forecast in Home Assistant

Тәжірибелік нұсқаулар және стиль

In this video, we'll show you how to retrieve a weather forecast in Home Assistant. By following this simple tutorial, you'll be able to access the latest weather information for your home or office.
Home Assistant is a powerful open-source platform that allows you to control your entire home or office from one interface. By following this tutorial, you'll be able to retrieve a weather forecast for your location in just a few minutes!
This tutorial explains how you can create a Jinja2 Trigger template in Home Assistant that makes use of an action. This way, you can call a service in the template that returns a value. This value can be stored in a variable. You can return that variable as the state of the template, or use that variable to calculate another value.
⭐ NOTE: as of Home Assistant 2023.12, the service is no longer weather.get_forecast, but weather.get_forecasts. You need to use the following code in the template now: {% set precipitation = my_forecast['weather.openweathermap'].forecast[daypart].precipitation %} ⭐
⭐ You can download the code that I created for this video at: ko-fi.com/s/bf6b252838 ⭐
Links referred to in this video:
* How to create your own Garden Watering System in Home Assistant: • How to Create YOUR OWN...
Blog version: www.smarthomejunkie.net/how-t...
⭐⭐⭐
* Join this channel to get access to perks: 📺 / smarthomejunkie
* Please consider becoming my patron 🏅 at / smarthomejunkie
* Or please support me by buying me a ☕ at ko-fi.com/smarthomejunkie/
⭐⭐⭐
⭐ If you want me to create a review of your product, please visit this page for information and rates: www.smarthomejunkie.net/revie... ⭐
⭐ I offer Consultancy and Training for your Home Assistant setup. Visit this page for more information: www.smarthomejunkie.net/servi... ⭐
My Devices: github.com/smarthomejunkie/My...
Instagram: / smarthomejunkie
Twitter: / smarth0mejunkie
Facebook: / smarthomejunkie
TikTok: / smarthomejunkie
Discord: / discord
Music by:
* 2TECH-AUDIO: 2tech-audio.bandcamp.com/
00:00:00 Introduction
00:00:50 The action parameter in Home Assistant
00:01:14 The Weather Get Forecast service in Home Assistant
00:01:53 Check results of the Weather Forecast Service in the developer tools.
00:02:37 Explaining what the total rain forecast for the next couple of hours is.
00:03:14 How to install Studio Code Server in Home Assistant.
00:03:32 How to create a templates.yaml file in Home Assistant.
00:04:15 Add the forecast code to the templates.yaml file.
00:07:19 Test the Get Forecast Trigger Template
00:07:56 Conclusion
#homeassistant #template #yaml #automations #smarthome #sensors #development

Пікірлер: 72

  • @SmartHomeJunkie
    @SmartHomeJunkie10 ай бұрын

    ⭐ NOTE: as of Home Assistant 2023.12, the service is no longer weather.get_forecast, but weather.get_forecasts. You need to use the following code in the template now: {% set precipitation = my_forecast['weather.openweathermap'].forecast[daypart].precipitation %} ⭐ See the description of this video for more information. ⭐ You can download the code that I created for this video at: ko-fi.com/s/bf6b252838 ⭐ Links referred to in this video: * How to create your own Garden Watering System in Home Assistant: kzread.info/dash/bejne/l2yhzqx7k8iZpbQ.html Blog version: www.smarthomejunkie.net/how-to-create-action-template-sensors-in-home-assistant

  • @martinmurer4954

    @martinmurer4954

    5 ай бұрын

    Maybe you should pin this comment to the top!

  • @SmartHomeJunkie

    @SmartHomeJunkie

    5 ай бұрын

    @@martinmurer4954 Weird. It was pinned to the top.

  • @BenCos2018

    @BenCos2018

    4 ай бұрын

    @@SmartHomeJunkieIt removes the pin when you edit it

  • @tomjones2860

    @tomjones2860

    3 ай бұрын

    If you change {% set precipitation = my_forecast['weather.openweathermap'].forecast[daypart].precipitation %} Don't you need to change the "probability" line too {% set precipitation_probability = my_forecast['weather.openweathermap'].forecast[daypart].precipitation_probability / 100 %} ???

  • @donaldhoudek2889
    @donaldhoudek288910 ай бұрын

    Congratulations on 40K subscribers!

  • @SmartHomeJunkie

    @SmartHomeJunkie

    10 ай бұрын

    Thank you!

  • @sevagjb
    @sevagjb10 ай бұрын

    i like it, i see advance work nice :)

  • @robertaccess
    @robertaccess10 ай бұрын

    intresting...

  • @Eldari-sr7db
    @Eldari-sr7db6 ай бұрын

    thanks for the Videos! i learn a lot from them. one question - what is the language of the template? is it possible to write it also in python?

  • @AndriusNera
    @AndriusNera10 ай бұрын

    Hello, I would like a sensor that can calculate daily or monthly costs based on daily or monthly electricity consumption and the variable nordpool hourly rate

  • @xelemorf
    @xelemorf8 ай бұрын

    @SmartHomeJunkie I would have an idea similar to this, which would announce the weather and temperature with Alexa for the next couple of hours when a button is pressed on the main door.

  • @fbutler
    @fbutler9 ай бұрын

    Thanks, I've downloaded the code to use as the framework for creating a weather.get.forecast based sensor containing the minimum temperature in the next 24 hours to enable a frost warning notification to be sent every day at 9:00am

  • @SmartHomeJunkie

    @SmartHomeJunkie

    9 ай бұрын

    Excellent!

  • @gorgorgonzales3090

    @gorgorgonzales3090

    7 ай бұрын

    I am trying to achive the same thing, how did you configure the sensorstate to reflect the min temperature? Thanks!

  • @SmartHomeJunkie

    @SmartHomeJunkie

    7 ай бұрын

    Ah! This is a great topic for a future video!

  • @gorgorgonzales3090

    @gorgorgonzales3090

    7 ай бұрын

    @@SmartHomeJunkie Oh that would be great! 🥳

  • @gmaclean1
    @gmaclean110 ай бұрын

    Love your videos, thank you. I however don’t have a love affair with home assistant when they make changes like this. I’m struggling to understand why they would discontinue the old weather system when it works and is easily understandable by users.

  • @SmartHomeJunkie

    @SmartHomeJunkie

    10 ай бұрын

    As far as I understood, some weather integrations cost money when you call the api. Using this service you can control your costs.

  • @eminteinko8552
    @eminteinko85529 ай бұрын

    Hi! Nice work, is it possible to transfer the rain forecast to cloud forecast as well? Thank you

  • @SmartHomeJunkie

    @SmartHomeJunkie

    9 ай бұрын

    There's no cloud forecourt attribute as far as I know.

  • @christian1603
    @christian160310 ай бұрын

    Hi ! Simple question... You have the entity weather.openweathermap coming from the openweathermap integration. How is it configured (hourly, daily, onecall_hourly or onecall_daily)? Or doesn't this matter any more ?

  • @SmartHomeJunkie

    @SmartHomeJunkie

    10 ай бұрын

    I think I defined it hourly, but I also think it doesn't matter if you use the service. Didn't test it though.

  • @erwingobee3890
    @erwingobee389010 ай бұрын

    Hi, was een goed concert vrijdagavond in Tilburg.

  • @SmartHomeJunkie

    @SmartHomeJunkie

    10 ай бұрын

    Haha, heb je me gezien? Ik ben zaterdag nog een keer geweest 🤣😳

  • @antoniobaldassarre7457
    @antoniobaldassarre74578 ай бұрын

    hi there, thank you very much for the help. After I follow your guide, I still cannot see the sensor in the dev tool. Any idea why ☹ ?

  • @SmartHomeJunkie

    @SmartHomeJunkie

    8 ай бұрын

    No idea. You might have missed a step somewhere.

  • @JoseBerruezo
    @JoseBerruezo10 ай бұрын

    Hello, why is your template showing "action: Property action is not allowed." ?

  • @SmartHomeJunkie

    @SmartHomeJunkie

    10 ай бұрын

    That is because Studio Code Server is not up to date yet.

  • @michelbeauregard6187
    @michelbeauregard618710 ай бұрын

    Hi, great video. I was using the response value of a weather service call in the action section of the automation as follows: service: weather.get_forecast data: type: hourly target: entity_id: weather.granby_forecast response_variable: response That response variable is temporary as its associated with the automation only. Which can be optimise for the purpose.

  • @francoisgrandcollot1027
    @francoisgrandcollot1027Күн бұрын

    Hello, many thx for your youtube video. May I have some help ? I don't know how to establish a calculation made from 2 entities ie: entitie apparent power that divides entitie inverter voltage so as to know the current and declare it as a new entitie. Do you have a simple example? Sincerely

  • @SmartHomeJunkie

    @SmartHomeJunkie

    Күн бұрын

    Please see this video and the playlist it is on : YAML & Jinja course Episode 5: Calculations and Date and Time kzread.info/dash/bejne/o3tslraQdNO-hJM.html

  • @francoisgrandcollot1027

    @francoisgrandcollot1027

    Күн бұрын

    I just found: parameters, inputs, create an input, template, model a sensor... + code THANKS

  • @michaelthompson657
    @michaelthompson6577 ай бұрын

    Hi, I have the met office weather integration which has the same 3 hour weather but it only has probability of precipitation and not precipitation aswell like you mentioned in this video. I have no idea how or what parts of the code to alter. Can you help?

  • @SmartHomeJunkie

    @SmartHomeJunkie

    7 ай бұрын

    Hmmmzzzzz.... If your integration does not provide the precipitation, there's no way to retrieve it. I am a bit puzzled though because each weather integration should provide that information. You might want to check out Openweathermap instead.

  • @michaelthompson657

    @michaelthompson657

    7 ай бұрын

    @@SmartHomeJunkie apologies, I mustn’t have explained myself correctly. It’s has separate sensors for daily and 3 husky precipitation but it also shoes precipitation with the get forecasts service like you showed here. My main problem is altering the code because it only has probability of precipitation and it doesn’t have precipitation too. So it only has one precipitation value, so I’m not sure what to do with the yaml code

  • @SmartHomeJunkie

    @SmartHomeJunkie

    7 ай бұрын

    I'm not sure what you mean. What result does the weather. show?

  • @henkoo123456
    @henkoo12345610 ай бұрын

    Is dit het enigste wat aangepast moet worden voor het programma Garden Watering System?

  • @SmartHomeJunkie

    @SmartHomeJunkie

    10 ай бұрын

    Yup

  • @Xpl0jd1
    @Xpl0jd110 ай бұрын

    I struggle abit with my HA, I got a IKEA button with Press "UP/DOWN", Hold "UP/DOWN" also have Press "LEFT/RIGHT". I´m trying to get brightness to go up and down by Hold "UP/DOWN" but fail, also want to colour cycle by Press "LEFT/RIGHT". I dont find any help, do you have a video about this that i missed? :D

  • @SmartHomeJunkie

    @SmartHomeJunkie

    10 ай бұрын

    Sure: Dim Lights THE RIGHT WAY In Home Assistant - TUTORIAL kzread.info/dash/bejne/fmGWxcOblMSzqKg.html

  • @Xpl0jd1

    @Xpl0jd1

    10 ай бұрын

    @@SmartHomeJunkie thank you! I missed the restart function on automations. But do you also have a video how to cycle throw different colours with side buttons?

  • @SmartHomeJunkie

    @SmartHomeJunkie

    10 ай бұрын

    @@Xpl0jd1 Yup... How to Cycle through Scenes like Hue using a Button in Home Assistant - TUTORIAL kzread.info/dash/bejne/oHaYpsZ8Ys28hcY.html

  • @Xpl0jd1

    @Xpl0jd1

    10 ай бұрын

    @@SmartHomeJunkie ah using scenes 🙈

  • @SmartHomeJunkie

    @SmartHomeJunkie

    10 ай бұрын

    @@Xpl0jd1 You can use it with single lights too, but in my example I used scenes.

  • @gigiduru659
    @gigiduru6595 ай бұрын

    Hi! I read about v2023.12 change and I modified to: - service: weather.get_forecasts ... {% for daypart in range(0, 7) %} {% set precipitation = my_forecast['weather.openweathermap'].forecast[daypart].precipitation %} But I get error in v2024.2.3: Error rendering state template for sensor.openweathermap_expected_precipitation: UndefinedError: 'dict object' has no attribute 'forecast'

  • @louisviciedo
    @louisviciedo10 ай бұрын

    similar issue as stated below "'my_forecast' is undefined" error when i try to use it in developer tools. Its been triggering for 12 hours now. ANy thoughts?

  • @SmartHomeJunkie

    @SmartHomeJunkie

    10 ай бұрын

    This is kinda weird. The code works perfect here. 🤷🏼‍♂️

  • @SmartHomeJunkie

    @SmartHomeJunkie

    10 ай бұрын

    Which weather integration do you use?

  • @louisviciedo

    @louisviciedo

    10 ай бұрын

    @@SmartHomeJunkie openweathermap, same as you Ed. Thanks!

  • @DarrenGerbrandt

    @DarrenGerbrandt

    2 ай бұрын

    Had this as well when I was browsing around and tried the copy/paste in the Template section of Developer tools but no error if I use it in the template.yaml file. So my thoughts are don't try it in the TEMPLATE section in the Developer Tools. It works fine if you follow the video instructions of adding the !include line to the configuration.yaml and then creating a template.yaml file and putting the template sensor info there as the video instructs.

  • @DarrenGerbrandt

    @DarrenGerbrandt

    2 ай бұрын

    @@SmartHomeJunkie I am assuming he's using the Template Editor in the TEMPLATE section of Developer Tools, I got the same error when I thought I would try it out but no error when making a template.yaml file and pasting the code into it.

  • @de3ra
    @de3ra4 ай бұрын

    I was trying to do this but with the twice daily forcast so voice assist can say what the daily weather report is when i ask it, but it seems the description is not pulling up. Is anyone able to help me understand why? It seems like it should be working. state: > {% set ns = namespace() %} {% for daypart in my_forecast %} {% if loop.first %} {% set ns.DetailedDescription = daypart.detailed_description %} {% endif %} {% endfor %} {{ ns.DetailedDescription }}

  • @SmartHomeJunkie

    @SmartHomeJunkie

    4 ай бұрын

    I'm not completely sure, but I believe voice assist cannot understand a command to tell this standardly yet. You can however create an automation that respond to a specific sentence and then send the weather info using TTS to your smart speaker.

  • @daveforrester61
    @daveforrester617 ай бұрын

    Have you noticed that the change in 2023.12 from weather.get_forecast to weather.get_forecasts breaks the template sensor as the new format response is subtley different. I got an error saying the response variable has no attribute "forecast". It actually does, but the dictionary is structured slightly differently. I haven't figured out how to fix it.

  • @SmartHomeJunkie

    @SmartHomeJunkie

    7 ай бұрын

    Yes, I know and already mentioned it in the description of this video and in the what's new video. I already changed the code on my side and will add it to the description as soon as I am back at my PC.

  • @daveforrester61

    @daveforrester61

    7 ай бұрын

    Sorry, but simply changing "weather.get_forecast" to "weather.get_forecasts" doesn't work, well not for me anyway. The response I get has "weather.openweathermap" as the first line, with "forecast" on line 2 and indented 2 spaces. My template sensor becomes unavailable because the "forecast" attribute is a level down in the dictionary response and I can't figure out how to make it use that level. Does this simple change actually work for you?

  • @SmartHomeJunkie

    @SmartHomeJunkie

    7 ай бұрын

    @@daveforrester61 I never said that it would be simple ;) Please see the first comment or video description on what to change exactly.

  • @daveforrester61

    @daveforrester61

    7 ай бұрын

    😂 that was the bit I missed. However, I did manage to figure it out myself with a bit of work in JSON and the template editor 😊. Enjoy your coffee and keep up the great work 👍

  • @ClintCambier1988
    @ClintCambier19887 ай бұрын

    I have tried all sorts of versions of this template. When I use the Template Editor, everytime I get the error "'forecast' is undefined". Does anyone know what might be wrong?

  • @SmartHomeJunkie

    @SmartHomeJunkie

    7 ай бұрын

    Did you read the NOTE in the description of this video? Home Assistant changed some things in 2023.12.

  • @ClintCambier1988

    @ClintCambier1988

    7 ай бұрын

    @@SmartHomeJunkie I did :-), numerous times but I must still be missing something or it's related to another factor that I'm not yet aware of. I have also tried minimizing the script to see if there's any syntax error but all I'm getting is "my_forecast is undefined". I'm on version HA Core 2023.12.3. If you prefer that I contact you in a different way and buy you another digital coffee up front, let me know. - trigger: - platform: time_pattern hours: "1" action: - service: weather.get_forecasts target: entity_id: weather.forecast_edugo_arena data: type: hourly response_variable: my_forecast sensor: - name: Rain Forecast Edugo Arena unique_id: 9ba20bcc-913f-48bd-a9f3-75c97acfdb3d unit_of_measurement: mm state: > {% set ns = namespace() %} {% set ns.totalprecipitation = 0 %} {% for daypart in range(0, 7) %} {% set precipitation = my_forecast['weather.forecast_edugo_arena'].forecast[daypart].precipitation %} {% set precipitation_probability = my_forecast[daypart].precipitation_probability %} {% if precipitation_probability > 0 %} {% set precipitation = precipitation * precipitation_probability %} {% endif %} {% set ns.totalprecipitation = ns.totalprecipitation + precipitation %} {% endfor %} {{ ns.totalprecipitation | float(0) | round(2) }} If I go to the Developer Tools > Services and use the following then I get the expected ["weather.forecast_edugo_arena"].forecast data structure. I also tried copy pasting the example from www.home-assistant.io/integrations/weather to the Developer Tools > Template and also there I received the "hourly is undefined" error.

  • @TomRoos712
    @TomRoos71210 ай бұрын

    I've recently downloaded the garden watering code and after 2 days I saw this video come live. Unfortunately I can't get it to work. It keeps giving me status unknown. You have any tips?

  • @SmartHomeJunkie

    @SmartHomeJunkie

    10 ай бұрын

    There must be an error in your code somewhere when the status stays unknown. It also depends on how long the time trigger is set. If it's set to one hour, you might have to wait for one hour before the status changes.

  • @Girbie1973

    @Girbie1973

    10 ай бұрын

    Have you been able to resolve it? I have exactly the same issue. I can't find any error in the code.

  • @TomRoos712

    @TomRoos712

    10 ай бұрын

    Haven't had time to look at it yet unfortunately.

  • @SmartHomeJunkie

    @SmartHomeJunkie

    10 ай бұрын

    @@TomRoos712 Are you on the latest version of Home Assistant?

  • @Ale-r3s
    @Ale-r3s18 күн бұрын

    thank you for the video and your affort. but honestly.. thats to complicated.. and the version is an other than 2023.12. it's not working for me.. i see this version upgrade as a disaster for homeassistant i mean.. we are looking for something reachable for everyone but now it's seems we need to study programming to implement a simple precipitacion forecast.. is that really the sense in that??

  • @SmartHomeJunkie

    @SmartHomeJunkie

    18 күн бұрын

    I agree. Please read the description of the video. There's been a slight change in the code.

  • @Ale-r3s

    @Ale-r3s

    18 күн бұрын

    @@SmartHomeJunkie I'm sorry i dont understand what exactly is to do. as i tried to say.. it has to be hold simple for everyone and this stuff it's just to complicated. and everytime a new version coming out.. we have to be scared of what again is complitely not working the same way and we start again with some kind of programming stuff from zero...

  • @radovanobal878
    @radovanobal878Ай бұрын

    they kicked a large bucket of manure with the forecast removal. It's made it infinitely harder for new users than it was with the old variable access.

  • @Tntdruid
    @Tntdruid10 ай бұрын

    123 start the coffeemaker 😄

Келесі