Hi! I have a water pump that I want to run at night any time between 20 and 23. My device is ESP8266 based and it does not seem to be able to deep sleep longer than 2 hours so I want to be able to let it wake up, set time and then start watering if the current hour is > 20 (or else go back to deep sleep).
I tried the following on_boot script but it seems like it can never access the current time correctly and thus the pump condition will never be true.
How can I make sure the condition has access to a correctly set time object when evaluating the condition? I tried to make sure the api is connected first but it does not seem to help.
/Peter
esphome:
name: greenhouseesp
friendly_name: GreenhouseESP
on_boot:
priority: -100.0
then:
- wait_until:
condition:
api.connected:
timeout: 30s
- logger.log: "API connected"
- if:
condition:
and:
- time.has_time
- lambda: |-
return id(homeassistant_time).now().hour > 20;
then:
- logger.log: "It is night. Watering."
- switch.turn_on: ghpump1
- delay: 40s
- switch.turn_off: ghpump1
- deep_sleep.enter: deep_sleep_1
else:
- logger.log: "It is day. No watering."
on_shutdown:
then:
- logger.log: "In shutdown..."
- switch.turn_off: ghpump1
esp8266:
board: esp01_1m
time:
- platform: homeassistant
id: homeassistant_time
deep_sleep:
id: deep_sleep_1
run_duration: 50s
sleep_duration: 2h