1.0  Brief Description Last updated: 2020-03-16

WiFiSecureAccess garage door opener is a smart controller that can be integrated with an existing garage door controller to provide smartphone based access. With this integration, one can also use Google Home, Google Nest or alexa to operate the garage. The garage can be operated from anywhere remote. One can also know the current status of the garage (whether open or closed) from remote. Notifications can be configured to send notifications if the garage door remains open for a long time. One can configure AutoClose such that the garage gets automatically closed after a pre-configured delay. Multiple users can be authorized to open/close the garage. The owner of the garage can revoke this authorization any time. It is also possible to configure the door such that the authorization gets automatically revoked after a date/time. In addition, one can configure open and close times such that only between these times the authrorized persons can access the garage door. It is also possible to set authrorizations such that some people are allowed to use only during some specific time period on pre-configured days of the week. This documentation describes how the smart controller can be installed on an existing garage door and how the smart device can be configured to meet all the needs.

Fig 1: pre-wired and pre-configured garage door controller.

This smart device can be purchased either from eBay or from Amazon. It will be available through other sources in the future. Search for WifisecureAccess in eBay or Amazon.


Buy Now

2  Installation

In this section, we will describe how the smart controller can be wired and integrated to your existing garage door controller.

2.1  Integrating Smart controller to your existing garage door

Step 1

In order to integrate the smart controller to your garage door, you need to locate the two terminals of a manual push button on your existing garage door controller. There are plenty of manufactures of the garage door and, therefore, the controller of the garage door can come in various designs. However, all garage doors will have a manual switch (push button) to open/close. This switch may either be located on the PCB of the garage door controller, or it may be mounted on the wall or elsewhere in the garage. On some garage door controllers, you may find two terminals on a terminal block on the main controller marked as 'Push Button'. Here are some example pictures:

Fig 2: An example of a terminal block on the back of a garage door controller




Fig 2A: Another view of an example of a terminal block on the back of a garage door controller


Here is another garage door controller from another manufacturer:
Fig 2B: Another view of an example of a terminal block on the back of a garage door controller

Or, in some cases, you may find a push button on the wall.
Fig 2C: Another view of an example of a terminal block on the back of a garage door controller

You can cable the smart controller to either the push button terminals on the main controller, or to the two terminals inside the push button on the wall. Test manually before cabling the smart controller to the push button terminals to confirm that this is compatible. To test it manually, short between the two terminals using a bare wire. You should be seeing the garage door either opens or closes. If so, this is compatible to the WiFiSecureAccess smart controller

If the garage door is compatible, cable the WifiSecureAccess smart controller to the push button terminals of the garage door. Refer to Fig 1 to see which wire from the smart controller is to be cabled to the push button terminals. Mount the controller anywhere convenient, preferably close to the pushbutton terminals (either on the wall, or near the terminal blocks on the garage controller). Note: The controller unit has a double-sided mounting tape at its back. So, you can mount it anywhere convenient, and no screw is required.
Fig 2D: Cable Smart device to the push button terminals of the existing garage door controller


Step 2

Next, install the magnetic sensor. This is optional. If you install this sensor, you can know from remote whether or not the garage is currently open or closed. This will also help sending alarm notifications. The pre-wired WiFiSecureAccess smart controller comes with this sensor. It has a 4.5 meter cable. Try not to extend this cable to avoid noise. If you do not need 4.5M length, you may cut that cable short. The shorter the cable, the better to avoide noise in reading sensor. Install as per your convenience such that the two parts (A and B) of the sensor align themselves (within 3mm space between them) when the garage is closed. Fix the part (Part B) with the cable on the fixed frame and the other one (part A) on the moving frame of the garage. The following are some pictures that will help you install this. Note: Both the parts of the magnetic sensor have double-sided mounting tape at their back. So, you can mount it anywhere convenient, and no screw is required.

Fig 2E: Magnetic switch on the garage door


Fig 2F: Two parts of a magnetic switch


Fig 2G: Installing magnetic switch

PS: In order for it to use the sensor to detect the current position of the garage door, not only that you have to install the sensor, but also you have to enable either one of the notifications (either buzzer or emai as per section 2.14 of this documentation).

Note:The garage door can be operated even without the sensor. As mentioned earlier, the sensor helps in knowing the current position of the garage door (whether open or closed) from remote accurately. You can also enable sending notifications if the garage remains open for a long time. Sending notifications are possible only if the sensor is installed. If you do not want the sensor installed, you may remove the sensor and the cable from the WiFiSecureAccess smart controller. You can either cut off that cable, or you may open the smart controller and remove the cabling. The following pictures show the inside cabling of the WiFiSecureaccess smart controller.
Fig 2H: Inside view of the Garage Door Controller

Fig 2I: Inside view of the Garage Door Controller

Note: If you want to use 12VDC power instead of the 110/240VAC power, you can remove the AC power cord and connect 12VDC to the 12VDC connector shown in the above picture. If you do so, place the jumper between DC and the middle pin.

Once all the installation and cabling are completed, power on the device by plugging its power cord to a 110/240VAC socket.

2.2  Setting up the App on your Smart Phone

If you have not downloaded the wifisecureaccess app yet, please download it to your smartphone now. Search for wifisecureaccess in either Apple Store or Google Play store.

App Store Icon Google Play Icon

Once downloaded, open the app and press Admin Dashboard. It will prompt you to enter your username and password to login. If you have not registered yet with https://wifisecureaccess.com, press 'Create NEW Account' button on this page and register.
Fig 3: App's opening page

Fig 3A: Login Page

Fig 3B: Register (Create a new account)

Follow the prompts and instructions. It needs your email address and telephone number as well as a password. Telephone number is optional. Password must have at least 8 characters (maximum 20 characters) and it must contain at least one lower case letter, one upper case letter, one numeric. The system will prompt you for your email verification. The system uses email address as your username. It also uses it to send notifications of events in the device, if you have configured the device to send you notifications.

The other two fields "Enable Two Factor Auth' and 'Timezone' will be defaulted to 'No' and 'US/Pacific' respectively. You can enable Two Factor Authentication by selecting 'Yes' for this field, if you want to. When selected 'Yes', a confirmation code will be sent to your email whenever you try to login. This is an additional layer of security for your account. The timezone is your timezone. Select it from the pull-down menu. The default is US/Pacific. Setting this to your timezone will help the system display the times of all your activity in your local time. All these parameters can be changed any time later by clicking 'My Profile' under 'User Admin" in the Dashboard.

If you are using a smart phone to register, you will see a page similar to Fig 3C. Or, any time in the future, if you open the app and click on the Admin Dashboard, the same display will be shown. You will notice that all the admin menu is collapsed. To see the admin menu, click on the three lines at the top right corner of this page as shown in Fig 3C and 3D.
Fig 3C: Dashboard Menu on Smartphone (collapsed)


Fig 3D: Dashboard Menu on Smast Phone

2.3  Initial Connection to WiFi

If this is a brand new device, its WiFi has been factory reset to the following:

