ninjaef
November 10, 2020, 7:52pm
1
On the lovelace ‘conditional’ card type, how would I mode the card on an attribute of an entity.
For example, take a climate entity on the generic-thermostat platform, that has the two (and only two) presets which are: away and none . There seems to be no way to mode on the preset mode. For example, the following does not work in lovelace yaml:-
- type: conditional
conditions:
- entity: climate.my_thermostat.preset_mode
state: 'away'
card:
..
..
ninjaef
November 10, 2020, 8:02pm
2
Never mind, solved.
I do no think it is possible directly in the conditional card
But is is possible to create a template sensor and mode on that:
# Example configuration.yaml entry
binary_sensor:
- platform: template
sensors:
my_thermostat_in_programmer_mode:
friendly_name: 'Room thermostat'
unit_of_measurement: 'degrees'
value_template: >-
{{ (state_attr('climate.my_thermostat','preset_mode') == 'away') and (states('climate.my_thermostat') == 'heat') }}
and change the lovelace to:
- type: conditional
conditions:
- entity: sensor.my_thermostat_in_programmer_mode
state: true
card:
..
..
voila!
Just FYI in case you find this thread.
2 Likes
You saved my day!
Though the Lovelace card config should use binary_sensor
and state: 'on'
!
- type: conditional
conditions:
- entity: binary_sensor.my_thermostat_in_programmer_mode
state: 'on'
ninjaef
November 22, 2020, 6:22pm
4
binary_sensors have binary logicality - so 1,true,on are all the same - logically.
I’ve tested it again, it works only with on
, but NOT with 1
or true
.
Disclaimer: I’m new to HA, so maybe missed something, but really tested it.
ninjaef
November 22, 2020, 8:00pm
6
no idea what your config is so cannot comment.