Closed Eucliwood090 closed 5 months ago
I don't see any indentation; but that my be a result of your copy/paste or typing. I would also try returning the state without the "if".
type: custom:button-card entity: switch.lum_tvlum_tv icon: mdi:floor-lamp lock: enabled: '[[[ return states[switch.cusisine.state ]]]' duration: 3 unlock: hold
Yikes, Missing "]" should be --> enabled: '[[[ return states[switch.cusisine].state ]]]' You probably had indentation. I dod; but leading blanks are stripped out here.
Unfortunately it doesn't work.
type: custom:button-card
variables:
cuisine: switch.cuisine1
entity: switch.lum_tvlum_tv
icon: mdi:floor-lamp
lock:
enabled: '[[[ return states[switch.cusisine1].state ]]]'
duration: 3
unlock: hold
use_light_color: true
collapsible_controls: true
Alas, much of this is trial and error. I am able to reference an entity "outside" of my custom button card. Single quoting the entity made this work. Also, you cannot assume (I did) that "on" is true while "off" is false.; use if/else to return true/false. The following worked for me. Give it a try:
lock:
enabled: |
[[[
if (states['switch.power_bar_office_socket_1'].state == "on") return true
else return false
]]]
Oh it's perfect It works well
I would like to lock a button if another button is already activated but I get errors and I don't understand why
` type: custom:button-card entity: switch.lum_tvlum_tv icon: mdi:floor-lamp lock: enabled: '[[[ if (states['switch.cuisine1'].state == "on") ; ]]]' duration: 3 unlock: hold use_light_color: true collapsible_controls: true
`