Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking change in 2024.4.0 #25

Open
crosenkr opened this issue Apr 5, 2024 · 3 comments
Open

Breaking change in 2024.4.0 #25

crosenkr opened this issue Apr 5, 2024 · 3 comments

Comments

@crosenkr
Copy link

crosenkr commented Apr 5, 2024

Weather entities do not have a forecast attribute anymore. Instead, you need to use the service get_forecasts. This breaks part of the code in sensor.yaml.

@voska
Copy link

voska commented Apr 5, 2024

I fixed it by turning it into a trigger. Here's my code:

  - trigger:
      platform: time_pattern
      minutes: "/1"
    action:
      - service: weather.get_forecasts
        data:
          type: hourly
        target:
          entity_id: weather.forecast_home
        response_variable: hourly
    sensor:
      - name: Weatherman Data
        state: "OK"
        attributes:
          weather_condition_now: >
            {% set cond_now = states('weather.forecast_home') %}
            {% if states('sun.sun') == 'below_horizon' %}
                {% if cond_now == 'sunny' %} night {% elif cond_now == 'partlycloudy' %} night-partly-cloudy {% else %} {{ cond_now }} {% endif %}
            {% else %}
                {{ cond_now }}
            {% endif %}
            
          weather_condition_0: >
            {% set cond0 = hourly['weather.forecast_home'].forecast[0].condition %}
            {% set next_setting = as_timestamp(state_attr('sun.sun', 'next_setting')) %}
            {% set next_rising = as_timestamp(state_attr('sun.sun', 'next_rising')) %}
            {% set cond0_time = as_timestamp(hourly['weather.forecast_home'].forecast[0].datetime) %}
            {% if cond0_time > next_setting or cond0_time < next_rising < next_setting %}
                {% if cond0 == 'sunny' %} night {% elif cond0 == 'partlycloudy' %} night-partly-cloudy {% else %} {{ cond0 }} {% endif %}
            {% else %}
                {{ cond0 }}
            {% endif %}
          weather_temperature_0: >
            {{ hourly['weather.forecast_galt_s_gulch'].forecast[0].temperature | round }}
          weather_timestamp_0: >
            {{ as_timestamp(hourly['weather.forecast_home'].forecast[0].datetime) | timestamp_custom('%I') | int }} {{ as_timestamp(hourly['weather.forecast_home'].forecast[0].datetime) | timestamp_custom('%p') }}

Note: I use apple weather as my source

@kneival
Copy link

kneival commented Apr 25, 2024

I fixed it by turning it into a trigger. Here's my code:

  - trigger:
      platform: time_pattern
      minutes: "/1"
    action:
      - service: weather.get_forecasts
        data:
          type: hourly
        target:
          entity_id: weather.forecast_home
        response_variable: hourly
    sensor:
      - name: Weatherman Data
        state: "OK"
        attributes:
          weather_condition_now: >
            {% set cond_now = states('weather.forecast_home') %}
            {% if states('sun.sun') == 'below_horizon' %}
                {% if cond_now == 'sunny' %} night {% elif cond_now == 'partlycloudy' %} night-partly-cloudy {% else %} {{ cond_now }} {% endif %}
            {% else %}
                {{ cond_now }}
            {% endif %}
            
          weather_condition_0: >
            {% set cond0 = hourly['weather.forecast_home'].forecast[0].condition %}
            {% set next_setting = as_timestamp(state_attr('sun.sun', 'next_setting')) %}
            {% set next_rising = as_timestamp(state_attr('sun.sun', 'next_rising')) %}
            {% set cond0_time = as_timestamp(hourly['weather.forecast_home'].forecast[0].datetime) %}
            {% if cond0_time > next_setting or cond0_time < next_rising < next_setting %}
                {% if cond0 == 'sunny' %} night {% elif cond0 == 'partlycloudy' %} night-partly-cloudy {% else %} {{ cond0 }} {% endif %}
            {% else %}
                {{ cond0 }}
            {% endif %}
          weather_temperature_0: >
            {{ hourly['weather.forecast_galt_s_gulch'].forecast[0].temperature | round }}
          weather_timestamp_0: >
            {{ as_timestamp(hourly['weather.forecast_home'].forecast[0].datetime) | timestamp_custom('%I') | int }} {{ as_timestamp(hourly['weather.forecast_home'].forecast[0].datetime) | timestamp_custom('%p') }}

Note: I use apple weather as my source

Legend.

@nrout-HA
Copy link

nrout-HA commented Jan 23, 2025

edit: ok, I don't know what happened. It's working. The only thing I can think of is I was reloading the template.yaml rather than all the yamls.

I'm finding this really confusing. I can't get anything to show up when I have the Trigger/Action/Sensor. This should go under my templates.yaml, correct?

This is a simple example I have. With this example, the state should be "OK", right? It just shows "Unknown" for me.

- trigger:
    platform: time_pattern
    minutes: "/1"
  action:
    - service: weather.get_forecasts
      data:
        type: hourly
      target:
        entity_id: weather.forecast_home
      response_variable: hourly
  sensor:
    - name: Weatherman Data
      state: "OK"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants