Need a Little help

gotcha. well let me know how that works. There are ways to still improve this but, i’d rather get the logic and actions correct first.

The stop routine still not working. It seems to be a real problem, I might do it using some logic ICs to create 3 separate signals, open, close, stop. I dont want to trouble you too much, Where in the world are you if you dont mind me asking, in in Christchurch NZ

im in the US. Did you try from the Somfy remote and/or the HA switch? So, didn’t Stop at all this time?

Tried from the somfy remote, I wont be using HA in this application, It didnt stop but just started the open and close routines again,

You can see in the logs the first push is remote open then I pressed stop, shows up as both Open and close and then continues on with the open routine

20:59:48][D][binary_sensor:036]: 'remote open': Sending state ON
[20:59:48][D][switch:012]: 'Open Switch' Turning ON.
[20:59:49][D][binary_sensor:036]: 'remote open': Sending state OFF
[20:59:49][D][switch:016]: 'rotate_open' Turning OFF.
[20:59:49][D][switch:016]: 'rotate_close' Turning OFF.
[20:59:49][D][switch:016]: 'retract_close' Turning OFF.
[20:59:49][D][switch:012]: 'retract_open' Turning ON.
[20:59:49][D][switch:055]: 'retract_open': Sending state ON
[20:59:50][D][binary_sensor:036]: 'remote open': Sending state ON
[20:59:51][D][binary_sensor:036]: 'Remote Close': Sending state ON
[20:59:51][D][binary_sensor:036]: 'Remote Close': Sending state OFF
[20:59:51][D][binary_sensor:036]: 'remote open': Sending state OFF
[21:00:04][D][switch:016]: 'retract_open' Turning OFF.
[21:00:04][D][switch:055]: 'retract_open': Sending state OFF
[21:00:04][D][switch:012]: 'rotate_open' Turning ON.
[21:00:04][D][switch:055]: 'rotate_open': Sending state ON
[21:00:19][D][switch:016]: 'rotate_open' Turning OFF.
[21:00:19][D][switch:055]: 'rotate_open': Sending state OFF

First thing I notice is the binary sensor does not stay On untill the action is complete. I misunderstood you, I thought you said they stay LOW. They only stay Low while the button is being pressed and that wont work with the sequence I used.

Right here is where the 15s delay is and it didn’t go off. Did you remove that ‘while’ and replace it with an ‘if’?

[20:59:49][D][switch:055]: 'retract_open': Sending state ON
[20:59:50][D][binary_sensor:036]: 'remote open': Sending state ON

Yes, I changed it to If,

ok. I’ve got to lay down. I’ll mess with it tomorrow. Did you say you don’t want or wont use HA switches for this?

Yes, I want it to be stand alone. Just to confirm the remote outputs only stay low while the button is pressed., Thanks so much, it must be late over there as we are about to go to bed here.

I made a few changes. Whenever you get a chance let me know how that is.

switch:
  - platform: gpio
    pin: GPIO16
    id: retract_open
#    interlock: &interlock_group1 [retract_open, retract_close]
  - platform: gpio
    pin: GPIO14
    id: retract_close
#    interlock: *interlock_group1 
  - platform: gpio
    pin: GPIO12
   # inverted: yes
    id: rotate_open
#    interlock: &interlock_group2 [rotate_open, rotate_close]
  - platform: gpio
    pin: GPIO13
   # inverted: yes
    id: rotate_close
