Want to grab forecast tomorrow at noon. How to get this sensor to work?

I created a sensor to get tomorrow’s weather, but it grabs the weather exactly 24 hours from now with this:

- platform: yr
  name: YRWeatherForecastSymbol24
  forecast: 24 # 1 day forecast
  monitored_conditions:
    - symbol

I realized I want the weather from noon the next day, so my thinking is this:

- platform: yr
  name: YRWeatherForecastSymbol24
  forecast: {{ 24 - now().hour + 12 }} # 1 day forecast at noon
  monitored_conditions:
    - symbol

I think I’m on the right track but ‘forecast’ is expecting an integer, not a formula. How can I get this second example to work by doing the math and putting the result in the ‘forecast’ field?

This mite work

forecast_template: {{ 24 - now().hour + 12 }}

my understand is when HA see the word template it know to do some Maths or something before setting the value

but if you have weather.met_no It has the next 5 days forecast
today beeing the the 25th

then by


can put that into a sensor

  - platform: template
    sensors:
     tomorrow_condition:
        value_template: >-
          "{{ states.weather.met_no.attributes.forecast.0.condition}}"

remeber

0 is always tomorrow
1 is tomrrow +1 day

1 Like

Thanks for the info, myle.

Unfortunately, I’m not sure that _template trick works on the sensors.yaml file. At least it didn’t work for me. By the way, that works on regular cards/pages with the custom:card-templater resource installed - not sure if it’s built into HA by default. (I DO have the card-templater installed, btw.)

I would use met_no but there is only a two day forecast, and I’d like three.

I have a feeling it’s a syntax thing to figure out my original question, but I’ve tried all the combos I can think of. So far I always get an error that it is expecting an integer, and I’m not sure how to fool an attribute that expecting an integer.