The rate of world population aging is increasing. This situation directly affects all countries socially and economically and, increasing their compromise and effort to improve the living conditions of this sector of society. In environments with large influxes of elderly people, such as nursing homes, the use of technology has shown promise in improving their quality of life. The use of smart devices allows people to automate everyday tasks and learn from them to predict future actions. Additionally, smartphones capture a wealth of information that allows to adapt to nearby actuators according to people’s preferences and even detect anomalies in their behaviour. Current works are proposing new frameworks to detect these behaviours and act accordingly. However, these works are not focused on managing multi-device environments where sensors and smartphones data are considered to automate environments with elderly people or to learn from them. Also, the most of these works require a permanent Internet connection, so the full benefit of smart devices is not completely achieved. In this work, we present an architecture that takes the data from sensors and smartphones in order to adapt the behaviour of the actuators of the environment. In addition, it uses this data to learn from the environment to predict actions or to extrapolate the actions that should be executed according to similar behaviours. The architecture is implemented through a use-case based on a nursing home located in a rural area. Thanks to this work, the quality of life of the elderly is improved in a simple, affordable and transparent way for them.