# ================== ROOF OPEN SCRIPT ================== open_roof: alias: "Open Observatory Roof" icon: mdi:home-roof mode: single sequence: # ---- Precondition checks ---- - if: - condition: not conditions: - condition: state entity_id: binary_sensor.roof_closed_sensor_s2 state: "on" then: - service: persistent_notification.create data: title: "🔴 Roof Open Failed" message: "Cannot open roof: Roof Closed Sensor (S2) does not confirm roof is closed. Roof may already be open or in an unknown position." notification_id: roof_open_failed - stop: "Precondition failed: S2 not closed" - if: - condition: not conditions: - condition: state entity_id: binary_sensor.roof_open_sensor_s1 state: "off" then: - service: persistent_notification.create data: title: "🔴 Roof Open Failed" message: "Cannot open roof: Roof Open Sensor (S1) is already reporting roof as open." notification_id: roof_open_failed - stop: "Precondition failed: S1 already open" - if: - condition: not conditions: - condition: state entity_id: binary_sensor.mount_parked_sensor_s3 state: "on" then: - service: persistent_notification.create data: title: "🔴 Roof Open Failed" message: "Cannot open roof: Mount Parked Sensor (S3) does not confirm mount is parked. Park the mount before opening the roof." notification_id: roof_open_failed - stop: "Precondition failed: Mount not parked" - if: - condition: not conditions: - condition: state entity_id: binary_sensor.its_raining_sensor_s4 state: "off" then: - service: persistent_notification.create data: title: "🔴 Roof Open Failed" message: "Cannot open roof: Rain Sensor (S4) is reporting precipitation. Roof will not open in wet conditions." notification_id: roof_open_failed - stop: "Precondition failed: Rain detected" # ---- All checks passed — trigger relay ---- - service: rest_command.dragonfly_relay_on data: relay: 6 - delay: milliseconds: 500 - service: rest_command.dragonfly_relay_off data: relay: 6 # ---- Wait for S1 to confirm roof is open ---- - wait_for_trigger: - platform: state entity_id: binary_sensor.roof_open_sensor_s1 to: "on" timeout: seconds: 30 continue_on_timeout: true - if: - condition: template value_template: "{{ wait.completed == false }}" then: - service: persistent_notification.create data: title: "⚠️ Roof Open Timeout" message: "Roof open command was sent but S1 did not confirm fully open after 30 seconds. Roof may be mid-travel or stalled. Check observatory immediately." notification_id: roof_open_timeout else: - service: persistent_notification.dismiss data: notification_id: roof_open_failed - service: persistent_notification.dismiss data: notification_id: roof_open_timeout # ================== ROOF CLOSE SCRIPT ================== close_roof: alias: "Close Observatory Roof" icon: mdi:home-roof mode: single sequence: # ---- Precondition checks ---- - if: - condition: not conditions: - condition: state entity_id: binary_sensor.roof_open_sensor_s1 state: "on" then: - service: persistent_notification.create data: title: "🔴 Roof Close Failed" message: "Cannot close roof: Roof Open Sensor (S1) does not confirm roof is open. Roof may already be closed or in an unknown position." notification_id: roof_close_failed - stop: "Precondition failed: S1 not open" - if: - condition: not conditions: - condition: state entity_id: binary_sensor.roof_closed_sensor_s2 state: "off" then: - service: persistent_notification.create data: title: "🔴 Roof Close Failed" message: "Cannot close roof: Roof Closed Sensor (S2) is already reporting roof as closed." notification_id: roof_close_failed - stop: "Precondition failed: S2 already closed" - if: - condition: not conditions: - condition: state entity_id: binary_sensor.mount_parked_sensor_s3 state: "on" then: - service: persistent_notification.create data: title: "🔴 Roof Close Failed" message: "Cannot close roof: Mount Parked Sensor (S3) does not confirm mount is parked. Park the mount before closing the roof." notification_id: roof_close_failed - stop: "Precondition failed: Mount not parked" # ---- All checks passed — trigger relay ---- - service: rest_command.dragonfly_relay_on data: relay: 6 - delay: milliseconds: 500 - service: rest_command.dragonfly_relay_off data: relay: 6 # ---- Wait for S2 to confirm roof is closed ---- - wait_for_trigger: - platform: state entity_id: binary_sensor.roof_closed_sensor_s2 to: "on" timeout: seconds: 30 continue_on_timeout: true - if: - condition: template value_template: "{{ wait.completed == false }}" then: - service: persistent_notification.create data: title: "⚠️ Roof Close Timeout" message: "Roof close command was sent but S2 did not confirm fully closed after 30 seconds. Roof may be mid-travel or stalled. Check observatory immediately." notification_id: roof_close_timeout else: - service: persistent_notification.dismiss data: notification_id: roof_close_failed - service: persistent_notification.dismiss data: notification_id: roof_close_timeout