Skip to content

Instantly share code, notes, and snippets.

@kassah
Created June 27, 2023 21:30
Show Gist options
  • Save kassah/e91cb1a1c01eccd7f545db70f4c17fed to your computer and use it in GitHub Desktop.
Save kassah/e91cb1a1c01eccd7f545db70f4c17fed to your computer and use it in GitHub Desktop.
Pool pump time ran so far today
globals:
# Pump on today in minutes, this should range from 0-1440
- id: pump_on_today_minutes
type: int
restore_value: yes
initial_value: '0'
- id: pump_on_last_minute
type: boolean
restore_value: no
switch:
- platform: output
name: "Pool Pump"
id: 'pool_pump_out_int'
output: 'pool_pump_out'
output:
- platform: gpio
id: 'pool_pump_out'
pin: 5
interval:
- interval: 30s
then:
- if:
condition:
- switch.is_on: pool_pump_out_int
then:
- lambda: -|
if (id(pump_on_last_minute)) {
id(pump_on_today_minutes) += 1;
id(pump_on_last_minute) = false;
} else {
id(pump_on_last_minute) = true;
}
time:
- platform: sntp
on_time:
# Every night at midnight
- seconds: 59
minutes: 59
hours: 23
then:
- globals.set:
id: pump_on_today_minutes
value: "0"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment