Last active
November 8, 2023 16:21
-
-
Save JeanOlivier/d69da57ec87129a8b10046ff558cd30c to your computer and use it in GitHub Desktop.
Home Assistant pyscript faikin Daikin Scheduler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Defining some lists for convenience | |
weekdays = [ | |
"monday", | |
"tuesday", | |
"wednesday", | |
"thursday", | |
"friday", | |
] | |
weekend = ["saturday", "sunday"] | |
all_days = weekdays + weekend | |
# Building on and off times... | |
# -------- | |
# Weekdays | |
# -------- | |
## Mornings | |
on_times = [f"once({d} 5:30)" for d in weekdays] | |
off_times = [f"once({d} 8:00)" for d in weekdays] | |
## Evenings | |
on_times += [f"once({d} 16:00)" for d in weekdays] | |
off_times += [f"once({d} 21:00)" for d in weekdays] | |
# -------- | |
# Weekends | |
# -------- | |
on_times += [f"once({d} 5:30)" for d in weekend] | |
off_times += [f"once({d} 21:00)" for d in weekend] | |
################### | |
## Logic follows ## | |
################### | |
# Convenience functions | |
def daikin_state(name, state): | |
log.info(f"Turning {state.upper()} {name}") | |
if state.lower()=="on": | |
climate.turn_on(entity_id=f"climate.{name}") | |
else: | |
climate.turn_off(entity_id=f"climate.{name}") | |
# Actually doing something | |
@time_trigger(*on_times, kwargs={"state": "on"}) | |
@time_trigger(*off_times, kwargs={"state": "off"}) | |
def control_daikin(state): | |
daikin_state("daikin", state) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment