scieee AI-readable full text Open interactive document viewer

Smart spaces: aware of users, preferences, behaviours and habits, in a non-invasive approach

Oliveira, Pedro Filipe Fernandes

Abstract

Numa nova era de desenvolvimento tecnológico, em que os utilizadores valorizam cada vez mais a qualidade de vida, seja na perspetiva de conforto, seja na perspetiva de não terem preocupações desnecessárias, impõe-se que as soluções tecnológicas caminhem nesse sentido, e vão de encontro à resolução dos problemas e dificuldades das pessoas. Os espaços inteligentes têm um papel fundamental como solução para assegurar o conforto do ambiente e de utilização, sem ignorar aspetos igualmente relevantes, como a sustentabilidade ambiental. São a solução por excelência para promover conforto ao nível de cada espaço da habitação ou mesmo ao nível das preferências individuais dos seus utilizadores, de forma totalmente transparente e não invasiva, e considerando aspetos como tipo de espaço (doméstico, profissional ou de lazer), características térmicas do espaço e dos equipamentos de promoção de conforto, tempos de reação, condições externas (temperatura), entre outros. Esta tese de doutoramento, realizada em contexto empresarial, visa demonstrar a viabilidade de definir uma framework, suportada por uma arquitetura multi-agente, para controlo de variáveis de conforto, como temperatura, luminosidade, e outras, que pode ser suportada por hardware low-cost e é aplicável ao parque edificado. Framework esta que se presta a diferentes implementações, consoante o tipo de espaço, personalização do conforto e privacidade desejada para os utilizadores e, eficiência na gestão dos recursos. A framework dá solução a aspetos como identificação dos utilizadores; gestão de conflitos resultantes de diferente preferências de conforto; segurança dos espaços, equipamentos e utilizadores; integração com serviços em cloud, incluindo partilha de preferências de conforto; entre outros. A framework foi validada em dois cenários de utilização, relativamente ao conforto e eficiência energética, tendo em ambos casos sido apurados resultados bastante satisfatórios, sendo de realçar o conforto com elevado nível de satisfação por parte dos utilizadores. Foi assim conseguida a completa especificação de uma framework que se espera que possa vir a ser um referencial para os fabricantes de soluções de conforto.

Full text

