Lovelace Push Button triggering temporary output on 8266 (In esphome)

I have an 8266 which I am using with ESPHome. On my lovelace dashboard I have a grid with a switch on it which toggles the state of D1 on the 8266. So far so good.

What I additionally want to do is have a button on the grid which is the equivalent of a push to make. When I click the button and hold it in it raises the output voltage on D2. The moment I ket g of the button the D2 voltage drops to 0. This is for safety as this is controlling a linear actuator which raises my train board into an upright position.

Here is the code “wot I wrote” for the directional switch but this is latching.

Thanks in advance.
switch:

  • platform: gpio
    name: “Direction”
    pin: D1
    restore_mode: ALWAYS_OFF
    on_turn_on:
    • logger.log: “Actuator up!”
      on_turn_off:
    • logger.log: “Actuator down!”

You can’t do that with Lovelace components. Long press is not an indefinitely long event, nor may it trigger an event independent from release. You may have to write your own card type to achieve this, as I don’t know of any cards that support this.

I had a feeling this may be the answer - thank you for replying.

Dave

Best you can probably do I think is just an auto off after x seconds on the switch.

Should be plenty of examples of that around if you want to do it that way.

The Custom Button Card has a hold_action that may do what you want.

Terry

1 Like