Hi Everyone, I just set up hassbian on raspberry pi yesterday and am amazed with the possibilities!
I realise there is a similar topic to mine, but unfortunately it doesn’t answer my question, because the OP found a different way to solve his issue.
I am trying to configure a switch which runs two different scripts for on and off, or a script that would check the boolean and do one thing or the other.
In the perfect world, I would be able to do this:
homeassistant:
customize:
switch.projector_screen:
emulated_hue_name: "The Screen"
switch projector_screen:
script_on: script.screen_down
script_off: script.screen_up
Is there anything like this available? I want to be able to tell Alexa Alexa, turn the screen on and Alexa, turn the screen off.
Below is what I got in my config file, I’m stuck because I don’t know how to do:
if (x is true) then do YYYY else do ZZZZ
From my research, it looks like you can only do if (x is true) then do YYYY else do nothing
input_boolean:
screen_open:
name: Projector Screen Open
initial: off
icon: mdi:projector-screen
script:
screen_down:
sequence:
- service: switch.turn_on
entity_id: switch.projector_screen
- delay: 00:00:01
- service: switch.turn_on
entity_id: switch.projector_screen
- service: input_boolean.turn_on
data:
entity_id: input_boolean.screen_open
- delay: 00:00:35
- service: switch.turn_off
entity_id: switch.projector_screen
screen_up:
sequence:
- service: switch.turn_off
entity_id: switch.projector_screen
- delay: 00:00:01
- service: switch.turn_off
entity_id: switch.projector_screen
- delay: 00:00:35
- service: input_boolean.turn_off
data:
entity_id: input_boolean.screen_open
switch:
platform: rpi_rf
gpio: 17
switches:
projector_screen:
pulselength: 363
protocol: 1
code_on: 16632836
code_off: 16632833
projector_screen_open:
pulselength: 363
protocol: 1
code_on: 16632836
code_off: 16632833
projector_screen_close:
pulselength: 363
protocol: 1
code_on: 16632833
code_off: 16632836
Script description:
The screen needs two rf signals to be sent in order to unroll it, that’s why there is a 1 second delay. It can’t be unrolled fully because there isn’t enough space, so there is a 35 second timer.
I tried to implement tracking of the screen state with the boolean, hoping I can do if(open) then run screen_up else run screen_down.
All help greatly appreciated
Thanks,
Lucas