So, when the device is powered ON, it is trying to join this WiFi. Therefore, in order to initially connect to WiFi, you need to setup a mobile hotspot on your smart phone temporarily to this SSID and password so that the device gets connected to internet which will enable you to change its WiFi. Note: (The device is not capable of 5G and so, WiFi must be 2.4G.)

If you are using iPhone, change its Personal hotspot WiFi settings to match the above and put Personal hotspot ON. To change your iphone's SSID, you need to change the name of your phone to MyPhone. This can be done in settings → General → About → Name. To change password, Settings → Personal Hotspot → Wi_Fi Password. Once changed, click on Allow Others to Join so that your Personal Hotspot is ON with this SSID and password.

If you are using an android phone, go to settings → Tethering and Mobile hotspot. Then click Mobile hotspot. Then click on the three dots at the top right and click 'Configure hotspot'. Then change the ssid and password of your mobile hotsopt to 'MyPhone' and '12345678'. Note: If your smartphone is capable of 5G hotspot as well as 2.4G, make sure that 2.4G is selected as the device is not capable of 5G. Also, check the Timeout settings of the hotspot. Set it such that it does not timeout too soon while you are using Hotspot. You can set it to Never time-out. After setting it, switch on your mobile hotspot (in the previous menu).


Once the personal Hotspot is ON, put on the device, if it is not already ON. You will notice that the device will join that WiFi and connect to internet. You will see in a few seconds that the LED changes colour to RED, and staying RED. If that is not happening, make sure that your personal Hotspot is configured correctly and that it is ON. You may repeat factory reset of the device as per section 2.6 of this documentation, if the device is not connecting to wifi. You may keep in mind that the factory reset button must be held pressed until the Blue LED starts flashing after resetting.

If the device is still not joining WiFi, ask for help by contacting contact@wifisecureaccess.com.

2.4  Taking Ownership of the Device


There are two ways in which you can take the ownership of a new device that you just bought. One method is by scanning the QRCode of the device using your smartphone, and the other method is by using a browser on a computer. Before you proceed, make sure that you have turned on the device and it has joined the WiFi of the Hotspot of your smart phone, as explained in the previous section of this documentation.

In the first method. open wifisecureaccess app on your smartphone and go to Scanning page and press Scan QRCode button. The camera will come ON. Scan the QR code of the device. The QRCode is on the label pasted on the box. Then follow the prompt. You will be prompted to confirm the buzzer sound as well as the color of the LED a few times to make sure that you have this device in front of you, having connected to internet. If everything is correct, it will assign the ownership of this newly bought device to yourself.

For the second method, open https://wifisecureaccess.com and click on Dashboard. If you are already logged in, you can see a tab "Take Device Ownership" in the sidebar menu. If this is your first device, you will see that on the main page as well. Click on that, and follow the prompt. After getting the confirmation that the device is turned on and connected to internet through its WiFi, you will be prompted to enter the QRCode of the device. Follow the rest of the prompts. If you respond to all the prompts correctly, the ownership of the device will be assigned to you and a popup window will appear confirming it.

Fig 6: Intial page view.

Once you have taken ownership of the device, your main dashboard page may look like the one shown in Fig 6A. And, if you expand the dashboard menu, you may see several otions as shown in Fig 6B.

Fig 6A: Dashboard view when you own a device

Fig 6B:Dashboard expanded menu when you own a device

Once the ownership is transferred, click on Home/industrial Automation Dashboard menu. Then click on My Devices in Automation. You will see your device listed there. If you have more than one device, all of them will be listed there. Once the device is assigned to you, nobody other than you will be able to configure it. In the later sections of this documentation, you will learn how to allow others to use this device. You will also learn how to configure this for your specific needs and how to use it.

2.5  Setting WiFi of the Device

In the dashboard menu, click on 'Devices Admin' to expand that menu. Then click on 'Set WiFi'. It will take you to a page where it will prompt you to enter the SSID and password of your WiFi. Make sure that the WiFi is 2.4G and not 5G. The device is not capable of 5G WiFi. Once entered, click Submit. If successful, you will see the device restarting, the led blinks blue and then changes to steady Red. The device is now set to go and ready for use.

If you accidentally entered wrong ssid or password, or if the device is not getting connected to WiFi after setting the ssid and password, you may have to do a factory reset as per the steps given below in section 2.6 of this documentation.

Fig 8: Setting WiFi of the Device.

The device will remember the WiFi that you set and will join that WiFi hereafter whenever power cycled or reset. At this time, you can switch off the mobile hotspot on your mobile phone. You can change your smart phone's name and WiFi password to whatever they were initially. After switching off the hotspot on your mobile phone, try resetting the device by pressing the reset button on the device. If everything is set correctly, the device will restart and join the WiFi. You will see LED blinking Blue while trying to join WiFi and then turning to red when joined WiFi and connected to internet and the cloud server.

If this is not happening, there is something wrong either with the ssid and password that you entered, or with your internet connection through WiFi. Make sure that the ssid and password that you se are that of a 2.4G wifi and not 5G. Make sure that your router has internet connection. If anything has gone wrong, do a factory reset of WiFi as per the steps in section 2.6 of this documentation, and then try to set WiFi again.

2.6  Doing a Factory Reset of WiFi

If need arises any time when the device is not connecting to the WiFi because of some issues with the WiFi of your router, you can do a factory reset of the WiFi of the device. Factory reset will change the WiFi of the device to ssid = MyPhone and password = 12345678. To do a factory reset, press and hold SW2 (Factory Reset button). While holding it, press and release SW1 (Reset button). Keep holding Factory Reset button until the device restarts and LED changes to flashing blue. At this moment, the ssid and password of the device has been reset to 'MyPhone' and '12345678' respectively. In other words, the device is now listening to join a wifi with ssid = MyPhone and password = 12345678. Now, follow the steps given in section 2.3 to connect to the device. Once connected, follow the steps in section 2.5 to set its new WiFi. (Refer to Fig 2I to locate the Reset and factory reset buttons).

2.7  Initial Minimum Configuration of the Device

Once the above configurations and installations are completed, the garage door is ready to be used using smartphone already without doing anything more. You can now operate it either using the WiFiSecureAccess App on the smartphone, or by GoogleHome or Alexa. The garage door can now be discovered by GoogleHome as well as Alexa. Currently, the device is autoconfigured for garage with default settings. Those default settings are normally enough for normal usage of the garage door. But, before you start using it, it is recommended to go through the various features that are described in the following sections of this document.

To start with, click on Access Control admin in the dashboard menu. Then click on My Devices in Access Control. You will see this device listed there. If this is your first garage controller, the name may be 'Garage'. If you have more than one device, all will be listed here.
Note: The pictures shown in this document are snapshots taken when using a computer. If you are doing this on a smatyphone, your view will be similar to Fix 6A and 6B. Fig 6B shows how to see all the dashboard menu.

Fig 9: Devices List.

Click on any device. It will show the details of that device. You will see its two output ports (GARAGE and BUZZER). It will show whether the output ports are currently ON or OFF. If it is ON, you will see a green circle with a check mark. If it is OFF, you will see an orange circle with a cross mark.

