Unlock the Hidden Weather Forecast in Home Assistant

Поделиться
HTML-код
  • Опубликовано: 16 июл 2024
  • 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
  • ХоббиХобби

Комментарии • 69

  • @SmartHomeJunkie
    @SmartHomeJunkie  10 месяцев назад +2

    ⭐ 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: ruclips.net/video/e8mlJBce3uQ/видео.html
    Blog version: www.smarthomejunkie.net/how-to-create-action-template-sensors-in-home-assistant

    • @martinmurer4954
      @martinmurer4954 4 месяца назад

      Maybe you should pin this comment to the top!

    • @SmartHomeJunkie
      @SmartHomeJunkie  4 месяца назад +1

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

    • @BenCos2018
      @BenCos2018 3 месяца назад

      @@SmartHomeJunkieIt removes the pin when you edit it

    • @tomjones2860
      @tomjones2860 2 месяца назад

      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
    @donaldhoudek2889 10 месяцев назад +6

    Congratulations on 40K subscribers!

  • @AndriusNera
    @AndriusNera 10 месяцев назад +4

    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

  • @robertaccess
    @robertaccess 10 месяцев назад +1

    intresting...

  • @sevagjb
    @sevagjb 10 месяцев назад +1

    i like it, i see advance work nice :)

  • @Eldari-sr7db
    @Eldari-sr7db 6 месяцев назад

    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?

  • @fbutler
    @fbutler 9 месяцев назад +1

    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 месяцев назад +1

      @@SmartHomeJunkie Oh that would be great! 🥳

  • @xelemorf
    @xelemorf 8 месяцев назад +1

    @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.

  • @gmaclean1
    @gmaclean1 10 месяцев назад

    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 месяцев назад +2

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

  • @eminteinko8552
    @eminteinko8552 8 месяцев назад

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

    • @SmartHomeJunkie
      @SmartHomeJunkie  8 месяцев назад

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

  • @JoseBerruezo
    @JoseBerruezo 10 месяцев назад +3

    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.

  • @erwingobee3890
    @erwingobee3890 10 месяцев назад +2

    Hi, was een goed concert vrijdagavond in Tilburg.

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 месяцев назад

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

  • @christian1603
    @christian1603 10 месяцев назад

    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.

  • @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.

  • @henkoo123456
    @henkoo123456 10 месяцев назад +1

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

  • @antoniobaldassarre7457
    @antoniobaldassarre7457 7 месяцев назад

    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  7 месяцев назад

      No idea. You might have missed a step somewhere.

  • @michaelthompson657
    @michaelthompson657 7 месяцев назад

    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?

  • @michelbeauregard6187
    @michelbeauregard6187 9 месяцев назад +1

    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.

  • @Xpl0jd1
    @Xpl0jd1 10 месяцев назад +1

    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 месяцев назад +1

      Sure:
      Dim Lights THE RIGHT WAY In Home Assistant - TUTORIAL
      ruclips.net/video/L-bcabdaMxE/видео.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 месяцев назад +1

      @@Xpl0jd1 Yup...
      How to Cycle through Scenes like Hue using a Button in Home Assistant - TUTORIAL
      ruclips.net/video/nBdDdC2jVUc/видео.html

    • @Xpl0jd1
      @Xpl0jd1 10 месяцев назад +1

      @@SmartHomeJunkie ah using scenes 🙈

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 месяцев назад

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

  • @louisviciedo
    @louisviciedo 10 месяцев назад +1

    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  9 месяцев назад

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

    • @SmartHomeJunkie
      @SmartHomeJunkie  9 месяцев назад

      Which weather integration do you use?

    • @louisviciedo
      @louisviciedo 9 месяцев назад

      @@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.

  • @gigiduru659
    @gigiduru659 4 месяца назад

    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'

  • @daveforrester61
    @daveforrester61 7 месяцев назад

    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 месяцев назад +2

      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 месяцев назад +2

      @@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
    @ClintCambier1988 6 месяцев назад

    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  6 месяцев назад

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

    • @ClintCambier1988
      @ClintCambier1988 6 месяцев назад

      @@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.

  • @de3ra
    @de3ra 4 месяца назад

    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.

  • @TomRoos712
    @TomRoos712 10 месяцев назад

    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-r3s 6 дней назад

    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  6 дней назад

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

    • @Ale-r3s
      @Ale-r3s 6 дней назад

      @@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...

  • @Tntdruid
    @Tntdruid 10 месяцев назад +2

    123 start the coffeemaker 😄