Handle offline state
openHASP can detect the state when the plate is disconnected from the network. With Group ID object property combined with batch processing, objects on the screen can act on locally connected devices without using the home automation system - letting you use only these devices when the network is down.
Prerequisites
In the use case presented below, the following assumptions are made:
- you have a plate with 2 local relays (configured on output GPIOs as lights), each relay added to a different group (Group 1 and 2 respectively).
- you want to have 2 toggle buttons on the screen acting directly on these relays when the plate is not yet, or disconnected from the WiFi network. No page navigation is needed as no other objects related to the home automation services have to be displayed. The buttons have the
groupid
property set to 1 and 2 respectively.
Configuration
In the plate's web UI keep the default /pages.jsonl
as Startup Layout. This will load immediately after plate boot, before the pate is connected to the network. If your network is not available after boot, this page configuration will be on screen while the plate keeps connecting in the background.
pages.jsonl
- loaded at boot, has only with objects related to local relays, and displays the hostname:
1 2 3 4 5 |
|
You can use batch processing and create scripts which run when the plate connects to the WiFi network or loses connection from it.
online.cmd
- batch script to run after connected to the WiFi network, it will clear the screen and load the pages with objects related to the home automation:
1 2 |
|
pages_online.jsonl
- to be loaded after connected to the WiFi network:
Put in pages_online.jsonl
the main configuration for the pages you'd like to use when the pate is connected to the network and the home automation system. See integrations examples corresponding to the home automation system you have.
offline.cmd
- batch script to run when connection is lost from the WiFi network, it will clear the screen and load the page only with objects related to local relays:
1 2 |
|
pages_offline.jsonl
- to be loaded after connection is lost to the WiFi network, has only with objects related to local relays:
1 2 3 4 |
|
Testing
- Reboot the plate. First only the buttons related to local relays are shown, these act the relays. After the plate connects to the network, screen is cleared and home automation-related pages are loaded.
- Kill the WiFi network. Plate detects the disconnection from the network, thus screen is cleared and only the buttons related to local relays are shown, relays can be turned on and off.
- Restore the WiFi network. Plate reconnects to the network, screen is cleared and home automation-related pages are loaded back again.