Fig 10: Device Details.

Now, click on Sensor Value on this page. You will see three sensors listed here: D7. The garage door controller has only one sensort input cabled to D7 of the microcontroller. You will also see the current values sensed by this input. D7 is an ON/OFF type input. If you bring the two parts of the magnetic sensor close to each other, and if you refresh this page, you will see that this displays as ON.

Fig 11: Device Details.

Now, click on Device information. It will display all the details of this device such as its mac address, QRCode, NFC TagID, name of the device, firmware version, device owner and so on. On the firmware build as well as firmware version tabs, it will show you the current version and the latest version available. If the firmware is not up to date, you will see an orange button to click on to update its firmware.

Checking and Updating Device Firmware

We Strongly recommend updating the firmware to the latest by clicking the link on this page, if it shows new firmware is available


Fig 12: Device Details.

There are several parameters of the device that are displayed in the Device Information (Fig 12). These are all for information. You mau have a close look at all of them. Number of reconnects in this is the number of times the device lost connection to the server since the last reboot. If you see a higher number here, that indicates a weak wifi, or some frequent issues in connecting to internet.

You can change the name of the device as well as the labels of each port, if you prefer. To change the name of the device, click on 'Configure Device' under Device Admin on the left side bar menu. It will present a form similar to Fig 13. You can Change the name of the device to anything you like.

There are several other configurable fields on this page that may be left as defaults now. Check the Timezone on this field. By default, it is set to the timezone of the owner of the device. If this is not correct, you may change it to the timezone where this device is installed. This helps in displaying all information in that timezone. Click here to know the format of different time zones. If this field is left empty, it will change it automatically either to the timezone of the owner of the device or UTC.

Fig 13: Configure Device.

The names of the ports are also changeable by clicking on 'Configure Ports' under 'Device Admin' in the Dashboard menu. Fig 14 is the form that will show up when clicking 'Configure Ports". What you see here are the default values. Keep them as they are. If you change the Relay1_label to anything else without the word garage, it will add that 'garage' into that name. The fields Allow in GoogleHome and allow in Alexa are by default 'Yes'. That makes this garage door discoverable in GoogleHome and alexa. If you do not want this garage to be discovered in GoogleHome or alexa, you may set these to 'No'. The field 'Relay Secure port' is a field for additional 2-factor authentication. If you set this to 'Yes', it will prompt for a pin whenever you try to open or close this garage. Your pin for this can be seen under My Profile. you can change the pin to anything you like. Note: We recommend not changing these labels now.
Fig 14: Device Labels.

2.8  Activating garage door using WiFisecureAccess app on the smart Phone

Once the device is installed and ports are configured, you can activate the ports in one of several ways: 1) Using the wifisecureaccess app on the smartphone, 2) by scanning the QRCode or NFC tag of the device, 3) Using Google Home assistant on your smart phone, 4) Using Amazon Alexa, or 5) Making an HTTPS POST call from any of your other applications or programs. In the following sections of this document, you will learn how to use all these different methods.

To activate garage door using the wifisecureaccess app, download the app on to your smart phone. Search for WiFiSecureAccess app in Google Play store or Apple Store. Once downloaded, open the app and press "activate a Device" button in the home screen. That will display all the devices owned by you (similar to Fig 9). Press the icon corresponding to the device you want to activate. It will activate that immediately. Any click on these buttons toggles the state of that port. If it is currently ON, pressing the button will put that port OFF. And, if it is currently OFF, pressing the button will put that port ON.
Fig 14_0: Open/Close Garage door


Note: As mentioned earlier in this documentation, everything that can be done by the wifisecureaccess app on a smartphone can also be done using a browser on a computer, except scanning QRCodes and NFC tags. So, you can activate a port from a browser by opening the https://wifisecureaccess.com and pressing Dashboard. On that page, you will see a link "Activate a Device". When you click that link, it will take you to the same page that you saw on the smartphone listing all your devices. So, by pressing the name of the device, you can activate the device from a browser.

2.9  Activating garage door by scanning either QRCode or NFC tag of the Device

As you know by now, by default, each device has been assigned a unique QRCode, and is pasted on the box of the device. You can also view and print its QRCode at any time by pressing Device Admin → Show QRCode Label in the dashboard menu. You can also change the QRCode of any of your devices in the 'Configure Device' menu (Fig 13). You can also delete the QRCode, if you do not want to use QRCode.

To activate garage door using QRCode, you can scan this device using wifisecureaccess app. Open the app, go to the scanning page and press Scan QRCode. The camera will become active, and now scan this QRCode. That will take you to the same page similar to Fig 9. There, press the name of the device to activate that device/port. If you are using this device for access control, scanning the QRCode or NFC tag will activate that device (More about access control will be seen on section 6 of this documentation).

It is also possible to assign a unique NFC tag to a device.

If you find a need to use NFC tags instead of QR codes, you can do so by purchasing NFC tags and associating it with the device. We support only Mifare Ultralight 14443-3A type of tags which has 7 bytes of UID. These are very inexpensive tags that you can buy from anywhere. These tags come as stickers as well. Given below is an example link to buy from Amazon. This is just an example. If this link is not available, or if you would like to use a different type, search for a similar item in ebay or Amazon. These NFC tags are available in different type of shapes and packaging. You can use the type you like so long as it is Mifare Ultralite with 7 bytes of UID.

Buy Now

To associate an NFC Tag with your smart device, open the app, go to the scanning page and press 'Scan NFC Tag' and scan the tag that you purchased. If this is a new tag and if it is not associated with any other device within our system, you will be taken to a page prompting you to select one of your devices to associate this tag to. The pulldown list will contain all the devices you own (all those devices that are powered on). iIf you have only one device with garage door, you will see only that in the pulldown menu. The Exit Tag option on this page may be left aas 'N'. Once you select a device and press submit, it will associate this tag with that device. On the other hand, if you are scanning any tag that is not compatible, or is being used by some other device, you will receive an error message. Once associated with your garage door, and if you scan it again, it will activate your garage door just like the same way you scan a qrcode.

You can fix the NFC Tag and/or the QRCode label at any convenient place to access this device.



2.10  Using Google Home assistant to activate a port of your device

WiFisecureAccess devices are compatible with GoogleHome, and, therefore, you can use Google Home assistant to operate the equipments connected to these devices. By default, the device is enabled to be discovered by GoogleHome. To check or to change, click on 'Configure Ports' under Device Admin in the dashboard. You will see a page similar to Fig 14A.
Fig 14A: Enabling Google Home assistant

On this page, make sure that 'Allow RELAY in GoogleHome' is set to 'Yes', if you want the garage to be activated using Google Home assistant. If you do not want to use Google Assistant to activate garage door, set them to 'No' and press Submit button.

If this is enabled to be discovered by Google Assistant, you can discover these ports in Google Assistant. Press + button in Google Home to add devices. Then press 'Set up device'. Then press 'Have Something already set up". On that page in Google Home, search for WiFiSecureAccess and select it. That will discover all the allowed ports of all your allowed devices.

