TensorFlow AI is now open source

With Google releasing TensorFlow as opensource has anyone looked at if it is possible to integrate some or all of the machine learning/intelligence into OpenHAB?

1 Like

I did something like this by using an open source python library to build a neural network that controlled my heating. In practice it predicted when it should turn on the heater (a pellets stove) to reach a given temperature target at a given time. Inputs were based on indoor and outdoor temperature (current and historic), humidity, and whether doors or windows were open.

It worked pretty well, but the problem is gathering sufficient training data. I guess this will be a problem for any complex systems such as a house, it is difficult to model this from the outside to create a training set, so it has to built from recorded data which takes time. Also, it’s difficult to control all the parameters, for instance, I did not have sensors on every window and door.

That being said, it looks really interesting, and it would be fun to try to build something on top of it :slight_smile:

2 Likes

Hi @frankose

I just found this post, have you got any recommended reading material for using that python neural network API? I’d be interested to investigate if “predictions” are something that can be incorporated into the python/jython rule engine.

I don’t know a great deal about machine learning but I imagine we could probably do something similar to Nest e.g.:
The room is 20C and thermostat is set to 23C. It takes roughly 30mins to get from 20C to 23C. I usually arrive home at 5pm so it predicts it needs to turn the heating on at 4:30pm so that it reaches target temperature by the time I arrive home.

The Nest-like approach is exactly why I am following this thread. I think there are also many more people who are interested into this.

This could also lead to much broader applications like:

  • Turn on the TV when I arrive home (if it is 90 % sure that I would do this)
  • Turning on the TV leads to higher room temperature, heating may be lowered by a learned value
  • On weekends there is no activity in the living room before 1pm, so it can be heated later, even if people are at home

and much more.

Same here that’s why I thought to bring attention to it with openhabs ability to talk to anything a machine learning system could form into a “Home Control Assistant” rather than an “Home Control Interface” If machine learning can be incorporated I could see other addons down the road. I use Out of Milk for my shopping so I know whats in my pantry and plan my meals accordingly. If I could offload the planning. The snapshot would be an inventory. the query would be meal recipies. multiple variables including who is supposed to be home and when it could even remind when to cooking. as well as other things timeing wise. every morning I have to get my daughter up and get her to school while nont waiking up my wife and youngest daughter. 5:30A my alarm goes off and I make a pot of coffee and go to the garage to have a cigarette, ~6:15A I turn her bedroom light on 100% to start her wakeing up. 630 I wake her up and get her started getting dresses and then jump in the shower, get out get dressed and leave at 7:10 to get her to school and get to work myself.

there is alot of things that can be on timers for automation easiest are the lights. kitchen, garage, girls bedroom, master bathroom, my closet. other things are the coffee machine, garage heater or fan depending on temperature, shower temp and when it turn on with something like the Moen TS3415 IO/Digital Shower Digital Control interfaced into OpenHAB as well. But I can see the intelligence coming in when say I have the day off or my daughter doesn’t have to go to school. what if I wake up 30min later and everything is running on schedule 30min ahead of me. with the learning side it can start these things based on when I get up and get moving.

Hi guys,

Thanks for your interest in my neural thermost code. I did some digging and was able to find what I had initially created back when I was using homeseer. The source code is available in the following repository: https://github.com/kolaf/homeseer

There are two files of interest, ann_learn_rate.py and ann_thermostat_rate.py. The first file bills and trains the neural network and is run at intermittent intervals. The second file is run at frequent intervals (e.g. every five minutes) to calculate the current hitting rate using the neural network and decide whether a heater should be switched on the pending on the current temperature and future temperature targets. In the current debilitation temperature target is given for every hour of every day in the week, and I had a nice JavaScript implementation that allowed me to “draw” the temperature target curve for each day. There are also a bunch of other files in the repository which are basically training data for neural networks and the trained neural networks.

The neural network library I use is pyfann. Documentation should be available online.

Unfortunately, the source code is not very well-documented, but here is a brief overview. We start with ann_learn_rate.py. We start with the addresses (rfxcom) of the temperature sensors and heating switches in the different rooms. All history is stored in a mysql database. For every room would pick out the periods when the heater was on and calculate the length of this period and the total change in temperature from beginning to end. This is the heating rate for the conditions measured at that time. The conditions measured at that time are selected in the heating_start_measurements for loop which basically picks out the state of every device in the system (temperature, humidity sensor, and heating switches) at the beginning of the heating period.

The value of every measurement is thne normalised since the version used of the neural network library did not handle normalisation by itself. This is done below the #scale comment.

The next step is to build training data files based on the measured data, and finally the neural network is built and trained, and written to a file.

The second file, ann_thermostat_rate.py is significantly simpler. It picks out the current state of all the temperature, humidity, and heating switch devices, together with the heating schedule for the next few hours (4). A neural network is created from the file built in the training session, and the measurements (but not the heating schedule) are fed into the neural network. The outcome of the neural network is the heating rate. Finally, based on the heating rate and the heating schedule a decision is returned on whether the heater should be switched on at this time or not (calculate_state).

I’m sorry if this is a bit unclear, but it was the best I could do on short notice. I haven’t worked closely with the internals of openhab, but I believe it should be reasonably simple to develop this as some kind of internal functionality.

The user must in some way define the measurements that should be part of the decisions for a specific neural network, as well as the switch that should be actuated by it in the background the system will gather statistics on the heating periods to store exactly how the heating rate is affected by the values of these measurements at the start of the heating period. A similar background job will regularly train the neural network at some appropriate (Long) interval. Finally, at frequent intervals the trained neural network is executed based on the current measurements.

I would be happy to answer any questions, and if anyone wants to build support for this in openhabin some way (using either pyfann,tensorflow, or anything else) I would be happy to help in any way I can. Anyway, this is a fun discussion :slight_smile:

3 Likes