Recently I installed a Raspberry Pi with Raspbian, and attached a touchscreen to it. The device is supposed to work as a display for our openHAB home automation system. All nice and shiny, except the Pi occasionally disconnects from the Wi-Fi - apparently in order to safe power. Once the network device is needed, the Wi-Fi is reconnected. That is the default setting.
That is quite annoying, because the HABpanel will lose it’s connection to the openHAB server, and no longer show widget updates. Some widgets like “time” will just continue to work, but other widgets like status of the washing machine, or the current outside temperature just show the last state, and never update.
The power saving is a function of the WLAN device, therefore the
wlan0 must be updated:
This works until the next reboot. And since I have all my devices setup using Ansible, I added two steps to the setup. First a small file:
Let’s say the name is
wlan0-power. I place it in my Playbook directory, under
files/, among with some other files for that Pi.
The next step is telling Ansible to deploy that file:
if-up.d directory holds scripts which will be executed when a (any) device comes up. Could check for the coccrect device name first, but I don’t bother much. This script will only execute once the device comes up. If the device is already up, nothing happens. Either run the script manually once, or reboot the Pi. Since it’s part of my initial deployment, there will be a reboot later in that Playbook - so I don’t have to reboot just for this file.