Fig 14B: Google Home Page

You can now rename these whatever you would like to. Hereafter, you can say 'Hey Google, turn ON *name of the port*'. That will switch on that port. If the device is in access control mode, you can say 'Hey Google, Open *name of that device*'. That will open that door or gate. Note that you can change the name of these ports in the "Device Configuration" menu (Fig 13) in WiFiSecureAccess dashboard, and/or within the Google Home. The name in Google Home need not necessarily be the same as that in the configuration within the dashboard of wifisecureaccess.com.

2.11  Using Amazon alexa to activate a port of your device

The ports of the smart device can also be activated using Amazon Alexa. You may download and install Amazon Alexa on your smart Phone. In Alexa, press 'more' and then click on 'skills and games'. Now search for wifisecureaccess, then enable that skill. When enabling the skill, it will take you to Wifisecureaccess.com and will prompt you to enter your email and password. this is your password for wifisecureaccess.com. If the entered credentials are correct, you may press Discover Devices. That will discover all the wifisecureaccess devices that you own.

As said earlier, garage is allowed to be discovered by Alexa by default. However, if you do not want this to be discovered by alexa, you may change the configuration. To check and change this configuration, click on Configure Ports under Device Admin the dashboard menu. You should now see a page similar to Fig 14C.
Fig 14C: Enabling Ports to be discovered by alexa

On this page, select 'Yes' for "Allow RELAY in Alexa" if you want garage to be discovered by Alexa. Press Submit after making the selection(s). Then, login to Alexa on your smartphone and discover ports as you did before. If all settings are correct, you should be seeing these ports discovered in your Alexa application on your smart phone. You can now use to activate these ports by saying, for example, "Alexa, turn on XYZ", where XYZ is the name you have given the port. Similarly, to turn the port OFF, you can say "Alexa, Turn off XYZ". All the features of Alexa are now available to you for managing the equipments connected to this smart devices.

2.12  Opening/Closing garage with an HTTPS POST call

You can also open or close the garage from any of your other application programs using an HTTPS POST call. This helps integrate the WiFiSecureAccess system/devices with your other application programs. This feature also helps the developers to integrate this with their programs.

To open or close the garage door, make an HTTPS POST call with the following details:

POST HTTP/1.1
Host: wifisecureaccess.com/devicePortsJson/
Content-Type: application/json
data = { "email": your_email, "password": your_password, "device_name": device_name, "action": action, }

Refer to Section 4.0 of this documentation below to see more details about this and to see a sample python program.

2.13  Enabling Two Factor Authentication (2FA) on any port

If you are using this device to activate any secure device such as a secure door, you can also enable 2FA on that port. To enable 2FA on any port, click 'Configure Ports' under Devices admin in the dashboard, just like the way it was done when enabling GoogleHome. You will see a page as in Fig 14D.
Fig 14D: Enabling 2FA on Ports

On that page, you will see a field 'RELAY Secure Port'. By default, it is disabled. If you want google home to ask you for your pin when trying to activate any of these ports, set this to 'Yes' and press Submit. Once set to Yes, whenever you tell Google assistant to, activate that port (such as 'Hey google, Open Door'), Google Assistant will respond 'Can I have your pin?'. If you are activating this port by scanning QRCode or NFC tag or by pressing 'activate' button on your smartphone, the system will prompt for the pin before it will activate this port. You will have to enter your pin correctly to open the door. Your pin can be seen under your profile (click My Profile under User Admin in dashboard to see it). By default, the pin is 1234. you can change it to anything you like. This 2FA is an extra layer of security to make sure that nobody else other than the authorized person can activate this port. Note: The above method of 2FA will not work with Alexa. For 2FA in Alexa, you need to set it in Alexa itself. Refer to documentation on Alexa for setting pin codes for Locks and Doors.

2.14  Enabling Notifications

In order to send notifications, or to sound buzzer when the garage door stays open for a long time, you need to install the magnetic sensor on the garage door and cable it to the smart controller as explained earlier. Installing sensor on the garage door is also required if you want to know the current position of the garage door accurately from remote.

If you have installed sensor, check and make sure that D7_type in the configuration is selected as "TWO STATE ON/OFF". To do that, click on "Configure Device" under Device Admin in the dashboard menu. That will open a page as shown below.

Fig 14E: Configure Notifications

On this page, you should be seeing D7_type as TWO STATE ON/OFF. If not, select it as TWO STATE ON/OFF and press submit.

On this same configuration page (Fig 14E), you can set the fields for sending notifications. Notification Email field shows the email address to send email notifications. By default, this is set to the email address of the owner of this device. You can change it to any other email address, if you want. If this email field is left blank, no emails will be sent.

The fields Notification Webhook URL is the URL of your webhook to which a call will be made when conditions are met to send notifications. Webhook key/token is the key or the token of your webhook. You may enter those in these two fields, if you are interested in making such calls to send notifications. If the Webhook URL is left blank, it will not make any such calls to webhook URL. The call is an HTTP POST call with the key token in the header ('Authorization': webhook_key), and with some data in the body in JSON format. The data will have the device name, sensor_name, current value of the sensor, and a message. The following is the type of call that will be made:

HTTPS POST call
url: The Notification webhook URL configured
headers = {'Authorization': webhook_key, 'Content-Type': 'application/json', 'Accept': 'application/json',}
data = {"controlDevice": control_device, "sensorDevice": sensor_device, "sensor": sensor_name, "message": msg_webhook, "currentVal": current_value, "limitSet": limitVal, "msg_code": msg_code}
requests.post(notification_webhook, data=json.dumps(data), headers=headers)

Next, the notifications have to be enabled such that it sends notifications when the garage door stays open for a long time. It is also possible to configure it to sound an alarm (buzzer) either once or repetaedly when the garage stays open.

To enable notifications, click on Configure Auto Controls under Device Admin in the dashboard menu. That will show you a page similar to the following.

Fig 14F: Enabling Notifications

If you want email or webhook call to be sent when the garage stays open, click on 'Input Port' iin the last row of this page and select 'D7 ON/OFF'. Then set the delay time. This is the time it will wait to send notifications or to sound buzzer since the garage was opened. If you want the notifications to be sent periodically when garage stays open, you can also set the 'Repeat Time Period' in seconds.

Similarly, if you want the buzzer to sound, you can select 'Input Port' as 'D7 ON/OFF' for the row corresponding to BUZZER (last but one row in Fig 14F). Here also, you can set the delay time, time period and the duration of the alarm as you desire. Note that, normally the defaults will work.

Selecting 'Input Port' as 'None' will disable that notification.

Special Note: On this page of Auto Controls (Fig 14F), you can see a field "put ON/OFF when". This is by default "GREATER THAN OR EQUAL TO". Do not change this if the sensor is installed as described earlier with two of its parts (A and B) aligning themselves (they come next to each other) when the garage is fully closed. In fact, that is the best installation for a garage door. However, there is a less desirable option of installing the two parts of the sensor such that they align themselves when the garage is fully open. If you install the sensor that way, this field "Port ON/OFF when" has to be set to "LESS THAN". We are not recommending this installation because it may report that the garage is closed when it is half open.

