gdc
(John)
March 1, 2024, 2:27am
1
Hi. I am new to programming, I an setting up an ESP8266 to open and close a louvre roof. I have most things working but cant get the stop function to operate. the SOMFY remote has 3 buttons ,open close and stop. the remote receiver outputs on 2 lines to the ESP one operates for open and the other for closed, both operate at the same time for the stop function. I can get the open and close functions to work perfectly but not the stop function, It stops the operation and then continues with opening the awning. I have included the code I’ve used for this,
Any help appreciated.
# Remote Control Open
binary_sensor:
- platform: gpio
name: "remoteopen"
id: remoteopen
pin:
number: GPIO05
mode: INPUT_PULLUP
inverted: true
# filters:
# - delayed_on: 500ms
on_press:
then:
- if:
condition:
and:
- binary_sensor.is_on: remoteopen
- binary_sensor.is_on: remoteclose
then:
- switch.turn_off: rotateopen
- switch.turn_off: rotateclose
- switch.turn_off: retractclose
- switch.turn_off: retractopen
else:
- switch.turn_off: rotateopen
- switch.turn_off: rotateclose
- switch.turn_off: retractclose
- switch.turn_on: retractopen
- delay: 15s
- switch.turn_off: retractopen
- switch.turn_on: rotateopen
- delay: 15s
- switch.turn_off: rotateopen
# Remote Control Close
- platform: gpio
name: "remoteclose"
id: remoteclose
pin:
number: GPIO04
mode: INPUT_PULLUP
inverted: true
filters:
- delayed_on: 500ms
on_press:
then:
- if:
condition:
and:
- binary_sensor.is_on: remoteopen
- binary_sensor.is_on: remoteclose
then:
- switch.turn_off: rotateopen
- switch.turn_off: rotateclose
- switch.turn_off: retractclose
- switch.turn_off: retractopen
else:
- switch.turn_off: rotateopen
- switch.turn_off: rotateclose
- switch.turn_off: retractopen
- switch.turn_on: retractclose
- delay: 15s
- switch.turn_off: retractclose
- switch.turn_on: rotateclose
- delay: 15s
- switch.turn_off: rotateclose
Can i suggest you use a cover instead? Youd like it much more. I see remoteopen and remoteclose but what are retractopen and retractclose? Seems like a lot of gpio switches to malke a motor go clockwise or counterclockwise. You need to provide more details
gdc
(John)
March 1, 2024, 9:04am
3
Thanks
Remote open/close are the outputs from the remote to the ESP,
Retract open slides the louvres so the vanes are retracted to the sides of the roof, a bit like pulling a blind up. Retract close moves the louvres over the opening again.
Rotate open rotates the louvres to a vertical open position, Rotate closed returns them to a horizontal closed position as below.
Rotate close – – – – – – –
Rotate open I I I I I I I
Retract open IIIIIII
Retract close I I I I I I I
Hope my little diagram of the vanes makes sense.
There are two motors in the roof, 1 for rotation of the vanes, the other for the retracting, there are two relays for each motor, 1 for forward 1 for reverse
I have included the full code this time, it basically repeats itself for each motion
I haven’t done anything with covers but will look into it.
# Setup relays
switch:
- platform: gpio
pin: GPIO16
id: retractopen
# interlock: &interlock_group1 [retractopen, retractclose]
- platform: gpio
pin: GPIO14
id: retractclose
# interlock: *interlock_group1
- platform: gpio
pin: GPIO12
# inverted: yes
id: rotateopen
# interlock: &interlock_group2 [rotateopen, rotateclose]
- platform: gpio
pin: GPIO13
# inverted: yes
id: rotateclose
# interlock: *interlock_group2
# Remote Control Open
binary_sensor:
- platform: gpio
name: "remoteopen"
id: remoteopen
pin:
number: GPIO05
mode: INPUT_PULLUP
inverted: true
# filters:
# - delayed_on: 500ms
on_press:
then:
- if:
condition:
and:
- binary_sensor.is_on: remoteopen
- binary_sensor.is_on: remoteclose
then:
- switch.turn_off: rotateopen
- switch.turn_off: rotateclose
- switch.turn_off: retractclose
- switch.turn_off: retractopen
else:
- switch.turn_off: rotateopen
- switch.turn_off: rotateclose
- switch.turn_off: retractclose
- switch.turn_on: retractopen
- delay: 15s
- switch.turn_off: retractopen
- switch.turn_on: rotateopen
- delay: 15s
- switch.turn_off: rotateopen
# Remote Control Close
- platform: gpio
name: "remoteclose"
id: remoteclose
pin:
number: GPIO04
mode: INPUT_PULLUP
inverted: true
filters:
- delayed_on: 500ms
on_press:
then:
- if:
condition:
and:
- binary_sensor.is_on: remoteopen
- binary_sensor.is_on: remoteclose
then:
- switch.turn_off: rotateopen
- switch.turn_off: rotateclose
- switch.turn_off: retractclose
- switch.turn_off: retractopen
else:
- switch.turn_off: rotateopen
- switch.turn_off: rotateclose
- switch.turn_off: retractopen
- switch.turn_on: retractclose
- delay: 15s
- switch.turn_off: retractclose
- switch.turn_on: rotateclose
- delay: 15s
- switch.turn_off: rotateclose
# Rain Close
- platform: gpio
name: "rainclose"
pin:
number: GPIO02
mode: INPUT_PULLUP
inverted: true
on_press:
then:
- switch.turn_off: rotateopen
- switch.turn_off: rotateclose
- switch.turn_off: retractopen
- switch.turn_on: retractclose
- delay: 15s
- switch.turn_off: retractclose
- switch.turn_on: rotateclose
- delay: 15s
- switch.turn_off: rotateclose
That helps. Do you have a product link or something similar to yours? I just want to make sure I understand, whats going on and how it works. Im not slow in the head, I would just rather not waste mine or your time by throwing out wrong guesses.
I see rotate and retract open/close but, your problem was with the Stop action. Where is the code for the stop action?
gdc
(John)
March 1, 2024, 9:36am
6
The stop action is the “and” part of the remote open and close sections.
The product is n NZ made patio louvre roof. The louvres are normally closed in the flat position, but can be rotated to a vertical position to let sun in or they can be retracted to the side to open the space fully to the sky. The louvres must be in the vertical position when the roof is being retracted open or closed, the louvres can only be rotated when the roof is fully closed or they would foul each other.
I am doing this as the controller that comes with the roof is faulty and the manufacturers want a massive amount to replace it as they now use a new type which requires a lot of mechanical modifications for it to work correctly
Can you post some pictures of your wiring? Im also curious about how the states change for the binary sensors? Is it a quick on/off or for example if you press remote_close, does the that binary_sensor stay On for the duration of the close movement?
gdc
(John)
March 1, 2024, 8:47pm
8
The 2 remote close and open outputs from the SOMFY controller stay low for the time the remote button is pushed, when the stop button is pressed they both go low for the duration of the press. The rain sensor output goes low for as long as the sensor detects rain. The binary sensor inputs just follow the remote presses duration.
The switch gpio outputs stay active for the time the louvres take to complete their operation plus a bit to allow for any additional drag that may occur. The motors are stopped by internal limit switches that are manually set to open at the correct position.
Manufacturers website Retractable Sky Louvres | Johnson & Couzins .
I didnt see any technical details except for the physical superstructure. If you open the esp logs in a browser tab and do the stop action. It will show you each action that it takes. It would be a helpful process of elimination to know if the unwanted action is being called from your automation, which it would show in the logs. If not there then it would indicate an electrical issue or possibly an issue with a limit switch, similar to how a obstacle sensor works on a overhead garage door.
either add the log events or just swap this code block for yours. I just defined each part of the automation and added a log event for the whole set of switch states rather than seeing switch after switch after switch… turn off and on. This just makes it easier to digest and less data to look through. So, when you get a chance just run this and see if the logs show the offending action being called after you press the Stop button. This will confirm that it’s the code or something electrical.
binary_sensor:
- platform: gpio
name: "remoteopen"
id: remoteopen
pin:
number: GPIO05
mode: INPUT_PULLUP
inverted: true
# filters:
# - delayed_on: 500ms
on_press:
then:
- if:
condition:
and:
- binary_sensor.is_on: remoteopen
- binary_sensor.is_on: remoteclose
- logger.log: "remoteopen conditions passed"
then:
- switch.turn_off: rotateopen
- switch.turn_off: rotateclose
- switch.turn_off: retractclose
- switch.turn_off: retractopen
- logger.log: "remoteopen then/stop action passed"
else:
- switch.turn_off: rotateopen
- switch.turn_off: rotateclose
- switch.turn_off: retractclose
- switch.turn_on: retractopen
- delay: 15s
- switch.turn_off: retractopen
- switch.turn_on: rotateopen
- delay: 15s
- switch.turn_off: rotateopen
- logger.log: "remoteopen else action passed"
# Remote Control Close
- platform: gpio
name: "remoteclose"
id: remoteclose
pin:
number: GPIO04
mode: INPUT_PULLUP
inverted: true
filters:
- delayed_on: 500ms
on_press:
then:
- if:
condition:
and:
- binary_sensor.is_on: remoteopen
- binary_sensor.is_on: remoteclose
- logger.log: "remoteclose conditions passed"
then:
- switch.turn_off: rotateopen
- switch.turn_off: rotateclose
- switch.turn_off: retractclose
- switch.turn_off: retractopen
- logger.log: "remoteclose then/stop action passed"
else:
- switch.turn_off: rotateopen
- switch.turn_off: rotateclose
- switch.turn_off: retractopen
- switch.turn_on: retractclose
- delay: 15s
- switch.turn_off: retractclose
- switch.turn_on: rotateclose
- delay: 15s
- switch.turn_off: rotateclose
- logger.log: "remoteclose else action passed"
gdc
(John)
March 3, 2024, 6:26am
12
To get your code to work I had to comment out the Log in the and statement.
I have run it and tested, logs below
[19:20:55][D][binary_sensor:036]: 'remoteclose': Sending state ON
[19:20:56][D][switch:016]: 'rotateopen' Turning OFF.
[19:20:56][D][switch:016]: 'rotateclose' Turning OFF.
[19:20:56][D][switch:016]: 'retractopen' Turning OFF.
[19:20:56][D][switch:012]: 'retractclose' Turning ON.
[19:20:56][D][switch:055]: 'retractclose': Sending state ON
[19:20:56][D][binary_sensor:036]: 'remoteclose': Sending state OFF
[19:21:01][D][binary_sensor:036]: 'remoteclose': Sending state ON
[19:21:01][D][switch:016]: 'rotateopen' Turning OFF.
[19:21:01][D][switch:016]: 'rotateclose' Turning OFF.
[19:21:01][D][switch:016]: 'retractopen' Turning OFF.
[19:21:01][D][switch:012]: 'retractclose' Turning ON.
[19:21:01][D][binary_sensor:036]: 'remoteopen': Sending state ON
[19:21:01][D][switch:016]: 'rotateopen' Turning OFF.
[19:21:01][D][switch:016]: 'rotateclose' Turning OFF.
[19:21:01][D][switch:016]: 'retractclose' Turning OFF.
[19:21:01][D][switch:055]: 'retractclose': Sending state OFF
[19:21:01][D][switch:016]: 'retractopen' Turning OFF.
[19:21:01][D][main:684]: remoteopen then/stop action passed
[19:21:02][D][binary_sensor:036]: 'remoteclose': Sending state OFF
[19:21:02][D][binary_sensor:036]: 'remoteopen': Sending state OFF
[19:21:11][D][switch:016]: 'retractclose' Turning OFF.
[19:21:11][D][switch:012]: 'rotateclose' Turning ON.
[19:21:11][D][switch:055]: 'rotateclose': Sending state ON
[19:21:16][D][switch:016]: 'retractclose' Turning OFF.
[19:21:16][D][switch:012]: 'rotateclose' Turning ON.
[19:21:26][D][switch:016]: 'rotateclose' Turning OFF.
[19:21:26][D][switch:055]: 'rotateclose': Sending state OFF
[19:21:26][D][main:586]: remoteclose else action passed
[19:21:31][D][switch:016]: 'rotateclose' Turning OFF.
[19:21:31][D][main:586]: remoteclose else action passed
It looks like the code keeps running after the “if” “then” statement has been completed . I thought it should stop after this and not continue with the “else” part.
That’s what’s happening but, Im not sure why. Try this, I just changed it around and moved the Stop action to a template switch instead of combining it with the Open and Close actions.
switch:
- platform: gpio
pin: GPIO16
id: retractopen
# interlock: &interlock_group1 [retractopen, retractclose]
- platform: gpio
pin: GPIO14
id: retractclose
# interlock: *interlock_group1
- platform: gpio
pin: GPIO12
# inverted: yes
id: rotateopen
# interlock: &interlock_group2 [rotateopen, rotateclose]
- platform: gpio
pin: GPIO13
# inverted: yes
id: rotateclose
# interlock: *interlock_group2
- platform: template
name: "Stop"
id: stop_movement
turn_on_action:
then:
- if:
condition:
and:
- binary_sensor.is_on: remoteopen
- binary_sensor.is_on: remoteclose
then:
- switch.turn_off: rotateopen
- switch.turn_off: rotateclose
- switch.turn_off: retractclose
- switch.turn_off: retractopen
- delay: 1s
- switch.turn_off: stop_movement
# Remote Control Open
binary_sensor:
- platform: gpio
name: "remoteopen"
id: remoteopen
pin:
number: GPIO05
mode: INPUT_PULLUP
inverted: true
# filters:
# - delayed_on: 500ms
on_press:
then:
- switch.turn_off: rotateopen
- switch.turn_off: rotateclose
- switch.turn_off: retractclose
- switch.turn_on: retractopen
- delay: 15s
- switch.turn_off: retractopen
- switch.turn_on: rotateopen
- delay: 15s
- switch.turn_off: rotateopen
# Remote Control Close
- platform: gpio
name: "remoteclose"
id: remoteclose
pin:
number: GPIO04
mode: INPUT_PULLUP
inverted: true
filters:
- delayed_on: 500ms
on_press:
then:
- switch.turn_off: rotateopen
- switch.turn_off: rotateclose
- switch.turn_off: retractopen
- switch.turn_on: retractclose
- delay: 15s
- switch.turn_off: retractclose
- switch.turn_on: rotateclose
- delay: 15s
- switch.turn_off: rotateclose
# Rain Close
- platform: gpio
name: "rainclose"
pin:
number: GPIO02
mode: INPUT_PULLUP
inverted: true
on_press:
then:
- switch.turn_off: rotateopen
- switch.turn_off: rotateclose
- switch.turn_off: retractopen
- switch.turn_on: retractclose
- delay: 15s
- switch.turn_off: retractclose
- switch.turn_on: rotateclose
- delay: 15s
- switch.turn_off: rotateclose
I switched it around a little bit here. With this one you’ll have controls/switches in HA you can use to call the same actions you can with the Somfy remote. I had to add ( _ ) between you’re id’s, it was driving me crazy, sorry.
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
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_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_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
- platform: template
name: "Close Switch"
id: close_switch
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: rain_close
- switch.turn_off: close_switch
- platform: template
name: "Open Switch"
id: open_switch
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
- delay: 500ms
- switch.turn_off: remote_open
- delay: 500ms
- switch.turn_off: open_switch
- 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
- delay: 500ms
- switch.turn_off: remote_open
- delay: 500ms
- switch.turn_off: open_switch
# Remote Control Open
binary_sensor:
- platform: gpio
name: "remote open"
id: remote_open
pin:
number: GPIO05
mode: INPUT_PULLUP
inverted: true
# filters:
# - delayed_on: 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_on: 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
# 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
gdc
(John)
March 4, 2024, 5:29am
15
Thanks for that, unfortunately the first code block doesnt follow the stop action at all.
it doesnt show in the logs.
The second block fails on install as per logs below.
INFO ESPHome 2024.2.0
INFO Reading configuration /config/esphome/esphome-web-13358f.yaml...
Failed config
switch.template: [source /config/esphome/esphome-web-13358f.yaml:50]
platform: template
name: Stop Switch
id: stop_switch
turn_on_action:
then:
- if:
condition:
and:
- binary_sensor.is_on:
id: remote_open
- binary_sensor.is_on:
id: remote_close
then:
- switch.turn_off:
id: rotate_open
- switch.turn_off:
id: rotate_close
- switch.turn_off:
id: retract_close
- switch.turn_off:
id: retract_open
- delay: 1s
- switch.turn_off:
id: stop_switch
- if:
condition:
and:
- switch.is_on:
id: open_switch
- switch.is_off:
Couldn't find ID 'close_close'. Please check you have defined an ID with that name in your configuration. These IDs look similar: "rotate_close", "remote_close", "close_switch".
id: close_close
then:
- switch.turn_off:
id: rotate_open
- switch.turn_off:
id: rotate_close
- switch.turn_off:
id: retract_close
- switch.turn_off:
id: retract_open
- delay: 1s
- switch.turn_off:
id: stop_switch
- if:
condition:
and:
- switch.is_on:
id: close_switch
- switch.is_off:
id: open_switch
then:
- switch.turn_off:
id: rotate_open
- switch.turn_off:
id: rotate_close
- switch.turn_off:
id: retract_close
- switch.turn_off:
id: retract_open
- delay: 1s
- switch.turn_off:
id: stop_switch
disabled_by_default: False
restore_mode: ALWAYS_OFF
optimistic: False
assumed_state: False
switch.template: [source /config/esphome/esphome-web-13358f.yaml:93]
platform: template
name: Close Switch
id: close_switch
turn_on_action:
then:
- if:
condition:
and:
- binary_sensor.is_off:
id: remote_open
- binary_sensor.is_on:
id: remote_close
then:
- switch.turn_off:
id: rotate_open
- switch.turn_off:
id: rotate_close
- switch.turn_off:
id: retract_open
- switch.turn_on:
id: retract_close
- delay: 15s
- switch.turn_off:
id: retract_close
- switch.turn_on:
id: rotate_close
- delay: 15s
- switch.turn_off:
id: rotate_close
- delay: 500ms
- switch.turn_off:
id: close_switch
- if:
condition:
and:
- binary_sensor.is_off:
id: remote_open
- binary_sensor.is_off:
id: remote_close
then:
- switch.turn_off:
id: rotate_open
- switch.turn_off:
id: rotate_close
- switch.turn_off:
id: retract_open
- switch.turn_on:
id: retract_close
- delay: 15s
- switch.turn_off:
id: retract_close
- switch.turn_on:
id: rotate_close
- delay: 15s
- switch.turn_off:
id: rotate_close
- delay: 500ms
- switch.turn_off:
id: close_switch
- if:
condition:
and:
- binary_sensor.is_on:
id: rain_close
then:
- switch.turn_off:
id: rotate_open
- switch.turn_off:
id: rotate_close
- switch.turn_off:
id: retract_open
- switch.turn_on:
id: retract_close
- delay: 15s
- switch.turn_off:
id: retract_close
- switch.turn_on:
id: rotate_close
- delay: 15s
- switch.turn_off:
id: rotate_close
- delay: 500ms
- switch.turn_off:
ID 'rain_close' of type gpio::GPIOBinarySensor doesn't inherit from switch_::Switch. Please double check your ID is pointing to the correct value.
id: rain_close
- switch.turn_off:
id: close_switch
disabled_by_default: False
restore_mode: ALWAYS_OFF
optimistic: False
assumed_state: False
switch.template: [source /config/esphome/esphome-web-13358f.yaml:149]
platform: template
name: Open Switch
id: open_switch
turn_on_action:
then:
- if:
condition:
and:
- binary_sensor.is_on:
id: remote_open
- binary_sensor.is_off:
id: remote_close
then:
- switch.turn_off:
id: rotate_open
- switch.turn_off:
id: rotate_close
- switch.turn_off:
id: retract_close
- switch.turn_on:
id: retract_open
- delay: 15s
- switch.turn_off:
id: retract_open
- switch.turn_on:
id: rotate_open
- delay: 15s
- switch.turn_off:
id: rotate_open
- delay: 500ms
- switch.turn_off:
ID 'remote_open' of type gpio::GPIOBinarySensor doesn't inherit from switch_::Switch. Please double check your ID is pointing to the correct value.
id: remote_open
- delay: 500ms
- switch.turn_off:
id: open_switch
- if:
condition:
and:
- binary_sensor.is_off:
id: remote_open
- binary_sensor.is_off:
id: remote_close
then:
- switch.turn_off:
id: rotate_open
- switch.turn_off:
id: rotate_close
- switch.turn_off:
id: retract_close
- switch.turn_on:
id: retract_open
- delay: 15s
- switch.turn_off:
id: retract_open
- switch.turn_on:
id: rotate_open
- delay: 15s
- switch.turn_off:
id: rotate_open
- delay: 500ms
- switch.turn_off:
ID 'remote_open' of type gpio::GPIOBinarySensor doesn't inherit from switch_::Switch. Please double check your ID is pointing to the correct value.
id: remote_open
- delay: 500ms
- switch.turn_off:
id: open_switch
disabled_by_default: False
restore_mode: ALWAYS_OFF
optimistic: False
assumed_state: False
sorry to be a pain
your fine. You got some indentations messed up
Also, these switch configuration settings need to go above the switch Action/Automation not below it.
Try this.
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
- 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:
- while:
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: GPIO05
mode: INPUT_PULLUP
inverted: true
# filters:
# - delayed_on: 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_on: 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
# 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
What are these actions between the 15s delays? Are these a situation where one motor(retract) is moving and needs to fully Open/Close before the next set of switch actions(rotate) can turn on?
If that’s the case, I’d strongly recommend breaking the rotate and retract actions into their own template switches/buttons and then instead of a fixed time delay, which could change for one reason or another, say there is mechanical issues one day which takes longer now(sh** happens!). Instead use a conditional check to verify the switch for the opposite motor is actually Off before you start the next Rotate or Retract action.
- switch.turn_on: retract_open
- delay: 15s
- switch.turn_off: retract_open
- switch.turn_on: rotate_open
- delay: 15s
- switch.turn_off: rotate_open
gdc
(John)
March 4, 2024, 7:19am
18
I ve copied and pasted your last code and it still fails on install. The delays are the operation time for the motors to run. They stop by their own internal limit switches. just seems easier to use them as setting the run time a little longer than needed ensures the action completes correctly.
INFO ESPHome 2024.2.0
INFO Reading configuration /config/esphome/esphome-web-13358f.yaml...
Failed config
switch.template: [source /config/esphome/esphome-web-13358f.yaml:50]
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:
and:
- binary_sensor.is_on:
id: remote_open
- binary_sensor.is_on:
id: remote_close
then:
- switch.turn_off:
id: rotate_open
- switch.turn_off:
id: rotate_close
- switch.turn_off:
id: retract_close
- switch.turn_off:
id: retract_open
- delay: 1s
- switch.turn_off:
id: stop_switch
- if:
condition:
and:
- switch.is_on:
id: open_switch
- switch.is_off:
Couldn't find ID 'close_close'. Please check you have defined an ID with that name in your configuration. These IDs look similar: "rotate_close", "remote_close", "close_switch".
id: close_close
then:
- switch.turn_off:
id: rotate_open
- switch.turn_off:
id: rotate_close
- switch.turn_off:
id: retract_close
- switch.turn_off:
id: retract_open
- delay: 1s
- switch.turn_off:
id: stop_switch
- if:
condition:
and:
- switch.is_on:
id: close_switch
- switch.is_off:
id: open_switch
then:
- switch.turn_off:
id: rotate_open
- switch.turn_off:
id: rotate_close
- switch.turn_off:
id: retract_close
- switch.turn_off:
id: retract_open
- delay: 1s
- switch.turn_off:
id: stop_switch
switch.template: [source /config/esphome/esphome-web-13358f.yaml:97]
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:
and:
- binary_sensor.is_off:
id: remote_open
- binary_sensor.is_on:
id: remote_close
then:
- switch.turn_off:
id: rotate_open
- switch.turn_off:
id: rotate_close
- switch.turn_off:
id: retract_open
- switch.turn_on:
id: retract_close
- delay: 15s
- switch.turn_off:
id: retract_close
- switch.turn_on:
id: rotate_close
- delay: 15s
- switch.turn_off:
id: rotate_close
- delay: 500ms
- switch.turn_off:
id: close_switch
- if:
condition:
and:
- binary_sensor.is_off:
id: remote_open
- binary_sensor.is_off:
id: remote_close
then:
- switch.turn_off:
id: rotate_open
- switch.turn_off:
id: rotate_close
- switch.turn_off:
id: retract_open
- switch.turn_on:
id: retract_close
- delay: 15s
- switch.turn_off:
id: retract_close
- switch.turn_on:
id: rotate_close
- delay: 15s
- switch.turn_off:
id: rotate_close
- delay: 500ms
- switch.turn_off:
id: close_switch
- if:
condition:
and:
- binary_sensor.is_on:
id: rain_close
then:
- switch.turn_off:
id: rotate_open
- switch.turn_off:
id: rotate_close
- switch.turn_off:
id: retract_open
- switch.turn_on:
id: retract_close
- delay: 15s
- switch.turn_off:
id: retract_close
- switch.turn_on:
id: rotate_close
- delay: 15s
- switch.turn_off:
id: rotate_close
- delay: 500ms
- switch.turn_off:
ID 'rain_close' of type gpio::GPIOBinarySensor doesn't inherit from switch_::Switch. Please double check your ID is pointing to the correct value.
id: rain_close
- switch.turn_off:
id: close_switch
switch.template: [source /config/esphome/esphome-web-13358f.yaml:157]
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:
and:
- binary_sensor.is_on:
id: remote_open
- binary_sensor.is_off:
id: remote_close
then:
- switch.turn_off:
id: rotate_open
- switch.turn_off:
id: rotate_close
- switch.turn_off:
id: retract_close
- switch.turn_on:
id: retract_open
- delay: 15s
- switch.turn_off:
id: retract_open
- switch.turn_on:
id: rotate_open
- delay: 15s
- switch.turn_off:
id: rotate_open
- delay: 500ms
- switch.turn_off:
ID 'remote_open' of type gpio::GPIOBinarySensor doesn't inherit from switch_::Switch. Please double check your ID is pointing to the correct value.
id: remote_open
- delay: 500ms
- switch.turn_off:
id: open_switch
- if:
condition:
and:
- binary_sensor.is_off:
id: remote_open
- binary_sensor.is_off:
id: remote_close
then:
- switch.turn_off:
id: rotate_open
- switch.turn_off:
id: rotate_close
- switch.turn_off:
id: retract_close
- switch.turn_on:
id: retract_open
- delay: 15s
- switch.turn_off:
id: retract_open
- switch.turn_on:
id: rotate_open
- delay: 15s
- switch.turn_off:
id: rotate_open
- delay: 500ms
- switch.turn_off:
ID 'remote_open' of type gpio::GPIOBinarySensor doesn't inherit from switch_::Switch. Please double check your ID is pointing to the correct value.
id: remote_open
- delay: 500ms
- switch.turn_off:
id: open_switch
I missed a couple things… sorry, i should have test compiled first. I updated that same code again and it conpiles for me
You might have to change this ‘while’ to an ‘if’ I was debating using while statements and missed one when I was changing them back.
So, do they not automatically turn off the switch/relay when it hits the internal limit switch?
- switch.turn_on:
id: rotate_close
- delay: 15s
- switch.turn_off:
id: rotate_close
- 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:
- while: # change to if
condition: # remote open action came from Somfy receiver
and:
- binary_sensor.is_on: remote_open
- binary_sensor.is_off: remote_close
gdc
(John)
March 4, 2024, 7:41am
21
No the relays just time out by the delay, there is no feedback from the motors