Home Assistant AppDeamon - Event predictor
WORK IN PROGRESS - CURRENTLY NOT COMPLETE AND NOT WORK
This is an idea under development (when I have free time)
I am Italian, sorry for any mistakes in English.
I want to try it right now!
This is a program in Python that I'm making in my spare time and is currently unfinished.
To try it and possibly contribute (thanks!) these are the ingredients:
- knowledge of Python
- a working instance of Home Assistant
- the appDeamon addon correctly installed and running
The idea (and the dream)
My goal (and dream) is for Home Assistant to decide autonomously when it is appropriate to activate a certain event, based on the history of one or more switches, relating the date and time and the status of other sensors. Based on the calculations performed, if the level of certainty is high it could directly activate the switch, or if it is low (uncertain) it could ask through Alexa (Amazon) if you want to proceed with the activation and based on the answer given it could even modify its data model.
Use case example
- An automation is automatically created to start the robot vacuum cleaner when nobody is at home, the time slot is from 14:00 to 18:00, the balcony door is closed and the humidity is below 60%.
- An automation is automatically created to turn on the television when someone is at home, it is between 20:00 and 22:00, dinner is being served, the temperature in the house is above 22°C and there is no upcoming appointment on the calendar.
- Asked if you want coffee if the time slot is from 12:00 to 14:00, someone is at home, you have just finished having lunch, the temperature at home is below 25°C - if not, the model is modified
Warning: all these automatic automations are based on actions already performed previously, according to probabilistic calculations.
It is not foreseen that the system considers to ask or to execute actions in a completely spontaneous way.
Progress & ToDo
- (OP#1) Getting the history of a specific switch in specified time period
- (DF#1) Getting the history from influxdb
- (OP#2) Getting the history of all connected sensors
- Caching the history
- (OP#3) get time slot from the history of the based on sensors
- (OP#4) Filters the BaseSwitch periodOn data by excluding insignificant events
- (OP#5) Save the model (and reuse for caching)
- (OP#6) Listen of variation on baseOnSensor
- (OP#7) Send an event to Home Assistant with the potential switch
- (Thanks @Pirol62) consider the variation of time (season, year, ecc...)
- Optimizing Code
- more Testing :)
- (OP#1) Getting the history of a specific switch (baseSwitch) in specified time period (by config)
- (OP#2) Getting the history of all connected sensors (basedOnSensor - declared on Config) in the time interval in which baseSwitch has been activated (on) since a time specified in configuration
- (OP#3) From the history of the various sensors (basedOnSensor), when they change state, group the times by rounding them to a value specified in the configuration, thus obtaining the day of the week, the hour, the minutes of the event and calculate the frequency of repetition
- (OP#4) Discard the data that are not satisfactory or because they are too few (by config)
- (OP#5) Save the model
- (OP#6) Listen to the variations of the basedOnSensor and compare them with the results of the model
- (OP#7) Send an event to Home Assistant with the potential switch to manage the probability of it happening. It will be in Home Assistant that will decide what to do, whether to activate the switch or ask the user if they want to activate it.
Problems and difficulties
- (DF#1) Unfortunately, I realized that I can't rely on HomeAssistant's history, because the save range for the data is very limited. I have to get the data from influxDB