without a basic pattern it will be very hard to get a pattern at all.
you dont need every second.
if all states from the involved entities save state like:
timestamp;state
you can calculate every state for every second.
so you can then start a calculation at night that makes an overview from all states at a given time
based on your given pattern you can the create events for the coming day based on this settings.
you dont. it would be insane to start reviewing that data manual.
you create settings. and you calculate a chance that something should happen.
for example you calculate at night how often the lights are switched on between 18:00 and 18:15
if thats over 75% of the times you switch them on automaticly on 18:00
then you realise that in the weekend they are always on when its not needed, so you add weekend days to the calculation
so your you calculate the percentage of certainty that the lights are switched on on weekdays between 18:00 and 18:15 and if its higher then 80% you switch them on.
over time you have more base rules and more data and you can do more calculation to get better results.
in the first period you could use logging to see how accurate your calculations are.
you create the eventgenerator and it logs like:
log > timestamp;i predict that the lights will be switched on, in that room inside the next 15 mins.
listen_state(light) for 15 mins
if light go on
log > timestamp;i was correct the lights did go on
if time gone by
log > timestamp;i was wrong lights didnt go on when i predicted it.
if you include states on which the prediction was based and actual states (or better send it to seperate log) then you can use that log to evaluate. calculate how often the prediction was right at the end of the day. and move that to a sensor.
now you got a visual result on how accurate your eventgenerator is.
it might be usefull to split that up at first. see how accurate it is every hour.
create a graph for that and you know in which timeframe you need to be more specific with your rules.
Ok, so now that we have lets say 26 sensors for a single room, how do we capture that data. Because the states of all the sensors needs to be identifiable at any point in time historically. Personally I think it’s easiest to handle it as a string of bits with each bit representing the on/off state of each sensor.
thats enough to calculate every state at each time later on.
you dont want to start saving every second. that would give you enormous amount of unneeded data, and it would kill your system.
with these saved statechanges, you can calculate at a quiet time (at night) what the state of everything was on which time.
you can save individual states like that and keep going back and checking to see what was the last state the other device was in (time consuming) but less storage required, or you can capture the state of all devices at the time of the event you are interested in (storage intensive) but quicker data lookups later on.
you dont get it.
you dont want to collect data every second and act upon it. thats just normal automations.
you want to collect data over a period of time and predict what will happen in the future.
predicting the future is never about what is at this moment, but what was in the past.
predicting the future is about using learnings from the past to make decisions for the future based on data in the present.
You are right we don’t want to capture data every second. I’ve already said that. As for what to capture both ways probably work. All I am saying is that there is a tradeoff between speed and storage. I’m wondering if anyone else has any insights to it.
you make actions in the present.
you dont use data from the present, because then it wouldnt be prediction anymore.
to make it workable you schedule events based on the past, for the next 24h
to make the predictions better you create a few diferent scenarios that get activated based on what is happening.
and indeed i would also love ideas from others.
at this moment i have
collected data
settings
base events
so all i actually need to do is make the calculations that predict.
i already partially do that by changing the thermostats based on an average from the last 2 months of bedtime and wakuptime.
temp, switches, motion, lux, etc.
but also sensors that are second level like times times we go to bed, get up, when someone is in a certain room, etc.
some things already for over 2 years.
ok, lets pick a specific room and tell me what sensors, switches, etc you are recording for that room only. Lets stick with one specific room in your house. Describe it to me. Don’t worry about the automations right now, just tell me about the smart devices.
i dont think in rooms.
but in general whats most important for me is heating, light, and motion
but i am way more interested in persons.
is a person sleeping, awake or occupying some room.
only if you know if people are somewhere, you can predict thir needs.
and the only importance for automations is that the people occupying the house get what they need.
I am looking at building in some AI for one specific use case. determining when the house wakes up.
Currently, i have no wake-up alarms that need to be set, i have kids that can end up waking the house any time from 6 am to 9 am, I have lux based lights as well as home assistant based alarm system that will need to be disabled every morning as well as turning on the lights if the brightness in the house meets the threshold.
My thoughts around adding AI are to predict and or determine when people in the house are awake and the house should also wake up lights, alarms etc.
I have been using home assistant for nearly two years now so have door sensors, motion sensors, smart lights etc, so i think there is enough data to see a pattern of what an awake house looks like, vs an asleep house, I can pick the time when everyone is up via the data.
I am doing research at the moment on what the best machine learning algorithms would be for this.
i predict that your kids will wake up between 6 and 9 am
its the same prediction you give, and probably the same prediction an AI will come to.
if you got door sensors and motion sensors, dont predict, but act on triggers
my house wakes up as soon as my wife wakes up for years now. (she also wakes up between 6 and 9)
i can try to predict that moment, so that the house will wake up 5 mins before her.
but if the time isnt regular, the prediction will probably be off.
its more usefull to let the house wake up at the same time.
in our case its just a few motion sensors that need to be triggered in a certain order in a certain timeframe.
I agree with @ReneTode. So, for my house, my wife and I are typically out of bed anywhere between 6 and 8 am. The house starts waking up every morning at 5:50 am and sets various lighting schedules to an “early morning” mode that get tripped on motion. The only deviancy is on weekends where the house starts waking up at 6:50 am.
I discovered Home Assistant a few years ago and I must say that it has really changed my life in the field of home automation, realizing many of my dreams and automating many situations.
After many experiments and many successes I realized that I was missing something, something really important.
Everything I created: routines, actions, scenarios, etc … are completely static and respond only to the conditions and directives imposed in the programming in Home Assistant.
What I was missing was a system of automatic understanding of certain situations that, based on experience and consideration of other sensors, would semi-automatically (or automatically) activate or deactivate a certain switch.
For example, if I always turn on the TV every day from 2pm to 6pm, at some point it will ask me if I have pleasure in watching TV, if the conditions are similar to those already passed.
I think this is a bit of everyone’s dream, and as a good Python programmer I couldn’t stop myself from trying such an approach, through the appDeamon addon.
If you are interested and want more information or if you want to help me in some way (even with the code) I leave you my github repository (in English)
Hoping not to have disturbed you, I thank you for reading and for any interest!
Good morning everyone,
I wanted to inform you that in these two weeks I have completely rethought and redone the code of my repository, which allows the activation of a switch according to your habits.
Still the project is under development and if you want to help me in some way, I would be really happy!
Some news:
Compatible with influxDB !
If influxDB is not available, use the HASS history
All objects are managed by Pandas frames
The day of the week, the season, the quarter, the beginning and the end of the month are taken into account.
Situations are generated through an internal patternMarching and are integrated in a heuristic way.
much more!
If you have practice with Pyton and want to help, I would be very happy!
Otherwise, if you want, you can buy me a beer
Good morning everyone and sorry for my long absence.
In this period I have done many experiments but I was not satisfied. I wrote this post to share with you my experiences and thoughts, so we can discuss them together.