#    interlock: *interlock_group2   

  - platform: template
    name: "Stop Switch"
    id: stop_switch
    disabled_by_default: False
    restore_mode: ALWAYS_OFF
    optimistic: False
    assumed_state: False  
    turn_on_action:
      then:
        - if:
            condition: # Stop if both binary sensors are on. Stop action for Somfy remote
              and:
                - binary_sensor.is_on: remote_open
                - binary_sensor.is_on: remote_close 
            then:
              - switch.turn_off: rotate_open
              - switch.turn_off: rotate_close
              - switch.turn_off: retract_close  
              - switch.turn_off: retract_open 
              - delay: 1s
              - switch.turn_off: stop_switch
        - if:
            condition:  # Stop if remote_open is running from HA switch on dashboard
              and:
                - switch.is_on: open_switch
                - switch.is_off: close_switch
            then:
              - switch.turn_off: rotate_open
              - switch.turn_off: rotate_close
              - switch.turn_off: retract_close  
              - switch.turn_off: retract_open 
              - delay: 1s
              - switch.turn_off: stop_switch
        - if:
            condition:  # Stop if remote_close is running from HA switch on dashboard
              and:
                - switch.is_on: close_switch 
                - switch.is_off: open_switch
            then:
              - switch.turn_off: rotate_open
              - switch.turn_off: rotate_close
              - switch.turn_off: retract_close  
              - switch.turn_off: retract_open 
              - delay: 1s
              - switch.turn_off: stop_switch
            else: 
              - logger.log: "No 'if' conditions passed"  
        - switch.turn_off: rotate_open
        - switch.turn_off: rotate_close
        - switch.turn_off: retract_close  
        - switch.turn_off: retract_open 
        - delay: 1s
        - switch.turn_off: stop_switch       
              
                
  - platform: template
    name: "Close Switch"
    id: close_switch
    disabled_by_default: False
    restore_mode: ALWAYS_OFF
    optimistic: False
    assumed_state: False  
    turn_on_action:
      then:
        - if:
            condition:  # remote close action came from Somfy receiver
              and:
                - binary_sensor.is_off: remote_open
                - binary_sensor.is_on: remote_close 
            then:
              - switch.turn_off: rotate_open
              - switch.turn_off: rotate_close
              - switch.turn_off: retract_open
              - switch.turn_on: retract_close          
              - delay: 15s
              - switch.turn_off: retract_close
              - switch.turn_on: rotate_close   
              - delay: 15s
              - switch.turn_off: rotate_close  
              - delay: 500ms
              - switch.turn_off: close_switch    
        - if:
             condition:  # Remote Close came from HA Switch
               and:
                 - binary_sensor.is_off: remote_open
                 - binary_sensor.is_off: remote_close     
             then:
               - switch.turn_off: rotate_open
               - switch.turn_off: rotate_close
               - switch.turn_off: retract_open
               - switch.turn_on: retract_close          
               - delay: 15s
               - switch.turn_off: retract_close
               - switch.turn_on: rotate_close   
               - delay: 15s
               - switch.turn_off: rotate_close  
               - delay: 500ms
               - switch.turn_off: close_switch   
        - if:
             condition:  # Remote Close came from rain_close
               - binary_sensor.is_on: rain_close 
             then:
               - switch.turn_off: rotate_open
               - switch.turn_off: rotate_close
               - switch.turn_off: retract_open
               - switch.turn_on: retract_close          
               - delay: 15s
               - switch.turn_off: retract_close
               - switch.turn_on: rotate_close   
               - delay: 15s
               - switch.turn_off: rotate_close  
               - delay: 500ms                             
               - switch.turn_off: close_switch                   
              
  - platform: template
    name: "Open Switch"
    id: open_switch
    disabled_by_default: False
    restore_mode: ALWAYS_OFF
    optimistic: False
    assumed_state: False  
    turn_on_action:
      then:
        - if:
            condition: # remote open action came from Somfy receiver
              and:
                - binary_sensor.is_on: remote_open
                - binary_sensor.is_off: remote_close 
            then:
              - switch.turn_off: rotate_open
              - switch.turn_off: rotate_close
              - switch.turn_off: retract_close  
              - switch.turn_on: retract_open          
              - delay: 15s
              - switch.turn_off: retract_open 
              - switch.turn_on: rotate_open    
              - delay: 15s
              - switch.turn_off: rotate_open       
                        
        - if:
            condition: # Rotate Open was pressed from HA switch
              and:
                - binary_sensor.is_off: remote_open
                - binary_sensor.is_off: remote_close 
            then:
              - switch.turn_off: rotate_open
              - switch.turn_off: rotate_close
              - switch.turn_off: retract_close  
              - switch.turn_on: retract_open          
              - delay: 15s
              - switch.turn_off: retract_open 
              - switch.turn_on: rotate_open    
              - delay: 15s
              - switch.turn_off: rotate_open       