2.15  Configuring Auto Close

With WiFisecureAccess smart controller, it is also possible to configure auto-closing of the garage door. For example, say, you want the garage door automatically closed 2 minutes after it is opened. This can be one by adding a word AutoClose in the port label of the port of the smart device connected to garage door controller. To configure this, click on 'Configure ports' under Device Admin in the dashboard menu. Then change the name of the relay1 Label from 'GARAGE' to 'GARAGR AutoClose'. Then press submit. Then, you need to set the duration for which the garage door should remain open before closing it automatically. Click on Configure Auto Controls under Device admin in the dashboard menu. Then change the value of 'Duration to stay activated (sec)' to whatever you prefer. If you want the garage door to remain open for 2 minutes before closing, then set this to 120. Press submit.

Fig 14G: Setting AutoClose Duration



Note: The duration is the time since you press the button to open the garage and not the time since the garage door comes to a full open position. So, make sure not to set this duration lower than the time needed for the garage/date to come to a full open position.

With the above configuration with AutoClose, the garage will automatically get closed two minutes after it is opened. With this autoClose in place, suppose that you want to keep the garage remain open anytime after you open it, you can use either Google Home or alexa, and say 'Hey google, Open *name of the decvice* during the time the garage is open. So, if you try to do so during the period when the garage is open (when in autoclose mode), it will cancel autoclose and will stay open. Then, if you want to close the garage, you can say "Hey Google, Close *name of the device*". This is a special handy feature of our smart device that you can configure and use.

PS. It is assumed that the cabling of the smart device is to the push button terminal of the garage door controller. Therefore, the smart device applies a pulse to it for opening or closing. If you are using it for opening a gate where it needs anything other than a pulse, this AutoClose feature will not work. Please contact us for any help

2.16  Displaying Device Use Records

The system keeps record of the use of this garage door for 30 days. At any time, you can see who used this garage door and at what time. To see the use records, click on 'Device Use records' under 'Device admin' in the dashboard menu. You will see a page similar to the one in Fig 38E with two columns (User and use_time)..

3.0  Allowing Multiple Users

This section explains how multiple users can be allowed to use a device. The owner is allowed to use all his devices all the time regardless of the settings described in this section. This section explains how the owner can allow others to use his devices and how to control and manage their authorization.

3.1  Allowing Others to Use Your Devices

You can allow or authorize the others to use your smart device. To allow someone else to use your device, they have to be registered with wifisecureaccess.com. So, request the other user to register with wifisucureaccess.com. To register, either download the app and open the app and press Admin Dashboard, or go to https://wifisecureaccess.com and click on dashboard in the top navigation bar. When it requests you to login, click on 'Create a New account'

Once they are registered, you add their email address to the Allowed Users group of your device as per the steps below:

First create a Device Group. This can be done by clicking 'Devices groups' under 'Device Groups' in the Dashboard menu.

Fig 36: Configure Device group

This page will display all the device groups that you have created so far. To add a new device group, just enter the name of the group in the bottom empty row and press submit. Make sure that the name that you entered is a new name. You can create as many groups as you need.

Next, click on 'Allowed Users' in the Dashboard menu. If you have created multiple groups, you may be prompted to select a group. You will then see a page similar to the one shown in Fig 37.

Fig 37: Configuring Allowed Users of a Group

In this form, enter the email address of the one whom you want to allow to use your device, and press Submit. If you have several users whom you want to allow, enter the email addresses of all of them, one at a time. You have now created a group of users.

Note: When you added the name of a user in a group, you could add an expiry date as well, if you want. Once an expiry date is addedd, that user will not be allowed after that expiry date. You can also remove any user from this group at any time by checking the delete box against that user's name and pressing Submit.

Next, you can configure your device such that all users in a group are allowed to use a device. To do that, click on 'Configure Device' under Device Admin in the Dashboard menu.

Fig 38: Configuring Devices with Device Group

In this page, select your device group, and press Submit. If all the above configurations are successful, all users in the selected device group are allowed to use this device.

When another customer is allowed to use to use your device, they will see this device in the list of devices they can use. Also, when they click on 'Show Device details', this allowed device will show up. If this device's port is enabled for GoogleHome or Alexa, the allowed users will show this device in GoogleHome or Alexa when they discover wifisecureaccess devices. But, keep in mind that the allowed users cannot change the configuration of a device.

So, if you install this device at an access door to open or close a door, all allowed users will be able to open and close that door. If you have set an expiry date, they will not be able to open or close this door after that expiry date. In later sections of this documentation, you will learn how to install this device as an access controller of a door.

3.2  Configuring Group Entry Controls

It is possible to create entry controls on the members of a device group. For example, if you want to allow the members of a group only between some specific time of a day, you can set the opening and closing times for a group. To do that, click on 'Group entry Control' under Device Groups. This tab will be available only if you have created a group. If you have created multiple groups, you will be prompted to select a group. Once selected, you will see a page similar to Fig 38A.

Fig 38A: Configuring Group Entry Control

On this page, set Opening time and closing time for this group. In the field 'Week' and 'Day', you have multiple options. If you select * for week, it applies this opening and closing times for all weeks of the year. Or, you can select a week that you want this applied to. Similarly, if you select * for Day, it will apply this to all days of a week. If you want this to apply to a particular day only, then select that day. You can also select the email address of a user this control must apply to. Then press submit.

Note: The general rule is that a member of the group is always allowed unless there is an open/close time in this table showing that the group is closed for him/her at that time of the day, on that day of the week of that year. An entry with opening time the same as closing time will mean no entry on that day of that week.

If no rows of controls is present, all users of this group will be allowed all the time, meaning that it is open all day, every week of the year. You can create a special closing and opening hours for a particular user by adding his email address in the 'User Email' field. If no user email is given, that opening and closing hours are applicable to everyone in that group. If opening and closing hours are missing for a user for any day of the week, the rule applicable to all will be used for that user.

You can add as many rows for each user as you want so long as those controls are different from each other. In other words, you can create an opening and closing hours for a user on Monday, another one for Tuesday and another one for, say, Thursday. And, if you leave all other days without specifying any control for that user, the general opening and closing hours used for all members of the group will be applied to this user.

You can also create multiple opening and closing hours within a day

Shown in Fig 38A is an example. In that, the first row is the opening and closing times for everybody on Saturday. The second row is the opening and closing times for everybody on Sunday. And, as the opening and closing time are the same on Sunday, it is effectively closed on Sunday. The third row is the opening and closing time for everyone on all other days of the week. The fourth and fifth rows apply to the user whose email address is given in the 'User Email' field. As per the fourth row, this user will be allowed between 10:00 and 12:00 on Tuesday, even though, all the others are allowed between 8:00 and 17:00 on Tuesdays(as per the third row). And, again, the fifth row specifically says that this user will not be allowed on any other days of the week. So, as special opening and closing times are given for a particular user covering every day of every week of the year, that rule will be applied to that user, and not the general rule. However, if a rule is not specified for a user for any day, the general rule will be applied to him for those days.

