Automate relays and remember states on reboot

So I have 8 relays connected to my pi4 pins running HA.

I did manage to get both pi4 and HA to reboot without flickering the relays (set invert to true and select pi4 pins that boot with pull down mode). I did notice that with either reboot (HA or PI4) it wouldn’t remember the state the gpio switches were on at reboot time. I haven’t tested but seems the rest of my switches (non pin ones) do tend to go back to the state the were on at reboot. Haven’t tested it, but the rest of the switches as via esp8266s so I think they just keep their current state while the pi4 reboots.

I was first going to try and figure out how to reboot to last state, but I might not have to worry about that if I am able to set up my automation the way I would need them to work.

3 of the 8 relays I want to control depending on what time of the day it is. How would I accomplish this with automation. I know I can google for answer, but often older solutions come up first. I want to use as least amount as yaml code as possible. For example my tasmotas are set up to auto discovery vs me setting up via yaml.

At reboot (or at any time for that matter). I want HA to check the time, and if it is X time, turn switch on, and if it is after y time, turn switch off. Basically switch would turn on and off at specific times, and at reboot system would know to either turn switch on or off depending on the time.

1 of the 8 relays would be triggered by temperature and humidity values. I have 4 DHT11s, how could I set up an automation where if any of the 4 temps and/or 4 humidity get to x or y number for relay to turn on, and once under the thresholds to turn back off?

The last 4 of 8 relays are the most tricky ones. Basically I want these relays to run every other day for 15 minutes each, but not concurrently (watering switches). However ideally I would want a fail safe mechanism. Let say relay A goes on 1pm to 1:15pm, relay B from 2pm to 2:15pm, relay C from 3pm to 3:15pm etc. If I lost power from 12:50pm to 2:20pm, I would like the system to recognize the scheduled events didn’t happen and compensate for them. How would I do so?

If it requires using yaml code, or if the easiest solution is using yaml code I don’t mind using it, but do want to make use of as many of the tools HA provides so we don’t have to create manual yaml code. Also don’t expect folks to write down the code for me. If you could just point me out on the right direction I would truly appreciate it.

Manny

1 Like

I intend to do exactly same. Will share what I do.