# Remote Control Open
binary_sensor:
  - platform: gpio
    name: "remote open"
    id: remote_open
    pin:
      number: GPIO5
      mode: INPUT_PULLUP
      inverted: true    
    filters:
      - delayed_off: 500ms  
    on_press:
      then:
        - if:
            condition:
              and:
                - binary_sensor.is_on: remote_open
                - binary_sensor.is_off: remote_close
            then: 
              - switch.turn_on: open_switch 
        - if:
            condition: 
              and:
                - binary_sensor.is_on: remote_open
                - binary_sensor.is_on: remote_close
            then:
              - switch.turn_on: stop_switch  
                
              
        
        
# Remote Control Close
  - platform: gpio
    name: "Remote Close"  
    id: remote_close
    pin:
      number: GPIO04
      mode: INPUT_PULLUP
      inverted: true    
    filters:
      - delayed_off: 500ms  
    on_press:
      then:  
        - if:
            condition:
              and:
                - binary_sensor.is_off: remote_open
                - binary_sensor.is_on: remote_close
            then: 
              - switch.turn_on: close_switch
        - if:
            condition: 
              and:
                - binary_sensor.is_on: remote_open
                - binary_sensor.is_on: remote_close
            then:
              - switch.turn_on: stop_switch        
              
        
        
        
# Rain Close
  - platform: gpio
    name: "rain close"
    id: rain_close
    pin:
      number: GPIO02
      mode: INPUT_PULLUP
      inverted: true     
    on_press:
      then:
        - switch.turn_on: close_switch

Here are the logs after your changes

[08:13:00][D][binary_sensor:036]: 'Remote Close': Sending state ON
[08:13:00][D][switch:012]: 'Close Switch' Turning ON.
[08:13:00][D][switch:016]: 'rotate_open' Turning OFF.
[08:13:00][D][switch:016]: 'rotate_close' Turning OFF.
[08:13:00][D][switch:016]: 'retract_open' Turning OFF.
[08:13:00][D][switch:012]: 'retract_close' Turning ON.
[08:13:00][D][switch:055]: 'retract_close': Sending state ON
[08:13:01][D][binary_sensor:036]: 'Remote Close': Sending state OFF
[08:13:05][D][binary_sensor:036]: 'Remote Close': Sending state ON
[08:13:05][D][switch:012]: 'Close Switch' Turning ON.
[08:13:05][D][switch:016]: 'rotate_open' Turning OFF.
[08:13:05][D][switch:016]: 'rotate_close' Turning OFF.
[08:13:05][D][switch:016]: 'retract_open' Turning OFF.
[08:13:05][D][switch:012]: 'retract_close' Turning ON.
[08:13:05][D][binary_sensor:036]: 'remote open': Sending state ON
[08:13:05][D][switch:012]: 'Stop Switch' Turning ON.
[08:13:05][D][switch:016]: 'rotate_open' Turning OFF.
[08:13:05][D][switch:016]: 'rotate_close' Turning OFF.
[08:13:05][D][switch:016]: 'retract_close' Turning OFF.
[08:13:05][D][switch:055]: 'retract_close': Sending state OFF
[08:13:05][D][switch:016]: 'retract_open' Turning OFF.
[08:13:06][D][binary_sensor:036]: 'Remote Close': Sending state OFF
[08:13:06][D][binary_sensor:036]: 'remote open': Sending state OFF
[08:13:06][D][switch:016]: 'Stop Switch' Turning OFF.
[08:13:20][D][switch:016]: 'retract_close' Turning OFF.
[08:13:20][D][switch:012]: 'rotate_close' Turning ON.
[08:13:20][D][switch:055]: 'rotate_close': Sending state ON
[08:13:35][D][switch:016]: 'rotate_close' Turning OFF.
[08:13:35][D][switch:055]: 'rotate_close': Sending state OFF
[08:13:35][D][switch:016]: 'Close Switch' Turning OFF.

It is seeing the stop switch, but seems to still sneak in the rotate close before it happens and then on release of the stop it does a retract close, the same scenario happens when the open switch is pressed.

Do you know how to copy quotes and paste them? Can you break the log up into the actions that are correct and separate where the problem starts. Its difficult for me to look at them and tell which parts correspond with buttons you press and which are unwanted.

Like right here, this close operation looks OK to me. The Close operation works as it should, correct?

And here, did you press Open and then Stop right afterwards?

