[Solved] Pulse relay on tapping

Hello forum,
I’m rendering my retina to nil on searching a solution which will give a pulse to a GPIO for less than a second.

I’ve visited almost hundred pages trying to understand how one component is constructed and what are the parameters that will appear on the configuration.yaml.

My idea should to add another module to the one I modified. So similar to rpi_gpio, but it will do just a pulse and record the state on, unless another event will modify it.

The module will consist on turn the switch on for a customizable period an the turn it back off. All I found is just toggle, but a momentary switch I’m not able to get anything closer.

I read about to call a service which might act to change the state from on to off in a short while, but I doubt it will go less than a second, which HA time base. Anyway is not that suitable when a module can manage it in a smarter way (I think).

Hi, just to get you right, you want a Switch (ON/OFF) in the UI and everytime it changes you want to send a pulse on a GPIO via rpi_gpio?

In that case you could use an input_boolean as the UI switch and trigger an automation that controls the GPIO with little delay.

automation:
  trigger:
    platform: state
    entity_id: input_boolean.ui_switch
  action:
    - service: switch.turn_on
      entity_id: switch.rpi_gpio_1
    - delay:
        milliseconds: 250
    - service: switch.turn_off
      entity_id: switch.rpi_gpio_1
2 Likes

I do expect that when tapping on the Lovelace icon the GPIO will go from OFF>ON-period>OFF.
Your script gives me an idea, but I don’t expect to use a GPIO as event input. Probably in a next step I’ll need this way too.

As you mention I don’t have an entity input_boolean in my list.

You can define the input_boolean yourself in the configuration.yaml and use it as a UI switch input for automations and/or manipulate it via other automations.

Sorry to disagree…
AFAIK it should work that the picture card (as I’m using) will call a service on tapping the image and the service should activate a script like that one you showed above.

Now, the point is that I don’t know yet how this it will accomplish. It look trollish, somehow, but really I have a little knowledge to program yaml, in the way HA requires.

EDIT

Solved
So I realize a script

pulse_gate:
  sequence:
    - service: switch.turn_on
      entity_id: switch.gate
    - delay:
        milliseconds: 800
    - service: switch.turn_off
      entity_id: switch.gate

Then I wrote the picture entity the following

hold_action:
  action: none
image: /local/mypic.jpg
tap_action:
  action: call-service
  service: 'script.pulse_gate'
type: picture

But it seems the delay is not as wanted. I’ll try to tune it up.

1 Like

Good to hear that you’re on track now :wink:

Thank you for guidance, which gave the right input to create a pulse like the way I wanted.

I’d comment that the HA framework is almost another language, on the way we need to make thing happen.