Lovelace switch that sends a "1" as long as you hold and goes back to "0" when released?

Of course, thank you for having a look!

- alias: pushbutton
  trigger:
  - entity_id: switch.kitchen_light
    platform: state
    to: 'on'
  action:
    - alias: Send 1 UNTIL the switch is off
      repeat:
        sequence:
          # Put you action that sends "1" below
          - service: light.turn_on
            entity_id: light.smafil
          # Put your delay before sending the next "1"
          - delay:
              milliseconds: 200
        until:
          # stop loop when switch is turned off
          - condition: state
            entity_id: switch.kitchen_light
            state: 'off'
  mode: single
- service: light.turn_on
  entity_id: light.smafil

Why are you turning on a light to lift the TV? I’m really confused.

You say you have a switch that controls the TV lift, how does this switch work? Do you need to turn it on and off and on and off again and again until the TV is at the desired position? Does it send a repeating command for a given time and lift the TV? Can you show the configuration of this switch?

Sorry to confuse you; that code is for a test that I set up.

I need a Lovelace switch/button that can control a switch that I have in switch.yaml
As long as that switch in the yaml file is active/high/‘1’, the lift moves.
The lift had a remote control but the controller broke and now I’m controlling it with a KNX actuator.

Moving up has a different switch then the one to move down.

How have you solved this now?
I need it too. :slight_smile:

Not since it seems there is no proper solution for this.
An option is to use a timer in an automation that switches off after a predefined time-frame but this al depends on the situation.

In another situation where I needed a short pulse, I have used an automation that calls a switch.turn_on and 50 milliseconds later switch.turn_off

2 Likes

@Nick4 great solution or:

1 Like

I think it is not a ideal solution for this topic. Here we look for a switch which will be ON as long as it is pressed (either by finger on the mobile device or mouse and click&press on the computer) and will turn OFF once the mouse or finger is released.
There is is change request to make it available:

I am using the “test” solution and in most of the cases it works as I wanted.