I’m trying to conditionally set the option value for my blind as shown below.
If the current state is 0 or 100, I want to open else close it.
The code works if I just set option: ‘open’ or option: ‘close’ but if I try to return this value in the script below it fails. Is there anything obviously wrong with my code?
Note that I’m trying 2 different methods for my if statements but neither method seems to work.
thanks
tap_action:
action: call-service
service: input_select.select_option
service_data:
option: |
[[[
let cmd = 'close';
if (input_select.office_blinds.state == '0'){
cmd = 'open';
}
if is_state('input_select.office_blinds','100'){
cmd = 'open';
}
return cmd;
]]];
target:
entity_id: input_select.office_blinds