Your RPI process should keep the link up, and given this, then the main reason for a disconnect would this WiFi issue -- which as you say is very sporadic. Rebooting (say once or twice a day) is the best remedy here, IMO, as this is most likely to renegotiate the entire stack including WiFi properly.
As a general point very much +1 on your approach of keeping the IoT devices and their stacks local and simple. I am adopting the same approach. In my case the only external internet connection to my RPi is an SSL link from an application running on my public ellisons.org.uk. So my Android tablet on roam-about talks to an ellisons.org.uk URI which presents a publicly accessible portal with the necessary authentication, etc. This then talks to my RPi and my devices only talk to the RPi.
The idea of IoT devices talking directly over the Internet using HTTP / HTML horrifies me. In practice, any attacker would have to compromise my portal application, and then go via it then to compromise my HA system on the the RPi to get at my devices.
gschmott wrote:I think there is another useful RAM saving technique/approach/library mentioned here as well:
Massive memory optimization: flash functions
In terms of general memory saving techniques, the advice we give is the same, and our approach is pretty similar; it's just that we developed our implementations in parallel.