Top Banner
1/1/2017 0 Project WOHA Smart Home App Burduja Carina, Tanasa Larisa, Ionita Diana UAIC - FEAA
35

Project WOHA  · Web viewThe main REST principle that WOHA follows is: the communication between our app and the smart house’s devices (sensors and actuators) is done through the

Sep 30, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Project WOHA  · Web viewThe main REST principle that WOHA follows is: the communication between our app and the smart house’s devices (sensors and actuators) is done through the

0

1/1/2017

Project WOHA

Smart Home App

Burduja Carina, Tanasa Larisa, Ionita DianaUAIC - FEAA

Page 2: Project WOHA  · Web viewThe main REST principle that WOHA follows is: the communication between our app and the smart house’s devices (sensors and actuators) is done through the

ContentsWOHA..........................................................................................................................................................2

Architecture.................................................................................................................................................2

Users Module..............................................................................................................................................5

Device Module.............................................................................................................................................6

Additional features......................................................................................................................................7

1

Page 3: Project WOHA  · Web viewThe main REST principle that WOHA follows is: the communication between our app and the smart house’s devices (sensors and actuators) is done through the

WOHAThe main REST principle that WOHA follows is: the communication between our app and the smart house’s devices (sensors and actuators) is done through the controller layer.

The application “it is not aware” of the existence of the other smart devices, the app only communicates with the controller, at the same time the smart appliances are not ‘aware’ of the existence of WOHA app, they only communicate with the controller. The different smart appliances which are located in the same home are not ‘aware’ of each other’s existence.

The Server, using the ‘Device Controller’ makes all the connections between the app and the smart devices possible, even the connection between devices.

WIFI GET

POST

ETHERNET

GET/POST

smartsocket

bluetooth bluetooth

Figure 1. The REST communication schema for WOHA

Architecture

The architecture of WEB application WOHA contains:

2

SmartOven

SmartVentillator

WOHA APPDB

WashingMachine

SmartTVHOME

CONTROLLER

(GATEWAY)

SERVER

Page 4: Project WOHA  · Web viewThe main REST principle that WOHA follows is: the communication between our app and the smart house’s devices (sensors and actuators) is done through the

- Server – can be a computer which behaves as a node, controlling all the informational flows on the network. The main source of information is the controller. The input is stored in database or passed further to the application UI.

- Controller – represents a single point of contact from all devices to the server.- Sensors - devices that do not have operating system can be deployed with a sensor, which

transmits/receives message from controller.- Actuators – devices

In order to use WOHA you must have smart devices in a ‘smart’ house; these devices are connected to the server via wiring or wireless. This is the path on which they communicate their actual state. The server is empowered with a language which understands messages from controller and from the application. All the changes in UI (get, post) are managed by the server, if needed the information goes to controller to execute the action, and then it is transmitted to a database for storing purposes.

By using the controller, we have a greater level of freedom for adding and removing devices without affecting other devices or components. The application interacts only with the server, not directly with the devices. At the same time, changes can be made in the application, without affecting the actual device behavior. This is the reason why we can have this application on mobile device, on web or other support. The object-independent interface allows the developers to extend the controlling methods exploring a lot of possibilities.

How is the application actually working? The server is retrieving data on regular basis and posts the updates in the database. The changes of one device state like heating turned on might take some time to be physically activated but the message transmitted from the server to the controller and from the controller to the sensors or actuators are instant. The database is storing information about users and devices. All the rooms and all the devices that a user creates are stored in the database. Every time when a device/room is deleted the server automatically updates the database in order to have an up to date overview.

TASK FLOWS SECTION

The task flow of the application it is based on a very simple concept even if there are many steps to be fulfilled in order to call a function. All the specific requests coming from the user are dealt by the controller. It is the one that helps the web and the mobile applications communicate with the devices. As we presented above the communication between the app and devices follows the pattern: SMART DEVICES-CONTROLLER-SERVER-CONTROLLER-WOHA APP.

For a better understanding the following diagram presents the process, the only data structure used by WOHA are JSON format- it is dynamically created when the user presses certain button or chooses certain values to be set for some custom functions or for creating a new room/ user.