Here’s what I’m seeing… you pushed the button remote_close then…

That’s all within 1 second. Binary sensor remote_close is pressed and released.

4 seconds later binary sensor remote_close is pressed again but, looking at the time stamps there is a a remote_open that happens at the same time 13:05 and I assume that was actually supposed to be when you pressed the Stop button? So it looks like they aren’t in sync.

Also the “sneaking in the rotate_close” is actually the action after the 15s delay in the Close operation and you can tell because the timestamp shows exactly 15s between the first Close operation and then that sneaky rotate_close action. It looks like if you’re in the middle of an Open or Close operation and press Stop, the Close action(close switch) needs to manually turned Off in the Stop sequence.

then:
              - switch.turn_off: rotate_open
              - switch.turn_off: rotate_close
              - switch.turn_off: retract_open
              - switch.turn_on: retract_close          
              - delay: 15s
              - switch.turn_off: retract_close
              - switch.turn_on: rotate_close   
              - delay: 15s
              - switch.turn_off: rotate_close  

Try this.

switch:
  - platform: gpio
    pin: GPIO16
    id: retract_open
#    interlock: &interlock_group1 [retractopen, retractclose]
  - platform: gpio
    pin: GPIO14
    id: retract_close
#    interlock: *interlock_group1 
  - platform: gpio
    pin: GPIO12
   # inverted: yes
    id: rotate_open
#    interlock: &interlock_group2 [rotateopen, rotateclose]
  - platform: gpio
    pin: GPIO13
   # inverted: yes
    id: rotate_close
#    interlock: *interlock_group2   

  - platform: template
    name: "Stop Switch"
    id: stop_switch
    disabled_by_default: False
    restore_mode: ALWAYS_OFF
    optimistic: False
    assumed_state: False  
    turn_on_action:
      then:
        - switch.turn_off: close_switch
        - switch.turn_off: open_switch
        
        - switch.turn_off: rotate_open
        - switch.turn_off: rotate_close
        - switch.turn_off: retract_close  
        - switch.turn_off: retract_open 
        - delay: 1s
       # - switch.turn_off: stop_switch    
        - logger.log: "Stopped"   
              
                
  - platform: template
    name: "Close Switch"
    id: close_switch
    disabled_by_default: False
    restore_mode: ALWAYS_OFF
    optimistic: False
    assumed_state: False  
    turn_on_action:
      then:        
        - if:
            condition:  # remote close action came from Somfy receiver
              and:
                - binary_sensor.is_off: remote_open
                - binary_sensor.is_on: remote_close 
            then:
              - switch.turn_off: stop_switch
              - switch.turn_off: rotate_open
              - switch.turn_off: rotate_close
              - switch.turn_off: retract_open
              - switch.turn_on: retract_close          
              - delay: 15s
              - switch.turn_off: retract_close
              - switch.turn_on: rotate_close   
              - delay: 15s
              - switch.turn_off: rotate_close  
              - delay: 500ms
              - switch.turn_off: close_switch    
        
        - if:
             condition:  # Remote Close came from rain_close
               - binary_sensor.is_on: rain_close 
             then:
               - switch.turn_off: stop_switch
               - switch.turn_off: rotate_open
               - switch.turn_off: rotate_close
               - switch.turn_off: retract_open
               - switch.turn_on: retract_close          
               - delay: 15s
               - switch.turn_off: retract_close
               - switch.turn_on: rotate_close   
               - delay: 15s
               - switch.turn_off: rotate_close  
               - delay: 500ms                             
               - switch.turn_off: close_switch                   
              
  - platform: template
    name: "Open Switch"
    id: open_switch
    disabled_by_default: False
    restore_mode: ALWAYS_OFF
    optimistic: False
    assumed_state: False  
    turn_on_action:
      then:
        - if:
            condition: # remote open action came from Somfy receiver
              and:
                - binary_sensor.is_on: remote_open
                - binary_sensor.is_off: remote_close 
            then:
              - switch.turn_off: stop_switch
              - switch.turn_off: rotate_open
              - switch.turn_off: rotate_close
              - switch.turn_off: retract_close  
              - switch.turn_on: retract_open          
              - delay: 15s
              - switch.turn_off: retract_open 
              - switch.turn_on: rotate_open    
              - delay: 15s
              - switch.turn_off: rotate_open       
                        
        - if:
            condition: # Rotate Open was pressed from HA switch
              and:
                - binary_sensor.is_off: remote_open
                - binary_sensor.is_off: remote_close 
            then:
              - switch.turn_off: stop_switch
              - switch.turn_off: rotate_open
              - switch.turn_off: rotate_close
              - switch.turn_off: retract_close  
              - switch.turn_on: retract_open          
              - delay: 15s
              - switch.turn_off: retract_open 
              - switch.turn_on: rotate_open    
              - delay: 15s
              - switch.turn_off: rotate_open       

