Files
sarah/config/lovelace/button_card_templates/progress_button.yaml
T
2020-04-30 00:32:32 +03:00

51 lines
1.4 KiB
YAML

progress:
variables:
min_value: 5
max_value: 40
normal_value: 19
high_value: 23
low_color: "var(--primary-color)"
normal_color: "var(--color-green)"
high_color: "var(--color-red)"
degrees: 180
triggers_update: all
show_state: true
show_name: true
styles:
name:
- position: absolute
- width: 100%
- text-align: center
- top: 66%
- font-size: 1em
state:
- position: absolute
- top: 17%
- width: 100%
- display: flex
- align-items: center
- justify-content: center
- font-size: 1.9em
icon:
- position: absolute
- top: 0
- right: 0
- height: 16px
- transform: translateX(5px)
card:
- background: >
[[[
var temp = entity.state;
var color = temp < variables.normal_value
? variables.low_color
: temp < variables.high_value
? variables.normal_color
: variables.high_color;
var percent = (temp - variables.min_value)/(variables.max_value - variables.min_value) * 100;
var gradient = 100 - percent;
var degrees = variables.degrees + "deg";
return 'linear-gradient('+ degrees +', var(--paper-card-background-color) 0%, var(--paper-card-background-color)' + gradient + '%, ' + color + ' ' + gradient + '%)'
]]]