3

Page 5: Project WOHA  · Web viewThe main REST principle that WOHA follows is: the communication between our app and the smart house’s devices (sensors and actuators) is done through the

JSON format is what WOHA send to the controller and then the controller sends gets and posts to the server, a JSON format is received by the controller from the server and then the end user sees the results on the UI as buttons, lists, search results, different pictures, etc.

Figure 2. Application's flow

MAIN MODULES SECTION

The application is composed of two main modules: “Users” module that contains all the operations and information involving the users and the “Devices” module that contains all the operations and information regarding the devices installed. The figure below highlights the application’s modules and its main functions.

4

Page 6: Project WOHA  · Web viewThe main REST principle that WOHA follows is: the communication between our app and the smart house’s devices (sensors and actuators) is done through the

Figure 3. Application's main modules

Users Module

The authentication step:Standard authentication using a user ID (or previously registered email address) and a password which must comply with the ‘strong policy password’ (length min 8-10 characters, complexity, upper case, lower case and digits and the topology: the new password must be different from the old ones and the actual word ‘password’ must not be accepted for this field)TLS (transport layer security)- using HTTPS as a protocol for preventing the brute force attack over the password of a certain user – we offer a security feature: lock the account after 3 attempts of an invalid password typed and send a notification on the user’s email address as a warning that somebody tries to access his account and future steps that must be taken to secure it. An additional layer of security would be the ‘2 steps verification’ that uses a different token for each session when a certain user tries to login, a unique ‘one time code’ is provided via a text message on his personal phone.Another mechanism for authentication is the OAUTH method that allows users to login using either his Facebook, Google account.Session ID and AUTH token are kept in cookies on the browser for just a few minutes and then they will expire for security reasons.If a user locks himself out from the application at late hour at night, we provide a password reset link that will grant him the access to his ‘house’ and 24/7 support via service desk.

Add user: name, status, user rights (by category: Family member, Admin, Guest)All the operations that the end user performs using WOHA App are done via REST and the input and output data format is only JSON, all the communication client-server is done via GET and POST commands using JSON format and specific URI’s.

Add a new user example:

5

Page 7: Project WOHA  · Web viewThe main REST principle that WOHA follows is: the communication between our app and the smart house’s devices (sensors and actuators) is done through the

POST path/addUser- a JSON data structure

Figure18. Search JSON

Verify the current user’s status (all the registered users of a specific ‘home’):GET path/getUsers- a JSON that contains the details of all users

Manage user’s details:GET path/getUser+UserID

A JSON that contains all the details for a specific user identified by a unique user ID- shows name, access rights, category and if the user has the power to grant and revoke access for other user and a ‘history’ with all the users to whom he already did that)

If an update of the user’s details is required, the following command will be used:POST path/setUsersPermissions + userID+ the new ‘object’ with its new settings

When another registered user requests access from the Admin, first the application will show the active request and then we will grant it:

GET path/getActiveRequests- shows the pending requests receivedPOST path/setActiveRequests+ requestID+ objectThe main operations and use cases regarding the USER module of WOHA are:

6

Page 8: Project WOHA  · Web viewThe main REST principle that WOHA follows is: the communication between our app and the smart house’s devices (sensors and actuators) is done through the

Device Module

Each module of WOHA has a specific use case that shows the main tasks a user can perform on the application, based on his granted rights and category(Family member, Guest, Family Friend) The main use cases regarding the devices, function management are listed above:

Figure 4. Use case devices module -1

7

Page 9: Project WOHA  · Web viewThe main REST principle that WOHA follows is: the communication between our app and the smart house’s devices (sensors and actuators) is done through the

Figure 5. Use

case

devices module -2

Figure 6. Use case devices module -3

The Devices Module handles the house creation and maintains all the customized items created for the whole application. A user, with the right access, is able to create his home, rooms and populate the rooms with objects/devices (usually the Admin). When the user is choosing an option the server automatically assigns an ID to the object. At the same time, all the actions and interactions are made via get (to retrieve information) and post (to bring and display data). For example, on Home Menu we have:

