Toggle Relays for Blinds

Hi Team,
new to Home Assistant (have been using OpenHab for quite some time but im finding its limitations so trying to see if HA will do a better job!)

My setup Raspberry Pi4. HA (latest). My MQTT is still on my OH server (not that I need it for this question - but so you know).

I have set up (and working) ESPHome on an ES8266 4-port relay board to switch some 12V roller blind motors up and down.
The dc motor (with its hardstops) is wired in relay common for Relay 1 and Relay 2
12Vdc+ is wired Relay1NC and Relay2NO
12Vdc- is wired Relay2NO and Relay2NC

The logic is:
Relay 1 on and Relay 2 off - no movement
Relay 1 on and Relay 2 on - UP
Relay 1 on and Relay 2 off - Down
Relay 1 off and relay 2 off - no movement.

This is all working using the .yaml of switch:

  • platform: gpio
    pin: GPIO16 #or GPIO15 to avoid brief power-on at boot
    name: Relay1
    id: relay1
  • platform: gpio
    pin: GPIO14
    name: Relay2

I want to make a button setup where - if I press the “up” button, the blinds go up. if I release the button, the movement stops. (Eventually I will want to have a hold-for-a-few seocnds and the blinds will automagically gontinue to their endstop - but I’ll start with this simple setup first).
Similarly: with down.

in OH I could do this with a custom 3-way toggle switch,
or a blocky rule/script:
If (button-press(up) = ON & relay 1 is off) then turn relay2=on
else (if relay1 is on) then (turn relay1 off & relay2 on)
if button-press(up) = RELEASE then turn relay2=off
…etc…

I’ve searched the forums but they all seem to assume I’m using commercial blind equipment - or I building a set of blinds using mqqt (which I can do - I just thought I liked the integrations of esphome)…

I simply want a push button on my Overview etal. called UP… and another called DOWN.

anyway…
still learning .yaml and how this platform fits together.
Be gentle - as i learn I’ll try to stop asking stupid questions (I hope!)

Answered my own question!

Now I have a button for “up” one for “stop” and one for down.

In case anyone else is looking for the solution:

Inside ESPHome the .yaml should read:

output:
  - platform: gpio
    pin: GPIO16
    id: relay1
  - platform: gpio
    pin: GPIO14
    id: relay2
#button
button:
  - platform: template
    name: "Up"
    on_press:
      - output.turn_off: relay1
      - output.turn_off: relay2
  - platform: template
    name: "Down"
    on_press:
      - output.turn_on: relay2
      - output.turn_on: relay1
  - platform: template
    name: "Stop"
    on_press:
      - output.turn_on: relay2
      - output.turn_off: relay1