Roll back temperature units to fit screen (#625)

This should fix #617
This commit is contained in:
Edward Firmo
2023-04-06 00:19:43 +02:00
committed by GitHub
parent 124b9d87d5
commit 5a0715064d

View File

@@ -3097,6 +3097,7 @@ variables:
##### WEATHER ####
weather_entity: !input "weather_entity" # used only during the creation of weather in variables
temperature_units: '°'
##### Home page #####
page_home:
@@ -3768,28 +3769,6 @@ action:
- alias: Home page
conditions: "{{ trigger.event.data.new_state.state == nextion.pages.home }}"
sequence: &refresh_page_home
- &variables-weather
variables:
weather_attribution: "{{ state_attr(weather_entity, 'attribution') | default('unavailable') if weather_entity is string else 'unavailable' }}"
weather_type: >
{% if 'AccuWeather' in weather_attribution %} AccuWeather
{% elif 'OpenWeatherMap' in weather_attribution %} OpenWeather
{% elif 'SMHI' in weather_attribution %} SMHI
{% elif 'met.no' in weather_attribution %} Met.no
{% elif 'OpenWeatherMap' in weather_attribution %} OpenWeather
{% else %} Other
{% endif %}
weather_units:
hours_of_sun: "{{ state_attr(weather_entity, 'hours_of_sun_unit') | default('h') if weather_entity is string and state_attr(weather_entity, 'hours_of_sun_unit') else 'h' }}"
precipitation: "{{ state_attr(weather_entity, 'precipitation_unit') | default('mm') if weather_entity is string and state_attr(weather_entity, 'precipitation_unit') else 'mm' }}"
precipitation_probability: "{{ state_attr(weather_entity, 'precipitation_probability_unit') | default('%') if weather_entity is string and state_attr(weather_entity, 'precipitation_probability_unit') else '%' }}"
pressure: "{{ state_attr(weather_entity, 'pressure_unit') | default('') if weather_entity is string and state_attr(weather_entity, 'pressure_unit') }}"
temperature: "{{ state_attr(weather_entity, 'temperature_unit') | default('°') if weather_entity is string and state_attr(weather_entity, 'temperature_unit') else '°' }}"
thunderstorm_probability: "{{ state_attr(weather_entity, 'thunderstorm_probability_unit') | default('%') if weather_entity is string and state_attr(weather_entity, 'thunderstorm_probability_unit') else '%' }}"
uv_index: "{{ state_attr(weather_entity, 'uv_index_unit') | default('') if weather_entity is string and state_attr(weather_entity, 'uv_index_unit') }}"
visibility: "{{ state_attr(weather_entity, 'visibility_unit') | default('') if weather_entity is string and state_attr(weather_entity, 'visibility_unit') }}"
wind_speed: "{{ state_attr(weather_entity, 'wind_speed_unit') | default('') if weather_entity is string and state_attr(weather_entity, 'wind_speed_unit') }}"
- service: "{{ nextion.commands.set_settings_entity }}"
data:
entity: 'unknown'
@@ -3858,7 +3837,7 @@ action:
- service: "{{ nextion.commands.text_printf }}"
data:
component: home.outdoor_temp
message: "{{ (outdoor_temp | round(1) ~ weather_units.temperature) if is_number(outdoor_temp) else (mui[language].unavailable if outdoor_temp in ['unavailable', 'unknown', None] else outdoor_temp) }}"
message: "{{ (outdoor_temp | round(1) ~ temperature_units) if is_number(outdoor_temp) else (mui[language].unavailable if outdoor_temp in ['unavailable', 'unknown', None] else outdoor_temp) }}"
continue_on_error: true
##### NSPanel Indoor Temp #####
@@ -3890,7 +3869,7 @@ action:
- service: "{{ nextion.commands.text_printf }}"
data:
component: home.current_temp
message: "{{ (indoor_temp_state | round(1) ~ weather_units.temperature) if is_number(indoor_temp_state) else (mui[language].unavailable if indoor_temp_state in ['unavailable', 'unknown', None] else indoor_temp_state) }}"
message: "{{ (indoor_temp_state | round(1) ~ temperature_units) if is_number(indoor_temp_state) else (mui[language].unavailable if indoor_temp_state in ['unavailable', 'unknown', None] else indoor_temp_state) }}"
continue_on_error: true
##### Weather Icon Home Page #####
@@ -4378,7 +4357,6 @@ action:
message: "{{ button_pages_labels[button_page_index].label }}"
continue_on_error: true
- *variables-weather
##### NSPanel build Button page #####
- repeat:
for_each: "{{ button_pages_buttons[first_button:last_button] }}"
@@ -4419,7 +4397,7 @@ action:
{% if not current_entity_state_available %} 0
{% elif item_domain == 'light' and current_entity_state == 'on' and state_attr(repeat.item.entity, 'brightness') != None %} {{ (state_attr(repeat.item.entity, 'brightness') | int * 100 /255) | round(0) }}%
{% elif item_domain == 'cover' and current_entity_state in ['open', 'opening', 'closing'] and state_attr(repeat.item.entity, 'current_position') != None %} {{ (state_attr(repeat.item.entity, 'current_position') | int(100)) | round(0) }}%
{% elif item_domain == 'climate' and current_entity_state != 'off' and state_attr(repeat.item.entity, "current_temperature") != None %} {{ (state_attr(repeat.item.entity, "current_temperature") | float) | round(0) }}{{ weather_units.temperature }}
{% elif item_domain == 'climate' and current_entity_state != 'off' and state_attr(repeat.item.entity, "current_temperature") != None %} {{ (state_attr(repeat.item.entity, "current_temperature") | float) | round(0) }}{{ temperature_units }}
{% else -%} 0
{% endif -%}
- *delay-default
@@ -4794,7 +4772,6 @@ action:
- alias: Climate page
conditions: "{{ trigger.event.data.new_state.state == nextion.pages.climate }}"
sequence:
- *variables-weather
- variables:
hvac_mode: "{{ states(entity_long) | default('unavailable') if entity_long is string else 'unavailable' }}"
outdoor_temp_state: "{{ states(outdoortemp) | default('unavailable') if outdoortemp is string else 'unavailable' }}"
@@ -4809,13 +4786,13 @@ action:
- service: "{{ nextion.commands.text_printf }}"
data:
component: outdoor_temp
message: "{{ (outdoor_temp | round(1) ~ weather_units.temperature) if is_number(outdoor_temp) else (mui[language].unavailable if outdoor_temp in ['unavailable', 'unknown', None] else outdoor_temp) }}"
message: "{{ (outdoor_temp | round(1) ~ temperature_units) if is_number(outdoor_temp) else (mui[language].unavailable if outdoor_temp in ['unavailable', 'unknown', None] else outdoor_temp) }}"
continue_on_error: true
- service: "{{ nextion.commands.text_printf }}"
data:
component: current_temp
message: "{{ (state_attr(entity_long, 'current_temperature') | round(1) ~ weather_units.temperature) if is_number(state_attr(entity_long, 'current_temperature')) else '' }}" # mui[language].unavailable?
message: "{{ (state_attr(entity_long, 'current_temperature') | round(1) ~ temperature_units) if is_number(state_attr(entity_long, 'current_temperature')) else '' }}" # mui[language].unavailable?
continue_on_error: true
- if: "{{ hvac_mode != 'off' and is_number(state_attr(entity_long, 'temperature')) }}"
then:
@@ -4864,15 +4841,33 @@ action:
- service: "{{ nextion.commands.text_printf }}"
data:
component: climate.hotwater_temp
message: "{{ (hotwatertemp_state | round(1) ~ weather_units.temperature) if is_number(hotwatertemp_state) else hotwatertemp_state }}"
message: "{{ (hotwatertemp_state | round(1) ~ temperature_units) if is_number(hotwatertemp_state) else hotwatertemp_state }}"
continue_on_error: true
## PAGE WEATHER (WEATHER01 to WEATHER05) ##
- alias: Weather pages
conditions: "{{ trigger.event.data.new_state.state in nextion.pages.weatherpages }}"
sequence:
- *variables-weather
- variables:
weather_attribution: "{{ state_attr(weather_entity, 'attribution') | default('unavailable') if weather_entity is string else 'unavailable' }}"
weather_type: >
{% if 'AccuWeather' in weather_attribution %} AccuWeather
{% elif 'OpenWeatherMap' in weather_attribution %} OpenWeather
{% elif 'SMHI' in weather_attribution %} SMHI
{% elif 'met.no' in weather_attribution %} Met.no
{% elif 'OpenWeatherMap' in weather_attribution %} OpenWeather
{% else %} Other
{% endif %}
weather_units:
hours_of_sun: "{{ state_attr(weather_entity, 'hours_of_sun_unit') | default('h') if weather_entity is string and state_attr(weather_entity, 'hours_of_sun_unit') else 'h' }}"
precipitation: "{{ state_attr(weather_entity, 'precipitation_unit') | default('mm') if weather_entity is string and state_attr(weather_entity, 'precipitation_unit') else 'mm' }}"
precipitation_probability: "{{ state_attr(weather_entity, 'precipitation_probability_unit') | default('%') if weather_entity is string and state_attr(weather_entity, 'precipitation_probability_unit') else '%' }}"
#pressure: "{{ state_attr(weather_entity, 'pressure_unit') | default('') if weather_entity is string and state_attr(weather_entity, 'pressure_unit') }}"
#temperature: "{{ state_attr(weather_entity, 'temperature_unit') | default('°') if weather_entity is string and state_attr(weather_entity, 'temperature_unit') else '°' }}"
thunderstorm_probability: "{{ state_attr(weather_entity, 'thunderstorm_probability_unit') | default('%') if weather_entity is string and state_attr(weather_entity, 'thunderstorm_probability_unit') else '%' }}"
uv_index: "{{ state_attr(weather_entity, 'uv_index_unit') | default('') if weather_entity is string and state_attr(weather_entity, 'uv_index_unit') }}"
#visibility: "{{ state_attr(weather_entity, 'visibility_unit') | default('') if weather_entity is string and state_attr(weather_entity, 'visibility_unit') }}"
wind_speed: "{{ state_attr(weather_entity, 'wind_speed_unit') | default('') if weather_entity is string and state_attr(weather_entity, 'wind_speed_unit') }}"
page_name: "{{ trigger.event.data.new_state.state }}"
page_index: "{{ (page_name[-2:] | int(0)) - 1 }}"
@@ -4960,9 +4955,9 @@ action:
##### Display temperature min/max when available
- variables:
temperature_string: >
{{ (temp_min | round(0) ~ weather_units.temperature) if is_number(temp_min) }}
{{ (temp_min | round(0) ~ temperature_units) if is_number(temp_min) }}
{{ '/' if is_number(temp_min) and is_number(temp_max) }}
{{ (temp_max | round(0) ~ weather_units.temperature) if is_number(temp_max) }}
{{ (temp_max | round(0) ~ temperature_units) if is_number(temp_max) }}
- if: "{{ (is_number(temp_min) or is_number(temp_max)) and temperature_string is string and temperature_string | length > 0 }}"
then:
- service: "{{ nextion.commands.text_printf }}"
@@ -5852,7 +5847,6 @@ action:
- condition: template
value_template: "{{ nextion.pages.current == nextion.pages.home and is_number(trigger.event.data.new_state.state) }}"
sequence:
- *variables-weather
### LABEL Outdoor Temp Font Color ###
- *delay-default
- service: "{{ nextion.commands.font_color }}"
@@ -5865,7 +5859,7 @@ action:
- service: "{{ nextion.commands.text_printf }}"
data:
component: home.outdoor_temp
message: "{{ trigger.event.data.new_state.state | round(1) }}{{ weather_units.temperature }}"
message: "{{ trigger.event.data.new_state.state | round(1) }}{{ temperature_units }}"
continue_on_error: true
##### INDOOR TEMP - entity #####
@@ -5876,7 +5870,6 @@ action:
- condition: template
value_template: "{{ nextion.pages.current == nextion.pages.home and trigger.event.data.new_state.state not in ['unavailable', 'unknown', None] }}"
sequence:
- *variables-weather
### LABEL Indoor Temp Font Color ###
- *delay-default
- service: "{{ nextion.commands.font_color }}"
@@ -5889,7 +5882,7 @@ action:
- service: "{{ nextion.commands.text_printf }}"
data:
component: home.current_temp
message: "{{ trigger.event.data.new_state.state | round(1) }}{{ weather_units.temperature }}"
message: "{{ trigger.event.data.new_state.state | round(1) }}{{ temperature_units }}"
continue_on_error: true
##### INDOOR TEMP - nspanel #####
@@ -5900,7 +5893,6 @@ action:
- condition: template
value_template: "{{ nextion.pages.current == nextion.pages.home and is_number(trigger.event.data.new_state.state) }}"
sequence:
- *variables-weather
- if: "{{ indoortemp is not match 'sensor.' }}"
then:
### LABEL Indoor Temp Font Color ###
@@ -5915,6 +5907,7 @@ action:
- service: "{{ nextion.commands.text_printf }}"
data:
component: home.current_temp
message: "{{ trigger.event.data.new_state.state | round(1) }}{{ temperature_units }}"
message: "{{ trigger.event.data.new_state.state | round(1) }}{{ weather_units.temperature }}"
continue_on_error: true
@@ -5926,7 +5919,6 @@ action:
- condition: template
value_template: "{{ nextion.pages.current == nextion.pages.home and trigger.event.data.new_state.state not in ['unavailable', 'unknown', None] }}"
sequence:
- *variables-weather
- if: "{{ outdoortemp is not match 'sensor.' }}"
then:
### LABEL Outdoor Temp Font Color ###
@@ -5941,13 +5933,12 @@ action:
- service: "{{ nextion.commands.text_printf }}"
data:
component: home.outdoor_temp
message: "{{trigger.event.data.new_state.attributes.temperature | round(1)}}{{ weather_units.temperature }}"
message: "{{trigger.event.data.new_state.attributes.temperature | round(1)}}{{ temperature_units }}"
continue_on_error: true
- service: "{{ nextion.commands.text_printf }}"
data:
component: climate.outdoor_temp
message: "{{trigger.event.data.new_state.attributes.temperature | round(1)}}{{ weather_units.temperature }}"
continue_on_error: true
message: "{{trigger.event.data.new_state.attributes.temperature | round(1)}}{{ temperature_units }}"
- service: "{{ nextion.commands.printf }}"
data:
@@ -5965,7 +5956,6 @@ action:
# - condition: template
# value_template: "{{ climate_optimistic == false }}"
sequence:
- *variables-weather
- variables:
heating_state: "{{ mui[language].climate.states.off if trigger.event.data.new_state.state == 'off' else mui[language].climate.states.on }}"
heating_bt_pic: "{{ nextion.pics.heating.button.off if trigger.event.data.new_state.state == 'off' else nextion.pics.heating.button.on }}"
@@ -5973,7 +5963,7 @@ action:
- service: "{{ nextion.commands.text_printf }}"
data:
component: current_temp
message: "{{ trigger.event.data.new_state.attributes.current_temperature | round(1)}}{{ weather_units.temperature }}"
message: "{{ trigger.event.data.new_state.attributes.current_temperature | round(1)}}{{ temperature_units }}"
continue_on_error: true
- service: "{{ nextion.commands.text_printf }}"
data:
@@ -6022,17 +6012,16 @@ action:
id: hotwatertemp_state
- "{{ nextion.pages.current == nextion.pages.climate and trigger.event.data.new_state.state not in ['unavailable', 'unknown', None] }}"
sequence:
- *variables-weather
- service: "{{ nextion.commands.text_printf }}"
data:
component: home.hotwater_temp
message: "{{ trigger.event.data.new_state.state | round(1) }}{{ weather_units.temperature }}"
message: "{{ trigger.event.data.new_state.state | round(1) }}{{ temperature_units }}"
continue_on_error: true
- *delay-default
- service: "{{ nextion.commands.text_printf }}"
data:
component: climate.hotwater_temp
message: "{{ trigger.event.data.new_state.state | round(1) }}{{ weather_units.temperature }}"
message: "{{ trigger.event.data.new_state.state | round(1) }}{{ temperature_units }}"
continue_on_error: true
# - delay:
# milliseconds: "{{ delay_value }}"