GPIO switch with High-Z/input?

I’m trying to toggle a GPIO pin from high to low, but keep it as input in the meantime, for safety. This is because it’s interfacing with another (commercial) microcontroller.

I need to momentary press the switch, wait a bit, then press it again. Here’s my code, but the output remains high. Ideally, it should switch from input (no pullup) to output low:

switch:
  - platform: gpio
    pin: D3
    id: relay1
    inverted: yes
    interlock: [relay2]
  - platform: template
    name: "Blinds Up"
    icon: "mdi:blinds"
    turn_on_action:
    - switch.turn_on: relay1
    - delay: 100ms
    - switch.turn_off: relay1
    - delay: 2000ms
    - switch.turn_on: relay1
    - delay: 100ms
    - switch.turn_off: relay1

  - platform: gpio
    pin: D4
    id: relay2
    inverted: yes
    interlock: [relay1]
  - platform: template
    name: "Blinds Down"
    icon: "mdi:blinds"
    turn_on_action:
    - switch.turn_on: relay2
    - delay: 100ms
    - switch.turn_off: relay2
    - delay: 2000ms
    - switch.turn_on: relay2
    - delay: 100ms
    - switch.turn_off: relay2

Nevermind, it worked without setting the pin to input, it just behaved a bit strange at the start. However, the answer might still be useful for someone else in the future.

Topic 2: is there any way to add a momentary switch in HA that acts on a normal switch? Right now, the switch (left-right toggle) is toggled once on click, toggled back on the second click. Is there any template that keeps it activated as long is it’s kept clicked/tapped and deactivates it once it’s over?