Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 109130

Template sensor to show maximum temperatur of remaining day

$
0
0

Hello everyone :slight_smile:
I created my first template to get weather based triggers for automations.
It works fine so far.

- trigger: 
  - trigger: time_pattern
    minutes: /1
  action:
    - action: weather.get_forecasts
      target:
        entity_id:
          - weather.forecast_home
      data:
          type: hourly
      response_variable: stundenvorhersage
  sensor:
    - name: Temperaturvorhersage der nächsten Stunde
      unique_id: temperature_forecast_next_hour
      state: "{{ stundenvorhersage['weather.forecast_home'].forecast[1].temperature }}"
      unit_of_measurement: °C

However as you can see “stundenverhersage” contains the hourly forecast for the next 24 hours.
It should be easy but I don’t get it running. I want to find the maximum temperature value out of these data. With the side permission, filtered by the current date, so that I get the maximum temperature out of the data of the remaining hours of the current day.

What I did is this:

    - name: Maximale Temperatur des verbleibenden Tages
      unique_id: temperature_maximum_remaining_day
      state: >
        {% set max_temp = -999 %}
        {% set today = now().date().isoformat() %}
        {% for forecast in stundenvorhersage['weather.forecast_home'].forecast %}
          {% set forecast_date = forecast.datetime[8:10] %}
          {% if forecast_date == today[8:10]%}
            {% set max_temp = [max_temp, forecast.temperature] | max %}
          {% endif %}
        {% endfor %}
      unit_of_measurement: °C

Anyone any idea? Probably easy. Unfortunately I am new to home assistant and coding.

I am using the standard met.no weather service.
What I get is the value of the entity = “-999”.

Thank you for your help!

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 109130

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>