Automation with RPi-rf

Hi.

I have a switch setup using rpi-rf component which controls my projector screen over 433mhz radio. Turning it “on” lowers the screen and turning if “off” stops it from lowering any further.

I was hoping someone might be able to point me in the correct direction…

I’d like to set a timer on the switch to be “on” for 15 seconds when triggered then return to “off” (it takes 15 seconds for the screen to lower to the desired height)

To return the screen back to the raised position it requires the signal for “off” to be sent twice, can this also be occomplished in home assistant?

Thanks for any help or advice.

something like this perhaps? Can it be copied anywhere in the configuration.yaml (sorry to for such a noob question)

  • alias: ‘lower screen’
    trigger:
    platform: state
    entity_id: switch.projector_screen
    from: ‘off’
    to: ‘on’
    for:
    seconds: 15
    action:
    service: homeassistant.turn_off
    entity_id: switch.projector_screen

I think scripts would be better here.

script:
  screen_down:
    sequence:
      - service: homeassistant.turn_on
	entity_id: switch.projector_screen
      - delay: 00:00:15
      - service: homeassistant.turn_off
        entity_id: switch.projector_screen
  screen_up:
    sequence:
      - service: homeassistant.turn_off
        entity_id: switch.projector_screen
      - delay: 00:00:01
      - service: homeassistant.turn_off
        entity_id: switch.projector_screen 

Not sure if you can have the 1 second delay between button presses for the screen up script (your screen may see it as two separate presses, not a double click). That may be to long but I don’t think HA is coded to allow fractions of a second. Without the delay it may not clearly transmit both signals. You can try it without, just put a # before that line and HA won’t read it.

To answer your other question, automations all need to go under the automation heading. In the example above everything below the script line is read as a script by HA. You would need to add automation: to your config file and place the automation below it for HA to read it as an automation.

Pay close attention to the spacing in your config file. Component names like script: and automation: have no leading spaces. Items under those always are lead with two spaces. To add multiple items under a component see the script example above. Lead with a dash indented by two spaces each time.

1 Like

Any reason to use homeassistant.turn_on rather than switch.turn_on?

@silvrr Thank you for your help, I really appreciate it.
I can’t believe I didn’t consider a script, this is perfect!

I didn’t expect someone to write the whole thing for me - so really, thank you.

Also thanks for the advice in regards to editing the config file, I’ll keep that in mind.

@CCOSTAN If I’m honest, I don’t really know the difference between homeassistant.turn_on & switch.turn_on

I’ve been searching the forums for a while trying to find a suitable solution to the above, both of these appeared in examples.

If you know the difference and care to explain, I’d appriciate that.

1 Like

It’s just what I always use.

1 Like

Hi, I just found this topic and I suspect we have the same screen - HomeGear 100".

To close the screen, how do you deal with having to turn off a switch that theoretically is already off?

I looked at your script definition, does this mean that you will have to say “Alexa turn on screen down” and “Alexa turn on screen up”? (because there are two separate scripts)

I’m trying to somehow get to “Alexa turn the screen on/Alexa turn the screen off” but I feel like I’m missing something.

Any help would be greatly appreciated.

My config:

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
      - 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


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