Universidade do Minho Escola de Engenharia Pedro Filipe Fernandes Oliveira Smart spaces: aware of users, preferences, behaviours and habits, in a non-invasive approach March, 2023 UMinho | 2023 Pedro Filipe Fernandes Oliveira Smart spaces: aware of users, preferences, behaviours and habits, in a non-invasive approach Doctoral Program in Computer Science of the Universities of Minho, Aveiro and Porto Universidade do Minho Escola de Engenharia Pedro Filipe Fernandes Oliveira Smart spaces: aware of users, preferences, behaviours and habits, in a non-invasive approach Pedro Filipe Fernandes Oliveira Doctoral Program in Computer Science of the Universities of Minho, Aveiro and Porto Work developed under the supervision of: Professor Doutor Paulo Jorge Freitas de Oliveira Novais Professor Doutor Paulo Jorge Teixeira Matos COPYRIGHT AND TERMS OF USE OF THIS WORK BY A THIRD PARTY This is academic work that can be used by third parties as long as internationally accepted rules and good practices regarding copyright and related rights are respected. Accordingly, this work may be used under the license provided below. If the user needs permission to make use of the work under conditions not provided for in the indicated licensing, they should contact the author through the RepositoriUM of Universidade do Minho. License granted to the users of this work Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/deed.en i Acknowledgements Obtaining a Ph.D. degree is normally seen as a solitary process, in which the candidate spends several years studying and specializing on some topic, and focusing on personal achievements. On this PhD not only personal achievements, but also on establishing connecting points and on sharing lessons learned with the peers. Many people had an influence on the work described in this thesis. Following I would like to mention those who had most impact. First of all I must mention Paulo Novais and Paulo Matos, who more than supervisors became friends. They provided unconditional support giving me the opportunity to carry out my research thesis, for his guidance, many conversations and improvements. Also, I would like to express my sincere appreciation to the Intelligent Systems research group at ”Research Centre ALGORITMI” for the great working environment provided, the productive discussions and overall cooperation. Last but not least, I want to extend my deepest gratitude to my friends for their friendship, support and patience. Finally, I would like to dedicate a few lines to my family, who has always been supportive and encouraging, giving me the conditions to go further, specially to my parents José and Justina. This work is also yours, with all my gratitude, Pedro Oliveira iii STATEMENT OF INTEGRITY I hereby declare having conducted this academic work with integrity. I confirm that I have not used plagiarism or any form of undue use of information or falsification of results along the process leading to its elaboration. I further declare that I have fully acknowledged the Code of Ethical Conduct of the Universidade do Minho. Braga, 10 de março de 2023 (Pedro Filipe Fernandes Oliveira) v Assinado por: PEDRO FILIPE FERNANDES OLIVEIRA Num. de Identificação: 13020963 Data: 2023.03.10 18:12:23 +0000 Contents List of Figures xvii List of Tables xxi Acronyms xxv 1 Introduction 1 1.1 Overview..................................... 1 1.2 Context and Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.3 Problemdefinition ................................ 3 1.4 Research hypothesis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.5 Objectives .................................... 6 1.6 Research methodology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.7 Thesisorganization................................ 8 2 Smart Spaces 9 2.1 StateoftheArt.................................. 9 2.2 Support Concepts and Technologies . . . . . . . . . . . . . . . . . . . . . . . . 9 2.2.1 IoT Appliance level . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 2.2.2 DeviceTypes............................... 18 2.2.3 Communication level . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 2.2.4 IoTPlatforms............................... 31 2.3 AmbientIntelligence ............................... 37 2.3.1 Concepts ................................ 37 2.3.2 Projects ................................. 39 2.3.3 Challenges and Trends . . . . . . . . . . . . . . . . . . . . . . . . . . 44 2.4 A User in a Smart Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 2.5 Synthesis..................................... 47 xiii 3 Characterization and Methods 49 3.1 General Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 3.1.1 Required and Relevant Data . . . . . . . . . . . . . . . . . . . . . . . 49 3.1.2 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 3.1.3 User identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 3.1.4 Detection and characterization of the user at the space . . . . . . . . . . 54 3.1.5 Detection and characterization of the user in the environment . . . . . . . 55 3.1.6 Preferences conflict management in the environment . . . . . . . . . . . 55 3.1.7 Comfort - Predictive vs. Reactive . . . . . . . . . . . . . . . . . . . . . 56 3.2 User Behaviour Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 3.2.1 Simulation Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 3.2.2 Validation and Statistical Analysis . . . . . . . . . . . . . . . . . . . . . 61 3.3 Overall System Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 3.3.1 Preference’s Card . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 3.3.2 System Information and Constrains . . . . . . . . . . . . . . . . . . . . 64 3.3.3 System Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 3.4 AUPBHFramework................................ 69 3.4.1 Introduction ............................... 69 3.4.2 Multi-Agent System Architecture . . . . . . . . . . . . . . . . . . . . . 71 3.4.3 Multi-Agent System Schema . . . . . . . . . . . . . . . . . . . . . . . 74 3.4.4 Conflicts Management . . . . . . . . . . . . . . . . . . . . . . . . . . 74 3.5 SystemDataPrivacy ............................... 78 3.5.1 Security and Privacy . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 3.5.2 AttackVectors .............................. 79 3.5.3 Secure Attack Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . 81 3.6 ImportantResults................................. 84 4 Usage Scenarios 87 4.1 Smart space definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 4.2 Evaluationscenarios ............................... 88 4.2.1 HomeScenario ............................. 88 4.2.2 WorkScenario.............................. 90 4.2.3 SystemActuators............................. 92 4.3 Evaluation methodology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 4.4 Resultsanalysis.................................. 95 4.4.1 HomeScenario ............................. 96 4.4.2 WorkScenario.............................. 99 4.5 Summary..................................... 102 xiv 5 Conclusions 105 5.1 Summary..................................... 105 5.2 Discussion and Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 5.3 Hypothesis validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 5.4 Contributions................................... 109 5.4.1 Direct contributions . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 5.4.2 Additional contributions . . . . . . . . . . . . . . . . . . . . . . . . . . 110 5.5 AcademicOutcomes ............................... 110 5.5.1 Related publications . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 5.5.2 Other publications . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 5.5.3 Scientific events participation . . . . . . . . . . . . . . . . . . . . . . . 113 5.5.4 Committees/Projects advisor . . . . . . . . . . . . . . . . . . . . . . . 114 5.6 Limitations.................................... 116 5.7 Future Research Directions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 Bibliography 119 Appendices A SQL Scripts 131 A.1 Create_DB_PhD ................................. 131 A.2 Insert_All_DB_Data.sql . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 B User Behaviour Simulation - Code 139 B.1 randomsClass.java ................................ 139 B.2 Generate_User_Simulation.java . . . . . . . . . . . . . . . . . . . . . . . . . . 141 C User Behaviour Simulation - Validation 161 C.1 Function_Test_ChiQ.R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 C.2 Function_Plot.R.................................. 164 D Local System - BLE 167 D.1 Start_BLE_RaspPI.js ............................... 167 E Data Layer - Web Services Server 173 E.1 Access.java.................................... 173 E.2 AccessManager.java ............................... 212 E.3 LocalSystemWS.java ............................... 220 E.4 PreferencesCardWS.java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230 E.5 UserWS.java ................................... 233 xv List of Figures 1 Overallscenario. ................................... 4 2 Contextualization of Time/Space Dimensions. . . . . . . . . . . . . . . . . . . . . . 5 3 User movement - Time/Space Dimensions. . . . . . . . . . . . . . . . . . . . . . . 5 4 The Internet of Things (IoT) evolution [49]........................ 10 5 The IoT evolution by category [49]. .......................... 10 6IoT Ecosystem [72]................................... 12 7IoT number of devices installed by Entity [72]...................... 12 8 Global Wearable Device Unit Shipments Forecast [72].................. 13 9 Smart Home adoption curve [72]............................ 14 10 Global Connected-Home device shipments by device category [72]............ 15 11 Most important factors and capabilities in an IoT platform [94].............. 15 12 Forecast: Global IoT device installation base (Billions) [94]................ 16 13 Forecast: Total IoT device annual installations (Billions) [94]............... 16 14 Forecast: Global IoT Investment (Billions ($)) [94].................... 16 15 Types of IoT solutions companies are using [94]..................... 17 16 Annual smart city investment (Billions ($)) [94]. .................... 17 17 Annual smart city data generated (Billions of terabytes) [94]............... 18 18 Amazon Echo line [9].................................. 21 19 Alexa controlled device types [9]. ........................... 21 20 Apple Homepod [11].................................. 21 21 Beacons example’s [125]................................ 22 22 Bluetooth Low Energy (BLE) example applications. . . . . . . . . . . . . . . . . . . . 24 23 Near Field Communication (NFC) example applications. . . . . . . . . . . . . . . . . 26 24 IEEE 802.11 (Wi-Fi) Direct example applications. . . . . . . . . . . . . . . . . . . . . 27 25 ZigBee network example [8]. ............................. 28 26 ZigBee example applications [8]. ........................... 28 xvii 27 Z-Wave example applications [77]............................ 29 28 Thread network [76]. ................................. 30 29 Thread border router [131]............................... 30 30 Apple Home Kit [123]. ................................ 32 31 Google Brillo and Weave [123]. ............................ 33 32 Smart home network topology [76]. .......................... 34 33 Geofencing....................................... 35 34 Ambient Intelligence (AmI) and contributing technologies. . . . . . . . . . . . . . . . 38 35 AmI agent interaction with the environment. . . . . . . . . . . . . . . . . . . . . . . 38 36 AmI characteristics................................... 39 37 AmI System - Use Case diagram. . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 38 AmI System - Communication process. . . . . . . . . . . . . . . . . . . . . . . . . 53 39 Detection and characterization of the user at the space. . . . . . . . . . . . . . . . . 54 40 Detection and characterization of the user in the environment. . . . . . . . . . . . . . 55 41 Preferences conflict management in the environment. . . . . . . . . . . . . . . . . . 56 42 Diagram - Users behaviour simulation workflow. . . . . . . . . . . . . . . . . . . . . 59 43 Histogram - User Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 44 Histogram - Time Delays. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 45 Raspberry. ...................................... 65 46 ZigBeeSensor. .................................... 65 47 Overall System Architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 48 Environment scenario. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 49 Smart environment functioning example. . . . . . . . . . . . . . . . . . . . . . . . 68 50 Example of the System in a environment. . . . . . . . . . . . . . . . . . . . . . . . 71 51 Multi Agent System (MAS) architecture. ........................ 72 52 MAS schema...................................... 74 53 Two agents constraints table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 54 AttackVectorA..................................... 80 55 AttackVectorB..................................... 80 56 AttackVectorC..................................... 81 57 AttackVectorD..................................... 81 58 System Privacy - Architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 59 System - First Utilization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 60 Home Scenario - Local System’s installation. . . . . . . . . . . . . . . . . . . . . . . 89 61 Work Scenario - Local System’s installation. . . . . . . . . . . . . . . . . . . . . . . 91 62 Thermostat desired temperature. . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 xviii 63 Thermostat current temperature. . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 64 Fancoilthermostat................................... 92 65 Smartbulb....................................... 93 66 Smartspeaker..................................... 93 67 Smartsecuritysystem. ................................ 93 68 Home Scenario - Global Average Satisfaction - 6 Months. . . . . . . . . . . . . . . . . 97 69 Home Scenario - Day Energy consumption (mean value). . . . . . . . . . . . . . . . . 100 70 Home Scenario - Energy consumption - 6 Months. . . . . . . . . . . . . . . . . . . . 101 71 Work Scenario - Global Average Satisfaction - 6 Months. . . . . . . . . . . . . . . . . 101 72 Work Scenario - Day Energy consumption (mean value). . . . . . . . . . . . . . . . . 102 73 Work Scenario - Energy consumption - 6 Months. . . . . . . . . . . . . . . . . . . . 103 xix List of Tables 1 Review Protocol criteria . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2 Wearables - Common sensor’s data [112]........................ 20 3AmI Projectsreview................................... 43 4 Parameters and different delays. . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 5 Randomnessfactor................................... 60 6 Parameters/Schedules................................. 60 7 Preference’s Card example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 8 System Information example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 9 System Preferences constraints example. . . . . . . . . . . . . . . . . . . . . . . . 66 10 User’s type/proportions - Home space. . . . . . . . . . . . . . . . . . . . . . . . . 76 11 User’s type/proportions - Work space. . . . . . . . . . . . . . . . . . . . . . . . . . 76 12 User’s type/proportions - Public/Social space. . . . . . . . . . . . . . . . . . . . . . 76 13 Example of preference value calculation - Home space. . . . . . . . . . . . . . . . . 77 14 Example of preference value calculation - Work space. . . . . . . . . . . . . . . . . . 77 15 Home Scenario - Users characterization. . . . . . . . . . . . . . . . . . . . . . . . . 89 16 Home Scenario - Local system’s characterization. . . . . . . . . . . . . . . . . . . . 89 17 Home Scenario - Total registered samples. . . . . . . . . . . . . . . . . . . . . . . . 90 18 Home Scenario - Local System’s registered samples. . . . . . . . . . . . . . . . . . . 90 19 Work Scenario - Users characterization. . . . . . . . . . . . . . . . . . . . . . . . . 90 20 Work Scenario - Local system’s characterization. . . . . . . . . . . . . . . . . . . . . 91 21 Work Scenario - Total registered samples. . . . . . . . . . . . . . . . . . . . . . . . 91 22 Work Scenario - Local System’s registered samples. . . . . . . . . . . . . . . . . . . 92 23 Satisfactionmetrics. ................................. 95 24 Home Scenario - Global Average Satisfaction - 6 Months. . . . . . . . . . . . . . . . . 96 25 Home Scenario - Temperature Average Satisfaction - 6 Months. . . . . . . . . . . . . . 96 xxi 1 Introduction This chapter starts with a subject overview, identifies the context and motivation, defines the problem, formulates the research hypothesis, the goals to be achieved are enumerated, and concludes with a document organization brief. 1.1 Overview We are on a new era of interaction between people and physical spaces. Users want that those spaces smartly adapt to their preferences in a transparent way. Considering this, managing comfort preference’s conflicts of the different users and spaces on an IoT adaptive system is an actual problem, and with several research already done. As shown in [3] there are new opportunities for research in the field of smart environments that should be explored. In particular the concepts of smart homes and home automation [1], currently in growing expansion in the scientific and research point of view, as the market demands for better solutions in this field. The aim is to take advantage of emerging technologies available in the market that support the denominated wearable devices [50] [54], and the non-invasive particularity of these to, in an autonomous way, adapt the environment to the comfort preferences of each user (e.g. thermal, acoustic, air quality, light, sun exposure). Provide comfort according to the preferences of each individual, is a challenge and an opportunity to create innovative solutions and new paradigms in the context of Intelligent Environments (IE) [13] [108]. User behaviour analysis in smart environments is performed mainly using data collected from the sensors dispersed throughout the environment [15] [17]. As concluded in [16], the perfect learning system for smart environments has not yet been found, and each new valuable contribution in this field puts us one step closer to the true concept of intelligent environments [38], more than ten years later, this statement is still current. It is also referred the need and the challenge of establishing a new effective paradigm for AmI, where the focus becomes the user and the ability to manage the complexity and richness of everyday human life [108] [16]. A recurring challenge in this field is the conflicts of interest management among the several users at the space [59] [116], that in this work was addressed through the use of MAS, as 1 CHAPTER 1. INTRODUCTION well user information and real-time data acquisition from different sensors [32] [73]. It will be possible, making use of technologies and emerging wearable devices available on the market (e.g. smartwatches, smartphones, fitness trackers) [59], to focus the data collection process on the user, always considering that it will be a non-invasive process. This will significantly leverage/enrich the decision-making process and overtake the physical limits so far imposed by the need of sensors statically placed in a space [37] [20]. After analyzing the state of the art, it can be pointed out the scientific innovation and contribution that this thesis can bring to this field: conceive and design new solutions and paradigms that contribute to turn into a reality the concept of IE. Besides the scientific contributions, this work produced relevant results with industrial application since it has been carried out jointly with an industrial partner. Prior to this proposal, this partner conducted several market and search studies. Concluding that the international market does not offer solutions with such intelligence level, user-oriented or based on non-intrusive techniques of data acquisition. There are products with some features implemented, but which always need the programming and configuration of the product by the user, are oriented to the spaces and not to the individual or do not have the capability of self adjustment using Artificial Intelligence (AI) to enable predictive capabilities and improvements in the product effectiveness in the decision-making process. Also at the industrial market, the big players like Amazon , Google , Tado , Honeywell , and others doesn’t have the kind of features proposed by this thesis. 1.2 Context and Motivation This Ph.D thesis has joint supervision of the Intelligent Systems Labs (Islab) , a research group integrated in the ALGORITMI Research Centre , coordinated by the supervisor Paulo Novais, and Polytechnic Institute of Bragança, represented by the supervisor Paulo Matos, and it is integrated in the applied research activities and technological development of Techwelf, Lda ., a company dedicated to Intelligent Environment solutions design, also represented by Paulo Matos. Thus, it is intended that this work, in addition to the scientific component, also has practical and applicable results by the company. There are few industrial applications in real context of this research, at the AmI field. It is intended that the resulting investigation of this thesis is implemented by the company involved, in the development of solutions for smart environments that it intends to place on the market. Having this thesis an element of industrial application, is important to consider the economic relevance of this market type, particularly in terms of size, value and growth potential, as stated by the largest global consulting firms forecasts (Gartner [6], McKinsey [87] and Business Insider [94]). As stated in section 2.2, a significant number of technological changes, as well new technologies introduction, has enabled the appearance and IoT evolution. This combined with the fact that such devices prices have come down drastically, placing sensors, processing power, bandwidth and more storage, available to more users and allowing a larger number of IoT appliances. These numbers are transversal to 2 1.3. PROBLEM DEFINITION several application fields, and the common factor is mainly its exponential growth expected in the coming years. There is also the personal motivation to deal with the challenges identified in the AmI field referred in section 1.1, and presented in detail later at section 2.3.1. Particularly in what concerns to privacy, security, and management of multiple users in the same environment. 1.3 Problem definition The problem/challenge, need or, on the economic perspective, opportunity, which aims to overcome, can be defined in general terms as a contribute to create intelligent environments capable of adapting to the users comfort needs/preferences, in an automatic, transparent and non-invasive way, whether these environments are for domestic, professional or public use. In addition, and although the focus is always on people, it is always important yo enhance the optimization of other aspects, such as the resources efficient management, the ecological footprint reduction, and others. This challenge relatively to users, currently has as main difficulty the people mobility and the disparity of habits, schedules and every individual comfort preferences. The same is aggravated by physiological conditions, derived from a large number of factors (tiredness, mood, etc.), impacting the user preferences, in such way that current systems cannot measure. Contextualize user preferences, is a process involving many variables and different dimensions, which makes this a high complexity problem. In addition to the physiological conditions mentioned above, there are two critical and essential dimensions, these are the space (user location) and the time (day period). The spatial dimension introduces challenges associated with the user versus space relationship, whether in the generic concept of space or by type of space: personal, professional, public/social or other. Contextualize the user location is essential to optimize the comfort conditions and contribute to the performance and solution effectiveness. The time dimension is equally critical, because the comfort preferences will change over the day course, as well the week or even the year. For example, the comfort preferences may be different between daytime and night-time, or between weekday and weekend/holidays. Namely it is know that the temperature in the human comfort context depends of different physiologically conditions, like mood, stress, anxiety, as well the physical conditions of each user. In this dimension, it is also important to assess the changes over the year, that will have the seasons influence, which naturally also change user’s comfort preferences, because it has to be considered not only the effective temperature, but also the thermal sensation, that naturally it will also have influence. In this paradigm, which is intended to be the comfort superlative, there are at least these three dimensions: time, space and user comfort preferences. The time and space dimensions are critical to contextualize the user’s personal preferences, and provide the necessary information that will allow assess future preferences in a useful time. 3 CHAPTER 1. INTRODUCTION It should be noted that Heating, Ventilating and Air Conditioning (HVAC) systems that promote comfort have different operation latencies (inertia). Early forecast of user presence and respective comfort preferences allows to surpass this latency, namely starting its functioning in due time, to achieve the desired comfort conditions. The same solution also allows to optimize energy savings associated with such equipment, since it allows to forecast when the systems may be disabled or placed to operate more efficiently. This savings can be defined in several aspects such as energy, maintenance, useful life period, etc. And these are the main problem issues, of course there are accessory issues, such as the management of more than one user in the same space, among others that naturally arised and had to be addressed. Figure 1shows the scenario of an environment around which the present work was developed. Explaining this figure, it can be seen the user, that do the necessary input information to the system, namely the parameters that different actuators need, to do its function. Next, the local system must perform the synchronization and information share. Following, the system must perform the different environment components (climatization systems, security systems, other smart systems) management. Figure 1: Overall scenario. This scenario represents an environment at a given location and at a given point in time. As mentioned above, for a proper solution that fits all users, it is necessary to consider the user mobility. This implies considering the time and space dimensions [99]. As such, for a better understanding of the overall scenario in the user’s daily life, figure 2contextualizes the temporal and space dimensions present in this problem and already mentioned above. We can see that different user locations, combined with time context, naturally results in an environment with different characteristics. This kind of global scenario is also addressed in this thesis [100]. Like is represented at Figure 2, user moves between different spaces during the time. Also for a better understanding, of this problem aspect, at Figure 3is represented the movement of two users, and we can see how different the schedules and habits of each one are. 4 1.4. RESEARCH HYPOTHESIS Figure 2: Contextualization of Time/Space Dimensions. Figure 3: User movement - Time/Space Dimensions. 1.4 Research hypothesis Considering the AmI field and this Ph.D. thesis scope, it is possible to evidence that there are different issues to be addressed. The comfort preference’s management currently have different obstacles as well as a diverse number of specificities. Thus, the following questions elucidation it is intended to approach the research problem: • How can we characterize an environment ? • How human comfort is defined ? 5 CHAPTER 1. INTRODUCTION • What are the human preference’s set ? • Can we automatically detect user preference’s ? • Is it possible to solve/minimize user comfort preference´s conflicts ? • Can human comfort be measured ? Considering all this questions, they have been materialized and define the proposed research hypothesis as: A Smart space as a transparent, non-intrusive and safe solution to guarantee the satisfaction and comfort of users according to their preferences and routines . 1.5 Objectives Considering the problem definition, and the research hypothesis already detailed, the aim of this thesis is to create an architecture that takes advantage of emerging technologies that support wearable devices (e.g. smartwatches, smartphones, fitness trackers) and the non-invasive characteristic of these, for collecting data in an autonomous and transparent way without user intervention. And with that information, assist the comfort system decision-making processes to adapt the environment to suit each user’s comfort preferences (e.g. thermal, acoustic, air quality, lighting, sun exposure). Specifically this thesis aims to achieve the following goals: • Characterize different types of environments (AmI); • Characterize comfort in its different aspects and dimensions; • Set a base architecture for a non-invasive system that takes advantage of different technologies (smartwatches, smartphones, fitness trackers), that facilitate user’s interaction with existing systems [22]; • Represent different stakeholders, contexts and problem dimensions, who cooperate to achieve the optimal solution [21]; • Manage the possible conflicts of interest, namely between users at the same space [90]; • Develop solutions that allow ubiquity in users identification and their comfort preferences, in an automatic and transparent way, enhancing the integration between space, time and user; • Apply the proposed architecture at a health facility and/or a higher education institution, taking advantage of the existing company’s partnerships; • Evaluate the architecture using real/simulated conflict management problems, between distinct users that share the same space. 6 1.6. RESEARCH METHODOLOGY 1.6 Research methodology Even with some literature works discussing if Computer Science (CS) is really a science or an engineering, according to Hassani [63], researches on this field can have theoretical or experimental nature or even both of them. Besides that, just like in other study fields, CS researches may use quantitative or qualitative methods. To ensure that research is validated as reliable and relevant, both academically and in society, it must demonstrate rigorous development and be susceptible to discussion and confirmation. This is why a robust research method is imperative to the success of any study. Design Science Research (DSR) is a theory that investigates the knowledge generation in the designing artifacts process, that is, how design methods can constitute research of a scientific nature [66]. It has its origins in engineering and the sciences of the artificial, is based on a problem-solving paradigm and aims to create innovations that define the ideas, practices, technical capabilities and products through which the analysis, design, implementation, management and use of information systems can be effectively and efficiently realized [124] [65] [104]. The DSR aims to raise research performance in Information Systems (IS) through a concise and conceptual framework, execute and evaluate the research. This methodology was selected for adoption to solve this problem, as it was understood to be the most appropriate for the objectives to be achieved in order to solve the proposed problem, and to answer the research hypothesis indicated at section 1.4. The DSR methodology will be applied in the development of this thesis, in order to develop artifacts to solve the proposed problem, namely the full architecture necessary to support the resolution, as well as the MAS development. This artifacts will depend on the different objectives analysis identified at section 1.5. With this artifact development, it is understood that the proposed objectives are achieved and a solution is given to the presented problem. Review Protocol To start the review protocol development, the search string was defined through several iterations to find the most relevant articles related to the topic. Therefore, the search string used was as follows: (“Ambient Intelligence” OR “AmI” OR “smart-spaces”) AND (“comfort” OR “comfort preferences”) AND (“Multi-Agents” OR “MAS” OR “agents”) . For applying the search string, the following data sources were defined: IEEE Digital Library , ACM Digital Library , Google Scholar , Scopus and Springer Link . After the inclusion and exclusion criteria are defined, to filter the obtained papers set. The used criteria are show at table 1. With the different criteria defined, the online tool Parsif.al 1was then used to continue the Systematic Literature Review (SLR). 1https://parsif.al/ 7 CHAPTER 1. INTRODUCTION Inclusion Exclusion Scientific papers Only after 2010 Partial documents Full technical No access Less than 5 citations Table 1: Review Protocol criteria Using the search string, 4880 articles were initially found, and after applying the different criteria, the results went down to 820 articles. After using the final criterion of more than 5 citations, it was reduced to 52 articles. The protocol review is defined as follow: 1. Search at Data Sources using the search string defined before; 2. Results filter using inclusion and exclusion criteria; 3. Read Abstracts and Conclusions; 4. Read Full Papers; 5. Definition of final papers set. 1.7 Thesis organization This document is organized into five main chapters. In chapter 1, an introduction is performed, and further the problem definition, the objectives and is presented the research hypothesis and methodology that motivates this doctoral thesis development. Chapter 2describes the state of the art at field, both in terms of scientific practices, such as emerging technologies, as well its economic viability. Chapter 3describes the developed work and the approach proposed for the implementation, since the general requirements, architecture, detailed description, and other developed work such the user behaviour simulation, MAS and system data privacy. At chapter 4are defined and characterized the usage scenarios, the evaluation methodology, and a result analysis is also performed. This thesis is concluded at chapter 5, with some summary and final considerations, the conclusions discussion, hypothesis validation, contribution of this work, the limitations and some future research directions are also pointed out. 8 2 Smart Spaces This chapter start with a state of the art review, continues with the support concepts and technologies detail, do a extensive detail of AmI field and finalizes with the user in a smart space concept specification. 2.1 State of the Art This section presents a literature survey in the areas related to the problem under study. It begins with the approach to the IoT topic, moving to the devices analysis, communication technologies and platforms, that are relevant for this thesis. Ending with the survey, description and review of the more relevant projects in the field of smart environments, and in this thesis context. 2.2 Support Concepts and Technologies It’s already been pointed out, as the next industrial revolution that will change the way businesses, governments and consumers interact with the physical world. This is the Internet of Things, commonly called IoT. There are already studies that analyze the growth and the IoT ecosystem, which allows entities (consumers, businesses and governments) connect and control their IoT devices in different scenarios. The idea of IoT has emerged more than a decade in the Massachusetts Institute of Technology (MIT) laboratories [85]. Initially, the use of IoT was associated with Radio-Frequency Identification (RFID) technology and its application in tracking products in supply chains [54]. But the IoT has evolved from the approach based on RFID technology, for a vision that encompasses the IoT as a society where a diversity of different objects are connected ubiquitously [54]. The Internet Business Solutions Group (IBSG) at Cisco , reinforces this view by claiming that the IoT is the moment that more things than people are connected to the Internet. This connection is achieved by the incorporation of small sensors in a wide variety of objects, which enables that these objects with power processing and unique identifier may be connected to the Internet [120]. Going further, the IoT, not only lets things communicate with each other, but also creates new ways for people to communicate with things [20]. 9 CHAPTER 2. SMART SPACES now estimated to the year 2024. Figure 12: Forecast: Global IoT device installation base (Billions) [94]. Related to the installed devices annual increase, we can analyze the figure 13, and see that the peak is expected to be at 2022 and 2023 with 8 billions of IoT devices installation, and this will slowly decreasing to close to 7.5 billions of IoT devices at 2026. Figure 13: Forecast: Total IoT device annual installations (Billions) [94]. That’s because the number of devices growth will be fueled by falling device costs on both an upfront and continuing basis. Overall, the forecast at figure 14 points that, companies and consumers will spend almost 15 trillion of dollars on IoT devices, solutions, and supporting systems from 2018 through 2026, with the annual investment surpassing 1 trillion of dollars in 2021, and 1.5 trillion of dollars in 2022. Figure 14: Forecast: Global IoT Investment (Billions ($)) [94]. 16 2.2. SUPPORT CONCEPTS AND TECHNOLOGIES Analyzing IoT solutions types that companies are using in figure 15, we highlight above all remote monitoring, which is utilized by 62% of respondent. Remote monitoring devices provide a wealth of data on assets and equipment that can be leveraged to follow utilization and trends, ensure proper procedures are being followed, and enable large-scale analysis to increase efficiency and engage in useful practices like predictive maintenance. And similarly, 43% of respondents say their companies use IoT devices for asset tracking. Many firms use IoT devices to gain visibility throughout their supply chains or to enable better tracking of shipped goods. These simple IoT devices can provide critical data to streamline operations and identify potential issues or bottlenecks. Figure 15: Types of IoT solutions companies are using [94]. Regarding the smart cities topic, in figures 16, investment in this field can be analyzed. In 2018, two primary types of smart city solution providers emerged telecoms and tech giants, and they promise to define the market moving forward. The main types of companies involved in working with cities and public-private partnerships to implement smart city programs are telecoms, and technology giants. So far, telecoms have been far more successful in putting solutions into place, and generating results [94]. Figure 16: Annual smart city investment (Billions ($)) [94]. 17 CHAPTER 2. SMART SPACES Also at figure 17 the information generated in billions of terabytes can be analyzed, with a estimation that smart city systems will generate nearly 180 billion terabytes of data each year by 2023. Figure 17: Annual smart city data generated (Billions of terabytes) [94]. 2.2.2 Device Types Following the different device types that can be accommodated by this thesis, are fully detailed, and explained his viability to the use on this thesis. Smartphones The ongoing technological revolution has also contributed to the mobile devices massification with more features, storage capacity and data processing. Currently these devices are called ”smartphones”, derived from the characteristics indicated above. Despite its massification, it was not long ago that the technology arrived to the general public. With its advanced computing capabilities and other features, smartphones have quickly gained popularity. Before the smartphones invention, there were several devices that were used, including traditional mobile phones, and Personal Digital Assistants (PDA) devices. Continuously, the technology was combined and the concept of smartphone was born. The first prototype comes in 1992 with the name of Simon , by IBM [110] having features such as PDA and fax, touch screen and other more advanced. Ten years later, it was time for the Kyocera company launched on the market the QCP 6035 model, the first to combine phone and computer functions. The operating system was the Palm OS and had internet connection [35]. Second part of nineteen decade, many mobile phone users have started using PDA. Initial PDA performed different systems such as Blackberry OS and Palm OS . Nokia launched a phone combined with a PDA in 1996. The device was called Nokia 9000 [110]. This manufacturer, turned out to spread the smartphones use worldwide. However, the real revolution came in 2007, with the Apple’s smartphone introduction and, later in 2008, the Android system smartphones introduction by Google . Currently these two systems represent 96.3% of the global smartphone market [71]. 18 2.2. SUPPORT CONCEPTS AND TECHNOLOGIES Related to that fact, this thesis is intended to be compatible with those two platforms, and thus achieve a high potential users market share. These devices have mostly one or more communication technologies, identified in the section 2.2.3, allowing full compatibility with the proposed system. As shown in figure 1, the smartphone will be one of the possibilities which user can interact with the system as input device. Other kind of possibilities provided are demonstrated below. Wearables As noted above, wearables are still in mass adoption process, however, as a less invasive device that the phone, and assumed that always be in user possession. It is also the type of device most used in this thesis context. This will allow the user mobility, without using invasive processes, such as using a specific device, or some type of manual querying to the user. Because, as it is known in many user’s daily activities (sports, leisure, hygiene, others), they are carried out without the smartphone presence. However, it is assumed that wearable is most of the time in user possession, enabling a ubiquitous interaction with the system. These devices are currently on the market in diverse ways, from watches, necklaces, bracelets, and even jewelry. What will covers almost all users and situation types. Concerning that, sensors present in wearables, and data that they allow to acquire, has also been increasing. Since the sensors miniaturization and integration process in the wearables will allow it. Currently, the most common data that these devices collect is listed in the table 2. In a brief table description, we find different sensor types, which collect several data, important and necessary for the systems optimization process. Pedometer is currently the most common sensor. It is present in most equipment’s, including newer smartphones, and it collects user steps number. Another sensor that has become common, from most practical data acquisition forms, is the heartbeat, and it is currently in several fitness bracelets and smartwatches. We also have less common sensors, which some are already present in wearables available at domestic market, like Electrocardiogram (ECG). However some are already in industrial market, while others are still in development, and scheduled for market introduction in near future. Examples of such sensors, are Electroencephalography (EEG) for brain activity analysis, Electromyography (EMG) sensor for muscle activity and Photoplethysmogram (PPG) to blood volumetric measurement. The Peripheral Oxygen Saturation (SpO2) sensor to analyze oxygen saturation, needle biosensor to analyze glucose level, body temperature sensor and sweat sensor [119] are already implemented in medical devices for private use, and some state of the art smartwatches. It is also expected that the continuous sensors miniaturization allow to introduce them in smaller and domestic use wearables. Portable biosensors design and development, allow them to be integrated into wearables for different physiological indicators monitoring, and has caught the scientific community and industry attention in recent years [103]. The main reason for this fact, is health care costs rising as well recent technological advances, that allow to achieve device miniaturization including bio-sensors, and smart textiles development that integrate these devices in user clothes. With this kind of devices, users can do some health 19 CHAPTER 2. SMART SPACES Sensor Data Example Units Pedometer Steps counting 1000 Integer EMG Muscle activity walking 90 ms EEG Brain activity signals 90 ms ECG Electrical activity of heart signals 90 ms PPG Volumetric blood measurement 15 mmHg SpO2 Oxygen saturation 98 % Bio-sensor needle Blood Glucose level 5 mmol/L Heart Rate Number of hearth contractions 80 bpm Temperature Body temperature 36 ºC or ºF Sweat Skin water evaporation rate 25 g/min.m2 Table 2: Wearables - Common sensor’s data [112]. care monitoring, at his own home, and with its own devices, without need to pay a much higher cost at health care units. Also micro-electronics development, particularly in wireless communications, and systems based on wearable sensors, can transform health care, enabling proactive people management involved in health care and status of patients ubiquitous monitoring. Such systems may include different physiological sensor types, transmission and processing modules, enabling the creation of mobile, discrete and cost effective solutions. Enabling continuously monitoring of different and relevant activity parameters for health, throughout the user’s daily life and independent from where they are. Due to all these features, wearables will also be used for interaction with the proposed system. Smart Speakers Nowadays we find in the market several intelligent speakers options. Namely all major manufacturers, such as Apple , Google and Amazon , have developed products in this line. Taking advantage of this product line and his software for great innovations in home automation, especially voice control of all smart peripherals available at user’s home. Some of these devices also have integrated displays, thus allowing user feedback, as well viewing information from peripheral such as security devices. Amazon has the Echo product line, which allows the Amazon’s cloud-based voice service be available on tens of millions Amazon devices and third-party device manufacturers. With Alexa , we can create natural voice experiences that offer a more intuitive way to interact with technology that is used everyday. Namely with device control and automation like cameras, lights, TV’s and others, as shown in figure 18 and 19. Apple has the Homepod available, which in addition to being a speaker, allows integration with the so called Apple Home Kit detailed in subsection 2.2.4, thus allowing interconnection with the remaining interconnected devices, as well control with voice instructions. In this sense too, these peripherals can be integrated into this thesis, as these devices usually exist in 20 2.2. SUPPORT CONCEPTS AND TECHNOLOGIES Figure 18: Amazon Echo line [9]. Figure 19: Alexa controlled device types [9]. Figure 20: Apple Homepod [11]. different house spaces, for musical reproduction. Thus, they can be used to user detection and interact with the different performance systems available in the home automation system. Beacons Beacons , also known as iBeacons , is a more friendly name for ”indoor proximity system” technology. In practice, it allows to locate objects or people carrying these, with high accuracy in closed areas. Making a parallel, Beacons are for indoors, as Global Positioning System (GPS) is for outdoor environments. Because of steel structures and other factors construction derived of enclosed spaces, it is natural that GPS signal is weak when users are inside this kind of spaces. In these cases, Beacons are a great solution: being relatively inexpensive hardware, and fairly small size to be installed on wall or a shop terminal. Because it is a technology very precise and applicable on a large scale (low cost), they have been used in Point of Sale (POS) processing, events, transit systems, corporate buildings, institutions, 21 CHAPTER 2. SMART SPACES schools, public spaces, as well private residences. Beacon operation method, uses BLE to detect other devices proximity and transmit a unique identifier number which is then received by the device operating system with which it is communicating. After establish the communication, two actions can be taken by the system, namely: • Passive action , is simply to save (in local memory or in database) the connection existence. For example, the smartphone X approached the sensor Y. In practice this means that a given space user just passed the location where the Beacon is installed. • Active action , happens when communication starts some activity on the user’s device. Sending notifications, system status change, or start an action within a specific application, are some of the possible activities. As an example, the case of receiving a notification for a particular sale within a retail space. All this is managed by the users smartphone. It is important to note that smartphone never sends user data to the Beacon , unless the user explicitly allows, to avoid privacy and security problems. Beacons do not have the ability to detect geographic locations. Only allowing that the smartphone can known the distance between it and the beacon. For other location is necessary to use complementary technologies, such as GPS, Geofencing, or Wireless (WIFI) networks. Beacons have interoperability between (iPhone OS (iOS), Android , Windows , etc.) platforms. Requiring only that devices have Bluetooth 4.0 or higher. Beacons do not have any kind of intelligence. Being in this case, all necessary intelligence in the application installed on the device that interacts with Beacon . Applications to interact with Beacons must be previously installed on the devices because Beacons cannot install any application on the device. In figure 21, are some Beacons examples, currently present on the market. Figure 21: Beacons example’s [125]. 2.2.3 Communication level Related to communication technologies, for this thesis are explored and detailed BLE,NFC,Wi-Fi Direct, Zigbee, Z-Wave, and also Thread, all of them are following detailed. Bluetooth Low Energy Bluetooth Low Energy (BLE) is an extension of Bluetooth 4.0 standard. It was introduced by the Special Interest Group (SIG) in late 2009 and is optimized specifically for devices that use small batteries 22 2.2. SUPPORT CONCEPTS AND TECHNOLOGIES and require a very small consumption [81]. Devices that support BLE communications are certified as Bluetooth Smart Devices at SIG. They operate in the same Industrial, Scientific and Medical Radio Bands (ISM) than traditional Bluetooth devices, which is divided into 40 channels: 3 for advertising process and 37 for data communication. It will be a standard for new decade that will support the called IoT. A major advantage over traditional Bluetooth is a very reduced consumption, which is achieved by the device search simplification and connection procedures and activity window reduction, typically by sending only small data packets for a few seconds and entering standby mode rest of the time. At the connection beginning, the client device synchronizes its clock with server device and so it just need to wake up periodically to send data. The time between packet exchange sequence start is called connection interval. Data packets are usually much smaller than traditional Bluetooth packets, the maximum size of a BLE packet is 2971 bits. They are transmitted at 1 Mbit/s through the air, allowing an active transmit window of only a few microseconds [47]. To optimize power consumption, BLE data transfer speed is of 0.26 Mbit/s compared to 0.7 and 2.1 Mbit/s of the traditional Bluetooth, which is not critical for most applications/users. It is designed to send small data pieces (state exposure). Data can be made available by local events and be customer read at any time. The interface model is simple Generic Attributes (GATT). Another important limitation of this is coverage radius to be a maximum of 50 meters (with 10 meters limitation for good signal quality in normal working environments such as offices), half of the maximum allowed by the traditional Bluetooth 4.0 [25]. The device server is responsible for establishing the network connection, the client device on the other hand is constantly waiting at advertising mode in order to receive discovery requests. To establish a connection between two or more devices, server device must send a discovery message, which is broadcast sent to all devices within range, repeatedly going through all Bluetooth frequencies. Client devices with active discovery mode, listen to discover messages in the frequency with which they are assigned and, when they receive this kind of messages, send a response to the server device, containing its address and class, as well additional data that may be requested. Device server can then automatically or by user’s selection, send a connection request for the specified client device, if this one is configured to accept connection requests, it will reply with a response. Otherwise will refuse connection attempt [70]. After the server device receives a positive connection response, the connection is successfully established, on both sides. Last version is the Bluetooth 5.3 specification, and it was presented by the Bluetooth SIG in July 2021 and aim, among other goals, to make the technology more suitable for applications based on the IoT, such as smart speakers or lamps, as well wearables, such as smart watches or bracelets. To this end, Bluetooth 5.3 has a connection subtracting mode that allows a device to move from a high to low performance state and vice versa more quickly, contributing to energy savings. This is useful, for instance, for a smartwatch that transmits data to a smartphone: once that data has been sent, the device can more quickly switch back to a reduced work mode to save battery life. 23 CHAPTER 2. SMART SPACES The new version also introduces a channel rating enhancement. To reduce the risk of interference, the Bluetooth frequency range is divided into several channels. Those that are congested or noisy are classified as ”bad” to be avoided during communication. In previous technology versions, this channel classification is established only by the main communication device. In Bluetooth 5.3, both the main device and the peripheral (the one with which the main communicates) participate in the channel classification process. Thus, the accuracy on the channels to be avoided increases, making the connection more stable. Another novelty of Bluetooth 5.3 that contributes to energy savings and, in addition, can improve connection efficiency, is the introduction of the AdvDataInfo (ADI) parameter in advertising packages (remembering, the way the device transmits a signal to warn that is available for connection). Figure 22, illustrates some of the most common application examples of BLE technology. Figure 22: BLE example applications. Near Field Communication Near Field Communication (NFC), is a wireless communication technology, Japan is one of the NFC adoption pioneers, and the technology as taken shape in 2002 by Philips and Sony hands. From beginning, the idea was to use the technology on mobile devices, mobile phones, digital cameras, laptops, etc [136]. At the time, the two companies were determined to promote the NFC, which is why they presented its specification to Standards organization for information and communication systems (ECMA), an organization responsible for the standards of communication and information systems. In 2003, the technology was recognized by the standard ISO/IEC 18092 . However, the NFC only began to heat up in mid 2004, when the NFC Forum was created, an organization that gathers now about 150 companies interested in the development and use of applications based on NFC. Among them, are: Google , PayPal , RIM , LG , American Express , Nokia , Samsung , Intel , NEC , Visa , Huawei and Qualcomm . Note that NFC is in some way based on RFID, a more consolidated technology that enables, as the name implies, radio frequency identification applications. But since there are so many options for this purpose, such as WIFI and BLE, the advantage of its adoption in relation to others, can be seen, not so much by what technology does, but mainly how it does. In a few words, the NFC is a specification that allows wireless communication between two devices through a simple approach between them, without the need to enter passwords, click buttons, or take 24 2.2. SUPPORT CONCEPTS AND TECHNOLOGIES any action to establish the communication. So long as the devices are close enough, the communication is automatically established and the corresponding action taken. These devices can be mobile phones, tablets, ID cards, electronic tickets and any other item capable of support the installation of a NFC chip [41]. The distance that the devices must be with each other to establish a connection, is really short (the maximum is about 10 centimeters), to make clear the intention of communication, without that it can happen accidentally. A range so limited, should not be seen as a disadvantage, but a security requirement. The NFC technology is designed to allow communication between two devices and no more than that. The principle is simple: one plays the role of initiator, having the task of starting the communication and control the exchange of information. The other plays the Target role, and should respond to the Initiator requests. Communication is established using radio frequency, from 13.56 MHz, with data transmission speeds ranging between 106, 212 and 424 kb/s (kilobits per second). Transmission can occur in two ways: • Passive : in this mode, only one of the devices (usually the initiator) produces the connection RF signal. The second device is only powered by it. This makes it possible to put NFC tags on items that do not receive direct power supply, such as cards, packaging and posters. • Active : in this mode, both devices produce the radio signal. It is for example, the mode used in payment systems involving a smartphone and a receiver in the stores payment terminal. We must also consider that there are three operating modes, which together increase the usage possibilities: • Reading and writing : based on the passive communication, allows reading or modifying data on a NFC device such as a receiver that discounts existing credits in a travel pass. • Peer-to-peer : it is a method for bidirectional exchange of information between the two devices, each can send or receive data to the other. It may be useful, for example, for exchanging files between two mobile phones. • Card emulation : in this mode, the NFC device behaves/works and is seen as a smart card. NFC technology may be used in a wide number of applications, including most critical applications involving confidential user data. An example can be seen in the Google Wallet service [57], which enables the user to pay the bills using a smartphone with Android operating system (mobile payment) instead of the traditional credit card or cash. The process is quite simple: the user approaches his smartphone to a receiver, which may be at the cash register of the shopping center, and should both devices have an NFC chip. Once communication is established (about a few seconds), the terminal receives the process 25 CHAPTER 2. SMART SPACES is possible to have a number of intelligent devices (lamps, alarms, etc.) from multiple manufacturers, that are able to communicate and work together. This framework directly supports BLE and Wi-Fi as communication technologies. Other technologies such as Z-Wave or ZigBee are supported indirectly by using bridges [92]. One of the biggest advantages of this framework, is the possibility of use voice control, derived from the integration with Siri technology. Real automation, requires voice and gesture control, avoiding the use of smartphones and associated applications in the interaction with the devices. The interaction is much easier and natural using voice commands, for example, through a smart watch. Other features that distinguish HomeKit of competitor alternatives, will be described below. Apple bet on two main technologies for communication with smart devices, these being the BLE and Wi-Fi. This position is justified by the attempt to create a consolidated standard of communication, and so dispense the use of hubs (bridges), that competition uses to support other communication protocols ( ZigBee , Z-Wave ) [134]. Additionally, this allows most of the communication processes to be transmitted locally and specifically to the devices, when the control is performed within the local network of housing. Rather, other hubs on the market, which typically commands passing first through the cloud and then sent to the local hub and then to the specific device. In this case, there is no dependence of the cloud, for operation and control of internal devices. In short, this solution demonstrates how Apple using communication standards, enables the unification of devices using the existing smartphone, and the network connection present in the house. This avoids the necessity of additional costs and difficulties for the user with more devices. Having the role of central point, passed to the smartphone. Please note, that in this case the cloud is also available, and can also make up a central point if the developers opt for it. The cloud is currently used to centralize information from all devices connected to the home, with all the mobile devices that the user own. Having this the role of synchronize all data between devices, keeping these always with the most current information. Figure 30, illustrates the presentation of HomeKit by Apple during the conference Worldwide Developers Conference (WWDC) on 2014. Figure 30: Apple Home Kit [123]. 32 2.2. SUPPORT CONCEPTS AND TECHNOLOGIES Android Things/Google Brillo In early 2015, at the Google I/O conference organized by this multinational, was presented the Brillo and Weave , the proposed solution of this company for the interconnection of smart devices. Brillo is an operating system derived from Android but adjusted for IoT devices. It supports WIFI and BLE. The Brillo system promotes the connectivity of the various devices so that they are able to communicate through a common language. Allowing the connection of devices through the user’s phone, so that it can control devices such as thermostats, alarm, etc. Brillo also allows the management and storage of data collected from the sensors, and is designed to run on connected devices with few hardware resources (memory and low-frequency processors). According to Google , beyond WIFI and BLE technology, Brillo has minimal system requirements (32 MB RAM). This emphasis on low power consumption ensures that the appliances and devices, such as door locks, can also connect to the system. Brillo brings simplicity and speed of software development for hardware, providing a lightweight operating system based on Android , central services, a development kit, and a developer console. Can be chosen a variety of hardware features and customization options, and quickly move from prototype to production and make a scale management with updates Over the Air (OTA), metrics, and reports. On the other hand, Weave is a multi-platform common language that will allows Brillo devices, smartphones, and the Internet to communicate with each others. Existing Android devices will be able to automatically detect Brillo devices. The Weave uses a common language that allows sensors and platform devices to communicate through a simplified process using the Cloud. This solves the fragmentation problem that currently exists in home automation, allowing connected devices to communicate in several ways, as well using different software. In Figure 31, can be seen the operation envisaged between the different devices that can integrate this platform. Figure 31: Google Brillo and Weave [123]. Recently, Google announced its new IoT initiative based on Android , the Aptly named Android Things . It was back in May 2015 that Google announced Project Brillo as its IoT operating system, having looked at the feedback it received from developers about Brillo , Google decided to ditch it and create Android 33 CHAPTER 2. SMART SPACES Things . By adding Android to the name, Google is emphasizing that developers are able to use familiar Android Software Development Kit (SDK),Application Programming Interface (API) and services including the Google Cloud Platform . Android Things is only a preview at the moment, however enough of the final operating system is working so that developers can start creating Android Things based projects. Matter Matter started life in 2019 as Connected Home over IP (CHIP) project, a collaboration between some of the biggest players in tech: Apple , Google , Amazon , Samsung , the ZigBee Alliance , and other tech brands, which aimed to create a unified smart home standard. The idea was that this would make it easier for manufacturers to develop products that work both with all three major voice assistants and also each other. At May 2021, the name was changed to Matter , while the ZigBee Alliance was rebranded as the Connectivity Standards Alliance (CSA). Rather than introducing any entirely new technology, which would slightly defeat the object of being a unifying force, Matter uses only existing standards: Ethernet, Wi-Fi,BLE for initial pairing, and Thread . As well making things simpler and improving interoperability, Matter also wants to make smart home more reliable and secure, and the inclusion of Thread will be key to that. The list of devices that Matter will cover is pretty exhaustive, lighting and electrics, heating and cooling, locks and security devices, windows and blinds, and TV’s are all included. And the line-up of alliance members and participants includes more than 240. In short, it should have the whole smart home covered. At figure 32 we can see a smart home network topology composed by different Thread devices and Matter controllers. Figure 32: Smart home network topology [76]. 34 2.2. SUPPORT CONCEPTS AND TECHNOLOGIES Geofencing Geofencing makes use of technologies such as RFID,GPS, cell phone antennas and even Wi-Fi signals to establish a virtual geographic perimeter. From this, it is possible to configure notifications triggering via push, Short Message Service (SMS), advertising on social networks or several other types of alerts or commands for devices that cross this perimeter, based on their geolocation. At first it may seem simple, with limited functions, but the possibilities for using this technology are very wide. That is why it is so important to understand what geofencing is and how it can contribute to improving the functioning of companies. Geofencing is a way to engage consumers based on hyper localization, and it can do a lot in terms of triggering immediate sales, as well understanding the buyer’s mindset. For example, a store could standing up a simple geofence in an area that surrounds its physical location. When users pass, they receive an alert or agreement triggered by location making them considerably more likely to stop and buy. Alternatively, a car dealer, for example, could set up a geolocation designed to target individuals who are leaving a rival dealership after looking for a vehicle. Hitting them with a zero percent financing offer on a comparable car model at that time is more likely to make them come to the comparison shop, or at least consider an alternative option. Finally, even if a geofenced offer or notification does not trigger an immediate visit or sale, it does allow a company to know exactly where a consumer went, and where they were when they received the message, which can help with refining to target efforts future based on which communications were most successful. Figure 33: Geofencing. Smart Cities Currently, the world’s main cities struggle to become more innovative spaces through Information and Communications Technology (ICT). Its use not only implies improvements in the provision of services, but also paves the way to transform our cities into true smart cities. To be classified as a “smart city”, it is not enough to be sustainable in just one area. The implementation of new technologies, the participation of citizens in public life, the search for efficiency in the management of available resources, increasing the citizens and visitors quality of life, are some of the characteristics that make a city smarter. 35 CHAPTER 2. SMART SPACES We can say that the smart cities evolution is on the rise, causing more and more cities to enter this plan. However, those that are not, already know what a smart city is and what benefits it can bring to both citizens and institutions. The European Union defines Smart Cities, as a set of systems and people that interact intelligently, using energy, materials, services and resources in a sustainable way. We can say that it is a kind of fusion between people and systems that move in harmony, seeking to guarantee the urban spaces sustainable development. Basically, smart cities are those that invest in technology to improve municipal management and provide their citizens with a better quality of life and spaces sustainability. When we talk about smart cities, we are referring to those cities where an optimized functioning of all administrations, whether public or private, in topics involving urban planning, sustainable and inclusive cities, the environment, and many others, has been incorporated, always with the objective of satisfying citizens and institutions. When we talk about the smart cities characteristics, we can mention the following: • Efficient urban planning; • Environmental sustainability improvement; • Technologies applied to education and health; • E-commerce system; • Shared data (open data). Also, as main smart cities benefits, we can identify the following: •IoT close relationship; • Improves citizens relationship; • Environment protection; • Mobility improvement; • More liveable cities. Also in Portugal, more and more municipalities are attentive to technological innovations capable of building smart cities, promoting a healthy lifestyle, responsible use of public spaces, sustainable development and a growing quality of life. The percentages give substance to this idea. Today, more than half of the world’s population lives in large urban centers and the trend, according to the United Nations (UN), is to increase. By 2050, 70% of the population will live in large cities. All this brings a serious set of challenges to municipal management, namely with regard to pollution, car circulation, housing or access to services. 36 2.3. AMBIENT INTELLIGENCE 2.3 Ambient Intelligence This section introduces the AmI definitions and concepts, details an extensive review of different projects in this field. And also identifies the challenges and trends that currently exists. 2.3.1 Concepts The AmI field, currently appears as an emerging field of study of information systems, and with a perspective of potential future impact. Scrutinizing the term, it is defined by the Merriam-Webster Dictionary [91] as existing/present everywhere (ubiquitously). But in the literature we have several other definitions/concepts like: • A developing technology that will increasingly make our everyday environment sensitive and responsive to our presence [2]. • A potential future in which we will be surrounded by intelligent objects and in which the environment will recognize the presence of persons and will respond to it in an undetectable manner [48]. • “Ambient Intelligence” implies intelligence that is all around us [86]. • The presence of a digital environment that is sensitive, adaptive, and responsive to the presence of people [39]. • A vision of future daily life... contains the assumption that intelligent technology should disappear into our environment to bring humans an easy and entertaining life [40]. • A new research area for distributed, non-intrusive, and intelligent software systems [109]. • In an AmI environment people are surrounded with networks of embedded intelligent devices that can sense their state, anticipate, and perhaps adapt to their needs [132]. • A digital environment that supports people in their daily lives in a nonintrusive way [3]. • A digital environment that proactively, but sensibly, assists people in their daily lives [14]. Analyzing the current landscape, the reference company in the AmI field is undoubtedly the Philips . In fact, it was this company that in 1998 proposed the concept of AmI in a series of workshops, which were organized by this multinational [146]. At these workshops have been developed different scenarios that would lead to a consumer electronics industry, which was considered at the time as fragmented, until an expected reality in 2020, with friendly devices that make available support for information, communication and entertainment ubiquitously. This development involves several departments of Philips , including research, design and global brand management. However, the first official publication mentioning the term AmI happens in 1999 in the 37 CHAPTER 2. SMART SPACES German magazine IT Monitor [4] and stresses the importance of Mark Weiser work, who worked for a long period of time in a new concept for mobile computing called ubiquitous computing [137]. This concept had enough influence and is considered the beginning of new developments, such as pervasive computing launched by IBM , and AmI by Philips. On the other hand, ambient intelligence designation was defined by the advisory group for the information society and technology of the European community. From its definition, we can see that AmI has a decisive relationship with many computer science areas. The contributing technologies are organized into five areas, as shown in figure 34. A key factor in AmI research is the presence of intelligence, as the Russell and Norvig notion of an intelligent agent [118]. In this way, the AmI algorithm perceives the environment state, and users using sensors, reasons about the data using a variety of AI techniques, and acts upon the environment using controllers in such a way that the algorithm achieves its intended goal. Figure 34: AmI and contributing technologies. The process is illustrated at figure 35. Following, we focus on technologies that assist with sensing, reasoning, and acting. Figure 35: AmI agent interaction with the environment. 38 2.3. AMBIENT INTELLIGENCE The agent perceives the environment state and residents using sensors. The agent models and reasons about this information, ultimately using it to make a decision. After, the environment state is changed through the present actuators. On the other hand, while AmI draws from the AI field, it should not be considered AI synonymous. The Information Society Technologies advisory group (ISTAG) identifies five key technologies that are required to see AmI as a reality [48]. Two of these technologies fall outside the typical AI research scope, namely Human Computer Interface (HCI) interfaces and secure systems and devices. Among others, as we can see at figure 36 the three major characteristics, that characterize AmI are: intelligence, ubiquity and transparency. Because each AmI concept element, implies supporting the lives of users in different contexts. The combination of intelligence and technology should help people’s lives during the daily life, and evolve to the user state adapt. Also in these cases, the emotional part is important and will affect the way user’s live, individually and independently upon its quotidian. Figure 36: AmI characteristics. 2.3.2 Projects Smart environments are already under study [98] [115] for some time, and during the state of the art survey in this field, were identified the reference projects worldwide, that are described below. The MavPad project involves the replication of a small apartment with traditional divisions such as bedroom, living room, bathroom and kitchen. This apartment has been fitted with different types of information-gathering sensors, concerning the context and users, trying with that, give intelligence to the environment [145]. The iDorm project uses motion sensors, temperature, humidity and light, and already have automation mechanisms for monitoring the doors, heat, and blinds. The same is characterized mainly by the use of techniques based on fuzzy logic, for the process of learning the preferences of users within an environment. It was developed at the University of Essex (United Kingdom). 39 CHAPTER 2. SMART SPACES It was created a dorm, which served as an experimental environment. It is an inhabited environment that enables various activities such as sleep, work and leisure activities. To do so the environment has bed, desk, wardrobe and entertainment system, also containing various sensors for detecting temperature and occupancy (user seated, user lying), humidity and light levels. The present actuators allow opening and closing doors, and adjusting heaters and curtains. The computational components incorporated in this project include: an integrated agent that receives the time of day, as well as, the sensor readings within the environment (ambient light and temperature) and outside the room (ambient light and temperature), the state of windows (open or closed) and user activity (sitting, sleeping, using the entertainment system or using the computer). This agent contains the user’s learned behaviour and, taking advantage of this and the information gathered from the sensors using a fuzzy logic technique, determines which actions to take. These actions can go through adjustment of heating/cooling, lights or blinds. This project also includes a robot equipped with obstacle avoidance, controlled by the iDorm agent. Allowing the food transportation, medicines, or other necessities. The agent has robot real-time location, which allows to send instructions for this move to a destination depending on the items it carries. Two types of rules were created, static and user-independent, they have the kind of reaction in case of emergency and the light and temperature settings when the room is not occupied. And the rules that are being learned regarding the user’s personal preferences. For individual identification of users is used an ID. The process consists of a period of monitoring and activity analysis each time a new user enters the environment. These examples are then used in the learning phase. Since this is based on negative reinforcement, it is assumed that users will make changes in the environment always they feel uncomfortable. The technique used in this process was the Incremental Synchronous Learning (ISL) based on fuzzy logic. After these processes (monitoring, learning), the iDorm agent initiates the environmental monitoring process. When there are changes in user preferences, the learning process checks whether to change any of the rules is needed. The authors state that is also stored a set of information (limited to 450 rules), containing the rules of the previous occupants. This information is used after the initial monitoring phase, and the system tries to find the best match with the stored data. So, the learning starts from an initial rule. In the experimental results of this project, is reported environmental occupation by a user (5.5 days/132 hours). This had the ability to interact with the environment using a PDA. After the experimental period, the number of rules learned over time was analyzed. It was based on the assumption that if the system had a good performance in learning preferences, then they would be few settings interventions by the user, and these interventions would also later be learned by the system. It was found that within 24 hours, a large number of rules is learned, and after that the number decreased significantly up to 60 hours. In the period between 60 and 72 hours there was an increase in the learned rules, and after 72 hours has not learned any other rule. The change in the period between 60 and 72 hours can be explained due to the introduction of new activities by the user in their daily routine during this period. It also concluded that the embedded 40 2.3. AMBIENT INTELLIGENCE agents dramatically reduce the need for user intervention and that the information stored, also reduces the learning time that the ISL needs. As future work is aimed the implementation of this project in environments with multiple users, and in fully functional apartments. In the case of Sensor 9K , this is a middleware layer that allows to promote the creation of applications for intelligent environments [44]. A relatively more recent project than the above is the I3A , it covers a building using a network of sensors that allow to have different data from each of the sensors in the network, including: temperature, Carbon dioxide (CO2),Carbon monoxide (CO), humidity , state of appliances, etc. This project allows prototyping solutions for smart environments, taking advantage of the ability of such sensors can be programmed individually [45]. The Saves project includes an intelligent environment, designed for use in construction and user occupancy profiles to maintain and regulate the temperature of a building [79]. The MavHome project ( Managing an Intelligent Versatile Home ) was developed at the University of Texas . Aiming to create a room that can act as a rational agent, which has sensors and actuators, to get information about users and so can provide comfort and efficiency. In this case, comfort is referred to as the atmosphere of the environment, including temperature, ventilation, lighting, etc. As efficiency being assessed by the gas and electricity costs to achieve the desired comfort. Being main objectives of the project, reduce user intervention in environmental monitoring and reducing energy consumption. The architecture of this project, uses a rational hierarchy of agents. Each agent has four layers: decision, information, communication and physical. The sensors collect environmental information, transmit the data to the agents, the information is stored in the database, and new information can be passed to the decision layer, where it is decided whether any action should be taken. In this case, the decisions are passed to the appropriate actuators of the physical layer for implementing the actions. The communication process uses the Common Object Request Broker Architecture (CORBA) model, is point to point and publish-subscribe. This project combines several algorithms for learning the habits of users, it is assumed that only one user is in the home each time. The agents try to predict their next move, and perform action policies to changing environmental conditions. The learning of user habits is achieved by mining the data collected from user interaction with the environment, and of these extract patterns. The components of this project have been implemented and tested in a work environment and in an apartment of a student. Information gathered from sensors including light, temperature, humidity, movement and status of doors and windows. And the results obtained show a reduction about 72 to 76% in manual interaction by the user in both tested environments. The GENIO project come from the effort of two companies in Spain. Fagor and Ikerlan , who want to coat the homes of ambient intelligence. The name of this project comes from the word in the Spanish language concerning ”genius”, that is, ensuring their wishes. In this project, the various appliances (washing machine, oven, refrigerator, sensors and alarms) are networked and are managed by a central controller. This controller allows to keep a conversation and respond to user instructions in their native 41 3 Characterization and Methods At this chapter the general requirements are explained, the overall architecture and the user behaviour simulation is detailed. Following all the MAS aspects are depicted, as well several points that must be considered, since the data and relevant information, as well the security and privacy issues that these data imply. Finishing with all the important results achieved. 3.1 General Requirements In the following subsections are detailed the general requirements, namely: the required and relevant data, the user identification process, the detection and characterization of the user at the space and at the environment, and do the distinction between predictive and reactive comfort. 3.1.1 Required and Relevant Data Any intelligent environment necessarily implies a process of data collection/acquisition. It will be using this information that the environment/space will optimize their decisions in a autonomous and intelligently way. The existing literature already points out several ways of obtaining data in this kind of spaces. Imperatively the most traditional way on the market are sensors, these allow to collect different kinds of information (temperature, humidity, luminosity, presence, etc.) [16]. These sensors can be isolated, dispersed throughout the environment or integrated into other devices, that users use and carry with them in their daily routine, in a non-invasive way. These sensors are currently in devices such as smart watches, fitness bracelets, smartphones, etc. This IoT ubiquity will enable a constant information reading needed, for use by these intelligent environments. Especially with low power and miniaturized sensors, and technology evolution that allows communication between them and the Internet. There are currently several research projects that aim to create economically viable sensors for physiological analysis [112], as indicated in table 2that could be most valuable for a prediction and medical examination of each individual. 49 CHAPTER 3. CHARACTERIZATION AND METHODS This kind of control, was previously only possible in appropriate environments, and using expensive large size devices, which is not allowed in any way, that each person could perform their own control independently and regardless of their technical knowledge. The capacity of wearable devices to acquire physiological information, is of great relevance. Currently the wearables that are already on the market, collect certain indicators, as previously indicated in table 2, that using health models, already well validated scientifically, make possible to determine user comfort satisfaction. This information is relevant to change comfort conditions of a particular environment. Its use only become possible and practicable recently, since only now technology has enabled miniaturization of this sensor type, and so these are integrated into wearable devices with a commercial value that is accessible to most users. In addition to these factors, using other fields of study, and in particular concerning indoor location, can be used the dispersion of terrestrial magnetic field, to have very high accuracies in indoors location [129], [127]. This is very important, to get distance between users and actuators that allow comfort conditions (heating, cooling, air quality). With this is possible to optimize operation of these actuators. This information is even more important on large size environments, containing a large number of comfort actuators, where they may be adjusted according to users environment dispersion. Thus, for this type of systems it is necessary, as well extremely relevant, to identify the necessary information. And that in some way is to be highlighted or even essential for the system functioning. According to the literature, the preferences that are understood as comfort in the daily life of the human being are well defined [52] [83]. Clearly as essential, temperature and relative humidity are defined. These are the ones that are most present in homes, as these are also the actuators that are most present (heat pump, air conditioning, boiler, etc.). Other preferences, despite being considered and intervening in human comfort and well-being, are not usually so relevant and considered in the implementation of smart homes currently carried out, perhaps mainly because actuators that automatically control this type of preferences are not so common nowadays. In particular, the possibility of luminance and brightness are currently beginning to be common in LED applications installed in homes. On the other hand, other preferences defined as multimedia, from the sound volume, to the type of music and favorite playlists. They are currently not so common, due to the fact that actuators allowing this type of control are not yet widespread. Thus, in section 3.3.1, the preferences card is defined, which includes the different preferences identified in this section, as being important for the user comfort as well for the user and space safety. 3.1.2 Detailed Description This thesis, particularly this subsection refers several times the space and environment concepts. As such, it is necessary to contextualize them, prior to use. 50 3.1. GENERAL REQUIREMENTS By space it means the global context where the user is located , namely the building, housing or public space. On the other hand, environment refers to the specific location within a given space , namely the internal division, as the hall, room, or office, being the space naturally wider, and the environment inserted in the space. The process and learning model proposed to the system is intended to be scientifically innovative, taking advantage of the latest research in this field and combining multiple factors and technologies described below: • Context awareness , as described above since the context is entirely relevant in such systems. In the literature, context sensitive systems are described as members of the ubiquitous computing environments. These systems consider different information related to space, environment, resources, users and the relationship between each of them. They intend to get personalized decisions depending on contextual factors. In this way, we can have different decisions, to the same situation in different contexts [122]. The contextualization elements can be obtained in several ways as described in [19]. • Use of sensors information combined with machine learning techniques, including Sequence Discovery , Fuzzy Logic , Genetic Programming , Multi-Layer Perceptron , as described in [135], get habits information of the users present at the environment. • Use of logical sensors , there are three types of sensors used to assess the context in such systems: physical, virtual and logical. Physical sensors capture the context of the information, and are dispersed throughout the environment. Virtual sensors are specified and configured to collect contextual information using as sources applications or services. Logical sensors, through the combination of physical and virtual sensors, intended to determine logical values for the attributes to be collected. For a smart environment contextualization, the attributes are typically collected using the three types of sensors depending on the contextual nature within the smart environments. • Use dynamically scaled priorities rules , which must have the information considered essential for the correct functioning of the system, including the limits for the different parameters, like system reliability or user safety. • Use of MAS , representing the different entities involved in the negotiation process, allowing an efficient outcome under different situations. That said, the practical applicability of this thesis is the specification of an IE, namely to ensure a solution that covers the following features: • User identification; 51 CHAPTER 3. CHARACTERIZATION AND METHODS • Detection and characterization of the user at the space; • Detection and characterization of the user in the environment; • Preferences conflict management in the environment; All these points can be seen in detail at the following subsections. 3.1.3 User identification In this thesis, the user identification is one of the essential tasks and it will be analyzed carefully later. However in a first approach, there are two situations, explained below: • User ID sharing: in this situation, when the user enters in the environment, the devices that are with him (smartphone, wearables, etc.) pass the user ID to the system that controls the environment. The system validates the ID in the Cloud, and from this it will get user’s preference card, this concept is detailed at subsection 3.3.3. The system will then use the received card information, to adapt the environmental comfort conditions, using the automation available in the environment. In this case the system must be permanently connected to the Internet, so that is allowed access to the cloud. • User preferences card sharing: In this case the user enter the environment, and share directly with the system its preferences card, using the card available in his compatible device (smartphone, wearable, etc.). The system collects data from these preferences and adapts, as in the previous case, the environment comfort conditions, using for that purpose the automated systems available in the environment. In this case, the system does not require an Internet connection, and all the process may be performed offline. Both situations assume that the user has no part in the process, and is completely transparent to him. The use case diagram present in figure 37, illustrate the operating modes provided for the implementation of user detection process, and sharing of his preferences card with the environment system. Initially are defined two use cases, depending on system network connection status. For systems located in environments where there is no cloud connection, or where system is offline, the user device share the preferences card directly with the system. Continuously the system proceeds to the environment adjustment according to existing needs and different actuators on the environment. In case of missing actuators, the respective shared preference will be discarded. The other case implies a permanent system connection to the cloud. In this situation, the user does not directly share his preferences card, but his user ID, and this ID is validated in the cloud. 52 3.1. GENERAL REQUIREMENTS Figure 37: AmI System - Use Case diagram. Upon successful validation carried out by the system, the user preferences card will be returned from the cloud. After a correct reception by the system, it will ensure environment management in the same way mentioned above. In figure 38, an example of an environment is illustrated to demonstrate the use cases described above. Note that the communication processes, represented in this figure on arrow format, are expected to be user transparent and completely independent of its intervention. After the user ID cloud validation, the respective preferences card is downloaded into the local system, and the control is made automatically by the local system, adjusting all the preferences existing in the environment. Figure 38: AmI System - Communication process. It is important to highlight that it is necessary to do this user identification process at a periodic basis, not only to identify new users but also to detect when users leave the environment. Also, this periodic time can’t be too low (few minutes), to avoid the user detection, when it only enters and leaves the environment after few minutes, because in this kind of situations it isn’t expected to actuate. Also the periodic time can’t be too high, to detect all the users that stay some time on the environment and leave after. It was decided to use a 30 minutes period, with this, the system must do a full users 53 CHAPTER 3. CHARACTERIZATION AND METHODS detection, 48 times per day. This number seems to be a good balance to surpass the identified situations described above. 3.1.4 Detection and characterization of the user at the space In their daily lives, user moves through different spaces and situations where although there are routines, it becomes difficult to identify accurately and efficiently which are their movements and location. In this sense, having real-time user’s location within a particular space, is an extreme valuable information regarding environment optimization using forecast methods, as explained in detail at subsection 3.1.7. In the past, this information was just captured using presence sensors disposed statically, and had several gaps, including the existence of many points where they did not obtain information (blind spots). Its fixed nature, constant maintenance, usually restricted to specific areas where user identification was a critical need, is no longer sufficient for the current people mobility reality and the need for more ubiquitous solutions [16]. The limitations of motion sensor technology together with the understanding that to actually be smart, a smart home needs to be able to detect who is present, lead us to the inevitable conclusion. For intelligent smart home automation, a different presence detection solution is needed. In figure 39, is illustrated an example of a context as described above. This figure shows a space divided in different environments. It can be seen, that naturally users move between environments, and so there may be environments with one or more users, as well empty environments. Collect and evaluate this type of information is relevant, to optimize space conditions in general and of the environment in particular. Figure 39: Detection and characterization of the user at the space. 54 3.1. GENERAL REQUIREMENTS 3.1.5 Detection and characterization of the user in the environment In addition to user’s location in space, described above. It may also be extremely important to get specific user location within the environment. Because this distance will have influence, especially in the specification of their comfort conditions, allowing to know the distance among the heating/cooling sources, as well other equipment’s available in the environment that interfere with comfort conditions. With this information, response and configuration of these devices can be adjusted in real time to increase effectiveness performance, both in terms of service quality, such as energy efficiency, which will result in an obvious and desired energy costs reduction for the final consumer. This type of indoors proximity information was previously technologically unfeasible, especially due to the costs of implementing a solution like that. Currently existing sensors type and technologies, particularly in terms of BLE [25], are fully market implemented and at reduced cost to the user, which enables the optimization in a relevant way, and overcome the type of problems identified above. In figure 40, is illustrated a context example as described above. This describes an environment example, where there are two users, and the proposed system should identify them. Figure 40: Detection and characterization of the user in the environment. 3.1.6 Preferences conflict management in the environment Another problem that stays current in research is the conflict preferences management, which is also applicable in the AmI field. It is known that each person is unique in its individuality, and this naturally translates in his comfort preferences, that also vary with the physiological and physical conditions of each one. Namely there may be incompatibilities between the comfort preferences of different users that are in the same environment. To overcome incompatibility, it must exist obvious compromises between the different stakeholders preferences. This process should also be completely independent and transparent to users. 55 CHAPTER 3. CHARACTERIZATION AND METHODS In the conflict management field, there are currently several work undergoing, most of it through the use of agents that carry out negotiations for potential conflicts resolution [90]. In figure 41, is illustrated an example of context as described above. Can be verified an environment where three users are present, which will invariably have different preferences. What will lead the system to act in order to overcome the best of these differences, as explained in detail at section 3.4.4. Figure 41: Preferences conflict management in the environment. 3.1.7 Comfort - Predictive vs. Reactive Especially regarding space temperature and humidity, there are different factors that influence the actuators performance to achieve the expected comfort conditions. Such as the interior and exterior space temperature, area, coating materials, among others, there is a period of inertia dependent on all these factors. So all this is considered when planning the space to achieve the desired comfort, as all of them will be a fundamental factor to consider when defining the inertia period, that is, the time period since a temperature is requested until it is effectively reached in space. In addition to these factors, actuators also have different inertia times associated with their operation mode, it is well defined that, for example, underfloor heating systems have a significantly higher inertia value compared to air conditioning or fan coil systems. Because in this type of systems, in a normal space area, for the ascent of 3 to 4 degrees, we may need time periods in the order of 10 to 20 hours. In other words, it is clear how central this issue of inertia becomes, when we are talking about providing the user with immediate comfort. So to overcome this period of time that goes from the temperature request until the space actually reaches that temperature, there are thus two different methodologies to achieve comfort: reactive and predictive. • Reactive : that is, the one that only reacts after the user is present in the space, and only then the different actuators begin the process of adjusting to the user’s preferences. So in this case, it 56 3.2. USER BEHAVIOUR SIMULATION is natural that depending on the actuators present and the different factors previously identified, there is a significant latency. Which can lead to the fact that in certain cases the space does not even reach the desired conditions during the period of time that the user remains in it. In other words, this is a very ineffective process, as the user ends up not feeling comfortable during the most or the entire time he remains in the space. • Predictive : this methodology emerged to overcome the inefficiency of the previous method, especially with the use of more passive actuators. The operation method of these involves prior knowledge of the times and temperatures expected for these times, and thus start to act for the necessary time before the presence of users, and so at the time of their presence the desired conditions are already achieved. This type of methodology identifies the reaction time necessary to reach a temperature differential between the current and the predicted one, and thus starts its operation with the number of hours necessary to reach the predicted temperature. In this thesis, the reactive methodology is explored, however with the solution and model implemented, the way is open for an easy evolution to the predictive methodology, with all the advantages that it has. With the times and places information at which the users are present, it will be possible to evolve to the space predictive adjustment. This can be seen as a future work to be developed, as detailed at section 5.7. 3.2 User Behaviour Simulation In this field some work was already done [30], [147], [68], [144]. This work it was been evaluated and improved, developing a more focused solution. Pursuing this effort, several information of hundreds users is needed to test a MAS that simulates these users behaviour, like in most research projects carried out, data are usually needed to simulate behaviour and efficiency of the proposed solutions, since it is necessary to use them to validate and test research carried out at the most diverse levels. The development of this simulation also arises from need to gather information on multiple users comfort preferences (temperature, humidity, musical playlist, musical genre, etc.). And besides that, also have information of how each user adapts their preferences to the place where he is [122]. This information, in addition to being necessary on a large scale (hundreds of users), would also be necessary in a very broad time-frame, always longer than one year. Because is known that comfort preferences normally vary according to the seasons. Getting data with this dimension and involving so many users is a difficult task and, in addition to users collaboration, would require a high cost, regarding the equipment needed to collect this information [135]. 57 CHAPTER 3. CHARACTERIZATION AND METHODS This card includes a comprehensive number of preferences, but not all of them are applicable in all environments, because lack of compatible equipment’s on the environment, or even because the environment configuration is not applicable. In this case, preferences not supported by the environment system are discarded. As shown at subsection 2.2.3, several technologies support this implementation and allow the communication process between user devices and the environment system. These technologies are in a relatively stable state, but still in an evolutionary process to obtain better performances at different aspects (data transmission rates, range, consumption). It was analyzed the feasibility of using NFC [136], BLE [25] and WIFI Direct [29] technologies. Not discarding the use of several simultaneously, if they complement each other in different situations. It is clear that different equipment manufacturers choose different technologies, and managing to cover a greater number of technologies compatible with the system, means reaching a larger number of possible users. The preferences card will initially have the characteristics defined at table 7, since such are currently the most common in user’s daily life. It is however a dynamic and scalable card, according to the required needs. All this preferences can at any time be adjusted by the user, using the smartphone application, this preferences are stored locally, and also at cloud. Naturally, it was expected that the preferences card it will be very stable, and any adjustment by the user, it will be punctual. Preference Example Units Temperature 20 ºC/ºF Luminance 30 Lux (lx) Brightness 80 Watts/cm2 Relative Humidity 45 % Sound 15 dBm Musical Genre Pop - Musical Playlist (Adele, U2) - Table 7: Preference’s Card example. 3.3.2 System Information and Constrains On the other hand, as mentioned in section 1.3, the system will also have to provide a range of information, including for security issues, which enable to alert wherever the reference security values taken as safe are exceeded. At table 8are represented the reference values for the most common gases that would jeopardize the users safety inside closed environments. Also, to have the temporal and space dimension context represented in figure 2, it is also stored the date, time, indoor location, and physical local GPS coordinates. All this information, obviously refers to 64 3.3. OVERALL SYSTEM SCENARIO the location where the system is installed. Table 8exemplifies the information that will be available in the system. This information is scalable and adaptable to specific requirements. Characteristic Example Units Name Local_Bedroom_GF - Time 20:00 Hours Date 20/11/2015 Date Indoor location Bedroom_GF - GPS coordinates 39,399872, -8,224454 - CO2 500 ppmv CO 2 ppmv Table 8: System Information example. Different presence, temperature, luminosity and humidity sensors were inserted in this system. Some of them include all features, like some sensors that use ZigBee [58] [61] communication technology as shown in Figure 46. In this way, all sensors collected information is passed through ZigBee to a receiver that is connected to a Raspberry representing the local system, as shown in Figure 45. Then all information is stored on a database, and then can be used by different agents present in the system. It is well known that security problems have relevant importance, particularly regarding intelligent environments, and all what can interact with user security. Also in this field, which deals with configuration parameters for user welfare, regarding different valences. It should be noted the importance to maintain these systems safety, since it is known that temperature and humidity values can impact well-being and even users health. Thus, it is necessary to define all actuators parameters, regarding security issues, especially maximum and minimum constraints values. Figure 45: Raspberry. Figure 46: ZigBee Sensor. All these values are configured on local systems, and then used by agents in the decision-making process. These values have a high priority, and will work as restrictions, to ensure actuators equipment safety, but mainly concerned to users safety. Table 9identifies defined preference constraints, these are always necessary for a correct private or public environment balance. A maximum value is defined for each preference, and the increment/decrement change range that can be performed. This table will be customized according to each location, 65 CHAPTER 3. CHARACTERIZATION AND METHODS and in the case of public places, it may have different restrictions, resulting from the specific environment of each space. In this way it is guaranteed the space and equipment’s safety. These validations are guaranteed in the logical layer, depending of each negotiation agent results, before the result sent to actuators. Preference/ Constrain Minimum Value Maximum Value Change Range Units Temperature 15 28 +- 0.5 ºC/ºF Luminance 0 40 +- 2 Lux (lx) Brightness 0 100 +- 2 Watts/cm2 Relative Humidity 20 80 +- 5 % Sound 0 30 +- 1 dBm Table 9: System Preferences constraints example. 3.3.3 System Architecture Figure 47, shows the developed architecture. Explaining this figure, it can be seen the user, that through of its different devices (smartphone, wearable, or other compatible) communicates with the system, and for that different technologies can be used (Wi-Fi Direct, NFC,BLE). Next, the system performs the information synchronization/share with the Cloud, to validate the information. And then the system will perform the different components management in the environment (climatization systems, security systems, other smart systems). Figure 48 shows an environment scenario around which the present work was developed. Explaining this architecture, first it can be seen one user who enters at the environment with his smartphone, and a Local System is present at the environment. In an autonomous way the smartphone communicates with the Local System , for this process different technologies can be used, like: Wi-Fi,NFC or BLE, and transmits the Universally Unique Identifier (UUID) to the Local System and this validates the UUID in the cloud, and after a correct match the respective preference’s card is retrieved by the Local System , also at figure 37 the use case diagram details all the architecture. With that information Local System start the negotiation process, as is in the schema at figure 52, when the negotiation is concluded, Local System has the final parameters to apply in the different actuators that are present at the environment like energy, security, multimedia, and other smart systems. Continuing figure 48 explanation, a second user enters the environment, when the 30 minutes period analysis process occurs, the same process of user validation and retrieve of preferences card and the negotiation process, and possible conflict management is done at Local System. Finalized the negotiation process, new result parameters will be achieved and in the same way the parameters will be sent to the different actuators present. 66 3.3. OVERALL SYSTEM SCENARIO Figure 47: Overall System Architecture. This analysis process will automatic occurs every 30 minutes period , and will detect all the new users that arrive at the environment, and in that way the environment always have the best comfort conditions to match all users preferences that are on the environment at a determined time. The entire framework/architecture was developed in order to be easily scalable, dynamically, and with no need to change. In this sense, at the users level, the increase of these is carried out in a transparent way through the application installation on their device and initial configuration of their comfort preferences card, from that moment, it will be automatically integrated into the system. Regarding performance, after verification it was also clearly achieved, as the application present in local systems ( Raspberry’s are used, to achieve a low cost solution, that has all the necessary requirements, to support the proposed work), and which controls all user entries in different locations, easily and quickly allows the communication to the server’s. The MAS solution performance, as it is critical and clearly lacks more computational power, will always be performed on the application server, and the results will be immediately communicated to each local system, so that they can be applied to each of the actuators present in the space. In this way, whenever it is necessary to increase performance for the MAS solution processing, it will also be possible and quick to scale the existing servers. On figure 49 we can see how the system reacts to the user movement, and it´s practical functioning at a smart environment. Three distinct moments in time, for the same environment, are shown. At period 1 (18h00) user 1, 2 and 3 are on the environment and the two actuators adjust to their preferences. Between period 1 and 2, user 4 enters the environment, in that way at the beginning of period 2 (18h30) the environment adjusts to the new preferences to now satisfy the four present users. Between period 2 67 CHAPTER 3. CHARACTERIZATION AND METHODS Figure 48: Environment scenario. and 3, user 1 leave’s the environment, in that way at the beginning of period 3 (19h00) the environment readjusts again to now satisfy the three present users preferences. Figure 49: Smart environment functioning example. 68 3.4. AUPBH FRAMEWORK 3.4 AUPBH Framework This section describes the proposed and developed framework, that was named: Aware of users, preferences, behaviours and habits (AUPBH). The following subsections details the used technologies, the MAS architecture and schema and the developed work related to conflicts management. 3.4.1 Introduction The AI field continues with an exponential growth rate, and multi-agent systems have been used to solve several situations, related to AmI. AmI is an ubiquitous, electronic and intelligent environment, recognized by different technologies/systems interconnection, in order to carry out different daily tasks in a transparent and autonomous way for the user [33]. Thus, multi-agent systems are made up of autonomous agents present in the environment and who have the ability to make decisions derived from interpreted stimulus and connection with other agents, to achieve common goals [142]. Currently there are different languages and platforms for the developments of this systems types, namely 3APL , Jack , Jade / Jadex , Jason , among others [26]. 3APL , Jadex and Jason use agents with cognitive reasoning models as an alternative to more traditional reactive models. Focusing on Belief- Desire-Intention (BDI) cognitive model, which allows the creation of intelligent agents capable of making decisions based on beliefs and perceptions, desires and intentions that the agent may have at a given moment. There are already different literature works that present solutions for integrating MAS with AmI, and specifically with Smart Homes, using Jade [74], [23], which is reactive, and using Jason with JaCaMo [88], [89], [10]. Jason is a framework with its own language for the development of cognitive MAS, and using the customized ARGO agents architecture it is possible to bridge the gap between MAS and actuators/sensors present in a real scenario. It as an agent-oriented programming language, has an AgentSpeak Java interpreter for the development of intelligent cognitive agents using BDI. The BDI consists of three basic constructions, following detailed: • Beliefs , are information taken as truths for the agent, which can be internal, acquired through the relationship with other agents or through the perceptions observed in the environment; • Desires , represent an agent’s motivation to achieve a certain objective; • Intentions , are the actions that the agent has committed to perform. AgentSpeak is a programming language focused on the agent approach, which is based on principles of the BDI architecture. In addition to these concepts, the Procedural Reasoning System (PRS) allows the agent to build a real time reasoning system for performing complex tasks. Jason’s agents have 69 CHAPTER 3. CHARACTERIZATION AND METHODS a reasoning cycle based on events that are generated from capturing perceptions of the environment, messages exchanged with other agents and through their own conclusions based on their reasoning. These events can be triggered using triggers that lead to the execution of plans (available in specific libraries) composed of several actions. Jason’s agents are programmed based on the definition of objectives, intentions, beliefs, plans and actions internal to the agent and actions performed in the environment. AMAS in Jason does not traditionally have an interface for capturing perceptions directly from the real world using sensors. Because Jason only uses a simulated environment, for that fact the ARGO custom architecture is used for this. AMAS using Jason and ARGO can be made up of traditional Jason and ARGO agents that work simultaneously. Jason agents can carry out plans and actions only at software level and communicate with other agents in the system (including ARGO agents). On the other hand an ARGO agent, is a traditional agent with additional characteristics, such as, for instance, the ability to communicate with the physical environment, perceive and modify it, and also filter the perceived information. This thesis, also propose an autonomous Smart Home model controlled by cognitive agents using Jason framework and ARGO architecture to manage physical devices, since ARGO agents allow communication with different controllers like Arduino or Raspberry [126]. For this implementation, different usage scenarios are developed and detailed at section 4.2, each with the different systems actuators to support the preferences detailed at subsection 3.3.1. To evaluate the MAS development, a series of performance tests were done considering parameters such as the number of agents, number of controllers, agents speed of reasoning, environment perception moment and information filtering, in order to explore different system implementation strategies. As well the user behaviour simulation described at section 3.2. And also a user satisfaction and energy consumption analysis is done and detailed at section 4.4. To optimize the proposed solution predictions, a MAS architecture was defined. The roles that each agent should represent, as well the negotiation process to be taken, the different scenarios in which this negotiation should take place and the way it should be processed were specified at subsection 3.4.2. For the implementation development, two phases are defined as follows: • Hardware ( Local System’s ) installation; •MAS development; First, the entire physical structure must be prepared, where the local devices ( Raspberry ) equipped with the network technologies previously identified at subsection 3.3.3 after this preparation they can detect the users inside the space, detecting the smartphone or wearable devices of each user. A prototype was thus implemented in a domestic house, considering all the MAS architecture detailed at subsection 3.4.2 and system actuators present in the house and detailed at subsection 4.2.3. For this purpose, a Raspberry is used per division, in this case three on the ground floor (living room/kitchen, office, bedroom) and three on the first floor (one at each environment), all this is detailed at section 4.2. 70 3.4. AUPBH FRAMEWORK Regarding the temperature actuators, these divisions have a hydraulic radiant floor heating system supported by a heat pump and also fan coils, and a home automation system that controls the different actuators detailed at subsection 4.2.3. To a more detailed view, a 3D model was designed, where the system operation for a specific space can be visualized, like can be seen in figure 50. Explaining the model, we can see different people present in the space, as well the present Local System , the different arrows illustrate the autonomous communication process between user’s peripherals (smartphones) and the Local System and also the communication with the central server (Cloud), which will allow to have the needed information for the MAS work and in that way reach the optimum comfort preferences values to use in the actuators. Figure 50: Example of the System in a environment. For the MAS performance evaluation, are considered the following parameters: • Number of agents used; • Agent speed reasoning; • Information filtering; • Environment perception time. The user satisfaction and energy consumption analysis is done and detailed at section 4.4. All the MAS implementation details are described in the following subsections. 3.4.2 Multi-Agent System Architecture On figure 51 the proposed MAS architecture specification is show, the different modules are separated, to easily identify the purpose of each one, the agents containing it and its purpose are also detailed. Following at subsection 3.4.3 the MAS schema is described. 71 CHAPTER 3. CHARACTERIZATION AND METHODS Figure 51: MAS architecture. Next, the MAS modules are fully described: •Data acquisition module, includes two agents types: the sensor agents will import necessary information from the sensors (temperature, luminance, brightness, sound) for the agents operation; the local system agent has all the system information for each local as detailed at table 8, and obtains the present users at each period (30 minutes). There will be one principal agent who will represent the local system, namely each individual environment, where it has the need to ensure individualized comfort conditions, such as a room inside a house, or a office inside a building. This agent will consider any directives that may exist for this environment, such as lower or upper limits to different comfort conditions, or also safety parameters that may be critical for a given space. This agent will have a obviously prevalence relative to others, since it will be the dominant for a given environment. •User information module, includes three agents types: the user preferences agent that will represent each user preferences that must be used in the negotiation process; the user behaviour agent that will have the user history information, to support forecast solutions; the manager agent, 72 3.4. AUPBH FRAMEWORK that will combine all the information and it will pass this to the negotiation agent, that will represent each use at the negotiation module. Regarding the users, each one will be represented by an agent, this will receive user preferences from main system, for the place where it is, as well for the time in which it is. Also in this situation there will be a prioritization that identifies which user will have environment supremacy according to the defined hierarchies present on tables 10,11 and 12, so it also has an reinforce in the negotiation process. •Negotiation module, includes five agents types: the weather forecast agent gets information from a external API, the security constraints agent that has all the information related to security of each local system as detailed at table 8, the Case-based reasoning (CBR) Agent learn behaviour patterns along with the other variables, the hierarchies agent that has the hierarchy type of each user, finally the negotiation agent will use all this information to apply the formula with the included hierarchies, and at the end it will always validate the maximum values imposed by the security constraints agent. At this module will be the negotiation between different agents involved, namely conflicts management between different users. After the negotiation process ends we will have as result, the values to be applied at the environment, and that will be processed by the action module. In decision-making process, all users agents and agents representing the environment will be considered. With the different priorities that each of them has, and with this information will begin the negotiation process, that is done at the negotiation module by the negotiation agent, and considering the directives that are defined at the agents: Security Constraints Agent, CBR Agent and Hierarchies Agent. This module is also prepared to take advantage of information regarding the behavior of users, and with it achieve predictive comfort, more details on this aspect are available a section 5.7. •Action module, after the negotiation module execution process, the values to be applied are obtained. These are used in this module and sent to actuators that will apply them in the different automation systems and actuators present at the environment. We have an agent for each of the four systems type, and a actuators manager agent, that validate the type of actuators that are present on each local, and according to this, it will use the appropriated operate agents, to operationalize the actuators presents on the space. After the negotiation result is achieved, will then be applied by the Actuators Manager Agent at the different system actuators present in the space, this is done in the Action Module. •User Behaviour Simulation module, using the information generated by the user behaviour simulation described at section 3.2, it was possible to achieve the equation 3.1. This module is 73 CHAPTER 3. CHARACTERIZATION AND METHODS the attack vectors have been identified, and these are following explained. Next, at subsection 3.5.3 are identified and detailed the techniques to minimize all the attack vectors identified at this subsection. Attack Vector A In the case of an attack that get the information transmitted in the communication process between the application and the local system, exemplified in figure 54, the information obtained will be only the user’s UUID. This information isolated has no value, because isn’t more than a random generated set of characters. Figure 54: Attack Vector A. Attack Vector B If the attacker gains full access to a local system as shown in figure 55, the information exposed will be the users UUID present in the space, and the respective preference’s cards, as well the local system ID. Also this information has little relevance. Figure 55: Attack Vector B. Attack Vector C In this case it is considered a hypothetical access to the server A, which contains the system logic layer. If that happens, the attacker will have access to the private key of the system, which will decode any UUID, or local system ID. Will also have access to all logical code of the system, as well as the access information to the database located on the server B. Figure 56 demonstrates the explained. This attack compromises all the information stored in the system. 80 3.5. SYSTEM DATA PRIVACY Figure 56: Attack Vector C. Attack Vector D An attack on the server B, affords access to all the information stored in the database. That includes the user’s UUID with the preference’s card’s associated, the local system’s ID’s and local GPS coordinates. Also in the database is the entire user history, contextualized time and locally, which allows to collect diverse usage patterns types. On figure 57 is illustrated this scenario. This is also a critical attack. Figure 57: Attack Vector D. 3.5.3 Secure Attack Vectors Currently IoT systems are in a big security risk. Especially because the developers, are not worried enough about the safety of such systems. However, with the growing trend of such systems and is integration in our everyday lives, this concern will have to increase as they start to appear isolated cases, which have harmed the users, both financially and in their safety and welfare. The proposed security architecture, to this IoT system, wants to avoid any of the presented risks, to this system users. 81 CHAPTER 3. CHARACTERIZATION AND METHODS Systems that deal with personal data always bring privacy and security issues. And also the balance of these issues, with the need that persons have in interact with spaces in a transparent way and that those spaces smartly adapt to their preferences. In this section, is proposed a solution to overcome these issues, and don’t compromise the balance between security and personal comfort. All attack vectors identified in subsection 3.5.2, are minimized using the techniques identified in this section. Consequently increasing significantly the complexity to an attacker can gain access to useful information, or can link this information to take advantage, or even affect the system users. As mentioned in section 1.5, one of this thesis priorities is to ensure privacy and data confidentiality. To achieve this goal, several mechanisms were designed in order to minimize the possible attack vectors. Figure 58 shows the overall context of the proposed architecture for the system. Includes the servers and existing communication mechanisms used and explained below. Figure 58: System Privacy - Architecture. Figure 59: System - First Utilization. 82 3.5. SYSTEM DATA PRIVACY •Use of UUID, to identify the user. The user identification process, it is necessary in this context to relate him to his preferences card, and is performed by generating a UUID in the first use of the system application. This unique UUID is randomly created by the application and is then validated their nonexistence on the server if the validation is positive, the UUID is associated with the user’s preference card. If the validation is not positive a new random UUID is generated and the validation process will be held again. The application will allow the user to export the UUID created for his personal email or store it locally in another way, so that if it wants to use more than one device in the system or switch the device, this can be done. Note that only the randomly generated UUID and the preferences card are transmitted to the server, so there is no possibility of user identification [80]. •Servers and component isolation, two physical servers will be used. In order to separate the logic and data layer (database). Therefore possible individual attacks, which enable access to any of the servers do not compromise the entire system. •Data encryption, all data transmitted between the servers are encrypted using Secure hash algorithm (SHA)-256 hash mechanisms, which introduces an extra security layer in protection of the data stored in the system [46]. •Server hardening, both servers only allow access through key mechanisms. Communication processes will be based on Hyper Text Transfer Protocol Secure (HTTPS) and Transport Layer Security (TLS) [46]. Other most common mechanisms for server hardening will be applied [140]. •Communication with the local system, as explained above, the communication between the user’s smartphone and the local system, can be performed using BLE,NFC or Wi-Fi Direct. These technologies have their own security mechanisms implemented at the stack level, which can be properly configured in the local systems to maximize security. However, the UUID is also ciphered with the Server A public key before is sent to the Local System. With that we can guarantee that the UUID can’t be captured in clear, and is only known by the smartphone application and the Server A . •GPS coordinates mask, even though the user anonymization process is covered, for greater safety and because issues related to the user’s location storage are critical. It is planned to convert the local systems GPS coordinates. This process is achieved by associating the coordinates to a randomly and periodically Local System ID change. Therefore the user’s location information from a system, will be stored using the user UUID and the system ID , which due to its periodic change will not relate any information that can allow to achieve the user tracking. These mechanisms implementation allows to significantly reduce the attack vectors identified at subsection 3.5.2. At the user data privacy level, the proposed architecture does not require to store any user 83 CHAPTER 3. CHARACTERIZATION AND METHODS information. So, even if the data is compromised, will not be possible to identify the user, or make any relationship with that information, also all the detail about privacy is detailed at subsection 3.5.1. 3.6 Important Results In addition to others, the main results of the work developed at this thesis, and presented in this section are the following: •Preference’s Card With the preference’s card definition, an innovative form of the user have his preferences stored at any device has been achieved, and in order to pass them autonomously to any environment that can be automatically adapted. In addition, at any time, the user can update his preferences, and they will be used in all future environments that it will be present. This whole concept is innovative, and is not currently present on any market, research product or platform, with state of the art focused on comfort management considering only the devices present in each environment, and having the need to be programmed in a individual form. •System Information and Constrains As regarding user’s preferences, there are also certain characteristics and aspects that say only respect to the environment and devices that are inserted in it. They are defined in section 3.3.2, and with the solution proposed by this thesis, also innovative in the way of ensuring the safety of users and equipment’s is achieved. As well anticipating its mobility, a concept already proposed by geolocation, but in another form, usually with the interaction between user device and a certain space only. With this proposal it was thus achieved the connection between different environments, and the movement that each user does between them. Here too, the literature and market don’t propose any similar solution. •Multi-Agent System AMAS light and scalable solution was achieved, as much the needs and that allows good performance using low cost hardware. Without which the global purpose of this solution would not make sense, because for it to be an effective solution, it is not enough to be technically viable, it must also be economically viable, whether for new or existing buildings. Thus all this system development, as well the way to feed him with the information needed for its operation has been developed, allowing a completely functional solution, which can be placed in production, for use by a commercial product/solution, as it is from the start planned in the development of this solution by the partner company. 84 3.6. IMPORTANT RESULTS It was also achieved the complete development of a solution to manage users preference’s conflicts that naturally exist. •System Architecture The entire architecture was developed with the intention of taking advantage of low cost hardware (Raspberry), and still achieving sufficient performance. All communication was developed, using NFC,BLE and Wi-Fi Direct. The entire services layer, which allows the collection and identification of present users, at every 30 minutes period, involving the different technologies and peripherals that users may be using (smartphones, wearables) was entirely developed. Thus, the entire system backend that supports the architecture and allows the good performance of the MAS solution, is fully developed and functional. •System Data Privacy In this type of solutions involving user’s sensitive and private information, especially in the anticipation of commercial purposes, it is essential to develop all accessory mechanisms that allow the privacy of all this information. Because currently the laws and regulations imposed by the European Union are increasingly and with more restrictions, with much more demanding when the product has a commercial purpose. Thus, the developed work in this thesis, can be considered as going beyond what is usually proposed in academic and scientific work, and safeguarding, that all current requirements of European regulation are met. •User behaviour Simulation With the creation of behaviour simulated information, a truly interesting and capable alternative was achieved, in cases where there is no possibility of collecting real information by the different conditions already identified at section 3.2. This user’s behavior and preferences simulation was clearly validated by the scientific community in different papers writhed and presented about it. The reviews were very positive, as well the possibility of taking advantage of the model to generate different information for different fields situations beyond the user preferences for which it was developed in this work. Thus being open the possibility of generalizing this simulated information, to make it as general and capable as possible, for use by the scientific community, in different cases of study. 85 4 Usage Scenarios This chapter aims to present the proposal’s validation by discussing two case studies, that are characterized and analyzed. The evaluation methodology is described, and it finishes with a detailed result analysis. 4.1 Smart space definition In the literature we find different definitions for the smart space concept, among which the following stand out: • A region of the real world that is extensively equipped with sensors, actuators and computing components [96]; • Work environments with embedded computers, information appliances, and multi-modal sensors allowing people to perform tasks efficiently by offering unprecedented levels of access to information and assistance from computers [117]; • Sentient, information-rich environment that sense and react to situational information to tailor themselves to meet users’ expectations and preferences [5]; • An environment stipulated by intelligent agents, services, devices, and sensors to provide relevant services and information to meeting participants on the basis of their contexts [36]; • An environment that acts as an intelligent agent that perceives and acts on the environment through sensors and actuators to reason about and adapt to its inhabitants [42]; • An assistive environment that can sense itself and its residents and enact mappings between the physical world and remote monitoring and intervention services [64]; • A well-defined area that is embedded with computing infrastructure that enables sensing and controlling of the physical environment [121]. 87 CHAPTER 4. USAGE SCENARIOS After analyzing all these definitions, and its application on this thesis field. It was formulated a customized definition to be applied on this thesis. In this document, the definition proposed for smart space is the following: ”A environment that adapts in a autonomously, automatically and in a non-invasive way to achieve the user desires and needs”. Adaptation means any, and all preferences adjustment that may be made in the space, namely those defined in section 3.3.1. All this, depends on the actuators present in the space, and the automation that they allow. In this way, the space should detect users entry and exit, automatically, and without the need for any interaction, and assess preferences of each one of them. After that, the space must adjust to the present users, reaching the ideal preferences to apply, for the different actuators. Each smart space has to bee seen, as the physically individual and well-defined space, with their own actuators that can adjust preferences individually and exclusively for the space in question. 4.2 Evaluation scenarios For the proposed framework analysis and evaluation, different scenarios were formulated. Initially it was applied in a two floors house. In this way, it was possible to validate the domestic space concept, with a family composed of two adult users and a child, characterized in subsection 4.2.1. Their individual preferences were defined, and the MAS system analysis was carried out during a six months period. The workspace concept was also defined, with different local systems being installed in the partner company’s offices, and also detailed in subsection 4.2.2. It was also planned to install some local systems, in partnership with the partner higher education institution, as well in a local health unit. But due to budget constraints, and costs associated with acquiring the high number of equipment’s ( Raspberry’s ) necessary for data acquisition, this was not possible. This fact was also aggravated, due to the constraints introduced by the pandemic, having been completely impossible to access the health unit at that period, as well the higher education institution. In section 4.4 the two defined scenarios results, are detailed, and explained for each of the aspects analyzed. 4.2.1 Home Scenario Table 15 characterizes the different users that compose the home scenario, where the username, user type and proportion used in the equation 3.1 are defined. 88 4.2. EVALUATION SCENARIOS Username Type Proportion User1 Adult 1 User2 Adult 1 User3 Child 0,75 Table 15: Home Scenario - Users characterization. For a greater detail of the installed local systems visible in figure 60, table 16 shows the name of each local system, its location and the associated divisions like open spaces that are somehow related, that is, the divisions in which the actuators present are controlled by the same local system. Local System Name Location Associated divisions Local_Livingroom Living room Living room/Kitchen Local_Bedroom_GF Bedroom_GF Bedroom_GF Local_Office Office Office Local_Suite_FF Suite_FF Suite_FF/ Wc_Suite Local_BedroomA_FF BedroomA_FF BedroomA_FF Local_BedroomB_FF BedroomB_FF BedroomB_FF Table 16: Home Scenario - Local system’s characterization. Figure 60 illustrates where the six different local systems ( Raspberry’s ) are placed in the home scenario. Figure 60: Home Scenario - Local System’s installation. Table 17 was developed, where all the entry records (samples) considered for analysis are represented, and they are divided by the six months under analysis (October 2021, November 2021, December 2021, 89 CHAPTER 4. USAGE SCENARIOS As previously mentioned, the results presented are preliminary and subject to industrial secrecy by the partner company. Therefore, all possible information is presented, considering the company’s intention to commercialize the developed product, there are thus several restrictions on more data availability. 4.4.1 Home Scenario Thus, all manual changes made during the testing phase were analyzed, and the satisfaction metric was calculated, by period of time/place. The average satisfaction was also measured, for the different periods: morning (8am-1pm), afternoon (1pm-7pm) and night (7pm-12pm). Satisfaction To assess the results, the scenarios identified in section 4.2 were defined. Also, the period definition for analyzing the identified scenarios was six months, as well the users present. To verify satisfaction, the equation 4.1 was used, and thus, the average satisfaction was reached, for the total number of users and time period, the results are shown at table 24. At figure 68 we can see the plot of this information. Time period Morning (8am-1pm) Afternoon (1pm-7pm) Night (7pm-12pm) Global Average Nr. of Days 182 182 182 182 Nr. of Periods 1820 2184 1820 1941,33 Avg. Insatisfaction 1,26% 3,16% 10,22% 4,88% Avg. Satisfaction 98,74% 96,84% 89,78% 95,12% Table 24: Home Scenario - Global Average Satisfaction - 6 Months. At table 25, we can see the different details for the temperature preference in the six months period analyzed. It is detailed the number of days and periods, and the average for satisfaction and insatisfaction for each one of the three periods (morning, afternoon and night). Time period Morning (8am-1pm) Afternoon (1pm-7pm) Night (7pm-12pm) Nr. of Days 182 182 182 Nr. of Periods 1820 2184 1820 Avg. Insatisfaction 2,96% 1,76% 0,42% Avg. Satisfaction 97,04% 98,24% 99,58% Table 25: Home Scenario - Temperature Average Satisfaction - 6 Months. At table 26, we can see the different details for the luminance preference in the six months period analyzed. It is detailed the number of days and periods, and the average for satisfaction and insatisfaction for each one of the three periods (morning, afternoon and night). 96 4.4. RESULTS ANALYSIS Figure 68: Home Scenario - Global Average Satisfaction - 6 Months. Time period Morning (8am-1pm) Afternoon (1pm-7pm) Night (7pm-12pm) Nr. of Periods 1820 2184 1820 Avg. Insatisfaction 2,75% 0,92% 4,95% Avg. Satisfaction 97,25% 99,08% 95,05% Table 26: Home Scenario - Luminance Average Satisfaction - 6 Months. At table 27, we can see the different details for the brightness preference in the six months period analyzed. It is detailed the number of days and periods, and the average for satisfaction and insatisfaction for each one of the three periods (morning, afternoon and night). Time period Morning (8am-1pm) Afternoon (1pm-7pm) Night (7pm-12pm) Nr. of Periods 1820 2184 1820 Avg. Insatisfaction 1,54% 1,47% 0,88% Avg. Satisfaction 98,46% 98,53% 99,12% Table 27: Home Scenario - Brightness Average Satisfaction - 6 Months. At table 28, we can see the different details for the relative humidity preference in the six months 97 CHAPTER 4. USAGE SCENARIOS period analyzed. It is detailed the number of days and periods, and the average for satisfaction and insatisfaction for each one of the three periods (morning, afternoon and night). Time period Morning (8am-1pm) Afternoon (1pm-7pm) Night (7pm-12pm) Nr. of Periods 1820 2184 1820 Avg. Insatisfaction 2,75% 2,29% 1,83% Avg. Satisfaction 97,25% 97,71% 98,17% Table 28: Home Scenario - Relative Humidity Average Satisfaction - 6 Months. At table 29, we can see the different details for the sound preference in the six months period analyzed. It is detailed the number of days and periods, and the average for satisfaction and insatisfaction for each one of the three periods (morning, afternoon and night). Time period Morning (8am-1pm) Afternoon (1pm-7pm) Night (7pm-12pm) Nr. of Periods 1820 2184 1820 Avg. Insatisfaction 0,37% 0,91% 1,1% Avg. Satisfaction 99,63% 99,09% 98,9% Table 29: Home Scenario - Sound Average Satisfaction - 6 Months. To summarize, and have a greater detail, one day was randomly selected from the period under study, and in table 30, average for satisfaction and insatisfaction for each one of the three periods (morning, afternoon and night) is presented. Time period Morning (8am-1pm) Afternoon (1pm-7pm) Night (7pm-12pm) Global Average Nr. of Periods 10 12 10 10,67 Avg. Insatisfaction 20% 0% 20% 13,33% Avg. Satisfaction 80% 100% 80% 86,67% Table 30: Home Scenario - Global Average Satisfaction - One Day. 98 4.4. RESULTS ANALYSIS Consumption Also regarding energy savings, and knowing that it is currently a factor that isn’t and cannot be neglected by any individual user or any business entity. Considering the costs increase with different energy types, as well the ecological footprint that its production represents, the savings metric was also calculated, always considering that the purpose of this solution would not have this as prime factor, but indeed the maximum user comfort. But knowing from the start that with all the introduced automatism’s (detection of users present at the space, adjustment to minimum reference values in empty spaces, etc.) by the proposed solution, a decrease in consumption would be expected by itself. Compared to solutions that only implement pre-programmed fixed adjustments and which most of the time don’t include any automatism, such as simply allowing to detect absence periods, for example in the workspace, such as vacations, holidays or others, in this scenario, savings are expected to be even more significant. To check exact values, the month global consumption was been verified for each analyzed space, and compared with the same month global consumption, after applying the solution. At table 31 we can see the mean value for the baseline day consumption, and the day consumption for the analyzed period, and also the difference in kWh, and the savings in percentage value. At figure 69 we can see the plot of this information. Scenario Baseline (kWh) Period analyzed (kWh) Difference (kWh) Savings (%) Home 35,2 32,05 3,15 9,84 Table 31: Home Scenario - Day Energy consumption (mean value). At table 32 we can see the total consumption value for the baseline, and for the 6 months period analyzed for the home scenario, and also the difference in kWh, and the savings in percentage value. At figure 70 we can see the plot of this information. 4.4.2 Work Scenario Satisfaction To assess the results, the scenarios identified in section 4.2 were defined. Also, the period definition for analyzing the identified scenarios was six months, as well the users present. To verify satisfaction, the equation 4.1 was used, and thus, the average satisfaction was reached, for the total number of users and time period, the results are shown at table 33. At figure 71 we can see the plot of this information. 99 CHAPTER 4. USAGE SCENARIOS Figure 69: Home Scenario - Day Energy consumption (mean value). Oct Nov Dec Jan Feb Mar Total Nr. of Days 31 30 31 31 28 31 182 Baseline (kWh) 806 960 1240 1426 952 930 6314 Period analyzed (kWh) 682 870 1209 1209 868 868 5706 Difference (kWh) 124 90 31 217 84 62 608 Savings (%) 18,18 10,34 2,56 17,95 9,68 7,14 10,66 Table 32: Home Scenario - Energy consumption - 6 Months. Time period Morning (8am-1pm) Afternoon (1pm-7pm) Global Average Nr. of Days 182 182 182 Nr. of Periods 1820 2184 2002 Avg. Insatisfaction 5,93% 17,72% 11,83% Avg. Satisfaction 94,07% 82,28% 88,17% Table 33: Work Scenario - Global Average Satisfaction - 6 Months. To summarize, and have a greater detail, one day was randomly selected from the period under study, and in table 34, average for satisfaction and insatisfaction for each one of the two periods (morning and afternoon) is presented. Consumption At table 35 we can see the mean value for the baseline day consumption, the day consumption for 100 4.4. RESULTS ANALYSIS Figure 70: Home Scenario - Energy consumption - 6 Months. Figure 71: Work Scenario - Global Average Satisfaction - 6 Months. the analyzed period, and also the difference in kWh, and the savings in percentage value. At figure 72 we can see the plot of this information. 101 CHAPTER 4. USAGE SCENARIOS Time period Morning (8am-1pm) Afternoon (1pm-7pm) Global Average Nr. of Periods 10 12 11 Avg. Insatisfaction 20% 8,33% 14,17% Avg. Satisfaction 80% 91,67% 85,83% Table 34: Work Scenario - Global Average Satisfaction - One Day. Scenario Baseline (kWh) Period analyzed (kWh) Difference (kWh) Savings (%) Work 42,5 36,4 6,1 16,76 Table 35: Work Scenario - Day Energy consumption (mean value). Figure 72: Work Scenario - Day Energy consumption (mean value). At table 36 we can see the total consumption value for the baseline, and for the 6 months period analyzed for the work scenario, and also the difference in kWh, and the savings in percentage value. At figure 73 we can see the plot of this information. 4.5 Summary The proposal described in chapter 3was validated here through two case studies analysis. They were created, based on that they are normally the two more representative used scenarios, and where this solution could have a significant added value. 102 4.5. SUMMARY Oct Nov Dec Jan Feb Mar Total Nr. of Days 31 30 31 31 28 31 182 Baseline (kWh) 992 1050 1519 1643 1036 992 7232 Period analyzed (kWh) 899 840 1364 1612 868 868 6451 Difference (kWh) 93 210 155 31 168 124 781 Savings (%) 10,34 25 11,36 1,92 19,35 14,29 12,11 Table 36: Work Scenario - Energy consumption - 6 Months. Figure 73: Work Scenario - Energy consumption - 6 Months. In this chapter, the two scenarios results were thus defined and analyzed. It was detailed the characterization and period analyzed in the different smart space scenarios, the detailed methodology, and the analysis was done considering satisfaction and consumption. Analyses were made, and the results were presented using tables and charts. Algorithms were presented to describe how the framework deals with uncertain situations after being identified in the case studies. We can see from the results analysis, the system high efficiency, with high percentages of satisfaction for both scenarios under analysis. With this we can have a reality sample of what this system could mean to increase comfort, as well the convenience and quality of people’s lives. 103 CHAPTER 4. USAGE SCENARIOS The analyzed period (6 months) is not very extensive, it can be seen anyway, as sufficient for this type of spaces (domestic, small company) analysis, where users remain in some way very constant, and where there is thus no significant variance in their preferences. 104 5 Conclusions This chapter closes the thesis, a summary with some final considerations is presented, and the thesis goals and achievements are highlighted and briefly discussed. The scientific contributions are described, and also some points to future research directions, based on the results so far reached are proposed in the last section. 5.1 Summary All this work led to different visits involving different institutions. In particular, visits were made to the Grupo de investigación en Bioinformática, Sistemas Informáticos Inteligentes y Tecnología Educativa (BISITE) research group at the University of Salamanca (USAL), to exchange experiences and collaborate in the solution presented development. A close collaboration was also carried out with the Research Centre in Digitalization and Intelligent Robotics (CeDRI) research center of the Polytechnic Institute of Bragança (IPB), namely with the participation in different conferences and workshops developed. Likewise, with the Algorimi research center at the University of Minho (UM), and with its members. Finally, I would like to highlight the different involvement of the partner company Techwelf , which has always leveraged the development of this thesis. All these partnerships were relevant for the knowledge sharing and experiences exchange, and also a significant enrichment of the developed work. Context-aware systems are, gradually, becoming a reality, intelligent devices that naturally interact with users are already available on the market. They will help the consolidation of AmI through intelligent environments. To build this kind of application, it is necessary to develop context-aware systems, which can sense what is happening in the environment and behave based on that. The system should use data of the surroundings to execute services aiming to assist users. However, this reasoning is not a trivial task. Moreover this complexity can be augmented due to the fact that data collected from sensors can be incomplete or incorrect. In this way, context-aware systems may not be able to process situations due to the data incompleteness or its reliability. 105 CHAPTER 5. CONCLUSIONS • Oliveira, P., Pedrosa, T., Novais, P., Matos, P., Towards to secure an IoT adaptive environment system (2019), Advances in Intelligent Systems and Computing, 801, pp. 349-352., DOI: 10.1007/978- 3-319-99608-0_43, Springer Verlag, 15th International Conference on Distributed Computing and Artificial Intelligence, DCAI 2018, ISSN: 21945357, ISBN: 9783319996073 • Oliveira P., Matos P., Novais P., Behaviour Analysis in Smart Spaces, 2016 Intl IEEE Conferences on Ubiquitous Intelligence & Computing, Advanced and Trusted Computing, Scalable Computing and Communications, Cloud and Big Data Computing, Internet of People, and Smart World Congress, ISAmI 2020, ISBN: 978-1-5090-2772-9, ISSN: 2150-329X, pp 880-887, 2016. Indexed: ISI Web of Science, Scopus, DBLP • Oliveira, P., Novais, P., Matos, P., Challenges in smart spaces: Aware of users, preferences, behaviours and habits (2017), Advances in Intelligent Systems and Computing, 619, pp. 268- 271., DOI: 10.1007/978-3-319-61578-3_34, Springer Verlag, 15th International Conference on Practical Applications of Agents and Multi-Agent Systems, PAAMS 2017, ISSN: 21945357, ISBN: 9783319615776 5.5.2 Other publications • Security constraints on a multi-agent system to manage users and spaces in a Adaptive Environment System 12th International Symposium on Ambient Intelligence (ISAmI’21) • Using Jason framework to develop a multi-agent system to manage users and spaces in an Adaptive Environment System 11th International Symposium on Ambient Intelligence (ISAmI’20) • Manage comfort preferences conflicts using a multi-agent system in an Adaptive Environment System 11th International Symposium on Ambient Intelligence (ISAmI’20) • Sistema multi-agente para a gestão de utilizadores e espaços num ambiente adaptativo VI Encontro de Jovens Investigadores • Generating real context data to test user dependent systems - application to multi-agent systems 17th International Conference on Practical Applications of Agents and Multi-Agent Systems (PAAMS’19) • A multi-agent system to manage users and spaces in a Adaptive Environment System 17th International Conference on Practical Applications of Agents and Multi-Agent Systems (PAAMS’19) • Towards to secure an IoT Adaptive Environment System 16th International Conference on Practical Applications of Agents and Multi-Agent Systems (PAAMS’18) 112 5.5. ACADEMIC OUTCOMES • Challenges in Smart Spaces: Aware of users, preferences, behaviours and habits 15th International Conference on Practical Applications of Agents and Multi-Agent Systems (PAAMS’17) • Planeamento e modelação de um ambiente inteligente para fábricas inteligentes IV Encontro de Jovens Investigadores • BLEGen - A Code Generator for Bluetooth Low Energy Services 7th International Conference on Computer Science and Information Technology (ICCSIT 2014) • Aplicação de Bluetooth Low Energy no controlo e monitorização de dispositivos de muito baixo consumo II Encontro de Jovens Investigadores • Code generator for bluetooth low energy services 11th International Conference Applied Computing • Espaços Inteligentes: Conhecedores de utilizadores, preferências, comportamentos e hábitos numa abordagem não invasiva Conferência Internacional em Processos de Co-Criação no Ensino Superior (In2CoP) • Aumentando a segurança de Ambientes Inteligentes IV Encontro de Jovens Investigadores 5.5.3 Scientific events participation During the Ph.D. course, the candidate has participated in several scientific events, such as summer schools, symposiums and conferences. Besides presenting papers with the ongoing research status, this events added the possibility of doing some scientific network and discussion with other related fields researchers. These events are at the following list: • International Summer School on Deep Learning (DeepLearn2017) in 2017, Bilbao, Spain; • 15th International Conference on Practical Applications of Agents and Multi-Agent Systems (PAAMS’17) in 2017, Porto, Portugal; • 16th International Conference on Practical Applications of Agents and Multi-Agent Systems (PAAMS’18) in 2018, Toledo, Spain; • 17th International Conference on Practical Applications of Agents and Multi-Agent Systems (PAAMS’19) in 2019, Ávila, Spain; • 11th International Symposium on Ambient Intelligence (ISAmI’20) in 2020, L’ Aquila, Italy; • 12th International Symposium on Ambient Intelligence (ISAmI’21) in 2021, Salamanca, Spain; 113 CHAPTER 5. CONCLUSIONS • 19th International Conference on Distributed Computing and Artificial Intelligence (DCAI’22) in 2022, L’ Aquila, Italy; • VII Ibero-American Congress on Entrepreneurship, Energy, Environment and Technology (CIEEMAT) in 2022, Bragança, Portugal; • Symposium of Applied Science for Young Researchers (SASYR 2022) in 2022, Viana do Castelo, Portugal; • International Conference on Optimization, Learning Algorithms and Applications (OL2A 2022) in 2022, Póvoa do Varzim, Portugal. 5.5.4 Committees/Projects advisor During the Ph.D. course, the candidate has participated in several conferences organizing committees, some journal editorial boards, and has been advisor of different graduation final projects. These are identified in the following subsections. Editorial Board • International Journal of Network Security & Its Applications ( IJNSA ) ISSN: 0974-9330, 0975-2307 http://airccse.org/journal/editorial.html • Journal of Artificial Intelligence and Big Data ( JAIBD ) ISSN: 2771-2389 DOI prefix: 10.31586/jaibd https://www.scipublications.com/journal/index.php/jaibd/editors Organizing Committees • Symposium of Applied Science for Young Researchers (SASYR 2022) http://sasyr.ipb.pt/ • International Conference on Optimization, Learning Algorithms and Applications (OL2A 2022) http://ol2a.ipb.pt/ • International Workshop on Additive Manufacturing and STEAM Education (IWAM 2022) http://iwam.ipb.pt/ • Seminário Luso-Brasileiro de Ensino Superio (SemLB 2022) http://semlb.ipb.pt/ 114 5.5. ACADEMIC OUTCOMES • International Conference on Co-Creation Processes in Higher Education (In2CoP 2020) http://in2cop.ipb.pt/ • VI Encontro de Jovens Investigadores do Instituto Politécnico de Bragança (EJI 2019) http://eji.ipb.pt/ • V Encontro de Jovens Investigadores do Instituto Politécnico de Bragança (EJI 2018) http://eji.ipb.pt/ • IV Encontro de Jovens Investigadores do Instituto Politécnico de Bragança (EJI 2017) http://eji.ipb.pt/ • III Encontro de Jovens Investigadores do Instituto Politécnico de Bragança (EJI 2016) http://eji.ipb.pt/ • XVII ENCUENTRO AECA (AECA 2016) http://xviiencuentroaeca.ipb.pt/ • VII Congresso Mundial de Estilos de Aprendizagem (CMEA 2016) http://cmea.ipb.pt/ • XVI Festival Nacional de Robótica 2016 https://robotica2016.ipb.pt/ Projects Advisor • Plataforma de maximização de aproveitamento fotovoltaico , (2022) http://projinf.estig.ipb.pt/~a48261 • IPB Student Mobile App , (2022) http://projinf.estig.ipb.pt/~a31611a40286 • IPBeacons at Campus - Mobile Application , (2021) http://projinf.estig.ipb.pt/~a40528a40534 • IPB mobile , (2021) http://projinf.estig.ipb.pt/~a35468a33884 • Dashboard para análise de desempenho académico , (2021) http://projinf.estig.ipb.pt/~a39964a37912 • IPBeacons no Campus – Aplicação móvel , (2020) http://projinf.estig.ipb.pt/~a36749a39236 115 CHAPTER 5. CONCLUSIONS • Plataforma de Gestão Integrada de Redes Sociais , (2020) http://projinf.estig.ipb.pt/~a36229 • Deteção automatizada e não invasiva de utilizadores num ambiente , (2019) http://projinf.estig.ipb.pt/~a35471 5.6 Limitations Regarding limitations, some can be highlighted, namely because this is a doctorate in a company, and with the company perspectives of commercializing the solution and patenting the work developed. There were some constraints derived from industrial secrecy, namely the possibility of implementing the prototype for testing in uncontrolled public access places. In this sense, tests were carried out in a domestic, and in a professional environment (office) belonging to the company. Also regarding the number of users needed and the respective information, as highlighted in section 3.2, due to the extreme difficulty of attracting sufficient number of users for validation, especially also with the pandemic effects, a simulation was carried out with the user data, which allowed testing the MAS with data as real as possible and his statistically validation. This limitation was thus overcome, which was also associated with the lack of hardware ( Raspberry’s ) that would represent the local systems and would collect all the necessary information, because for the amount of information needed (hundreds, one for each frequented place by each user). 5.7 Future Research Directions As any thesis, this one can be improved and evolved in different directions. Considering the results achieved in this thesis and the scientific contributions presented, it is possible to address some future research directions to complement and extend this thesis. During this thesis development, different research lines have been proposed and explored, in this way it can be more evolved, improved or also viewed with a different perspective. Namely, for future research, the aim is to continue analyzing human and climate factors that affects the comfort. For instance user distance to the actuators is a factor that can be optimized, because is understood that this distance affects thermic sensation that user gets, and also for instance the sound, or other preferences. Another work can be done according to maximize user comfort achieving the best energy savings. In this case further research is required to provide satisfactory (comfort/energy savings) agreements. Gamification can be one technique to incorporate, in a way that user has involvement in obtaining rewards for efficient energy behaviour, this can create a competition environment by the different users at the same space, and in this way the energy efficiency can be improved, and at the same way the consumption reduced. 116 5.7. FUTURE RESEARCH DIRECTIONS Also is important to refer the use of geofencing techniques to start predict user behaviors, and to anticipate is presence at the environments, in that way the environment can do an automatic adjustment to accommodate best comfort when user arrives, minimizing all actuators latencies that normally exist. Also with the user history, and application of AI models it can be performed the user routines discovery, with this we can surpass the use of more invasive techniques like geofencing. Also nowadays, we can use this kind of techniques, to see if a user is doing its normal routine, namely by inspecting what is the distance from the user current location to the next space where is expected to enter. If this distance is much more high than the expected, we can predict that the user is outside is routine, for instance it can be traveling. With this information, it can be achieved a predictive comfort as described at subsection 3.1.7, reducing significantly the consumption, because it can be predicted when the user is outside its normal routine, and for instance in that way we can turn off an entire day of climate control, if the system assess that the user doesn’t go to the office that day. This solution can also evolve, for using during user mobility, namely when user is driving at his own private car, or in public transports. The same principle apply in this kind of environments, and the preferences card can in the same way be shared with the vehicle, and the vehicle do his own adaptation according to the present users. The proposed solution can also be seen integrated with the big players platforms like Google , Amazon and Apple . Because as identified at subsection 2.2.2, users already have this kind of devices ( Apple Homepod , Apple TV , Amazon Echo , Google Nes t, and others) at their homes. In this way, this devices can be used to serve as local system’s, and integrate the proposed solution at their platforms described at subsection 2.2.4, like: Alexa , Homekit , or Android Things . This kind of integration, it will reduce costs to the user, and it will be a big achievement to the company, at the product commercialization. 117 Bibliography [1] E. Aarts and F. Grotenhuis. “Ambient intelligence 2.0: Towards synergetic prosperity”. In: Journal of Ambient Intelligence and Smart Environments 3.1 (2011), pp. 3–11 (cit. on p. 1). [2] E. H. Aarts and J. L. Encarnação. True visions: The emergence of ambient intelligence . Springer Science & Business Media, 2006 (cit. on p. 37). [3] E. H. Aarts and B. E. de Ruyter. “New research perspectives on Ambient Intelligence.” In: JAISE 1.1 (2009), pp. 5–14 (cit. on pp. 1,37). [4] L. Aarts E. Appelo. “Ambient Intelligence: thuisomgevingen van de toekomst”. In: IT Monitor 9/1999 (1999) (cit. on p. 38). [5] J. Al-Muhtadi et al. “Cerberus: a context-aware security scheme for smart spaces”. In: Proceedings of the First IEEE International Conference on Pervasive Computing and Communications, 2003.(PerCom 2003). IEEE. 2003, pp. 489–496 (cit. on p. 87). [6] V Alfonso et al. Market Trends: TSPs Must Invest in the Rapidly Evolving IoT Ecosystems Now . 2013 (cit. on p. 2). [7] W.-F. Alliance. “Wi-fi certified wi-fi direct”. In: White paper (2010) (cit. on p. 26). [8] Z. Alliance. “Zigbee alliance”. In: WPAN industry group, http://www. zigbee. org/. The industry group responsible for the ZigBee standard and certification (2010) (cit. on p. 28). [9] Amazon. Amazon Alexa .https://developer.amazon.com/en- US/alexa. 2020-05 (cit. on p. 21). [10] J. P. B. Andrade et al. “Uma abordagem com sistemas multiagentes para controle autônomo de casas inteligentes”. In: XIII Encontro Nacional de Inteligência Artificial e Computacional (ENIAC) (2016) (cit. on p. 69). [11] Apple. Apple Homepod .https://www.apple.com/homepod-2018/. 2020-05 (cit. on p. 21). [12] J. Aron. “How innovative is Apple’s new voice assistant, Siri?” In: New Scientist 212.2836 (2011), p. 24 (cit. on p. 31). 119 BIBLIOGRAPHY [13] J. C. Augusto et al. “Intelligent environments: a manifesto”. In: Human-Centric Computing and Information Sciences 3.1 (2013), pp. 1–18 (cit. on p. 1). [14] J. Augusto Wrede and P. Mccullagh. “Ambient Intelligence: Concepts and Applications”. In: Comput. Sci. Inf. Syst. 4 (2007-01), pp. 1–27. doi: 10.2298/CSIS0701001A (cit. on p. 37). [15] A. Aztiria. “Learning frequent behaviours of the users in intelligent environments”. In: Journal of Ambient Intelligence and Smart Environments 2.4 (2010), pp. 435–436 (cit. on p. 1). [16] A. Aztiria, A. Izaguirre, and J. C. Augusto. “Learning patterns in ambient intelligence environments: a survey”. In: Artificial Intelligence Review 34.1 (2010), pp. 35–51 (cit. on pp. 1,49,54). [17] A. Aztiria et al. “Discovering frequent user–environment interactions in intelligent environments”. In: Personal and Ubiquitous Computing 16.1 (2012), pp. 91–103 (cit. on p. 1). [18] S. Babar et al. “Proposed security model and threat taxonomy for the internet of things (IoT)”. In: Recent Trends in Network Security and Applications . Springer, 2010, pp. 420–429 (cit. on pp. 58, 79). [19] M. Baldauf, S. Dustdar, and F. Rosenberg. “A survey on context-aware systems”. In: International Journal of Ad Hoc and Ubiquitous Computing 2.4 (2007), pp. 263–277 (cit. on p. 51). [20] D. Bandyopadhyay and J. Sen. “Internet of things: Applications and challenges in technology and standardization”. In: Wireless Personal Communications 58.1 (2011), pp. 49–69 (cit. on pp. 2, 9,10). [21] F. Bellifemine, A. Poggi, and G. Rimassa. “Developing multi-agent systems with JADE”. In: Intelligent Agents VII Agent Theories Architectures and Languages . Springer, 2001, pp. 89–103 (cit. on pp. 6,74). [22] F. L. Bellifemine, G. Caire, and D. Greenwood. Developing multi-agent systems with JADE . Vol. 7. John Wiley & Sons, 2007 (cit. on p. 6). [23] K.-I. Benta et al. “Agent based smart house platform with affective control”. In: Proceedings of the 2009 Euro American Conference on Telematics and Information Systems: New Opportunities to increase Digital Citizenship . 2009, pp. 1–7 (cit. on p. 69). [24] R. M. Bergner. “What is behavior? And so what?” In: New ideas in psychology 29.2 (2011), pp. 147–155 (cit. on p. 46). [25] S. Bluetooth. “Bluetooth Core Specification Version 4.0”. In: Specification of the Bluetooth System (2010) (cit. on pp. 23,55,64). [26] R. H. Bordini, J. F. Hübner, and M. Wooldridge. Programming multi-agent systems in AgentSpeak using Jason . Vol. 8. John Wiley & Sons, 2007 (cit. on p. 69). [27] J. Cámara et al. “Reasoning about sensing uncertainty and its reduction in decision-making for self-adaptation”. In: Science of Computer Programming 167 (2018), pp. 51–69 (cit. on p. 47). 120 BIBLIOGRAPHY [28] A. Campbell. “The future of bacteriophage biology”. In: Nature Reviews Genetics 4.6 (2003), pp. 471–477 (cit. on p. 46). [29] D. Camps-Mur, A. Garcia-Saavedra, and P. Serrano. “Device-to-device communications with Wi-Fi Direct: overview and experimentation”. In: Wireless Communications, IEEE 20.3 (2013), pp. 96– 104 (cit. on p. 64). [30] M. Cárdenas, J. G. Sanz, and J. Pavón. “Testing Ambient Assisted Living Solutions with Simulations”. In: IFIP International Conference on Testing Software and Systems . Springer. 2018, pp. 56–61 (cit. on p. 57). [31] D. Carneiro and P. Novais. Behavioral Biometrics and Ambient Intelligence: New Opportunities for Context-Aware Applications. 2017 (cit. on p. 46). [32] D. Carneiro et al. “Enriching conflict resolution environments with the provision of context information”. In: Expert Systems (2013) (cit. on p. 2). [33] A.-C. Chaouche et al. “A higher-order agent model with contextual planning management for ambient systems”. In: Transactions on Computational Collective Intelligence XVI . Springer, 2014, pp. 146–169 (cit. on p. 69). [34] Y. P. Chaubey. Resampling-based multiple testing: Examples and methods for p-value adjustment . 1993 (cit. on p. 62). [35] E. S. Chen et al. “PalmCIS: a wireless handheld application for satisfying clinician information needs”. In: Journal of the American Medical Informatics Association 11.1 (2004), pp. 19–28 (cit. on p. 18). [36] H. Chen et al. “Intelligent agents meet the semantic web in smart spaces”. In: IEEE Internet computing 8.6 (2004), pp. 69–79 (cit. on p. 87). [37] M. Chui, M. Löffler, and R. Roberts. “The internet of things”. In: McKinsey Quarterly 2.2010 (2010), pp. 1–9 (cit. on pp. 2,10). [38] D. J. Cook. “Learning setting-generalized activity models for smart spaces”. In: IEEE intelligent systems 2010.99 (2010), p. 1 (cit. on p. 1). [39] D. J. Cook, J. C. Augusto, and V. R. Jakkula. “Ambient intelligence: Technologies, applications, and opportunities”. In: Pervasive and Mobile Computing 5.4 (2009), pp. 277–298 (cit. on pp. 37, 44). [40] C. K. Crutzen. “Invisibility and the meaning of ambient intelligence”. In: The International Review of Information Ethics 6 (2006), pp. 52–62 (cit. on p. 37). [41] K. Curran, A. Millar, and C. Mc Garvey. “Near field communication”. In: International Journal of Electrical and Computer Engineering (IJECE) 2.3 (2012), pp. 371–382 (cit. on pp. 25,26). 121 APPENDIX E. DATA LAYER - WEB SERVICES SERVER 171 String utilization_Preferences = null; 172 173 ArrayList<Utilization_Preferences> utilization_PreferencesList; 174 try 175 { 176 utilization_PreferencesList = new AccessManager().getUtilization_Preferences(); 177 Gson gson = new Gson(); 178 utilization_Preferences = gson.toJson(utilization_PreferencesList); 179 }catch (Exception e) 180 181 { 182 e.printStackTrace(); 183 } 184 return utilization_Preferences; 185 } 186 187 @POST 188 @Path("/getLocal_System_Present_Preferences/{UUID}") 189 @Produces("application/json") 190 191 public ArrayList<Local_System_Present_Preferences> getLocal_System_Present_Preferences ↩→(@PathParam("UUID") String UUID) 192 { 193 194 195 ArrayList<Local_System_Present_Preferences> utilization_PreferencesAtLocalSystemList = ↩→new ArrayList<>(); 196 197 int idUser =-1; 198 int idLocalSystem = -1; 199 200 try 201 { 202 idUser = new AccessManager().getIdUserforUUID(UUID); 203 } 204 205 catch (Exception e) 206 207 { 208 e.printStackTrace(); 209 idUser=-1; 210 } 211 212 if (idUser!=-1) 213 { 224 E.3. LOCALSYSTEMWS.JAVA 214 try 215 { 216 idLocalSystem = new AccessManager().getLastLocalSystemIDForUser(idUser); 217 218 } 219 catch (Exception e) 220 { 221 e.printStackTrace(); 222 idLocalSystem = -1; 223 } 224 } 225 else 226 { 227 utilization_PreferencesAtLocalSystemList = null; 228 } 229 if (idLocalSystem!=-1) 230 { 231 232 try 233 { 234 LocalTime hourToGetPeriod = LocalTime.now(); 235 236 Time timePeriod = Local_System_Present_Preferences.getTimePeriod(hourToGetPeriod); 237 238 System.out.println(timePeriod); 239 240 utilization_PreferencesAtLocalSystemList = new AccessManager(). ↩→getLocal_System_Present_Preferences(idLocalSystem, timePeriod); 241 242 }catch (Exception e) 243 244 { 245 e.printStackTrace(); 246 } 247 } 248 else 249 { 250 utilization_PreferencesAtLocalSystemList = null; 251 } 252 253 return utilization_PreferencesAtLocalSystemList; 254 } 255 256 257 @POST 225 APPENDIX E. DATA LAYER - WEB SERVICES SERVER 258 @Path("/updateLocalSystemPresentPreferences/{UUID}/{idPreference}/{PreferenceValue}") 259 @Produces("application/json") 260 261 public Boolean updateLocalSystemPresentPreferences(@PathParam("UUID") String UUID, ↩→@PathParam("idPreference") int idPreference, @PathParam("PreferenceValue") ↩→String PreferenceValue) 262 263 { 264 int idUser =-1; 265 int idLocalSystem = -1; 266 267 Boolean boolResponse; 268 try 269 { 270 idUser = new AccessManager().getIdUserforUUID(UUID); 271 } 272 273 catch (Exception e) 274 275 { 276 e.printStackTrace(); 277 idUser=-1; 278 } 279 280 if (idUser!=-1) 281 { 282 try 283 { 284 idLocalSystem = new AccessManager().getLastLocalSystemIDForUser(idUser); 285 286 } 287 catch (Exception e) 288 { 289 e.printStackTrace(); 290 idLocalSystem = -1; 291 } 292 } 293 else 294 { 295 boolResponse = false; 296 } 297 if (idLocalSystem!=-1) 298 { 299 try 300 { 226 E.3. LOCALSYSTEMWS.JAVA 301 302 boolResponse = new AccessManager().updateLocalSystemPresentPreferences(idLocalSystem, ↩→idUser, idPreference, PreferenceValue); 303 304 } 305 catch (Exception e) 306 { 307 e.printStackTrace(); 308 boolResponse = false; 309 } 310 } 311 else 312 { 313 boolResponse = false; 314 } 315 return boolResponse; 316 } 317 318 319 320 @POST 321 @Path("/RegisterUserAtLocalSystem/{UUID}/{idLocalSystem}") 322 @Produces("application/json") 323 324 public Boolean RegisterUserAtLocalSystem(@PathParam("UUID") String UUID,@PathParam(" ↩→idLocalSystem") int idLocalSystem) 325 { 326 327 String UUID_Validated = "-1"; 328 329 int idUser=-1; 330 331 Boolean boolResponse; 332 try 333 { 334 UUID_Validated = new AccessManager().validateUserUUID(UUID); 335 } 336 337 catch (Exception e) 338 339 { 340 e.printStackTrace(); 341 UUID_Validated="-1"; 342 } 343 227 APPENDIX E. DATA LAYER - WEB SERVICES SERVER 344 if (!UUID_Validated.equals("-1")) 345 { 346 347 try 348 { 349 idUser = new AccessManager().getIdUserforUUID(UUID); 350 351 }catch (Exception e) 352 353 { 354 e.printStackTrace(); 355 idUser=-1; 356 } 357 } 358 else 359 { 360 boolResponse=false; 361 362 } 363 364 if (idUser!=-1) 365 { 366 try 367 { 368 LocalTime hourToGetPeriod = LocalTime.now(); 369 370 Time timePeriod = Local_System_Present_Preferences.getTimePeriod(hourToGetPeriod); 371 372 System.out.println(timePeriod); 373 374 new AccessManager().insertHistoryForidUserAndLocalSystem(idUser, idLocalSystem, ↩→timePeriod); 375 376 boolResponse =true; 377 378 }catch (Exception e) 379 380 { 381 e.printStackTrace(); 382 boolResponse=false; 383 } 384 385 } 386 387 else 228 E.3. LOCALSYSTEMWS.JAVA 388 { 389 boolResponse= false; 390 } 391 return boolResponse; 392 } 393 394 395 @RolesAllowed("member") 396 @POST 397 @Path("/insertPreference_Live_Measurement/{ID_LocalSystem}/{ID_Location_Measured}/{ ↩→ID_Prefer_Measured}/{Pref_Value_Measured}") 398 @Produces("application/json") 399 400 public Boolean insertPreference_Live_Measurement(@PathParam("ID_LocalSystem") int ↩→ID_LocalSystem, @PathParam("ID_Location_Measured") int ID_Location_Measured, ↩→@PathParam("ID_Prefer_Measured") int ID_Prefer_Measured, @PathParam(" ↩→Pref_Value_Measured") String Pref_Value_Measured) 401 402 { 403 Boolean boolResponse; 404 405 try 406 { 407 LocalTime hourToGetPeriod = LocalTime.now(); 408 409 Time Time_Period = Local_System_Present_Preferences.getTimePeriod(hourToGetPeriod); 410 411 boolResponse = new AccessManager().insertPreference_Live_Measurement(ID_LocalSystem, ↩→ID_Location_Measured, Time_Period, ID_Prefer_Measured, Pref_Value_Measured); 412 413 } 414 catch (Exception e) 415 { 416 e.printStackTrace(); 417 boolResponse = false; 418 } 419 420 return boolResponse; 421 } 422 } 229 APPENDIX E. DATA LAYER - WEB SERVICES SERVER E.4 PreferencesCardWS.java 1 2package com.wsphd.webservices; 3 4 5 6import java.util.ArrayList; 7 8import javax.ws.rs.POST; 9import javax.ws.rs.Path; 10 import javax.ws.rs.Produces; 11 12 import com.wsphd.dto.Preferences_Card; 13 import com.wsphd.model.AccessManager; 14 15 16 17 import javax.ws.rs.PathParam; 18 19 @Path("/preferencesCardWS") 20 21 public class PreferencesCardWS { 22 23 @POST 24 @Path("/getPrefCardforUUID/{UUID}") 25 @Produces("application/json") 26 27 public ArrayList<Preferences_Card> getPrefCardforidUser(@PathParam("UUID") String UUID ↩→) 28 { 29 30 System.out.printf("UUID Received to Get Pref. Card: %s \n", UUID); 31 32 int idUser; 33 34 ArrayList<Preferences_Card> prefCardList; 35 36 try 37 { 38 idUser = new AccessManager().getIdUserforUUID(UUID); 39 40 }catch (Exception e) 41 42 { 230 E.4. PREFERENCESCARDWS.JAVA 43 e.printStackTrace(); 44 idUser=0; 45 } 46 47 if (idUser!=0) 48 { 49 try 50 { 51 prefCardList = new AccessManager().getPrefCardforidUser(idUser); 52 53 54 }catch (Exception e) 55 56 { 57 e.printStackTrace(); 58 prefCardList=null; 59 } 60 61 } 62 63 else 64 { 65 prefCardList=null; 66 } 67 return prefCardList; 68 } 69 70 71 @POST 72 73 74 @Path("/updatePrefCardforUUID/{UUID}/{IDPref}/{PrefValue}") 75 76 @Produces("application/json") 77 public Boolean updatePrefCardforUUID(@PathParam("UUID") String UUID, @PathParam(" ↩→IDPref") int IDPref, @PathParam("PrefValue") String PrefValue) 78 79 { 80 81 Boolean boolResponse = null; 82 System.out.printf("UUID Received to Update Pref. Card: %s \n", UUID); 83 System.out.printf("IDPref Received to Update Pref. Card: %d \n", IDPref); 84 System.out.printf("PrefValue Received to Update Pref. Card: %s \n", PrefValue); 85 86 int idUser=0; 231 APPENDIX E. DATA LAYER - WEB SERVICES SERVER 87 88 try 89 { 90 idUser = new AccessManager().getIdUserforUUID(UUID); 91 92 }catch (Exception e) 93 94 { 95 e.printStackTrace(); 96 idUser=0; 97 } 98 99 if (idUser!=0) 100 { 101 try 102 { 103 boolResponse = new AccessManager().updatePrefCardforidUser(idUser, IDPref, PrefValue); 104 105 boolResponse = true; 106 107 }catch (Exception e) 108 109 { 110 e.printStackTrace(); 111 boolResponse=false; 112 } 113 114 } 115 116 else 117 { 118 boolResponse=false; 119 } 120 return boolResponse; 121 } 122 } 232 E.5. USERWS.JAVA E.5 UserWS.java 1 2package com.wsphd.webservices; 3 4import java.sql.Time; 5import java.sql.Timestamp; 6import java.text.SimpleDateFormat; 7import java.time.LocalTime; 8import java.util.ArrayList; 9 10 import javax.annotation.security.RolesAllowed; 11 import javax.ws.rs.GET; 12 import javax.ws.rs.POST; 13 import javax.ws.rs.Path; 14 import javax.ws.rs.PathParam; 15 import javax.ws.rs.Produces; 16 17 import com.google.gson.Gson; 18 import com.wsphd.dto.History_Pref_User; 19 import com.wsphd.dto.Local_System_Present_Preferences; 20 import com.wsphd.dto.User; 21 22 import com.wsphd.model.AccessManager; 23 24 25 @Path("/userWS") 26 27 public class UserWS { 28 29 @RolesAllowed("member") 30 @GET 31 @Path("/users") 32 @Produces("application/json") 33 34 public String users() 35 { 36 String users = null; 37 ArrayList<User> userList; 38 try 39 { 40 userList = new AccessManager().getUsers(); 41 Gson gson = new Gson(); 42 users = gson.toJson(userList); 43 }catch (Exception e) 233