-
Notifications
You must be signed in to change notification settings - Fork 57
Open
Description
Just installed pyscript via HACS and added this script to the ~/pyscript folder using file editor :
@time_trigger("cron(*/15 * * * *)")
def water_heater():
level = float(state.get("sensor.hyper_1_electric_level") or 0)
if level > 98:
log.info(f"Water Heater ON (level: {level})")
task.executor(state.set, "light.water_heater_switch", "on")
elif level < 80:
log.info(f"Water Heater OFF (level: {level})")
task.executor(state.set, "light.water_heater_switch", "off")
else:
# Check if the current charging speed of the batteries is more than what the water heater would consume.
# We're only looking at one out of 2 batteries so take that into account
if float(state.get("sensor.hyper_1_output_pack_power") or 0) > 300/2:
log.info(f"Water Heater ON PV direct")
task.executor(state.set, "light.water_heater_switch", "on")
(Yes I know, need to introduce a correct margin to prevent it flip-flopping, just trying to make it work for now).
This is the error I'm getting :
Exception in <file.water_heater.water_heater> line 10: task.executor(state.set, "light.water_heater_switch", "off") ^ RuntimeError: no running event loop
Seems like something is completely wrong with the install, there's no event loop ?
Metadata
Metadata
Assignees
Labels
No labels