Skip to content

Commit

Permalink
Version 1.1.3 climate fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dwain committed Feb 16, 2020
1 parent da9725e commit ed61a27
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 42 deletions.
51 changes: 30 additions & 21 deletions dwains-theme/views/main/01.homepage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,33 +100,42 @@
show_name: false
{% endif %}
{% if room["climate"] or room["temperature"] %}
{% if room["climate"] %}
label: >
[[[
if(states['{{ room["climate"] }}']){
var icon = '';
{% if room["temperature"] %}
if(states['{{ room["temperature"] }}']){
var icon = '';
if(states['{{ room["climate"] }}'].attributes['hvac_action'] == 'heating'){
icon = '<ha-icon style="height: 15px;" icon="{{ _d_t_icons.climate_heating|default('mdi:radiator') }}"></ha-icon>'
{% if room["climate"] %}
if(states['{{ room["climate"] }}']){
if(states['{{ room["climate"] }}'].attributes['hvac_action'] == 'heating' || states['{{ room["climate"] }}'].attributes['hvac_action'] == 'heat'){
icon = '<ha-icon style="height: 15px;" icon="{{ _d_t_icons.climate_heating|default('mdi:radiator') }}"></ha-icon>'
}
}
{% endif %}
return (Math.round(states['{{ room["temperature"] }}'].state * 10) / 10) + '°' + icon;
} else {
console.log('Dwains Theme Error: Invalid rooms.yaml:{{ room["name"] }}.temperature entity!');
return 'Temperature error';
}
{% elif room["climate"] %}
if(states['{{ room["climate"] }}']){
var icon = '';
return (Math.round(states['{{ room["climate"] }}'].attributes.current_temperature * 10) / 10) + '°' + icon;
} else {
console.log('Dwains Theme Error: Invalid rooms.yaml:{{ room["name"] }}.climate entity!');
return 'Climate error';
}
]]]
{% else %}
label: >
[[[
if(states['{{ room["temperature"] }}']){
return (Math.round(states['{{ room["temperature"] }}'].state * 10) / 10) + '°';
} else {
console.log('Dwains Theme Error: Invalid rooms.yaml:{{ room["name"] }}.temperature entity!');
return 'Temperature error';
}
if(states['{{ room["climate"] }}']){
if(states['{{ room["climate"] }}'].attributes['hvac_action'] == 'heating' || states['{{ room["climate"] }}'].attributes['hvac_action'] == 'heat'){
icon = '<ha-icon style="height: 15px;" icon="{{ _d_t_icons.climate_heating|default('mdi:radiator') }}"></ha-icon>'
}
}
return (Math.round(states['{{ room["climate"] }}'].attributes.current_temperature * 10) / 10) + '°' + icon;
} else {
console.log('Dwains Theme Error: Invalid rooms.yaml:{{ room["name"] }}.climate entity!');
return 'Climate error';
}
{% endif %}
]]]
{% endif %}
{% else %}
label: '&nbsp;'
{% endif %}
Expand Down
47 changes: 26 additions & 21 deletions dwains-theme/views/main/rooms/room.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -303,37 +303,42 @@
tap_action:
action: navigate
navigation_path: {{ room["name"]|lower|replace(" ", "_") }}_climate
{% if room["climate"] %}
label: >
[[[
if(entity){
{% if room["temperature"] %}
if(states['{{ room["temperature"] }}']){
var temperature = (Math.round(states['{{ room["temperature"] }}'].state * 10) / 10) + '°';
} else {
console.log('Dwains Theme Error: Invalid rooms.yaml:{{ room["name"] }}.temperature entity!');
return 'Temperature error';
}
{% elif room["climate"] %}
if(states['{{ room["climate"] }}']){
var temperature = (Math.round(states['{{ room["climate"] }}'].attributes.current_temperature * 10) / 10) + '°';
} else {
console.log('Dwains Theme Error: Invalid rooms.yaml:{{ room["name"] }}.climate entity!');
return 'Climate error';
}
{% endif %}
{% if room["climate"] %}
if(states['{{ room["climate"] }}']){
if (entity.attributes.hvac_action == 'idle'){
return entity.attributes.current_temperature + '° <br>{{ _d_t_trans.climate.idle }}';
return temperature + '<br>{{ _d_t_trans.climate.idle }}';
} else if(entity.attributes.hvac_action == 'heating'){
return entity.attributes.current_temperature + '° <br>{{ _d_t_trans.climate.heating }} ' + entity.attributes.temperature + '°';
return temperature + '<br>{{ _d_t_trans.climate.heating }} ' + entity.attributes.temperature + '°';
} else if(entity.attributes.hvac_action == 'off'){
return entity.attributes.current_temperature + '° <br>{{ _d_t_trans.climate.off_text }}';
return temperature + '<br>{{ _d_t_trans.climate.off_text }}';
} else if(entity.attributes.hvac_action == 'heat'){
return entity.attributes.current_temperature + '° <br>{{ _d_t_trans.climate.heating }} ' + entity.attributes.temperature + '°';
return temperature + '<br>{{ _d_t_trans.climate.heating }} ' + entity.attributes.temperature + '°';
} else {
return entity.attributes.current_temperature + '°<br>' + entity.state;
return temperature + '<br>' + entity.state;
}
} else {
console.log('Invalid rooms.yaml:{{ room["name"] }}.climate entity!');
return 'Entity error!';
}
]]]
{% else %}
label: >
[[[
if(entity){
return (Math.round(states['{{ room["temperature"] }}'].state * 10) / 10) + '°'
} else {
console.log('Invalid rooms.yaml:{{ room["name"] }}.temperature entity!');
return 'Entity error!';
}
{% endif %}
return temperature;
]]]
{% endif %}
{% endif %}

#Card for covers (dwains-theme/plugins/button-cards-templates/rooms/child.yaml)
Expand Down

0 comments on commit ed61a27

Please sign in to comment.