8

Page 10: Project WOHA  · Web viewThe main REST principle that WOHA follows is: the communication between our app and the smart house’s devices (sensors and actuators) is done through the

- GET ‘path/getHomes’ + userID -> display the home for which the user has access.- POST ‘path/setHome’+object -> create a new home and push data into interface.

When we go to Rooms Menu and we perform actions the application works as following:

- GET ‘path/getRooms’+ userID+homeID+roomID+object- POST ‘path/setRoom’+ userID+homeID+roomID+object- POST ‘path/createRoom’+ userID+homeID+roomID+object- Post ‘path/deleteRoom’ + userID+homeID+roomID+object

We must remember that the JSON data format automatically retrieves and creates an unique ID for each object as device, room, house, function, user etc.

The same principle applies to Device Menu:

- GET ‘path/getDevices’ +userID+homeID+roomID -> display data about devices for this particular house, room, user.

- POST ‘path/setDevice’ + userID+homeID+roomID+object ->change the state of the device- POST ‘path/createDevice’+ userID+homeID+roomID+object -> create a new device- POST ‘path/deteleDevice’+ userID+homeID+roomID+object-> remove a device

Additional features

WOHA comes with a set of pre-made functions that come in handy for every Smart Home but it extends its capabilities by offering a higher customization level: creating your own function for your house where you choose all parameters, all the affected devices, the time frame, name etc.

The pre-made functions are:

1. All lights off- shuts down every light from the house: the app sends a request to the server which check the status of every smart bulb from the house, checks if the sensors are on or off and then changes the status for the on sensors in off sensors and keeps that state until the user decides to untick the box.

2. All doors locked- the app changes the status received from the smart doors sensors and activates the actuators which will shut down the doors and after that lock them

3. Activate burglar alarm- the server reeds the state of the smart device, then if a trigger is activated the server will send the commands to the sensors and (the user doesn’t see or even know about this process) the device changes its state from off to on and keeps it until it will be changed again.

4. Custom functions- Scheduled functions

GET path/customFunctions

9

Page 11: Project WOHA  · Web viewThe main REST principle that WOHA follows is: the communication between our app and the smart house’s devices (sensors and actuators) is done through the

GET path/customFunctions+functionID

GET path/customFunctions+ functionID+ obiect

POST-path/createFunction+ object

All the functions will be generated as JSON data format from 1 to x parameters.

SECTION PREDEFINED FUNCTIONS – ALL DOORS/WINDOWS LOCKED/ALL LIGHT OFF

Each device’s state from the house can be changed at any moment. But, when the user is in a hurry and he does not have time to update each device, one by one, the application provides some predefined functions in order to speed up the process. So, for example, if the user leaves the house and he forgot to switch off the lights, he can use the function “All lights off”. There are three predefined functions included in the application design but the user has also the possibility to create personalized functions, taking into consideration his needs at a certain moment. The above code refers to the predefined functions just described.

When the user presses certain buttons to create new functions, application will send a GET operation to the controller layer (for existing functions) and POST when he wants to create a new function. A JSON structure for this type of operations is presented above:

Figure 7. All doors closed function

10

Page 12: Project WOHA  · Web viewThe main REST principle that WOHA follows is: the communication between our app and the smart house’s devices (sensors and actuators) is done through the

Figure 8. All windows closed Function

Figure 9. All lights off function

SECTION PREDEFINED FUNCTIONS – ACTIVATE BURGLAR ALARM

11

Page 13: Project WOHA  · Web viewThe main REST principle that WOHA follows is: the communication between our app and the smart house’s devices (sensors and actuators) is done through the

Figure10. Burglar Alarm - 1

Figure11. Burglar Alarm Custom

SECTION PREDEFINED FUNCTIONS – SMOKE AND WATER ALARM

Figure 12. Smoke and Water Alarm

12

Page 14: Project WOHA  · Web viewThe main REST principle that WOHA follows is: the communication between our app and the smart house’s devices (sensors and actuators) is done through the

Figure 12. Smoke and Water Alarm Custom

SECTION PREDEFINED FUNCTIONS – SAVING MODE

