Is this the right approach?

There's many possible approaches, but here's a very simple and effective one that fits the domain:

Given the nature of the application, chronological order doesn't really matter, it doesn't matter if the Fan gets turned on before the Light e.g.

Also given that you can have e.g. a motion sensor to trigger a routine that reads the sensors, and perhaps a periodic temperature check, you can use the network below to act upon the extracted patterns (no need to complicate it further with chronological order and event tracking, we extract data to act upon, and event order in this domain isn't interesting)

For example: When a person enters a room. He first switches on the light and then he switches on the fan or Whenever the temp is less than 20 C, he switches off the AC.

Raw devices log might look something like this, T/F being True/False:

Person in room | Temperature | Light | Fan | AC ----------------------------------------------- T | 20 | T | T | T T | 19 | T | T | F F | 18 | F | F | F

With sufficient samples you can train a model on the above, e.g. Naive bayes is not sensitive to irrelevant features/inputs, so e.g. if you look at my first raw table above that includes all the variables and try to predict AC , with sufficient data it will understand that some inputs are not very important or completely irrelevant

Or if you know how before hand what the Light , Fan , and AC depend on, e.g. we know Light isn't going to depend on Temperature , and that Fan and AC don't care if Light is turned on or not (they can operate even if the person is sleeping e.g.) so you can break it down like below: