Skip to content

Instantly share code, notes, and snippets.

@Uriziel01
Created December 12, 2023 08:12
Show Gist options
  • Select an option

  • Save Uriziel01/11f263d1b5b03d273e4031413920fe5d to your computer and use it in GitHub Desktop.

Select an option

Save Uriziel01/11f263d1b5b03d273e4031413920fe5d to your computer and use it in GitHub Desktop.
globals:
- id: valve_status
type: boolean
restore_value: true
initial_value: "true"
switch:
- platform: gpio
pin: GPIO27
id: open_relay
interlock: [close_relay]
interlock_wait_time: 200ms
restore_mode: ALWAYS_OFF
- platform: gpio
pin: GPIO14
id: close_relay
interlock: [open_relay]
interlock_wait_time: 200ms
restore_mode: ALWAYS_OFF
- platform: template
name: "Main water valve"
lambda: return id(valve_status);
restore_mode: DISABLED
turn_on_action:
- globals.set:
id: valve_status
value: 'true'
- switch.turn_off: close_relay
- switch.turn_on: open_relay
- delay: 60s
- switch.turn_off: open_relay
turn_off_action:
- globals.set:
id: valve_status
value: 'false'
- switch.turn_off: open_relay
- switch.turn_on: close_relay
- delay: 60s
- switch.turn_off: close_relay
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment