I have a working ESP8266 board ESPHome and IR emitter + PIR.
I have the IR emitter sending a OFF code to my air conditioner every 2 hours, except between 10PM and 8AM.
What I can’t figure out, is how do I temporarily prevent the above automation from running for X hours IF there’s movement input from the PIR sensor (so the air conditioner is not turned of if there are people in the room)?
So you want the AC to turn off if there’s no movement in the room for 2 hours?
If so, and your automation is in ha use the motion sensor as a trigger but set a for: time of two hours.
Or if you are doing it all in esphome, use delayed_off set to 2 hours on the motion sensor and then fire your ac command.
I was just reading about ESPHome internal automation, that would be much better so the esp8266 boards don’t rely on home assistant server being online for the automation to work.
Automations in ESPhome are pretty easy, only slightly different from yaml in HA.
Here is an example of one of mine. It does a motion controlled light with restart such that any new motion retriggers it without the light first turning off.
If I understood, to integrate the script with the time parameter (to evaluate if the active period of the motion sensor, which would be only at daylight), I would have to use time in lambda, which involves C++ right? What would be the correct syntax for me to only run the script if I’m between 10AM and 22PM, for example?
Kinda… or you could make it more dynamic by using a Home Assistant time element to provide the time data. ESPhome has access to HA entities so you could use two input_datetime’s as the condition parameters and use those in the ESP automation. This would however require HA to be online. Another way to do this but without needing HA to be online is to publish those times to MQTT and have the ESP subscribe to the topic, then set the topic as ‘retained’.
Can’t test it right now since I fried my esp8266 yesterday by mistake, must wait till Tuesday now lol
Anyway, I think espeasy is more indicated for what I’m trying to do (I also need to learn the remote code directly into the firmware through a push button or something like that) and I don’t think esphome can do it.
Thank you very much for your help, it was precious.