If there are no rows present, or if there is only one row with * for week and * for day, with user email empty, that means that it is open all days of the week and all weeks of the year for all the users in that group. In addition to this, you can create special opening/closing hours for each and everyone in the group. They can be either the same or different for each user.

If you do not want to anyone to enter, create a control with opening and closing hours the same. If you want to allow anyone, say, between 10:00 and 12:00 on Wednesady and do not want to grant any access on any other day, create two rows of control. In the first row of control, set opening time as 10:00 and closing as 12:00, week as * and day as Wednesday. In the second row of control, enter any time (say, 10:00) for both opening and closing time and select * for week and * for day. And, if you leave the user_email blank, these two rules will be applied to all those in the group for whom no other special rules are created.

3.3  Creating a New Group by merging members of two other groups

If you have created two groups and you have added members in each group, and if you are interested in creating ai new group that should contain members of both the other groups, you can do so. First create a new empty group by clicking 'Devices Groups' under 'Device Groups' in the dashboard menu. Then click on 'Merge Device Groups' under 'Device groups' in Dashboard menu. You will see a page similar to Fig 38B.

Fig 38B: Merge Device Groups

On this page, select Destination group as the new empty group that you just created. Then, select the first group that you want to add to this in the 'Source Group' field. Then press Submit. Next, repeat the same to add the second group to the same new group by clicking 'Merge Device Groups' and selecting Destination Group as the new group and selecting the second group for the 'Source Group' field. Then, press submit. Now, you have a new group with members of two of the other groups that you selected.

3.4  Displaying number of people within an Office/Building

If you have installed separate doors for entry and exit, and if nobody is allowed to open or close the door either manually or by any other means other than wifisecureaccess system, the system keeps a count of the number of people within the room or building. If any of the door is for entry as well as exit (ENTRY/EXIT), you can install a separate QRCode or NFC tag for exits, instead of using the same entry tag. To configure a separate tag for exit, click on 'Configure device' under Device Admin in the dashboard menu. Then, set Exit QRCode. Refer to Fig 38C.

Fig 38C: Configuring Exit Tags for an ENTRY/EXIT door/gate

In this form, enter a number for Exit QRCode. Enter a number such that its lower 12 characters are the same as the MAC address of the device. Once entered, press Submit button. Then, you will see a tab at the bottom of the page 'SHOW EXIT QRCODE LABEL'. If you click on that, it will show you the exit QRCode label. You can save that image on to your computer and print it on any type of paper you want. Then paste that label anywhere near the door on the inside of the office/building. Now, to open the door/gate from inside (for exiting), scan this QRCode using the wifisecureaccess App on your smart phone. By doing so, not only that the door opens, but also keeps a count on the number of people exiting.

If you are using NFC tags, you need to get an NFC tag, and enter its UID as per the steps given in Section 2.9 of this documentation.

To display the number of people currently in the office/building, click on 'Devices Groups' under under 'Device groups' in the dashboard menu. You will see the occupancy in all the groups that you have created as shown in Fig 38D. Note: Ocuuupancy will be displayed only if you have at least one group configured with either separate doors for entry and exit or separate exit tags for exit on ENTRY/EXIT doors. Also, note that the accuracy of this depends on several factors such as 1) No one should be using any other means other than wifisecureaccess App to open/close the door/gate. 2) Remote access to open or close the door/gate must be disabled on ENTRY/EXIT type of doors/gates, and 3) Not more than one person enters or exits with one commad to open or close. You can re-correct this number any time manually by editing this field.
Fig 38D: Displaying Occupancy in an Office/Building

3.5  Displaying Group Use Records

The system keeps record of the use of all the doors/gates of this group. At any time, you can see who used this group at what time. To see the group use records, click on 'Group Use records' under "device groups' in the dashboard menu. If you have created multiple groups, you will be prompted to select the group. Once selected, you will see a page similar to Fig 38E

Fig 38E: Group Use records

4.0  Integration with your other Apps and programs

WiFiSecureAccess system has web interfaces that can be used by any of your applications programs or any other Apps to open or close the garage door. From your applications, you can make an HTTPS POST call to url https://wifisecureaccess.com/devicePortsJson/ giving your credentials and the name of your device and the action to be taken in a JSON format.

4.1  Opening/Closing garage with an HTTPS POST call

To open or close the garage door, make an HTTPS POST call with the following details:

POST HTTP/1.1
Host: wifisecureaccess.com/devicePortsJson/
Content-Type: application/json

Provide the credentials and data in the following JSON format:
data = { "email": your_email, "password": your_password, "device_name": device_name, "action": action, }

--where your_email and your_password are the email address and password of the owner of the device connected to your garage door. device_name is the name assigned to the device. action should be either "ON" or "OFF". If you want to open the garage, action must be "ON", and if you want to close the garage, action must be "OFF".

If a POST call is made as per that above format, the garage door will be activated as per the action specified. Refer to the following sample python program. This sample call will open the garage door.


#!/usr/bin/env python
import requests
import json

def main_loop():
   url = "https://wifisecureaccess.com/access/devicePortsJson/"
   #the following are just an example.  replace these with your's.
   device_name = "My Garage"   # replace this with the name of your device
   email = "tester@gmail.com"
   password = "12345678"
   action = "ON"
   data = {'email': email, 'password': password, 'device_name': device_name, 'action': action,}
   headers = {'Content-Type': 'application/json', 'Accept': 'application/json',}
   r = requests.post(url, data=json.dumps(data), headers=headers)

   if r.status_code == requests.codes['ok']:
      res = r.json()
      if res['result'] and res['result'] == 'SUCCESS':
         print("SUCCESS")
      elif res['msg']:
         print(res['msg'])
      else:
         print("FAIL")

   else:
      print("Server error or communication error")

if __name__ == '__main__':
  main_loop()

5.0  Copying Use Records and Parking Records to Local Computer

Our system keeps all the use records and parking records for 30 days only. However, our customers can copy these records at frequent intervals to their computer and store them longer. They can also use their own dedicated data analysis tools to anlyze these data. A simple program making a json call to our url will provide you these use records in json format. Given in this section are some sample test program to copy these records.

5.1  Copying Device Use Records

'Device Use Records' have the information of anybody's using this device. The owner of a device can see the use records in Dashboard by clicking 'Device Use Records' under 'Device Admin'. These records can also be copied at frequest intervals to your local computer. Given below is an example of a program to copy these records.


#!/usr/bin/env python
import requests
import json
import getpass
import os

