A computer-implemented method for controlling a device (Dev), said method comprising at least one iteration (I1-IT) comprising: • obtaining (S10), using sensors (SR), data (DT) representative of said user (Us) and of an environment (Env) in which the user is; • determining (S20), based on said data (DT), indicators (Em_I) of states of said user and at least one event indicator (Ev_I) of an event occurring in said environment (Env); • determining (S30), based on said state indicators (Em_I) and said data (DT), using a Bayesian inference model (BIM), probabilities (Em_P) of states of said user (Us); and • determining (S40), based on said probabilities (Em_P) and said at least one event indicator (Ev_I), using a first set of rules (CRM), at least one state (Em_S) of said user and at least one event (Ev_C) causing the user to be in said at least one state; said at least one iteration (I 1 -I 1 ) being repeated until a condition (Cdt) is fulfilled, said method being characterized in that it further comprises: • determining (S46) a profile (Pro) of said user (Us) based on said at least one state (Em_S) and event (Ev_C) obtained during at least one said iteration (I1-IT), and using a second set of rules (TRM) capturing changes over time and expressing the truth or falsity of statements at different times, said profile indicating a dominant state of the user during a period of time during which said at least one said iteration (I1-IT) is performed, • determining (S50), based on said at least one state (Em_S), event (Ev_C) obtained during at least one said iteration (I1-IT) and said profile (Pro) of said user (Us), using a control policy (CP), a control action (Ac) of said device; and • sending (S60) a command to said device (Dev) to perform said control action (Ac). • obtaining (S10), using sensors (SR), data (DT) representative of said user (Us) and of an environment (Env) in which the user is; • determining (S20), based on said data (DT), indicators (Em_I) of states of said user and at least one event indicator (Ev_I) of an event occurring in said environment (Env); • determining (S30), based on said state indicators (Em_I) and said data (DT), using a Bayesian inference model (BIM), probabilities (Em_P) of states of said user (Us); and • determining (S40), based on said probabilities (Em_P) and said at least one event indicator (Ev_I), using a first set of rules (CRM), at least one state (Em_S) of said user and at least one event (Ev_C) causing the user to be in said at least one state; • determining (S46) a profile (Pro) of said user (Us) based on said at least one state (Em_S) and event (Ev_C) obtained during at least one said iteration (I1-IT), and using a second set of rules (TRM) capturing changes over time and expressing the truth or falsity of statements at different times, said profile indicating a dominant state of the user during a period of time during which said at least one said iteration (I1-IT) is performed, • determining (S50), based on said at least one state (Em_S), event (Ev_C) obtained during at least one said iteration (I1-IT) and said profile (Pro) of said user (Us), using a control policy (CP), a control action (Ac) of said device; and • sending (S60) a command to said device (Dev) to perform said control action (Ac). <EOS>