# Remote Control Open
binary_sensor:
  - platform: gpio
    name: "remote open"
    id: remote_open
    pin:
      number: GPIO5
      mode: INPUT_PULLUP
      inverted: true    
    filters:
      - delayed_off: 250ms  
    on_press:
      then:
        - if:
            condition:
              and:
                - binary_sensor.is_on: remote_open
                - binary_sensor.is_off: remote_close
            then: 
              - switch.turn_on: open_switch 
        - if:
            condition: 
              and:
                - binary_sensor.is_on: remote_open
                - binary_sensor.is_on: remote_close
            then:
              - switch.turn_on: stop_switch  
                
              
        
        
# Remote Control Close
  - platform: gpio
    name: "Remote Close"  
    id: remote_close
    pin:
      number: GPIO04
      mode: INPUT_PULLUP
      inverted: true    
    filters:
      - delayed_off: 250ms  
    on_press:
      then:  
        - if:
            condition:
              and:
                - binary_sensor.is_off: remote_open
                - switch.is_off: close_switch 
            then: 
              - switch.turn_on: close_switch
        - else:
            - if:
                condition: 
                  and:
                    - binary_sensor.is_on: remote_open
                    - binary_sensor.is_on: remote_close
                then:
                    - switch.turn_on: stop_switch     

        
        
        
        
# Rain Close
  - platform: gpio
    name: "rain close"
    id: rain_close
    pin:
      number: GPIO02
      mode: INPUT_PULLUP
      inverted: true   
    delay_off: 250ms    
    on_press:
      then:
        - switch.turn_on: close_switc  

Unfortunately fails compiling.

Failed config

binary_sensor.gpio: [source /config/esphome/esphome-web-13358f.yaml:191]
  platform: gpio
  name: Remote Close
  id: remote_close
  pin: 
    number: GPIO04
    mode: INPUT_PULLUP
    inverted: True
  filters: 
    - delayed_off: 250ms
  on_press: 
    then: 
      - if: 
          condition: 
            and: 
              - binary_sensor.is_off: remote_open
              - switch.is_off: close_switch
          then: 
            - switch.turn_on: close_switch
      - 
        Unable to find action with the name 'else'.
        else: 
      - if: 
          condition: 
            and: 
              - binary_sensor.is_on: remote_open
              - binary_sensor.is_on: remote_close
          then: 
            - switch.turn_on: stop_switch
binary_sensor.gpio: [source /config/esphome/esphome-web-13358f.yaml:223]
  platform: gpio
  name: rain close
  id: rain_close
  pin: 
    number: GPIO02
    mode: INPUT_PULLUP
    inverted: True
  
  [delay_off] is an invalid option for [binary_sensor.gpio]. Please check the indentation.
  delay_off: 250ms
  on_press: 
    then: 
      - switch.turn_on: close_switch
switch:
  - platform: gpio
    pin: GPIO16
    id: retract_open
#    interlock: &interlock_group1 [retractopen, retractclose]
  - platform: gpio
    pin: GPIO14
    id: retract_close
#    interlock: *interlock_group1 
  - platform: gpio
    pin: GPIO12
   # inverted: yes
    id: rotate_open
#    interlock: &interlock_group2 [rotateopen, rotateclose]
  - platform: gpio
    pin: GPIO13
   # inverted: yes
    id: rotate_close
