> You also need to include fuses and other safety circuitry to ensure it doesn't exceed that threshold your microcontroller can accept.
I'd say you need to include other safety circuitry, as well as proper PCB design, to make sure it doesn't start a fire.
If you don't know what you're doing, don't rely on random stuff from AliExpress etc to be grid safe, and don't try to make stuff that connects to the grid yourself.
If you do not know what you're doing, for stuff like this I'd go with say Fibaro Z-Wave stuff or similar devices which have built-in power monitors, and can interface with Home Assistant or similar.
There are also cheap-ish USB devices that can do that [1] that you can stick in a raspberry pi and control with pretty much any language including python. For someone who shouldn’t be trusted with high voltage like me that’s the right level of tinkering.
Of course, that goes without saying, to be clear, I'm not advocating buying random off the shelf parts from AliBaba. I recommend doing proper research and getting certified safe parts for mains and I also agree not to play with the mains if you don't know what you're doing, it is far from a hobbyist thing and the only reason I did this is because I have a background in electrical and electronics.
Having said that, you can always buy "modules" from Siemens, Honeywell, etc. Get your circuits audited by someone with more experience, in particular by an experienced electrical engineer before using it live.
Have multiple levels of fail-safe, fuses, fire retardant casings, what not. Just think of every possible worse-case scenario before you do it.
After all, electricity is no joke and can literally kill you.
watermelon0 has the correct answer: [most] hobbyists should stick 100% to low-voltage low-current applications and use off the shelf certified hardware whene interfacing with high-voltage (i.e. mains) power.
If you have a device drawing high current, you would probably use a contactor (high-power relay), and then you can use low current (or even low voltage) relay/triac to drive the contactor from your circuit.
High power relays with safety certifications are typically used in mains boxes available commercially. In fact, I'm using the ones from my old mains box.
Even theoretically, the only way a relay could catch fire if the coil inside overheats or if you pass very high voltages to the coil. But, with a well designed circuit, it should be fine.
I'd say you need to include other safety circuitry, as well as proper PCB design, to make sure it doesn't start a fire.
If you don't know what you're doing, don't rely on random stuff from AliExpress etc to be grid safe, and don't try to make stuff that connects to the grid yourself.
If you do not know what you're doing, for stuff like this I'd go with say Fibaro Z-Wave stuff or similar devices which have built-in power monitors, and can interface with Home Assistant or similar.