If the devices is running esphome it is even possible to differentiate the communication channel based on the current situation
For example:
- API connected โ trigger action via HA
- WIFI connected (API not) โ trigger action via web hook
- No WIFI โ trigger action via direct device2device communication (for example esp-now)
I actually never bothered to integrate such a behavior into our esphome nodes because our setup with around 100 devices is rock solid anyway on wifi/lan since many years.