#    interlock: *interlock_group2   

  - platform: template
    name: "Stop Switch"
    id: stop_switch
    disabled_by_default: False
    restore_mode: ALWAYS_OFF
    optimistic: False
    assumed_state: False  
    turn_on_action:
      then:
        - switch.turn_off: close_switch
        - switch.turn_off: open_switch
        
        - switch.turn_off: rotate_open
        - switch.turn_off: rotate_close
        - switch.turn_off: retract_close  
        - switch.turn_off: retract_open 
        - delay: 1s
       # - switch.turn_off: stop_switch    
        - logger.log: "Stopped"   
              
                
  - platform: template
    name: "Close Switch"
    id: close_switch
    disabled_by_default: False
    restore_mode: ALWAYS_OFF
    optimistic: False
    assumed_state: False  
    turn_on_action:
      then:        
        - if:
            condition:  # remote close action came from Somfy receiver
              and:
                - binary_sensor.is_off: remote_open
                - binary_sensor.is_on: remote_close 
            then:
              - switch.turn_off: stop_switch
              - switch.turn_off: rotate_open
              - switch.turn_off: rotate_close
              - switch.turn_off: retract_open
              - switch.turn_on: retract_close          
              - delay: 15s
              - switch.turn_off: retract_close
              - switch.turn_on: rotate_close   
              - delay: 15s
              - switch.turn_off: rotate_close  
              - delay: 500ms
              - switch.turn_off: close_switch    
        
        - if:
             condition:  # Remote Close came from rain_close
               - binary_sensor.is_on: rain_close 
             then:
               - switch.turn_off: stop_switch
               - switch.turn_off: rotate_open
               - switch.turn_off: rotate_close
               - switch.turn_off: retract_open
               - switch.turn_on: retract_close          
               - delay: 15s
               - switch.turn_off: retract_close
               - switch.turn_on: rotate_close   
               - delay: 15s
               - switch.turn_off: rotate_close  
               - delay: 500ms                             
               - switch.turn_off: close_switch                   
              
  - platform: template
    name: "Open Switch"
    id: open_switch
    disabled_by_default: False
    restore_mode: ALWAYS_OFF
    optimistic: False
    assumed_state: False  
    turn_on_action:
      then:
        - if:
            condition: # remote open action came from Somfy receiver
              and:
                - binary_sensor.is_on: remote_open
                - binary_sensor.is_off: remote_close 
            then:
              - switch.turn_off: stop_switch
              - switch.turn_off: rotate_open
              - switch.turn_off: rotate_close
              - switch.turn_off: retract_close  
              - switch.turn_on: retract_open          
              - delay: 15s
              - switch.turn_off: retract_open 
              - switch.turn_on: rotate_open    
              - delay: 15s
              - switch.turn_off: rotate_open       
                        
        - if:
            condition: # Rotate Open was pressed from HA switch
              and:
                - binary_sensor.is_off: remote_open
                - binary_sensor.is_off: remote_close 
            then:
              - switch.turn_off: stop_switch
              - switch.turn_off: rotate_open
              - switch.turn_off: rotate_close
              - switch.turn_off: retract_close  
              - switch.turn_on: retract_open          
              - delay: 15s
              - switch.turn_off: retract_open 
              - switch.turn_on: rotate_open    
              - delay: 15s
              - switch.turn_off: rotate_open       

# Remote Control Open
binary_sensor:
  - platform: gpio
    name: "remote open"
    id: remote_open
    pin:
      number: GPIO5
      mode: INPUT_PULLUP
      inverted: true    
    filters:
      - delayed_off: 250ms  
    on_press:
      then:
        - if:
            condition:
              and:
                - binary_sensor.is_on: remote_open
                - binary_sensor.is_off: remote_close
            then: 
              - switch.turn_on: open_switch 
        - if:
            condition: 
              and:
                - binary_sensor.is_on: remote_open
                - binary_sensor.is_on: remote_close
            then:
              - switch.turn_on: stop_switch  
                
              
        
        
# Remote Control Close
  - platform: gpio
    name: "Remote Close"  
    id: remote_close
    pin:
      number: GPIO04
      mode: INPUT_PULLUP
      inverted: true    
    filters:
      - delayed_off: 250ms  
    on_press:
      then:  
        - if:
            condition:
              and:
                - binary_sensor.is_off: remote_open
                - switch.is_off: close_switch 
            then: 
              - switch.turn_on: close_switch
            else:
              - if:
                 condition: 
                   and:
                     - binary_sensor.is_on: remote_open
                     - binary_sensor.is_on: remote_close
                 then:
                     - switch.turn_on: stop_switch     

        
        
        
        
