FL550 / dwd_weather

Deutscher Wetterdienst integration for Home-Assistant
MIT License
197 stars 13 forks source link

Max Daily Temperature reporting "unknown" #136

Closed ars4l4n closed 2 months ago

ars4l4n commented 3 months ago

Version of home_assistant

Core 2024.7.2 Supervisor 2024.08.0 Operating System 12.4

Version of the custom_component

2.1.4

Describe the bug

This is the template I'm using under configuration.yaml:

template:
  - trigger:
      - platform: time
        at: "00:00:01"
      - platform: homeassistant
        event: start
      - platform: event
        event_type: event_template_reloaded
    action:
      - service: weather.get_forecast
        data:
          type: daily
        target:
          entity_id: weather.bad_homburg_wetterstation
        response_variable: weather_data
    sensor:
      - name: "Max temp Bad Homburg heute (DWD)"
        unique_id: max_daily_temp
        state: >-
          {{ weather_data.forecast[0].temperature }}
        unit_of_measurement: "°C"

I restarted HA which should've triggered the sensor, but there's no value.

Debug log

right after restart: https://pastebin.com/01zJMKYq

FL550 commented 3 months ago

Is there any value after some time?

elcajon commented 3 months ago

I assume your template is missing some key for the weather_data response variable.

Example from weather integration documentation.

template:
  - trigger:
      - platform: time_pattern
        hours: /1
    action:
      - action: weather.get_forecasts
        data:
          type: hourly
        target:
          entity_id: weather.home
        response_variable: hourly
    sensor:
      - name: Temperature forecast next hour
        unique_id: temperature_forecast_next_hour
        state: "{{ hourly['weather.home'].forecast[0].temperature }}"
        unit_of_measurement: °C

I assume you need something like {{ weather_data['weather.bad_homburg_wetterstation'].forecast[0].temperature }}

ars4l4n commented 2 months ago

Is there any value after some time?

no

ars4l4n commented 2 months ago

I assume your template is missing some key for the weather_data response variable.

what key though?

I assume you need something like {{ weather_data['weather.bad_homburg_wetterstation'].forecast[0].temperature }}

I put this as the state and the sensor still reports unknown, even after 1 day.

FL550 commented 2 months ago

@ars4l4n I've found two errors in your configuration. I marked them in bold:

template:

The first was missing an 's' and the second was missing the key of the weather station. With this everything should work as expected.

FL550 commented 2 months ago

@ars4l4n Were you able to resolve your issue?

FL550 commented 2 months ago

I'll close this for now. Feel free to reopen if you still need assistance.