I've been doing a bunch of home automation work recently. Here are some observations I've made:
1. Most extant home automation software is totally unreliable garbage. Buggy, slow, poorly designed. You want to reduce the amount of code you pull in as much as possible.
2. Raspberry pis are totally unreliable garbage. The hardware is just bad. There's no way to make them reliably operate for long periods of time without crashing, and there's no way to make them automatically recover from a crash (because the watchdog timer, or its driver, in the crappy broadcom chips they use is broken).
3. Most of this home automation software is optimized for users who don't know how to code at all, and is extremely poorly optimized for people who can write basic scripts or whatever.
4. Most of the radio protocols for wireless IoT devices are totally unreliable garbage.
After messing around with this on and off for a few years, the best setup I've found is:
1. Use a normal computer or server, not a raspberry pi. It doesn't need to be expensive or anything; just use a decent machine with an x86 processor. There are tons of great industrial PCs for cheap on ebay.
2. Use some kind of containerization setup for separating components. I strongly recommend using jails on FreeBSD, since you can treat jails as physically separate machines for networking/firewalling purposes (using vnets).
3. Make liberal use of VLANs to isolate IoT things from the internet and from each other.
4. Don't use any IoT devices that operate over WiFi. Ethernet is great, and dedicated wireless protocols (zigbee, z-wave, etc.) can be OK with a bunch of work.
5. If you want non-trivial automations, don't try to use some existing "user-friendly" or "low-code" or whatever home automation software. Just write a normal computer program that does the automations.
The specific stack I have for most of my automations in my current house is zigbee2mqtt running in one jail (this is by far the most problematic component), mosquitto running in another, and then my program which does the automations running in a third. My program can also do things like send me push messages via pushover.
I've managed to get a seemingly stable zigbee network with a not-totally-trivial number of devices (around 25 now) by using CC2652 radios and plenty of zigbee routers, and also turning off all lightbulbs before adding more devices to the network.
It's a shit show, and I can't really recommend getting into it right now unless you want to spend a bunch of time doing sysadmin tasks, or you only want very simple automations (in which case maybe use HomeKit or something).