Good day,
I’m having trouble converting the timing on my relays to have different timing for night and day.
Originally i have been using this code which is crude i know but it worked for what was needed.
- platform: gpio
pin: D7
name: "Greenhouse Pump"
id: "greenhousepump"
inverted: yes
icon: "mdi:water-pump"
- platform: gpio
pin: D8
name: "Dutch Bucket Solenoid Left"
id: "dbsolenoidl"
restore_mode: ALWAYS_ON
inverted: yes
interlock: ["towersolenoid", "dbsolenoidr"]
icon: "mdi:valve"
on_turn_on:
- delay: 10min
- switch.turn_on: "towersolenoid"
- delay: 30min
- switch.turn_on: "dbsolenoidr"
- delay: 10min
- switch.turn_on: "towersolenoid"
- delay: 30min
- switch.turn_on: "dbsolenoidl"
- platform: gpio
pin: D1
name: "Dutch Bucket Solenoid Right"
id: "dbsolenoidr"
inverted: yes
interlock: ["towersolenoid", "dbsolenoidl"]
icon: "mdi:valve"
- platform: gpio
pin: D5
name: "Tower Solenoid"
id: "towersolenoid"
inverted: yes
interlock: ["dbsolenoidl", "dbsolenoidr"]
icon: "mdi:valve"
This would keep the greenhouse pump running 24/7 and would alternate the open relays for the solenoids.
When changing the code to use sunset/sunrise like below. I can get the script to fire when sunset/sunrise is triggered, but it only runs through the script once, where i would like the relays to keep looping until state in the sun has changed.
- platform: gpio
pin: D7
name: "Greenhouse Pump"
id: "greenhousepump"
inverted: yes
icon: "mdi:water-pump"
- platform: gpio
pin: D8
name: "Dutch Bucket Solenoid Left"
id: "dbsolenoidl"
inverted: yes
interlock: ["towersolenoid", "dbsolenoidr"]
icon: "mdi:valve"
- platform: gpio
pin: D1
name: "Dutch Bucket Solenoid Right"
id: "dbsolenoidr"
inverted: yes
interlock: ["towersolenoid", "dbsolenoidl"]
icon: "mdi:valve"
- platform: gpio
pin: D5
name: "Tower Solenoid"
id: "towersolenoid"
inverted: yes
interlock: ["dbsolenoidl", "dbsolenoidr"]
icon: "mdi:valve"
script:
- id: day_time
then:
- switch.turn_on: "greenhousepump"
- switch.turn_on: "towersolenoid"
- delay: 30min
- switch.turn_on: "dbsolenoidr"
- delay: 10min
- switch.turn_on: "towersolenoid"
- delay: 30min
- switch.turn_on: "dbsolenoidl"
- id: night_time
then:
- switch.turn_off: "greenhousepump"
- delay: 60min
- switch.turn_on: "towersolenoid"
- switch.turn_on: "greenhousepump"
- delay: 10min
sun:
latitude: xx.xx
longitude: xx.xx
on_sunrise:
- then:
- script.stop: night_time
- script.execute: day_time
on_sunset:
- then:
- script.stop: day_time
- script.execute: night_time
My Coding expertise are not great at all and would be really helpful if someone could explain to me how to keep them looping. I presume i would need to make it a while condition for sun status above or below the horizon. but i cant get it right and breaks the code. any help or feedback would be a huge help.