It can be done safely, but I just prefer to stay away from 240V as much as possible!
In 2011 I made an Arduino-controlled "smart thermostat" system for home, controlling a 2400W oil column heater (and later a separate fan, used when the heater was needed on hi average power).
I used the predecessor product of these:
https://www.jaycar.com.au/wireless-3-outlet-mains-controller/p/MS6142At first I hacked into the supplied remote and attached wires from the Arduino across the manual push buttons. Later I reverse-engineered the connections those buttons made and used the datasheet for the chip inside to work out what codes were sent. Then I programmed a $2 chinese 433 MHz module to send the same codes.
The only problem with these is the control is open loop. You don't know if it really did it. I found that on average about one command in 1000 was lost to interference or whatever.
My code made a decision to possibly turn the heater on or off once every 30 seconds. The thermal mass of the heater averaged this out very nicely. Even if no change was needed I sent the previous command again anyway.
Well, the other problem is the devices aren't intended to be switched that frequently. I found they lasted about two winters (mid April to mid November) before becoming unreliable. Probably something on the order of half a million switching operations. Certainly well over 100k.