- id: automation_roof_button_s5 alias: "Roof Button S5 - Physical Button Handler" description: "Triggers on rising edge of S5 and routes to open, close, or stop/reverse based on roof state" mode: single max_exceeded: silent trigger: - platform: state entity_id: binary_sensor.roof_button_sensor_s5 to: "on" action: # ---- Mid-travel: neither open nor closed — emergency stop/reverse ---- - if: - condition: state entity_id: binary_sensor.roof_open_sensor_s1 state: "off" - condition: state entity_id: binary_sensor.roof_closed_sensor_s2 state: "off" then: - service: rest_command.dragonfly_relay_on data: relay: 6 - delay: milliseconds: 500 - service: rest_command.dragonfly_relay_off data: relay: 6 - service: persistent_notification.create data: title: "⚠️ Roof Emergency Stop/Reverse" message: "S5 pressed while roof was mid-travel. R7 pulsed to stop or reverse. Check roof position before proceeding." notification_id: roof_s5_midtravel - stop: "Mid-travel pulse sent" # ---- Roof is closed — attempt to open ---- - if: - condition: state entity_id: binary_sensor.roof_closed_sensor_s2 state: "on" then: - service: script.open_roof - stop: "Open roof script called" # ---- Roof is open — attempt to close ---- - if: - condition: state entity_id: binary_sensor.roof_open_sensor_s1 state: "on" then: - service: script.close_roof - stop: "Close roof script called"