def main_loop():
   while True:
      email = input("Enter email : ")
      if email and email != "":
         break
   email = email.upper()
   while True:
      password = getpass.getpass()
      if password and password != "":
         break
   while True:
      device_name = input("Device Name: ")
      if device_name and device_name != '':
         break
   if device_name.isspace():
      print("device name cannot be empty spaces")
      exit(1)
   while True:
      start_date = input("Start Date (yyyy-mm-dd hh:mm): ")
      if start_date and start_date != '':
         break
   if start_date.isspace():
      print("start_date cannot be blank spaces")
      exit(1)
   while True:
      end_date = input("End Date (yyyy-mm-dd hh:mm): ")
      if end_date and end_date != '':
         break
   if end_date.isspace():
      print("End_date cannot be empty spaces")
      exit(1)
   while True:
      file_name = input("File Name: ")
      if file_name and file_name != '':
         break
   if file_name.isspace():
      print("Error.  File name cannot be blank spaces")
      exit(1)

   s = requests.session()
   n_next = 0
   url = "https://wifisecureaccess.com/access/get_useRecordsJson/"
   headers = {'Content-Type': 'application/json', 'Accept': 'application/json',}
   try:
      f = open(file_name, "a+")
   except:
      print("Unable to open the file %s" % (file_name))
      exit(1)

   while True:
            data = {'email': email, 'password': password, 'records_type': 'device', 'device_name': device_name, 'start_date': start_date, 'end_date': end_date, 'n_next': n_next,}
            r = s.post(url, data=json.dumps(data), headers=headers)
            if r.status_code == requests.codes['ok']:
               res = r.json()
               if res['result'] and res['result'] == 'SUCCESS':
                  if n_next == 0:
                     print("Field Names: ", res['field_names'])
                     if os.stat(file_name).st_size == 0:
                        field_names = res['field_names']
                        for field_name in field_names:
                           f.write(field_name)
                           f.write(", ")
                        f.write("\r\n\r\n")
                  records = res['records']
                  for record in records:
                     for value in record:
                        if not value:
                           value = ''
                        print(value, end=", ")
                        f.write(value)
                        f.write(", ")
                     print()
                     f.write("\r\n")
                  n_next = res['n_next']
                  records_remaining = res['records_remaining']
                  if records_remaining == 0:
                     break
               else:
                  if 'msg' in res:
                     msg = res['msg']
                  else:
                     msg = ""
                  print("FAIL: ", msg)
                  break
            else:
               print(r)
               print("FAIL:  Communication error")
               break
   f.close()

if __name__ == '__main__':
  main_loop()
And, here is a screenshot of the terminal running this program:

$ python test_getDeviceUseRecords.py
Enter email : test53680@gmail.com
Password: 
Device Name: New_Device
Start Date (yyyy-mm-dd hh:mm): 2020-03-28 10:30
End Date (yyyy-mm-dd hh:mm): 2020-04-09 23:10
File Name: my_file.txt
{'result': 'SUCCESS', 'msg': 'Login Success'}
Field Names:  ['customer_email', 'use_time']
RAMAN.V.NATH@GMAIL.COM, 2020-04-08 00:41, 
RAMAN.V.NATH@GMAIL.COM, 2020-04-08 00:44, 
RAMAN.V.NATH@GMAIL.COM, 2020-04-08 00:45, 
TEST53680@GMAIL.COM, 2020-04-08 10:50, 
TEST53680@GMAIL.COM, 2020-04-08 10:52, 
TEST53680@GMAIL.COM, 2020-04-08 10:52, 
TEST53680@GMAIL.COM, 2020-04-08 10:52, 
TEST53680@GMAIL.COM, 2020-04-08 10:52, 
TEST53680@GMAIL.COM, 2020-04-08 10:52, 
The above program makes a call to the server. And, it prints out the records on the terminal window of the user's computer. It also appends the same data to the specified local file. Note that it appends the data to the file instead of creating a new file so that records read earlier will not be lost. You can use the data in the file for doing any analysis of the data. The System keeps the use records for 30 days only. So, the owner of the device may read this record, say, every 15 days giving the start data and end date appropriately so that you copy the data from the last end_date. As the program appends the new data to the file, all the previously read records are also in the same file. In doing so, you will have the complete record of as many days as you want. Note: the first line of the file will have the field names. Subsequent lines in the file are the records.

5.2  Copying Group Use Records

Group records is the use records of a group, showing who used the devices in this group and when. These records can be seen on the dashboard by clicking 'Group Records' under Device Groups in Dashbaord. To copy the same records into your computer, you need a program to make calls to the IOT server. Given below is a program to do that.


#!/usr/bin/env python
import requests
import json
import getpass
import os

def main_loop():
   while True:
      email = input("Enter email : ")
      if email and email != "":
         break
   email = email.upper()
   while True:
      password = getpass.getpass()
      if password and password != "":
         break
   while True:
      group_name = input("Group Name: ")
      if group_name and group_name != '':
         break
   if group_name.isspace():
      print("group name cannot be blank spaces")
      exit(1)
   while True:
      start_date = input("Start Date (yyyy-mm-dd hh:mm): ")
      if start_date and start_date != '':
         break
   if start_date.isspace():
      print("start_date cannot be blank spaces")
      exit(1)
   while True:
      end_date = input("End Date (yyyy-mm-dd hh:mm): ")
      if end_date and end_date != '':
         break
   if end_date.isspace():
      print("End_date cannot be empty spaces")
      exit(1)
   while True:
      file_name = input("File Name: ")
      if file_name and file_name != '':
         break
   if file_name.isspace():
      print("Error.  File name cannot be blank spaces")
      exit(1)

   s = requests.session()
   n_next = 0
   url = "https://wifisecureaccess.com/access/get_useRecordsJson/"
   headers = {'Content-Type': 'application/json', 'Accept': 'application/json',}
   try:
      f = open(file_name, "a+")
   except:
      print("Unable to open the file %s" % (file_name))
      exit(1)

   while True:
            data = {'email': email, 'password': password, 'records_type': 'group', 'group_name': group_name, 'start_date': start_date, 'end_date': end_date, 'n_next': n_next,}
            r = s.post(url, data=json.dumps(data), headers=headers)
            if r.status_code == requests.codes['ok']:
               res = r.json()
               if res['result'] and res['result'] == 'SUCCESS':
                  if n_next == 0:
                     print("Field Names: ", res['field_names'])
                     if os.stat(file_name).st_size == 0:
                        field_names = res['field_names']
                        for field_name in field_names:
                           f.write(field_name)
                           f.write(", ")
                        f.write("\r\n\r\n")
                  records = res['records']
                  for record in records:
                     for value in record:
                        if not value:
                           value = ''
                        print(value, end=', ')
                        f.write(value)
                        f.write(", ")
                     print()
                     f.write("\r\n")
                  n_next = res['n_next']
                  records_remaining = res['records_remaining']
                  if records_remaining == 0:
                     break
               else:
                  if 'msg' in res:
                     msg = res['msg']
                  else:
                     msg = ""
                  print("FAIL: ", msg)
                  break
            else:
               print(r)
               print("FAIL:  Communication error")
               break
   f.close()

if __name__ == '__main__':
  main_loop()
And, here is a sample snapshot of a terminal running this program:

