Good Day.
I want to add smart relays to my electrical panel to turn groups of smart devices on and off. I want to create scenarios in Home Assistant to turn these groups on and off when power is applied. How can I deactivate these devices in Home Assistant before disconnecting them from power, and reactivate them after they are turned on?
Thank you.
Please clarify your question…
You’ve identified a big portion of your needs, in very general terms. You need a little more detail for us to offer any guidelines. You just need to read the vendor documentation, understand the concepts, and then weave them into your custom solution. Yes, share your code (suitably </> formatted for readability in the forum) and we can offer suggestions as you go along. We won’t write the code for you, but there are many examples on these forums and GitHub that can be used for ideas. Your search skills may be challenged and honed. You shouldn’t expect us to do that for you.
Controlling power using switched relays is a fundamental part of automation. There are many examples, especially with ESPHome (which is fully integrated into HomeAssistant) where you may wish to start with one if their simple cookbook projects. Start small and go from there - learn to switch a bedside lamp on and off for example. Check in here as you progress, as others experience may pick up issues such as safety oversights or code errors.
A caution: Consulting ChatGPT and other AI bots, reddit or YouBoob, can lead you down the garden path as often their information is outdated, based on problems teported here rather than their solutions, the fast pace of changes in HomeAssistant and home automation outstripping their abilities to learn and regurgitate accurate information. Stick with the vendor documentation for accurate information.