13

Page 15: Project WOHA  · Web viewThe main REST principle that WOHA follows is: the communication between our app and the smart house’s devices (sensors and actuators) is done through the

The SavingMode Function works on the same principle as the custom function Holiday Mode but has different parameters, it doesn’t completely turn off the smart appliances in the house, it doesn’t lock all the doors and windows, it keeps the lights and temperature at some minimum values in order to save power, the values are synchronized with the seasons, locations and time zone for ex 15 degrees for winter time and lights at minimum intensity between 12-4 PM. The JSON is communicating with the server by automatically sending the values entered by the end user in the application field, then through the Controller the Sensors and Actuators from the SmartHouse are activated exactly with the state and values set by end user.

Figure 13. Savings Mode

SECTION PREDEFINED FUNCTIONS – HOLIDAY MODE

Figure 14. Holiday Mode

SECTION CUSTOM FUNCTIONS – CUSTOM HOLIDAY MODE

THE JSON FOR THE CUSTOM HOLIDAY MODE FUNCTION IS PRESENTED ABOVE:

Function: {“activateCustomFunctionHolidayMode”//custom function holiday mode//valori populate dinamic din campurile introduse de user(ex 20 grade){

"ActivateHolidayMode": [{"TemperatureSensor": [{

"name": "BedroomTemperatureSensor","activeStatus": "true","value": "20"

14

Page 16: Project WOHA  · Web viewThe main REST principle that WOHA follows is: the communication between our app and the smart house’s devices (sensors and actuators) is done through the

}, {"name": "LivingRoomTemperatureSensor","activeStatus": "true","value": "20"

}, {"name": "BathRoomTemperatureSensor","activeStatus": "true","value": "20"

}, {

"name": "KitchenTemperatureSensor","activeStatus": "true","value": "20"

}]

"BurglerAlarmSensor": [{"BurglerAlarmSensor": [{

"name": "alarmSensorMainEntrance","activeStatus": "true"

}] "Windows": [{

"name": "windowBedroom","lockstatus": "true"

}, {"name": "windowKitchen","lockstatus": "true"

}, {"name": "window1LivingRoom","lockstatus": "true"

},{"name": "window2LivingRoom","lockstatus": "true"

},{"name": "windowBathromm","lockstatus": "true"

}, {"name": "window1Garage","lockstatus": "true"

}]

"lights": [{"name": "lightsBedroom","status": "off"

}, {"name": "lightsKitchen","status": "off"

}, {"name": "lightsLivingRoom","status": "off"

}, {

15

Page 17: Project WOHA  · Web viewThe main REST principle that WOHA follows is: the communication between our app and the smart house’s devices (sensors and actuators) is done through the

"name": "lightsBathroom","status": "off"

}, {"name": "lightsGarage","status": "off"

}] "Doors": [{

"name": "doorBedroom","lockstatus": "true"

}, {"name": "doorKitchen","lockstatus": "true"

}, {"name": "doorLivingRoom","lockstatus": "true"

}, {"name": "doorBathroom","lockstatus": "true"

}, {"name": "doorGarage","lockstatus": "true"

}]"WasingMachine": [{

"name": "WashingMachineSensor","activeStatus": "false",//e oprit device-ul"powerStatus": "off"// nu primeste curent de la priza(blocata)}]

"SmartTV": [{"name": "SmartTVSensor","activeStatus": "false",//e oprit device-ul"powerStatus": "off"// nu primeste curent de la priza(blocata)}]

"SmartStove": [{"name": "StoveSensors","activeStatus": "false",//e oprit device-ul"powerStatus": "off",//nu primeste curent electric"GasIntake":"off"// nu primeste gaz

}]

}]"WaterSensor" [{

"name": "KitchenWaterSensor","location": "KitchenFloor","activeStatus": "true"

}, {"name": "BathroomWaterSensor","location": "BathroomFloor","activeStatus": "true"

16

Page 18: Project WOHA  · Web viewThe main REST principle that WOHA follows is: the communication between our app and the smart house’s devices (sensors and actuators) is done through the

}]

"SmokeSensor": [{"name": "KitchenSmokeSensor","activeStatus": "true"

}, {"name": "LivingRoomSmokeSensor","activeStatus": "true"

}]}]

}TIMER AND TRIGGER FOR CUSTOM FUNCTIONS

The end user can create highly customizable function and complex ones like the HolidayMode but he also can define some rules which will act like triggers and set in motion the SmartHome actuators or sensors when a certain condition is accomplished or reaches some specific values

For example: a rule can be created that every working day from Monday to Friday at 6 PM the HotTubeBathroomSensors are activated and a hot bath with essences is waiting for the end user to arrive (every day after work)-this rule can be disabled for some specific days if the end user changes his working hours and has overtime hours, before this action is performed a notification is send to the user’s device and he/ she has to manually accept it and then.

JSON:

Figure 15. Timer HotBath Function

EVENT-DRIVEN FUNCTION ON SMARTHOME

17

Page 19: Project WOHA  · Web viewThe main REST principle that WOHA follows is: the communication between our app and the smart house’s devices (sensors and actuators) is done through the

Physical events trigger the execution of PHP scripts for example if the desk phone rings and the TV is turned on automatically when the user picks up the phone the volume of the Smart TV reduces significantly.

How do we do it? In order to achieve this: the pick-up fork of the desk phone has a sensor that is activated when the user picks up the phone, this sensor has a listener that communicates with the controller layer which will automatically execute a script that activates SmartTV’s sensors and decreases its volume only if this object is turned on and close to the desk phone.

SETTINGS – BACKUP

The backup has the same functionality as the export feature. The application will export regularly an JSON containing all the settings of the created smart home (all the details about objects, users, homes, function, history of an application) The ‘old’ file will be stored until a new file will be generated (until a user will press the create a backup button) If by any means something happens with the application, the file can be brought up and the application restored. All the files and detail are stored in the cloud with the database as well. The users can store the backup files locally of they want but it is advised to keep at least the last 10 versions of a smart home. If the app crashes, the data won’t be lost and everything can be restored with the minimum down time if the cloud solution is adopted.

SETTINGS – IMPORT/EXPORT

The Import/export feature is configured to export/import all the objects contained by the application in JSON format. The file can be stored and used later for restoring a previous version or in case that some unwanted changes have been made over the application.

Each application must have an export and a back-up section. In order to have a better overview of all the devices states, the user has the possibility to export the relevant data about each one. For example, if the father wants to know if his son has watched TV in a certain day, he can easily make an export and check. For our application, all data is saved on a server as an automatic backup and when an export is made, all the information is selected from the server database. Each type of device has a special export template to be filled in when the information is saved in the database. Therefore, there were created separated export templates for each type of device, with the main relevant data to be exported, as follows:

Doors export template

{"exportDoors":[

18

Page 20: Project WOHA  · Web viewThe main REST principle that WOHA follows is: the communication between our app and the smart house’s devices (sensors and actuators) is done through the

{ "door":"doorBedroom", "status":"closed", "lastUpdate":"02-02-2017 18:30:16", "lastUpdatedBy":"admin" },{ "door":"doorKitchen", "status":"opened", "lastUpdate":"02-02-2017 18:45:23", "lastUpdatedBy":"ana" },{ "door":"doorLivingRoom", "status":"closed", "lastUpdate":"02-02-2017 14:45:25", "lastUpdatedBy":"admin" },{ "door":"doorBathroom", "status":"closed", "lastUpdate":"02-02-2017 10:15:03", "lastUpdatedBy":"ana" },{ "door":"doorGarage", "status":"closed", "lastUpdate":"02-02-2017 11:25:02", "lastUpdatedBy":"admin" }]}

Windows export template

{"exportWindows":[{ "window":"windowBedroom", "status":"closed", "lastUpdate":"02-02-2017 18:30:16", "lastUpdatedBy":"admin" },{ "window":"windowKitchen", "status":"opened", "lastUpdate":"02-02-2017 18:45:23", "lastUpdatedBy":"ana" },{ "window":"window1LivingRoom", "status":"closed", "lastUpdate":"02-02-2017 14:45:25", "lastUpdatedBy":"admin" },{ "window":"window2LivingRoom", "status":"opened", "lastUpdate":"02-02-2017 14:45:25", "lastUpdatedBy":"admin" },{ "window":"windowBathroom", "status":"closed", "lastUpdate":"02-02-2017 10:15:03", "lastUpdatedBy":"ana" },{ "window":"windowGarage", "status":"closed", "lastUpdate":"02-02-2017 11:25:02", "lastUpdatedBy":"admin" }]}

Lights export template

{"exportLights":[{ "light":"lightBedroom", "status":"On", "lastUpdate":"02-02-2017 18:30:16", "lastUpdatedBy":"admin" },{ "light":"lightKitchen", "status":"On", "lastUpdate":"02-02-2017 18:45:23", "lastUpdatedBy":"ana" },{ "light":"lightLivingRoom", "status":"Off", "lastUpdate":"02-02-2017 14:45:45", "lastUpdatedBy":"admin" },{ "light":"lightBathroom", "status":"Off", "lastUpdate":"02-02-2017 10:15:03", "lastUpdatedBy":"ana" },{ "light":"lightGarage", "status":"Off", "lastUpdate":"02-02-2017 11:25:02", "lastUpdatedBy":"admin" }]}

TV export template

{"exportTVs":[{ "tv":"tvBedroom", "status":"Off", "lastUpdate":"02-02-2017 18:30:16", "lastUpdatedBy":"admin", "lastChannel":"HBO" },{ "tv":"tvKitchen", "status":"Off", "lastUpdate":"02-02-2017 18:45:23", "lastUpdatedBy":"ana", "lastChannel":"MTV" },{"tv":"tvLivingRoom", "status":"Off","lastUpdate":"02-02-2017 14:45:25", "lastUpdatedBy":"admin", "lastChannel":"Discovery" }]}

Air-conditioner export template

{"exportair-Conditioner":[{ "air":"airBedroom", "status":"Off", "lastUpdate":"02-02-2017 18:30:16", "lastUpdatedBy":"admin" },{ "air":"airLivingRoom", "status":"Off", "lastUpdate":"02-02-2017 14:45:25", "lastUpdatedBy":"admin" }]},

Alarms export template

{"exportAlarms":[{ "alarm":"alarmFrontDoor", "status":"On", "lastUpdate":"03-02-2017 09:25:34", "lastUpdatedBy":"ana", "lastEmergency":"17-12-2016 17:30:36", "emergencyStoppedBy":"admin"},{ "alarm":"alarmGarage", "status":"On", "lastUpdate":"03-02-2017 09:25:34", "lastUpdatedBy":"ana", "lastEmergency":"17-12-2016 17:30:36", "emergencyStoppedBy":"admin"}

]}

Audio system export template

19

Page 21: Project WOHA  · Web viewThe main REST principle that WOHA follows is: the communication between our app and the smart house’s devices (sensors and actuators) is done through the

{"exportAudioSystem":[ { "audioSystem":"audioSystemLivingRoom", "status":"Off", "lastUpdate":"02-02-2017 18:30:16", "lastUpdatedBy":"admin", "lastChannel":"HBO", "lastVolume":"45 %", "lastSong":"All the single ladies" }]},

Radio export template

{"exportRadio":[ { "radio":"radioKitchen", "status":"Off", "lastUpdate":"02-02-2017 18:30:16", "lastUpdatedBy":"admin", "lastFrequece": "Radio Guerilla" }]}

Microwave export template

{"exportMicrowave":[ { "microwave":"radioKitchen", "status":"Off", "lastUpdate":"02-02-2017 18:30:16", "lastUpdatedBy":"ana", "lastTemperature":"45 degrees" }]}

Oven export template

{"exportOven":[ { "oven":"ovenKitchen", "status":"Off", "lastUpdate":"01-02-2017 11:21:36", "lastUpdatedBy":"ana", "lastTemperature":"220 degrees", "lastSelectedProgram":"cookies" }]}

Refrigerator export template

{"exportRefrigerator":[ { "refrigerator":"refrigeratorKitchen", "status":"On", "lastUpdate":"14-02-2016 14:02:48", "lastUpdatedBy":"ana", "lastTemperature":"4 degrees", "lastFunction":"autocleaner"}]}

Washing machine export template

{"exportWashingMachine":[ { "washingMachine":"washingMachineKitchen", "status":"Off", "lastUpdate":"01-02-2017 11:21:36", "lastUpdatedBy":"ana", "lastTemperature":"30 degrees", "lastSelectedProgram":"soft clothes" }]}

Water export template

{"exportWater":[ { "water":"waterBathroom", "status":"Off", "lastUpdate":"01-02-2017 20:12:58", "lastUpdatedBy":"ana", "lastTemperature":"35 degrees", "lastQuantityUsed":"28 L" }]}

Boiler export template

20

Page 22: Project WOHA  · Web viewThe main REST principle that WOHA follows is: the communication between our app and the smart house’s devices (sensors and actuators) is done through the

{"exportBoiler":[ { "boilerMachine":"boilerBathroom", "status":"On", "lastUpdate":"01-02-2017 11:21:36", "lastUpdatedBy":"ana", "lastTemperature":"80 degrees"}]}

Vacuum cleaner export template

{"exportVacuum Cleaner":[ { "vacuumCleaner":"vacuumCleanerLivingRoom", "status":"Off", "lastUpdate":"03-02-2017 09:05:14", "lastUpdatedBy":"ana", "lastSelectedProgram":"turbo power" }]}

Heat export template

{"exportHeat":[ { "heat":"heatLivingRoom", "status":"On", "lastUpdate":"03-02-2017 09:25:34", "lastUpdatedBy":"ana", "lastTemperature":"22 degrees"}]}

NOTIFICATION PANEL AND THE USE OF EXTERNAL AND INTERNAL API’S FOR WOHA

The user will receive notifications on his smartphone showing the daily summary of his smart home, the notifications are customizable and depend on the user’s rights.

If the use is not logon permanently to the WOHA app he can still receive notifications via SMS. This feature is implemented in WOHA using the external REST API from Twilio.. The cost per user per message for this service is very affordable just 0.0074 cents per SMS, and different plans are available, if you want that only the admin of a certain house to have access to this feature you can order a separate plan.

WOHA sends notifications for free inside the app environment but if the user is not logged in he cannot receive them and it is possible that the smoke alarm it is turned on and something happened with his house, that’s the main reason for using Twlio external API.1

The details in PHP for sending a message with an image URL can be read above

1 https://www.twilio.com/docs/api/rest/sending-messages

21

Page 23: Project WOHA  · Web viewThe main REST principle that WOHA follows is: the communication between our app and the smart house’s devices (sensors and actuators) is done through the

Figure 16. Send a message with Image URL in PHP

Another external API used is Google maps API2

This API is used if a certain user sets a special function like unlock the doors when I am in front of them. The exact coordinate taken from the user’s smartphone are used to unlock the door if it is in the proximity of the locked doors.

The following JSON example is to show the functionality of the Google Maps API

{   "results" : [      {         "address_components" : [            {               "long_name" : "1600",               "short_name" : "1600",               "types" : [ "street_number" ]            },            {               "long_name" : "Amphitheatre Pkwy",

2 https://developers.google.com/maps/documentation/geocoding/start

22

Page 24: Project WOHA  · Web viewThe main REST principle that WOHA follows is: the communication between our app and the smart house’s devices (sensors and actuators) is done through the

               "short_name" : "Amphitheatre Pkwy",               "types" : [ "route" ]            },            {               "long_name" : "Mountain View",               "short_name" : "Mountain View",               "types" : [ "locality", "political" ]            },            {               "long_name" : "Santa Clara County",               "short_name" : "Santa Clara County",               "types" : [ "administrative_area_level_2", "political" ]            },            {               "long_name" : "California",               "short_name" : "CA",               "types" : [ "administrative_area_level_1", "political" ]            },            {               "long_name" : "United States",               "short_name" : "US",               "types" : [ "country", "political" ]            },            {               "long_name" : "94043",               "short_name" : "94043",               "types" : [ "postal_code" ]            }         ],         "formatted_address" : "1600 Amphitheatre Parkway, Mountain View, CA 94043, USA",         "geometry" : {            "location" : {               "lat" : 37.4224764,               "lng" : -122.0842499            },            "location_type" : "ROOFTOP",            "viewport" : {               "northeast" : {                  "lat" : 37.4238253802915,                  "lng" : -122.0829009197085               },               "southwest" : {

23

Page 25: Project WOHA  · Web viewThe main REST principle that WOHA follows is: the communication between our app and the smart house’s devices (sensors and actuators) is done through the

                  "lat" : 37.4211274197085,                  "lng" : -122.0855988802915               }            }         },         "place_id" : "ChIJ2eUgeAK6j4ARbn5u_wAGqWA",         "types" : [ "street_address" ]      }   ],   "status" : "OK"}

Figure 17. JSON functionality of the Google Maps API

SETTINGS – SHOW CONNECTED USERS

When the user choses to use this feature, the application sends a GET to the server, to receive a list of all connected users. The server executes the method in PHP and finds out the users. The information is transmitted in JSON format and the list is populated in the UI.

SEARCH FIELD

The search will be configured with a script which runs in the server by populating a list of tags, called array, with all the objects in the application. It will be intuitive and will contain what the developers think the users will search. A default list(array) is provided to begin with and then after the app “learns” from the user’s searches will automatically increase this array with new values dictated from every user’s search field criteria.The application will create new tags once the users type them in the search field or actually create new objects. When they type new tags, the application will parse the current string and will check if they exist in the predefined array. The search field will populate the results based on a GET. When a new object is created the search array will be populated with the new object using a POST. JSON is the main communication way, the search is not an exception.

For example, if we are typing in the search field the value “do” then the default list will suggest as search options “dormitory” “Doru” (a user’s name) or “door”.

24

Page 26: Project WOHA  · Web viewThe main REST principle that WOHA follows is: the communication between our app and the smart house’s devices (sensors and actuators) is done through the

When you add a new device, room, user the command is:

“POST path/’createUser’+object and the object is a JSON with all data regarding the user (name, rights, status, category).

The new “Doru” user is added to the:” search” array.When an end user is typing a value the current string is parsed and added to the default array and at the same time the inclusion in the array in verified.This is how the app “remembers” the values of the search field and recommends the possible results showing a drop-down list or as in the Google search bar it autocompletes the other half of the word or expression.

BUSINESS INTELLIGENCE CAPABILITIES FOR WOHA

This feature will be further developed all the data related to the consumption of water, gas, energy in the smart home is kept in database. Using all this info the end user can see his houses’ average consumption monthly or yearly if he wants.

Further based on his ‘consumption model’ he can create future forecasts, customize some consumption plans and predict some future behaviors per each user.

If the data is available when the user choses he dates and the presses the graph button the data will be taken from the DB and presented as a bar chart, a pie chart, or a trend line.

25

Page 27: Project WOHA  · Web viewThe main REST principle that WOHA follows is: the communication between our app and the smart house’s devices (sensors and actuators) is done through the

IMPLEMENTATION LEVEL

Even if WOHA is not fully implemented, we have tested a function using PHP in order to demonstrate that the architecture that we created is functional and the JSON data format was the right choice for this type of application that uses the REST protocol.

Using PhpMyAdmin we tested the communication between the light sensors the controller layer and the action performed by the ‘test user’ using WOHA app.

First WOHA must connect to the DB:

26

Page 28: Project WOHA  · Web viewThe main REST principle that WOHA follows is: the communication between our app and the smart house’s devices (sensors and actuators) is done through the

Scenario: the user wants to see the lights status, ‘in the backend’ the following GET is created:

27

Page 29: Project WOHA  · Web viewThe main REST principle that WOHA follows is: the communication between our app and the smart house’s devices (sensors and actuators) is done through the

SEQUENCE DIAGRAM OF THE APPLICATION

Figure 1. Sequence Diagram

28