Skip to content

Commit

Permalink
Correction mapping to new get_forecasts data structure
Browse files Browse the repository at this point in the history
  • Loading branch information
chunkysteveo authored Dec 7, 2023
1 parent c779d93 commit e8e699f
Showing 1 changed file with 33 additions and 28 deletions.
61 changes: 33 additions & 28 deletions ha-configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ template:
moon_phase: >
{% set cond_moon = state_attr('sensor.moon_phase', 'icon') %}
{{ cond_moon.split('mdi:')[1] }}
temperature_unit: "{{ state_attr('weather.home','temperature_unit') }}"
wind_speed_unit: "{{ state_attr('weather.home','wind_speed_unit') }}"
precipitation_unit: "{{ state_attr('weather.home','precipitation_unit') }}"
wm_cond_now: >
{% set cond_now = states('weather.home') %}
{% if cond_now == 'partlycloudy' %}{% set cond_now = 'partly-cloudy' %}{% endif %}
Expand All @@ -26,13 +29,15 @@ template:
{% else %}
{{ cond_now }}
{% endif %}
wm_temp_now: >
{{ state_attr('weather.home','temperature') }}
wm_cond_0: >
{% set cond0 = weather_home_hourly.forecast[0].condition %}
{% set cond0 = weather_home_hourly['weather.home']['forecast'][0].condition %}
{% if cond0 == 'partlycloudy' %}{% set cond0 = 'partly-cloudy' %}{% endif %}
{% if cond0 == 'clear-night' %}{% set cond0 = 'night' %}{% endif %}
{% 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(weather_home_hourly.forecast[0].datetime) %}
{% set cond0_time = as_timestamp(weather_home_hourly['weather.home']['forecast'][0].datetime) %}
{% if states('sun.sun') == 'above_horizon' and cond0_time > next_setting %}
{% if cond0 == 'sunny' %} night {% elif cond0 == 'partly-cloudy' %} night-partly-cloudy {% else %} {{ cond0 }} {% endif %}
{% elif states('sun.sun') == 'below_horizon' and cond0_time < next_rising %}
Expand All @@ -41,22 +46,22 @@ template:
{{ cond0 }}
{% endif %}
wm_temp_0: >
{{ weather_home_hourly.forecast[0].temperature | round }}
{{ weather_home_hourly['weather.home']['forecast'][0].temperature | round }}
wm_precipitation_0: >
{{ weather_home_hourly.forecast[0].precipitation | round }}
{{ weather_home_hourly['weather.home']['forecast'][0].precipitation | round }}
wm_wind_speed_0: >
{{ weather_home_hourly.forecast[0].wind_speed | round }}
{{ weather_home_hourly['weather.home']['forecast'][0].wind_speed | round }}
wm_wind_dir_0: >
{{ weather_home_hourly.forecast[0].wind_bearing | round }}
{{ weather_home_hourly['weather.home']['forecast'][0].wind_bearing | round }}
wm_time_0: >
{{ as_timestamp(weather_home_hourly.forecast[0].datetime) | timestamp_custom('%I') | int }} {{ as_timestamp(weather_home_hourly.forecast[0].datetime) | timestamp_custom('%p') }}
{{ as_timestamp(weather_home_hourly['weather.home']['forecast'][0].datetime) | timestamp_custom('%I') | int }} {{ as_timestamp(weather_home_hourly['weather.home']['forecast'][0].datetime) | timestamp_custom('%p') }}
wm_cond_1: >
{% set cond1 = weather_home_hourly.forecast[1].condition %}
{% set cond1 = weather_home_hourly['weather.home']['forecast'][1].condition %}
{% if cond1 == 'partlycloudy' %}{% set cond1 = 'partly-cloudy' %}{% endif %}
{% if cond1 == 'clear-night' %}{% set cond1 = 'night' %}{% endif %}
{% set next_setting = as_timestamp(state_attr('sun.sun', 'next_setting')) %}
{% set next_rising = as_timestamp(state_attr('sun.sun', 'next_rising')) %}
{% set cond1_time = as_timestamp(weather_home_hourly.forecast[1].datetime) %}
{% set cond1_time = as_timestamp(weather_home_hourly['weather.home']['forecast'][1].datetime) %}
{% if states('sun.sun') == 'above_horizon' and cond1_time > next_setting %}
{% if cond1 == 'sunny' %} night {% elif cond1 == 'partly-cloudy' %} night-partly-cloudy {% else %} {{ cond1 }} {% endif %}
{% elif states('sun.sun') == 'below_horizon' and cond1_time < next_rising %}
Expand All @@ -65,22 +70,22 @@ template:
{{ cond1 }}
{% endif %}
wm_temp_1: >
{{ weather_home_hourly.forecast[1].temperature | round }}
{{ weather_home_hourly['weather.home']['forecast'][1].temperature | round }}
wm_precipitation_1: >
{{ weather_home_hourly.forecast[1].precipitation | round }}
{{ weather_home_hourly['weather.home']['forecast'][1].precipitation | round }}
wm_wind_speed_1: >
{{ weather_home_hourly.forecast[1].wind_speed | round }}
{{ weather_home_hourly['weather.home']['forecast'][1].wind_speed | round }}
wm_wind_dir_1: >
{{ weather_home_hourly.forecast[1].wind_bearing | round }}
{{ weather_home_hourly['weather.home']['forecast'][1].wind_bearing | round }}
wm_time_1: >
{{ as_timestamp(weather_home_hourly.forecast[1].datetime) | timestamp_custom('%I') | int }} {{ as_timestamp(weather_home_hourly.forecast[1].datetime) | timestamp_custom('%p') }}
{{ as_timestamp(weather_home_hourly['weather.home']['forecast'][1].datetime) | timestamp_custom('%I') | int }} {{ as_timestamp(weather_home_hourly['weather.home']['forecast'][1].datetime) | timestamp_custom('%p') }}
wm_cond_2: >
{% set cond2 = weather_home_hourly.forecast[2].condition %}
{% set cond2 = weather_home_hourly['weather.home']['forecast'][2].condition %}
{% if cond2 == 'partlycloudy' %}{% set cond2 = 'partly-cloudy' %}{% endif %}
{% if cond2 == 'clear-night' %}{% set cond2 = 'night' %}{% endif %}
{% set next_setting = as_timestamp(state_attr('sun.sun', 'next_setting')) %}
{% set next_rising = as_timestamp(state_attr('sun.sun', 'next_rising')) %}
{% set cond2_time = as_timestamp(weather_home_hourly.forecast[2].datetime) %}
{% set cond2_time = as_timestamp(weather_home_hourly['weather.home']['forecast'][2].datetime) %}
{% if states('sun.sun') == 'above_horizon' and cond2_time > next_setting %}
{% if cond2 == 'sunny' %} night {% elif cond2 == 'partly-cloudy' %} night-partly-cloudy {% else %} {{ cond2 }} {% endif %}
{% elif states('sun.sun') == 'below_horizon' and cond2_time < next_rising %}
Expand All @@ -89,22 +94,22 @@ template:
{{ cond2 }}
{% endif %}
wm_temp_2: >
{{ weather_home_hourly.forecast[2].temperature | round }}
{{ weather_home_hourly['weather.home']['forecast'][2].temperature | round }}
wm_precipitation_2: >
{{ weather_home_hourly.forecast[2].precipitation | round }}
{{ weather_home_hourly['weather.home']['forecast'][2].precipitation | round }}
wm_wind_speed_2: >
{{ weather_home_hourly.forecast[2].wind_speed | round }}
{{ weather_home_hourly['weather.home']['forecast'][2].wind_speed | round }}
wm_wind_dir_2: >
{{ weather_home_hourly.forecast[2].wind_bearing | round }}
{{ weather_home_hourly['weather.home']['forecast'][2].wind_bearing | round }}
wm_time_2: >
{{ as_timestamp(weather_home_hourly.forecast[2].datetime) | timestamp_custom('%I') | int }} {{ as_timestamp(weather_home_hourly.forecast[2].datetime) | timestamp_custom('%p') }}
{{ as_timestamp(weather_home_hourly['weather.home']['forecast'][2].datetime) | timestamp_custom('%I') | int }} {{ as_timestamp(weather_home_hourly['weather.home']['forecast'][2].datetime) | timestamp_custom('%p') }}
wm_cond_3: >
{% set cond3 = weather_home_hourly.forecast[3].condition %}
{% set cond3 = weather_home_hourly['weather.home']['forecast'][3].condition %}
{% if cond3 == 'partlycloudy' %}{% set cond3 = 'partly-cloudy' %}{% endif %}
{% if cond3 == 'clear-night' %}{% set cond3 = 'night' %}{% endif %}
{% set next_setting = as_timestamp(state_attr('sun.sun', 'next_setting')) %}
{% set next_rising = as_timestamp(state_attr('sun.sun', 'next_rising')) %}
{% set cond3_time = as_timestamp(weather_home_hourly.forecast[3].datetime) %}
{% set cond3_time = as_timestamp(weather_home_hourly['weather.home']['forecast'][3].datetime) %}
{% if states('sun.sun') == 'above_horizon' and cond3_time > next_setting %}
{% if cond3 == 'sunny' %} night {% elif cond3 == 'partly-cloudy' %} night-partly-cloudy {% else %} {{ cond3 }} {% endif %}
{% elif states('sun.sun') == 'below_horizon' and cond3_time < next_rising %}
Expand All @@ -113,15 +118,15 @@ template:
{{ cond3 }}
{% endif %}
wm_temp_3: >
{{ weather_home_hourly.forecast[3].temperature | round }}
{{ weather_home_hourly['weather.home']['forecast'][3].temperature | round }}
wm_precipitation_3: >
{{ weather_home_hourly.forecast[3].precipitation | round }}
{{ weather_home_hourly['weather.home']['forecast'][3].precipitation | round }}
wm_wind_speed_3: >
{{ weather_home_hourly.forecast[3].wind_speed | round }}
{{ weather_home_hourly['weather.home']['forecast'][3].wind_speed | round }}
wm_wind_dir_3: >
{{ weather_home_hourly.forecast[3].wind_bearing | round }}
{{ weather_home_hourly['weather.home']['forecast'][3].wind_bearing | round }}
wm_time_3: >
{{ as_timestamp(weather_home_hourly.forecast[3].datetime) | timestamp_custom('%I') | int }} {{ as_timestamp(weather_home_hourly.forecast[3].datetime) | timestamp_custom('%p') }}
{{ as_timestamp(weather_home_hourly['weather.home']['forecast'][3].datetime) | timestamp_custom('%I') | int }} {{ as_timestamp(weather_home_hourly['weather.home']['forecast'][3].datetime) | timestamp_custom('%p') }}
wm_cond_4: >
{% set cond4 = state_attr('weather.home', 'forecast')[0].condition %}
{% if cond4 == 'partlycloudy' %} partly-cloudy {% else %} {{ cond4 }} {% endif %}
Expand Down

0 comments on commit e8e699f

Please sign in to comment.