Trying to get a Linear FS20Z Isolated Contact Fixture Module to act like a toggle switch. Currently I am using it to open an close my garage door, but it is annoying to have to turn the switch off each time, would like to to auto reset.
Right now the Linear FS20Z has been auto discovered by HA, and is not in my configuration.
Help trying to make this work is much appreciated!
I was trying to make it work using the following code in my automation.yaml file(I have nothing in my configuration file):
alias: Toggle Garage Door
trigger:
platform: state
entity_id: switch.linear_fs20z_isolated_contact_fixture_module_switch_5_0
action:
service: switch.toggle
entity_id: switch.linear_fs20z_isolated_contact_fixture_module_5_0
Please format your code as outlined in the blue banner at the top of the page or highlight the block of code and press the </> button on the message toolbar. It makes it easier for people to spot indentation errors.
However you have a bigger problem than code formatting. If you toggle the state of a switch in an automation that triggers on the state of the same switch you are going to end up in an endless loop of the switch toggling on and off.
Delete that automation.
Write a script that toggles the switch to on then off, like so:
The reason I used discrete on and off service calls is in case the switch is already on for some reason.
This will give you a script called garage_door with the text “EXECUTE” next to it that you can tap. It will toggle the switch on for 1 second then off again. If you need the switch to stay on for longer adjust the delay: time (HH:MM:SS) in the script. You can give the script a friendly name in the customize: section of your configuration.yaml file.
The other option is to use an automation but only trigger when the switch is turned on. The action would then turn the switch off. You might need a delay before turning the switch off if the pulse is too short.
alias: Toggle Garage Door
trigger:
entity_id: switch.linear_fs20z_isolated_contact_fixture_module_5_0
platform: state
to: 'on'
action:
service: switch.turn_off
entity_id: switch.linear_fs20z_isolated_contact_fixture_module_5_0
Thank you for the response and sorry about how I pasted in my script earlier…
I implemented the script as you suggested. However, when executing the script nothing happens. Ive tried increasing the delay between 1 and 10 secs. Still no dice. Any suggestions on where to look next?