Reducing some complexity in my weather sensors.
This commit is contained in:
parent
915b62b7bc
commit
cce4bb973c
|
@ -103,6 +103,123 @@ sensor:
|
||||||
|
|
||||||
- platform: template
|
- platform: template
|
||||||
sensors:
|
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:
|
outside_pressure:
|
||||||
friendly_name: 'outisde pressure'
|
friendly_name: 'outisde pressure'
|
||||||
value_template: '{{ state_attr(''weather.home'',''pressure'') }}'
|
value_template: '{{ state_attr(''weather.home'',''pressure'') }}'
|
||||||
|
@ -111,18 +228,18 @@ sensor:
|
||||||
friendly_name: "Clothing Forecast"
|
friendly_name: "Clothing Forecast"
|
||||||
unit_of_measurement: ''
|
unit_of_measurement: ''
|
||||||
value_template: >-
|
value_template: >-
|
||||||
{%- if states('sensor.nws_daytime_temperature')|int > 63 %}
|
{%- if state_attr('sensor.current_forecast', 'high_temp')|int > 63 %}
|
||||||
{%- if states('sensor.nws_daytime_temperature')|int < 80 %}
|
{%- if state_attr('sensor.current_forecast', 'high_temp')|int < 80 %}
|
||||||
Nice
|
Nice
|
||||||
{% elif states('sensor.nws_daytime_temperature')|int > 95 %}
|
{% elif state_attr('sensor.current_forecast', 'high_temp')|int > 95 %}
|
||||||
Hot
|
Hot
|
||||||
{% else %}
|
{% else %}
|
||||||
Toasty
|
Toasty
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{% elif states('sensor.nws_daytime_temperature')|int < 64 %}
|
{% elif state_attr('sensor.current_forecast', 'high_temp')|int < 64 %}
|
||||||
{%- if states('sensor.nws_daytime_temperature')|int < 32 %}
|
{%- if state_attr('sensor.current_forecast', 'high_temp')|int < 32 %}
|
||||||
Freezing
|
Freezing
|
||||||
{% elif states('sensor.nws_daytime_temperature')|int > 50 %}
|
{% elif state_attr('sensor.current_forecast', 'high_temp')|int > 50 %}
|
||||||
Chilly
|
Chilly
|
||||||
{% else %}
|
{% else %}
|
||||||
Cold
|
Cold
|
||||||
|
@ -131,97 +248,39 @@ sensor:
|
||||||
Unknown
|
Unknown
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
nws_current_forecast:
|
nws_current_forecast:
|
||||||
friendly_name: 'Current Forecast'
|
friendly_name: 'Current Detailed Forecast'
|
||||||
value_template: "{{ states.weather.klzu_daynight.attributes.forecast[0].detailed_description | truncate(250, False) }}"
|
value_template: "{{ state_attr('sensor.current_forecast', 'description')}}"
|
||||||
nws_current_rain_forecast:
|
nws_current_rain_forecast:
|
||||||
friendly_name: 'Current Rain Chance'
|
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: '%'
|
unit_of_measurement: '%'
|
||||||
nws_current_temperature:
|
nws_current_temperature:
|
||||||
friendly_name: 'Current Temperature'
|
friendly_name: 'Current Temperature'
|
||||||
value_template: "{{ states.weather.klzu_daynight.attributes.temperature }}"
|
value_template: "{{ state_attr('weather.klzu_daynight','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 %}
|
|
||||||
device_class: temperature
|
device_class: temperature
|
||||||
nws_current_condition:
|
nws_current_condition:
|
||||||
friendly_name: 'Current Condition'
|
friendly_name: 'Current Condition'
|
||||||
value_template: "{{ states.weather.klzu_daynight.state }}"
|
value_template: "{{ states('weather.klzu_daynight') }}"
|
||||||
nws_current_humidity:
|
nws_current_humidity:
|
||||||
friendly_name: '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:
|
nws_current_visibility:
|
||||||
friendly_name: "Current Visability"
|
friendly_name: "Current Visability"
|
||||||
value_template: "{{ states.weather.klzu_daynight.attributes.visibility }}"
|
value_template: "{{ state_attr('weather.klzu_daynight','visibility') }}"
|
||||||
nws_current_windspeed:
|
nws_current_windspeed:
|
||||||
friendly_name: "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:
|
nws_overnight_low:
|
||||||
friendly_name: "Overnight Low"
|
friendly_name: "Overnight Low"
|
||||||
unit_of_measurement: ''
|
unit_of_measurement: ''
|
||||||
value_template: >-
|
value_template: >-
|
||||||
{% if states.weather.klzu_daynight.attributes.forecast[0].daytime == False %}
|
{{ state_attr('sensor.overnight_forecast', 'low_temp')}}
|
||||||
{{ 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 %}
|
|
||||||
current_inside_humidity:
|
current_inside_humidity:
|
||||||
friendly_name: "Current Inside Humidity"
|
friendly_name: "Current Inside Humidity"
|
||||||
unit_of_measurement: '%'
|
unit_of_measurement: '%'
|
||||||
value_template: "{{ states.climate.home.attributes.current_humidity }}"
|
value_template: "{{ state_attr('climate.home','current_humidity') }}"
|
||||||
lighting_stike_count:
|
lighting_stike_count:
|
||||||
friendly_name: "Lightning Strike Count"
|
friendly_name: "Lightning Strike Count"
|
||||||
value_template: "{{ states('sensor.acurite_6045m_3078_strcnt') }}"
|
value_template: "{{ states('sensor.acurite_6045m_3078_strcnt') }}"
|
||||||
|
|
|
@ -1288,25 +1288,25 @@ input_text:
|
||||||
name: Triggered Weather Alert IDs - UI
|
name: Triggered Weather Alert IDs - UI
|
||||||
icon: mdi:information-variant
|
icon: mdi:information-variant
|
||||||
max: 255
|
max: 255
|
||||||
initial: None
|
initial: 1
|
||||||
|
|
||||||
weatheralerts_triggered_pushbullet_alert_ids:
|
weatheralerts_triggered_pushbullet_alert_ids:
|
||||||
name: Triggered Weather Alert IDs - Pushbullet
|
name: Triggered Weather Alert IDs - Pushbullet
|
||||||
icon: mdi:information-variant
|
icon: mdi:information-variant
|
||||||
max: 255
|
max: 255
|
||||||
initial: None
|
initial: 1
|
||||||
|
|
||||||
weatheralerts_triggered_alert_ids:
|
weatheralerts_triggered_alert_ids:
|
||||||
name: Triggered Weather Alert IDs - Text
|
name: Triggered Weather Alert IDs - Text
|
||||||
icon: mdi:information-variant
|
icon: mdi:information-variant
|
||||||
max: 255
|
max: 255
|
||||||
initial: None
|
initial: 1
|
||||||
|
|
||||||
weatheralerts_triggered_audible_alert_ids:
|
weatheralerts_triggered_audible_alert_ids:
|
||||||
name: Triggered Weather Alert IDs - Audible
|
name: Triggered Weather Alert IDs - Audible
|
||||||
icon: mdi:information-variant
|
icon: mdi:information-variant
|
||||||
max: 255
|
max: 255
|
||||||
initial: None
|
initial: 1
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
Loading…
Reference in New Issue