KNN Machine Learning Component -- has it been tried?

Has anyone tried to implement a component using some of the simpler machine learning techniques like KNN?

Applications:
K-Nearest Neighbors could be used for a lot of things. It could estimate your desired thermostat temperature based on who is home, time of day, and the weather outside. It could be rounded up or down to guess if you want a light bulb on based on time of day and time since the last motion detection. Or it could estimate how long you want to leave the lights on after a motion detection depending on who is home, if there are guests, and the bayesian probability that the room is occupied.

Implementation:
A K-Nearest Neighbor (KNN) component could be added as a platform for the sensor. In the configuration, a user could instantiate the KNN sensor and list the devices or states or sensors to be used as inputs. When implemented, the KNN component could add a script or service that can take a “snapshot” of the current state of all those devices along with what the user has set the target output to be and use that snapshot at a data point for training.

Algorithm:
For those not familiar, KNN is a very low-processing algorithm especially if you keep the K low. It creates a multi-dimensional space from the inputs, associates a target value to each of those points, and plots each of the training points in that space. When called on to activate, it finds the current state in the state space along with the nearest 1 or 2 or 3 or ‘K’ previously saved training points and averages those to get the output value.