What is a safe number of devices on a residential Wifi?

I’m just getting started building my home automation system. I had several smart wifi plugs for Alexa and have now just setup OH and added 8 Kasa smart switches. I just realized I have over 20 wifi devices and have become concerned about what my wifi can handle. The wifi is a linksys mesh. There are 2 smart TVs, 2 iPads, a Linux desktop and the RPi OH system demanding most wifi attention. Probably the biggest user is the tv when streaming video but that’s not too often. I will be adding more stuff to my system soon. Some wifi, some zigbee and some zwave. What I’m wondering is should I lean toward the zigbee and zwave if it is available for a given type of device in order to keep from overloading my wifi. I am planning on in the near future 3 zwave door locks, several zigbee motion detectors, 2 thermostats(probably wifi) and some more switches and plugs. What is a “safe” number of wifi devices to have? What is excessive?

This all depends on what your WiFi access points are - a first guess would be to check the marketing for those to see what they claim they can handle.

I have one Unifi AP to which everything connects, and it’s yet to break a sweat at ~30 clients including a couple of heavy video streamers. And I’m sure it’ll be fine with quite a few more devices.

(Though I do try as much as possible to hard wire heavy data streaming devices)

As hafniumzinc said, it heavily depends on your wifi AP as well as your channel selected.
A standard unifi AP is rated for ~40 devices, while more advanced (and also expensive) unifi APs can handle easily more than 200+ devices (i.e. this Linksys mesh one, no idea if it is yours, is rated for 25+)

On the channel side, make sure that you use a 2.4Ghz and 5Ghz channel that is not congested, i.e. in use by potential neighbors etc. You can switch those channels in your AP and use a simple app on your phone to see what channels are used by who.

Edit: also take note that smarthome devices like sensors not really use a lot of bandwidth, compared to say, a streaming TV.

A mesh system is always going to be constrained by the capacity of the wired node because everything has to go through that. The best way to maximise capacity in an installation with multiple access points is to have them all wired; that way congestion can’t be managed by hopping between APs.

That said, the capacity of any network is more about the sum of data throughput than the number of devices, each of which only has a small overhead.

There might be other constraints such as the size of the DHCP address pool. In commercial situations, that’s usually handled by keeping the lease time low to free up addresses quickly once a user departs but for a domestic situation, where the devices are usually the same ones and you probably want to maintain their IP, you can expand the pool.