Do something between two triggers

Hello,

I have a remote that sends a signal when starting a long press and another signal when the long press ends. I want to use this to do something like “while in long press, increase luminosity” which translates to:

  • When the long press starts, begin increasing luminosity of a light
  • When the long press stops, stop increasing the luminosity of a light

However I’m clueless on how to implement this rule in HASS, any ideas? :confused:

Thanks

I think this would be two automations and a script:

Automation 1 -

- alias: Lights up on long press
  trigger:
    platform: state 
    entity_id: YOUR REMOTE 
    to: LONG PRESS 
  action:
    service: homeassistant.turn_on
    entity_id: script.lights_up

Automation 2 -

- alias: Lights stop changes
  trigger:
    platform: state 
    entity_id: YOUR REMOTE 
    to: LONG PRESS STOPPED 
  action:
    service: homeassistant.turn_off
    entity_id: script.lights_up

Script -

lights_up:
  sequence:
    service: light.turn_on
    data:
      entity_id: YOUR LIGHT 
      transition: 10
      brightness: 200

(syntax may be a bit wrong as it is totally off the top of my head and I’m not at a computer to check)

The idea is that you have a script that when activated gradually ups the lights to full over 10 seconds.

Activate the script on long press, stop it on long press release.

Hope this helps.