The aim of this paper is to improve the autonomy of medically monitored patients in a smart home instrumented only with binary sensors; overwatching the disease evolution, that can be characterized by behaviour changes, is helped by detecting the activities the inhabitant performs. Two contributions are presented. On one hand, using sequence mining methods in the flow of sensor events, the most frequent patterns mirroring activities of the inhabitant are discovered; these activities are then modeled by an extended finite automaton, which can then be used for activity recognition and generate activity events. On the other hand, given the set of activities that can be recognized, another automaton is built to model requirements from the medical staff supervising the inhabitant; it accepts activity events, and residuals are defined to detect any behaviour deviation. The whole method is applied to the dataset of Domus, an instrumented smart home. Note to Practitioners-This paper was motivated by the will of providing a model of the behaviour of the inhabitant at home, from which formal methods can be applied to verify some properties, namely detect behaviour deviations. The input of the framework is a log file of binary sensor events (rising and falling edges); a pre-filtering of the log might be required to get rid of repetitive, noisy events (namely spurious events generated by motion sensors, for which only the first rising edge and last falling edges are relevant). This recorded log is assumed to be recorded without sensor faults, and to be characteristic of a typical routine of the inhabitant. In order to build this model, based on the Extended Finite Automata (EFA) formalism, sequence mining techniques (first contribution of the article) are adapted: the more frequent the sequence is, the more important for the inhabitant the habit is. The second contribution of the paper is the ability to detect behaviour deviations, which is criticial for healthcare at home and disease management. The technique of "residuals", mainly used in manufacturing, has been adapted to EFAs. It requires medical requirements, defined by the medical staff, based on the activities it wants to keep an eye on. A suiting log of sensors events and medical requirements are the only prerequisite to the application of the method.