Weather Today's Forecast desperation

Hi!

Basically, I want to know when I leave the house in the morning whether I need to take an umbrella with me to work or not, or whether thunderstorms are to be expected.

Since the change in Weather (weather.get_forecasts service) and the update to OpenWeatherMap API V3.0, I can no longer get an entity to show me today’s forecast condition as an entity.

When I run this service in the developer tools:

service: weather.get_forecasts
data:
  type: daily
target:
  entity_id:
    - weather.openweathermap

I receive this response (see image). I would now like to have only the condition for today (shown in green) as a separate entity (that I can show for example on a display).

To update this new entity, I intend to create an automation that executes the service every hour and updates the new entity. Something like this:

alias: Update Weather Today
trigger:
  - platform: time_pattern
    hours: /1
condition: []
action:
  - service: weather.get_forecasts
    target:
      entity_id: weather.openweathermap
    data:
      type: daily

But how do I get from here to my entity? After hours of trial and error, I would be very grateful for specific tips. :pray:

personally i would recommend that you just create a sensor that has your forecast.

template:
  - trigger:
      - platform: time_pattern
        hours: /1
    action:
      - service: weather.get_forecasts
        data:
          type: daily
        target:
          entity_id: weather.openweathermap
        response_variable: daily
    sensor:
      - name: Temperature daily forecast 
        unique_id: daily_forecast
        state: "{{ daily['weather.openweathermap'].forecast[0].condition}}"

however if you really want to set it to another entity (like an input_text?)
then in your yaml, this is the part you need which should have the forecast as a string in this template:

{{ daily['weather.home'].forecast[0].condition}}
1 Like

Thanks for your answer. I am not a developer, so sorry for my stupid question: Is this code meant for an automation, or for the configuration.yaml?

if you do the sensor, you should put it in your configuration.yaml.

if you already have a template: section in your configuration.yaml, then add that to your existing template section but remove the first line.

you’ll need to restart homeassistant after adding to configuration.yaml.

Not sure, where I fail.

Yes, I did a restart, but the configuration leads to an unknown entity state.


Do you have an idea of what’s wrong?

That weather.home should be weather.openweathermap

1 Like

@styphonthal is right. Sorry for my miss above. I corrected it.

Also the trigger is set for hourly, so it may stay unknown until the top of the hour. If you want to test it, change the hours trigger to minutes… Just for testing

My problem already starts here somewhere on line 329/330, even if I remove the two lines as in your example above.


Whatever I try, I get errors.

wait, you’ve switche the format here. and you’re mxiing hold and new formats for sensors.

you can’t put my example under - platform: template

it should be how you had it above but with the edit fixed.

Ok, ok. With this configuration:

The entity looks good:

I have many other errors now, but not sure if related:

I will check tomorrow, it’s already late in Switzerland.
So, thank you very much for your support so far! :blush:

Possibly because you put armedad’s example into the sensor: section of your configuration.yaml file. That’s not where it belongs. It should go into the template: section


I highly recommend you review the documentation for the Template integration and then you’ll understand why adding platform: template to a Trigger-based Template Sensor is invalid.

1 Like

those other errors look quite unrelated to this. so either they were there before, or while you were adding/remove sections of your configuration.yaml, you accidentally inserted an error or something like that.

if this is working now for you i’d recommend you close out this thread (please mark my post above that has the working code as “solution” if you would) and start a new thread with these errors if you can’t figure it out.

1 Like

The weather sensor works now, thanks a lot! :clap: – The new problems were due to the fact that the order in my configuration.yaml was mixed up :slight_smile:

1 Like