Use products on open protocols. Zigbee is the current standard. Anyhting using a zigbee radio, and to a lesser extent another protocol called zwave, can talk to any hub with a compatible radio. They are local, dedicated radio networks that do not have to talk to anyone else's servers.
There is a newer protocol called "matter" that a lot of big names have gotten behind. These devices are slowly rolling out, but id check for matter compatibility with any hub at this point.
As for the hubs, use open source that are not cloud based. The largest and most active project is called Home assistant. Its robust, has good options to build it yourself or buy devices, and it's dedicated to being forever FOSS. Another hub in the same "local, FOSS" ethos is called Hubitat. Their UI/hardware was easier than home assitant for a long time, but not really anymore. I still consider them more "turnkey" but both systems work great and support literally thousands of devices.