Modbus: Button instead of Switch

I am connecting Home Assitant to my existing PLC using Modbus. I can sussefully configure a switch and connect it to a coil.

But now I have one coil (garage door) for which I do not want to toggle state (0/1) using a switch but just want to send a pulse to it using a button.

The goal: I have a button shown in Home Assistant. When I click on the button is sets the coil to “1” for a certain time period (e.g. 100ms) and then sets the coil back to “0”.

Can this be done in Home Assistant? Any pointers to where I can find documentation on how to do that?

Thanks a lot for any hints.

You can use a script, and it will appear as a button on the interface.
An alternative is using a switch, and an automation that sets it to off after it has been turned on for 100ms.

The script aproach sounds good. In such a script I would need a function to write a coil. I was searching the documentations but could not find out how to write such a coil from a script. Could anyone point me in the right direction how I can write a Modbus coil from a script? Thanks.

Hi,

Has this been solved?

My 2 cents…I have done this with function into the PLC. I use the switch in Hass to “set” or “reset” coils. This is pure a PLC configuration and as such easier to solve than with a script.

Let me know if you need more information on the PLC programming. I can look it up if you want.

Regards

hschroyen

Good idea about doing this in the PLC! But I have solved it in a different way:

  • New coil in the PLC that has the status “door open” or “door closed”
  • Then a switch for this on HASS
  • When I set the switch to “off” (=door closed) the PLC ensures that the door is closed by issuing the according pulse commands to the door controller

So again: a pure PLC solution because I am too dumb to program HASS. :wink:

Hi there

I got also the Problem as I use a WAGO 750-841 for my whole house control… I use the Function “Stromstoss” on my Wago for all binary Lights and other stuff, as I use pushbuttons 24VDC to control evereything and know I would’nt programm any new PLC- Components on it for every application on my PLC…

@arnadan or @abmantis
you spoke of a script, where do I found information upon this?

Thank you very much

Neo

In HA configuration. Just create a script that calls the service you have.

thx, got it - found this

  - id: button1_auto
    trigger:
      platform: state
      entity_id: input_boolean.button1
    action:
      - service: switch.turn_on
        data:
          entity_id: switch.Switch1
      - delay:
          milliseconds: 300
      - service: switch.turn_off
        data:
          entity_id: switch.Switch1
      - service: input_boolean.turn_off
        data:
          entity_id: input_boolean.button1

[https://community.home-assistant.io/t/siemens-logo-8/129281/44](https://community.home-assistant.io/t/siemens-logo-8/129281/44)