# Rain Close
  - platform: gpio
    name: "rain close"
    id: rain_close
    pin:
      number: GPIO02
      mode: INPUT_PULLUP
      inverted: true   
    filters:  
     - delayed_off: 250ms    
    on_press:
      then:
        - switch.turn_on: close_switch    

Ahh, thats working better, in fact correctly. I had to add

              - delay: 500ms
              - switch.turn_off: open_switch 

to the open switch template or it ran on to the HA part that was still there and repeated the actions, I have since deleted the HA code in open Switch and all works spot on.
I am now going to study what you did so I can learn from it for future projects.

Thanks ever so much for you over and above help, Indentation gets me, got to find a good tutorial on it.
Regards John

Awesome!
Part of the problem was you had all the logic under your 2 binary sensors. There’s nothing specifically wrong with doing that, its just that in your case you needed to do a lot of logic and conditional statements all in those 2 sensors and it just adds a lot of extra complexity that wasn’t necessary especially for anyone starting to learn.

One of the big problems that i overlooked several times…whoops. When you added those 15s second delays to the Open and Close sequences, there was nothing to turn them Off so, if for example you were doing a Close and you pressed Stop. The Stop sequence would run but then the Close would still be running too and then you’d get “random” Open or Closes and it was just those 15s delays running out and then throwing
the remaining switches On/Off that came after the 15s delays. Adding some switch.turn_off: to the Stop action and vise versa the open and close actions turn off the stop switch when they turn on.

- platform: template
    name: "Stop Switch"
    id: stop_switch
    disabled_by_default: False
    restore_mode: ALWAYS_OFF
    optimistic: False
    assumed_state: False  
    turn_on_action:
      then:
        - switch.turn_off: close_switch
        - switch.turn_off: open_switch

This doesnt cover every possibility but, this is indentation in a nutshell. Things further to the left are “higher order” configurations and if something belongs to it, then it goes underneath and is indented. Binary_sensor is a high order sensor, its all the way to the left. Platform, name, id, and pin are each a configuration of Binary_sensor and therefore only 2 indents. Number, mode, inverted do go to Binary_sensor sensor but, more specifically they are configurations of pin: and therefore they go below and 2 indents to the right of ‘pin’. Next is ‘filters’ its a configuration of the Binary_sensor and its directly in line with the other main configurations. Just like how number: is a configuration of pin: - delayed_off: is a configuration option of filters and goes underneath and indented 2 spaces right. This is how the program knows what goes with what

binary_sensor:
  - platform: gpio
    name: "remote open"
    id: remote_open
    pin:
      number: GPIO5
      mode: INPUT_PULLUP
      inverted: true    
    filters:
      - delayed_off

Here its the same, ‘then’ is a config or action of turn_on_action so it goes underneath and indented 2 spaces right. Same for ’ - if ’ it is a configuration of ‘then’ thats why its underneath and indented 2 spaces right and same goes for ‘condition’ with its ‘and’ that is indented 2 spaces further and once more for the 2 binary sensors, they what’s being checked by ‘and’ so they go underneath and 2 indents to the right.

With this. Its the exact same same. Either it goes directly under or it goes underneath and indented

turn_on_action:
      then:
        - if:
            condition: # remote open action came from Somfy receiver
              and:
                - binary_sensor.is_on: remote_open
                - binary_sensor.is_off: remote_close 
            then:
              - switch.turn_off: stop_switch
              - switch.turn_off: rotate_open
              - switch.turn_off: rotate_close
              - switch.turn_off: retract_close  
              - switch.turn_on: retract_open          
              - delay: 15s
              - switch.turn_off: retract_open 
              - switch.turn_on: rotate_open    
              - delay: 15s
              - switch.turn_off: rotate_open       
                        
        - if:
            condition: # Rotate Open was pressed from HA switch
              and:

Thanks for that, what a helpful person you are :ok_hand:

Whoa! Whoa! Dont say that publicly! Ive got a reputation to uphold on here and now people are going to think im a nice guy…

I don’t, I think you’re trying too hard :wink: