From cce4bb973c3ce729e4d275a37227b605256b65e8 Mon Sep 17 00:00:00 2001 From: Jeffrey Stone Date: Tue, 1 Mar 2022 22:08:45 -0500 Subject: [PATCH] Reducing some complexity in my weather sensors. --- config/packages/weather.yaml | 211 ++++++++++++++++++----------- config/packages/weatheralerts.yaml | 8 +- 2 files changed, 139 insertions(+), 80 deletions(-) diff --git a/config/packages/weather.yaml b/config/packages/weather.yaml index 52e95ba..70d8147 100755 --- a/config/packages/weather.yaml +++ b/config/packages/weather.yaml @@ -103,6 +103,123 @@ sensor: - platform: template sensors: + current_forecast: + friendly_name: Current Forecast + unit_of_measurement: '' + icon_template: mdi:weather-sunny + value_template: >- + {% set forecast = state_attr('weather.klzu_daynight','forecast')[0] %} + {{ forecast.condition }} + attribute_templates: + high_temp: >- + {% set forecast = state_attr('weather.klzu_daynight','forecast')[0] %} + {{ forecast.temperature }} + wind_bearing: >- + {% set forecast = state_attr('weather.klzu_daynight','forecast')[0] %} + {{ forecast.wind_bearing }} + wind_speed: >- + {% set forecast = state_attr('weather.klzu_daynight','forecast')[0] %} + {{ forecast.wind_speed }} + precipitation_probability: >- + {% set forecast = state_attr('weather.klzu_daynight','forecast')[0] %} + {{ forecast.precipitation_probability }} + description: > + {% set forecast = state_attr('weather.klzu_daynight','forecast')[0] %} + {{ forecast.detailed_description | truncate(250, False) }} + overnight_forecast: + friendly_name: Overnight Forecast + unit_of_measurement: '' + icon_template: mdi:weather-sunny + value_template: >- + {% if is_state('binary_sensor.overnight', 'on') %} + {% set forecast = state_attr('weather.klzu_daynight','forecast')[0] %} + {% else %} + {% set forecast = state_attr('weather.klzu_daynight','forecast')[1] %} + {% endif %} + {{ forecast.condition }} + attribute_templates: + low_temp: >- + {% if is_state('binary_sensor.overnight', 'on') %} + {% set forecast = state_attr('weather.klzu_daynight','forecast')[0] %} + {% else %} + {% set forecast = state_attr('weather.klzu_daynight','forecast')[1] %} + {% endif %} + {{ forecast.temperature }} + wind_bearing: >- + {% if is_state('binary_sensor.overnight', 'on') %} + {% set forecast = state_attr('weather.klzu_daynight','forecast')[0] %} + {% else %} + {% set forecast = state_attr('weather.klzu_daynight','forecast')[1] %} + {% endif %} + {{ forecast.wind_bearing }} + wind_speed: >- + {% if is_state('binary_sensor.overnight', 'on') %} + {% set forecast = state_attr('weather.klzu_daynight','forecast')[0] %} + {% else %} + {% set forecast = state_attr('weather.klzu_daynight','forecast')[1] %} + {% endif %} + {{ forecast.wind_speed }} + precipitation_probability: >- + {% if is_state('binary_sensor.overnight', 'on') %} + {% set forecast = state_attr('weather.klzu_daynight','forecast')[0] %} + {% else %} + {% set forecast = state_attr('weather.klzu_daynight','forecast')[1] %} + {% endif %} + {{ forecast.precipitation_probability }} + description: >- + {% if is_state('binary_sensor.overnight', 'on') %} + {% set forecast = state_attr('weather.klzu_daynight','forecast')[0] %} + {% else %} + {% set forecast = state_attr('weather.klzu_daynight','forecast')[1] %} + {% endif %} + {{ forecast.detailed_description | truncate(250, False) }} + tomorrow_forecast: + friendly_name: Tomorrows Forecast + unit_of_measurement: '' + icon_template: mdi:weather-sunny + value_template: >- + {% if is_state('binary_sensor.overnight', 'on') %} + {% set forecast = state_attr('weather.klzu_daynight','forecast')[1] %} + {% else %} + {% set forecast = state_attr('weather.klzu_daynight','forecast')[2] %} + {% endif %} + {{ forecast.condition }} + attribute_templates: + high_temp: >- + {% if is_state('binary_sensor.overnight', 'on') %} + {% set forecast = state_attr('weather.klzu_daynight','forecast')[1] %} + {% else %} + {% set forecast = state_attr('weather.klzu_daynight','forecast')[2] %} + {% endif %} + {{ forecast.temperature }} + wind_bearing: >- + {% if is_state('binary_sensor.overnight', 'on') %} + {% set forecast = state_attr('weather.klzu_daynight','forecast')[1] %} + {% else %} + {% set forecast = state_attr('weather.klzu_daynight','forecast')[2] %} + {% endif %} + {{ forecast.wind_bearing }} + wind_speed: >- + {% if is_state('binary_sensor.overnight', 'on') %} + {% set forecast = state_attr('weather.klzu_daynight','forecast')[1] %} + {% else %} + {% set forecast = state_attr('weather.klzu_daynight','forecast')[2] %} + {% endif %} + {{ forecast.wind_speed }} + precipitation_probability: >- + {% if is_state('binary_sensor.overnight', 'on') %} + {% set forecast = state_attr('weather.klzu_daynight','forecast')[1] %} + {% else %} + {% set forecast = state_attr('weather.klzu_daynight','forecast')[2] %} + {% endif %} + {{ forecast.precipitation_probability }} + description: >- + {% if is_state('binary_sensor.overnight', 'on') %} + {% set forecast = state_attr('weather.klzu_daynight','forecast')[1] %} + {% else %} + {% set forecast = state_attr('weather.klzu_daynight','forecast')[2] %} + {% endif %} + {{ forecast.detailed_description | truncate(250, False) }} outside_pressure: friendly_name: 'outisde pressure' value_template: '{{ state_attr(''weather.home'',''pressure'') }}' @@ -111,18 +228,18 @@ sensor: friendly_name: "Clothing Forecast" unit_of_measurement: '' value_template: >- - {%- if states('sensor.nws_daytime_temperature')|int > 63 %} - {%- if states('sensor.nws_daytime_temperature')|int < 80 %} + {%- if state_attr('sensor.current_forecast', 'high_temp')|int > 63 %} + {%- if state_attr('sensor.current_forecast', 'high_temp')|int < 80 %} Nice - {% elif states('sensor.nws_daytime_temperature')|int > 95 %} + {% elif state_attr('sensor.current_forecast', 'high_temp')|int > 95 %} Hot {% else %} Toasty {%- endif %} - {% elif states('sensor.nws_daytime_temperature')|int < 64 %} - {%- if states('sensor.nws_daytime_temperature')|int < 32 %} + {% elif state_attr('sensor.current_forecast', 'high_temp')|int < 64 %} + {%- if state_attr('sensor.current_forecast', 'high_temp')|int < 32 %} Freezing - {% elif states('sensor.nws_daytime_temperature')|int > 50 %} + {% elif state_attr('sensor.current_forecast', 'high_temp')|int > 50 %} Chilly {% else %} Cold @@ -131,97 +248,39 @@ sensor: Unknown {%- endif %} nws_current_forecast: - friendly_name: 'Current Forecast' - value_template: "{{ states.weather.klzu_daynight.attributes.forecast[0].detailed_description | truncate(250, False) }}" + friendly_name: 'Current Detailed Forecast' + value_template: "{{ state_attr('sensor.current_forecast', 'description')}}" nws_current_rain_forecast: friendly_name: 'Current Rain Chance' - value_template: "{{ states.weather.klzu_daynight.attributes.forecast[0].precipitation_probability }}" + value_template: "{{ state_attr('sensor.current_forecast', 'precipitation_probability')}}" unit_of_measurement: '%' nws_current_temperature: friendly_name: 'Current Temperature' - value_template: "{{ states.weather.klzu_daynight.attributes.temperature }}" - device_class: temperature - nws_daytime_temperature: - friendly_name: 'Daytime Temperature' - value_template: >- - {% if states.weather.klzu_daynight.attributes.forecast[0].daytime == True %} - {{ states.weather.klzu_daynight.attributes.forecast[0].temperature }} - {% elif states.weather.klzu_daynight.attributes.forecast[1].daytime == True %} - {{ states.weather.klzu_daynight.attributes.forecast[1].temperature }} - {% endif %} + value_template: "{{ state_attr('weather.klzu_daynight','temperature') }}" device_class: temperature nws_current_condition: friendly_name: 'Current Condition' - value_template: "{{ states.weather.klzu_daynight.state }}" + value_template: "{{ states('weather.klzu_daynight') }}" nws_current_humidity: friendly_name: 'Current Humidity' - value_template: "{{ states.weather.klzu_daynight.attributes.humidity }}" + value_template: "{{ state_attr('weather.klzu_daynight','humidity') }}" nws_current_visibility: friendly_name: "Current Visability" - value_template: "{{ states.weather.klzu_daynight.attributes.visibility }}" + value_template: "{{ state_attr('weather.klzu_daynight','visibility') }}" nws_current_windspeed: friendly_name: "Current Windspeed" - value_template: "{{ states.weather.klzu_daynight.attributes.wind_speed }}" + value_template: "{{ state_attr('weather.klzu_daynight','wind_speed') }}" nws_overnight_low: friendly_name: "Overnight Low" unit_of_measurement: '' value_template: >- - {% if states.weather.klzu_daynight.attributes.forecast[0].daytime == False %} - {{ states.weather.klzu_daynight.attributes.forecast[0].temperature }} - {% elif states.weather.klzu_daynight.attributes.forecast[1].daytime == False %} - {{ states.weather.klzu_daynight.attributes.forecast[1].temperature }} - {% endif %} - nws_overnight_forecast: - friendly_name: "Overnight Forecast" - unit_of_measurement: '' - value_template: >- - {% if states.weather.klzu_daynight.attributes.forecast[0].daytime == False %} - {{ states.weather.klzu_daynight.attributes.forecast[0].detailed_description | truncate(250, False) }} - {% elif states.weather.klzu_daynight.attributes.forecast[1].daytime == False %} - {{ states.weather.klzu_daynight.attributes.forecast[1].detailed_description | truncate(250, False) }} - {% elif states.weather.klzu_daynight.attributes.forecast[2].daytime == False %} - {{ states.weather.klzu_daynight.attributes.forecast[2].detailed_description | truncate(250, False) }} - {% endif %} - nws_forecast_tomorrow: - friendly_name: "Forecast Tomorrow" - unit_of_measurement: '' - value_template: >- - {%- if states.weather.klzu_daynight.attributes.forecast[1].daytime == True %} - {{ states.weather.klzu_daynight.attributes.forecast[1].detailed_description | truncate(250, False) }} - {% elif states.weather.klzu_daynight.attributes.forecast[2].daytime == True %} - {{ states.weather.klzu_daynight.attributes.forecast[2].detailed_description | truncate(250, False) }} - {%- endif %} - nws_forecast_rain_tomorrow: - friendly_name: "Rain Chance Tomorrow" - unit_of_measurement: '%' - value_template: >- - {%- if states.weather.klzu_daynight.attributes.forecast[1].daytime == True %} - {{ states.weather.klzu_daynight.attributes.forecast[1].precipitation_probability }} - {% elif states.weather.klzu_daynight.attributes.forecast[2].daytime == True %} - {{ states.weather.klzu_daynight.attributes.forecast[2].precipitation_probability }} - {%- endif %} - nws_forecast_tomorrow_night: - friendly_name: "Forecast Tomorrow Night" - unit_of_measurement: '' - value_template: >- - {%- if states.weather.klzu_daynight.attributes.forecast[1].daytime == True %} - {{ states.weather.klzu_daynight.attributes.forecast[2].detailed_description | truncate(250, False) }} - {% elif states.weather.klzu_daynight.attributes.forecast[2].daytime == True %} - {{ states.weather.klzu_daynight.attributes.forecast[3].detailed_description | truncate(250, False) }} - {%- endif %} - nws_forecast_rain_tomorrow_night: - friendly_name: "Rain Chance Tomorrow Night" - unit_of_measurement: '%' - value_template: >- - {%- if states.weather.klzu_daynight.attributes.forecast[1].daytime == True %} - {{ states.weather.klzu_daynight.attributes.forecast[2].precipitation_probability }} - {% elif states.weather.klzu_daynight.attributes.forecast[2].daytime == True %} - {{ states.weather.klzu_daynight.attributes.forecast[3].precipitation_probability }} - {%- endif %} + {{ state_attr('sensor.overnight_forecast', 'low_temp')}} + + current_inside_humidity: friendly_name: "Current Inside Humidity" unit_of_measurement: '%' - value_template: "{{ states.climate.home.attributes.current_humidity }}" + value_template: "{{ state_attr('climate.home','current_humidity') }}" lighting_stike_count: friendly_name: "Lightning Strike Count" value_template: "{{ states('sensor.acurite_6045m_3078_strcnt') }}" diff --git a/config/packages/weatheralerts.yaml b/config/packages/weatheralerts.yaml index 2f85190..e4f04cc 100755 --- a/config/packages/weatheralerts.yaml +++ b/config/packages/weatheralerts.yaml @@ -1288,25 +1288,25 @@ input_text: name: Triggered Weather Alert IDs - UI icon: mdi:information-variant max: 255 - initial: None + initial: 1 weatheralerts_triggered_pushbullet_alert_ids: name: Triggered Weather Alert IDs - Pushbullet icon: mdi:information-variant max: 255 - initial: None + initial: 1 weatheralerts_triggered_alert_ids: name: Triggered Weather Alert IDs - Text icon: mdi:information-variant max: 255 - initial: None + initial: 1 weatheralerts_triggered_audible_alert_ids: name: Triggered Weather Alert IDs - Audible icon: mdi:information-variant max: 255 - initial: None + initial: 1 ################################################################################