$ python test_get_groupUseRecords.py
Enter email : test53680@gmail.com
Password: 
Group Name: My House
Start Date (yyyy-mm-dd hh:mm): 2020-03-10 0:0
End Date (yyyy-mm-dd hh:mm): 2020-04-11 0:0
File Name: my_file.txt
{'result': 'SUCCESS', 'msg': 'Login Success'}
Field Names:  ['device_name', 'device_use_type', 'customer_email', 'use_time']
New_Device, CONTROL/SENSOR, TEST53680@GMAIL.COM, 2020-04-07 08:01, 
New_Device, CONTROL/SENSOR, TEST53680@GMAIL.COM, 2020-04-07 07:59, 
New_Device, CONTROL/SENSOR, TEST53680@GMAIL.COM, 2020-04-07 07:59, 
New_Device, CONTROL/SENSOR, TEST53680@GMAIL.COM, 2020-04-06 23:10, 
New_Device, CONTROL/SENSOR, TEST53680@GMAIL.COM, 2020-04-06 23:10, 
New_Device, CONTROL/SENSOR, TEST53680@GMAIL.COM, 2020-04-06 23:09, 
New_Device, CONTROL/SENSOR, TEST53680@GMAIL.COM, 2020-04-06 23:09, 
New_Device, CONTROL/SENSOR, TEST53680@GMAIL.COM, 2020-04-06 23:08, 
New_Device, CONTROL/SENSOR, TEST53680@GMAIL.COM, 2020-04-06 23:08, 
New_Device, CONTROL/SENSOR, TEST53680@GMAIL.COM, 2020-04-06 23:06, 
New_Device, CONTROL/SENSOR, TEST53680@GMAIL.COM, 2020-04-06 23:06, 
New_Device, CONTROL/SENSOR, TEST53680@GMAIL.COM, 2020-04-06 23:06, 
New_Device, CONTROL/SENSOR, TEST53680@GMAIL.COM, 2020-04-06 23:06, 
New_Device, CONTROL/SENSOR, TEST53680@GMAIL.COM, 2020-04-06 23:04, 
New_Device, CONTROL/SENSOR, TEST53680@GMAIL.COM, 2020-04-06 23:00, 
The above program makes a call to the server. And, it prints the records on the terminal of your computer. It also appends the same data to the specified file on your local computer. Note that it appends the data to the file instead of creating a new file so that all previously read data are retained in the file. This data in the file will help you analyse it using any of your sophisticated tools. Keep in mid that the system keeps records for 30 days only. So, you will have to copy the records, say, every 15 days or so giving the start date as the end date given when copying data last time. As the program appends the data to the same file, it will have all the previously read data as well. That way, your file will have all the records for a much longer time.

5.3  Copying Customer Use Records

Customer use records are the records of a customer's use of all the devices in the system. You can see your use records of any devices in the system in Dashboad by clicking 'My Use Records' under 'User Admin' in Dashboard. If you want the same records copied into your local computer to keep the data for longer time, or to do detailed data analysis for your special needs, you need a program to make calls to the server. Given below is a program in python to get these records from the server.


#!/usr/bin/env python
import requests
import json
import getpass
import os

def main_loop():
   while True:
      email = input("Enter email : ")
      if email and email != "":
         break
   email = email.upper()
   while True:
      password = getpass.getpass()
      if password and password != "":
         break
   while True:
      start_date = input("Start Date (yyyy-mm-dd hh:mm): ")
      if start_date and start_date != '':
         break
   if start_date.isspace():
      print("start_date cannot be blank spaces")
      exit(1)
   while True:
      end_date = input("End Date (yyyy-mm-dd hh:mm): ")
      if end_date and end_date != '':
         break
   if end_date.isspace():
      print("End_date cannot be empty spaces")
      exit(1)
   while True:
      file_name = input("File Name: ")
      if file_name and file_name != '':
         break
   if file_name.isspace():
      print("Error.  File name cannot be blank spaces")
      exit(1)

   s = requests.session()
   n_next = 0
   url = "https://wifisecureaccess.com/access/get_useRecordsJson/"
   headers = {'Content-Type': 'application/json', 'Accept': 'application/json',}
   try:
      f = open(file_name, "a+")
   except:
      print("Unable to open the file %s" % (file_name))
      exit(1)

   while True:
            data = {'email': email, 'password': password, 'records_type': 'customer', 'start_date': start_date, 'end_date': end_date, 'n_next': n_next,}
            r = s.post(url, data=json.dumps(data), headers=headers)
            if r.status_code == requests.codes['ok']:
               res = r.json()
               if res['result'] and res['result'] == 'SUCCESS':
                  if n_next == 0:
                     print("Field Names: ", res['field_names'])
                     if os.stat(file_name).st_size == 0:
                        field_names = res['field_names']
                        for field_name in field_names:
                           f.write(field_name)
                           f.write(", ")
                        f.write("\r\n\r\n")
                  records = res['records']
                  for record in records:
                     for value in record:
                        if not value:
                           value = ''
                        print(value, end=", ")
                        f.write(value)
                        f.write(", ")
                     print()
                     f.write("\r\n")
                  n_next = res['n_next']
                  records_remaining = res['records_remaining']
                  if records_remaining == 0:
                     break
               else:
                  if 'msg' in res:
                     msg = res['msg']
                  else:
                     msg = ""
                  print("FAIL: ", msg)
                  break
            else:
               print(r)
               print("FAIL:  Communication error")
               break
   f.close()

if __name__ == '__main__':
  main_loop()
And, here is an example snapshot of a local terminal running this program.

$ python test_getCustomerUseRecords.py
Enter email : test53680@gmail.com
Password: 
User Timezone (example: Australia/Sydney) deault: UTC
(Refer https://en.wikipedia.org/wiki/List_of_tz_database_time_zones): US/Pacific
Start Date (yyyy-mm-dd hh:mm): 2020-04-08 08:21
End Date (yyyy-mm-dd hh:mm): 2020-04-08 10:53
File Name: my_file.txt
{'result': 'SUCCESS', 'msg': 'Login Success'}
Field Names:  ['device_name', 'device_use_type', 'group_name', 'use_time']
New_Device, CONTROL/SENSOR, None, 2020-04-08 10:52, 
New_Device, CONTROL/SENSOR, None, 2020-04-08 10:52, 
New_Device, CONTROL/SENSOR, None, 2020-04-08 10:52, 
New_Device, CONTROL/SENSOR, None, 2020-04-08 10:52, 
New_Device, CONTROL/SENSOR, None, 2020-04-08 10:52, 
New_Device, CONTROL/SENSOR, None, 2020-04-08 10:52, 
New_Device, CONTROL/SENSOR, None, 2020-04-08 10:52, 
New_Device_H1.2, CONTROL/SENSOR, None, 2020-04-08 10:52, 
New_Device_H1.2, CONTROL/SENSOR, None, 2020-04-08 10:51, 
New_Device_H1.2, CONTROL/SENSOR, None, 2020-04-08 10:51, 
New_Device_H1.2, CONTROL/SENSOR, None, 2020-04-08 10:51, 
D8BFC0F2D182, CONTROL/SENSOR, None, 2020-04-08 10:50, 
A020A62FC8BD, CONTROL/SENSOR, None, 2020-04-08 08:21, 
The above program makes a call to the server. Refer to the suggestions given for reading group records in the previous section about copying records. Those comments apply here as well.