Self learning thermostat

Hello everyone, this is my first post here.
I’m working on simple university project (concept?) in field of smart home solution. I would like to build some self learning thermostat based on previous user activity. Some module will collect data about manual settings related to temperature for example for previous whole month. That kind of statistics would allow us to figure out mean temperature and standard deviation for each hour in modelling weekday. After that we will be able to have following data:

{Monady, {0: 21 (+/- 1), 1: 20 (+/- 0.5), 2: 19 (+/- 0), 3:19 (+/- 0), …, 6:19 (+/- 0.75), 7:20 (+/- 0.75), 8:21 (+/- 0), 9:21 (+/- 0), …, 23:21 (+/- 0)}
Tueasday, {…}
…}

This data would give us precise statistical ranges for user temperature based on previous heating history.

First part of this solution presented above I’ve implemented as simple Java based project - [1] that reads temperature history from CSV file and return map that holds statistics for given month (it can be easily extended, but I wouldn’t like to complicate it much at the beginning). I think this could be easily integrated with temperature based smart home solution.

My question for You is there any solution available that would allow to generate thermostat rules for every hour in day? I did some research on this forum and I found that there is something called generic thermostat [2] that would allow to define temperature in range and with given tolerance but it seems to be only generic solution. To achieve my goal I should generate multiple configuration rules that trigger for hour change and check proper condition (hour, weekday, temperature) and define thermostat/heating action. However it would complicate rules because for example week we would need 7x24x2=336 automation rules. Is there any similar solution or how do You thing difficult it would be to develop something like this?

Regards!

[1] - https://github.com/lgadawski/weekday-stats
[2] - https://home-assistant.io/components/climate.generic_thermostat/

If you can provide your value to HA it could be easily put into a single automation that would update a thermostat.

Say you provide the value from your table over MQTT as an input to HA. From there you could have a single automation that would monitor that sensor for a state change (new temp over MQTT) and the set the thermostat temp based on that value.

Or you could just use AppDaemon with HA to code your work in Python. Either way it’s definitely something that can be done. I’ve actually been thinking of something similar. Taking the output of every sensor and device when it changes. Writing those to a database and using some type of analytics engine to look for relationships I hadn’t recognized. Big data for a little house kind of thing.

@silvrr, reasonable idea. Do You mean some local app (resides even concurrently with HA on same host) that uses cron job or some rule engine thath push every hour proper value to HA over MQTT?

@turboc, what do You mean by using AppDaemon with HA? Some separate mobile service that would check for every hour if thermostat settings are same as should be based on statistics and update HA thermostat properly?

Don’t focus on MQTT, it was just an example. Basically find a way to pull or push your data into a HA sensor. Then HA can monitor that sensor for when the value changes and that will trigger an automation to update the thermostat setting.

All of the sensors are documented here:

1 Like

AppDaemon is a bolt on to HA that allows you to write automation’s in python instead of YAML. You can have events fire every minute if you like or however often you like. If you knew when the next temperature change was going to be you could have it run a specific procedure at that time (doesn’t have to check every minute) and that procedure could check the thermostat against the desired temperature and adjust it if needed. Basically anything you can do in Python you could do in AppDaemon.