Closed hAMMERlized closed 1 year ago
Hi Sebastian, I would try something like this :
icon: |
[[[
var discharging = states['input_boolean.dummy_battery_discharging'].state;
var charging = states['input_boolean.dummy_battery_charging'].state;
var generating = states['input_boolean.dummy_pv_generating'].state;
return discharging === 'on' ? 'mdi:battery-arrow-down' :
(charging === 'on' && generating === 'on') ? 'mdi:XY' :
charging === 'on' ? 'mdi:battery-arrow-up' :
generating === 'on' ? 'mdi:solar-power-variant' : 'mdi:solar-panel';
]]]
Okay so the trick is to use two & signs and to put both variables inside the brackets? Funny i din't figure it out myself. So simple.
Thanks anyway. Will see tomorrow if it works when the sun comes out at start charging the battery.
Just for info, how about a OR condition? Like sensor "a" OR " sensor "b" are on display icon XY?
Is it two of the horizontal lines ||
instead of &&
?
It's working. Thanks again!
Hey man,
i am trying to change my icon depending on the state of 3 sensors (on / off), but i struggle with a AND condition.
This is my code so far:
What i need is changing the icon if 2 conditions (in this case 2 input_boolean sensors) are set to ON. For example if
input_boolean.dummy_pv_generating
ANDinput_boolean.dummy_battery_charging
are ON, display icon XY.Can you help me figuring out how the code will look like? Thanks.
Regards, Sebastian