Hi everyone,
I’, trying to use counters + custom button card in order to have an inventory style panel in home assistant. It’s gonna be use to track how many drams are left in each of my scotch bottle in my cabinet.
Here’s a snapshot of what I’ve been able to achieve up to now.
Here’s the code that need optimization/fixing :
color: red
color_type: icon
entity: counter.bottle1
hold_action:
action: call-service
service: counter.reset
service_data:
entity_id: entity
icon: 'mdi:battery-unknown'
label: Label test
lock:
duration: 5
enabled: 'yes'
unlock: tap
name: Octomore 10
show_state: 'yes'
show_unit: 'yes'
size: 60px
state:
- icon: 'mdi:battery'
operator: ==
value: '100'
- icon: 'mdi:battery-90'
operator: '>='
value: '90'
- icon: 'mdi:battery-80'
operator: '>='
value: '80'
- icon: 'mdi:battery-70'
operator: '>='
value: '70'
- icon: 'mdi:battery-60'
operator: '>='
value: '60'
- icon: 'mdi:battery-50'
operator: '>='
value: '50'
- icon: 'mdi:battery-40'
operator: '>='
value: '40'
- icon: 'mdi:battery-30'
operator: '>='
value: '30'
- icon: 'mdi:battery-20'
operator: '>='
value: '20'
- icon: 'mdi:battery-10'
operator: '>='
value: '10'
- icon: 'mdi:battery-outline'
operator: <
value: '10'
styles:
card:
- background-color: silver
- font-size: 18px
- color: Red
grid:
- grid-template-areas: '"n i" "s i" "l i"'
- grid-template-columns: 50% 50%
name:
- font-weight: bold
- font-size: 18px
- color: white
tap_action:
action: call-service
service: counter.decrement
service_data:
entity_id: entity
type: 'custom:button-card'
units: '%’
Apart from advices to optimize the cards, I’d like to introduce conditional formating for state value (i.e. 95 %) so it appears green, yellow or red depending on the value (i.e. green from 50 to 100%, yellow from 15% to 49% and red under 15%).
Also, I’ve tried to optimize the states by having the icon update dynamically based on state (instead of programming multiple instances like I did) but I couldn’t achieve it.
Thanks to anyone who would take the time to help me