The overall mission of this project is to implement advanced control techniques to make the intelligent home a reality that is accessible through Homeassistant. That is, a home that is able to gather data, turn it into information, establish a goal based on that information, and move towards it.
HAOS offers basic automations regarding turning switches on and off, or if the device supports it, tuning a specific variable (such as light intensity). These automations, although user friendly and fairly effective, have only the capabilities to implement condition-based control systems (if temperature <20 turn on heater
or if temperature >22 turn off heater
and so on). This is prone to unintended consequences if set up incorrectly. Similarly, to account for many conditions, control logic implemented via if
statements is tedious to set up.
To develop a true 'intelligent' home, the home needs to be able to automatically control actuators based on goals and constraints set by the user. The vision is to have the user input some relatively basic parameters (for example, keep temperature at 20°C) and some weights (for example, minimise energy consumption (30% priority) and keep me comfortable (70% priority)). The controller then deals with when to turn the heating on, and may use data such as energy price, current room temperature, external temperature etc.
The initial stages of this project will consider home heating systems since they are both expensive and carbon intensive. Similarly, most homes with traditional heating systems consider a house's radiators as a single output. However, the homeowner should be able to switch between choosing whether to heat the house or the people in the house, and potentially let the controller choose when to prioritise which.
MPC is a technique for optimally controlling MIMO systems.
The inspiration came from this post, with the intention to create a real-life version of the controller. Similarly this research has demonstrated the potential for energy and cost savings.
Image from here
To realise this, there are three key components of the system that need to function properly - the optimiser, the model and the state estimator (see figure). All three rely on an accurate model of the system in question. To get the system model through data, system identification can be used, which requires adequate signal processing methods to minimise modelling errors.
PySINDy emphasises the use of sparse regression, and seems the most appropriate System ID method to use so far. PySINDY also returns models in a state-space format, making it more appropriate for eventual integration within the rest of the control logic.
The EKF-SINDy paper and the corresponding code provide an approach for creating an Extended Kalman Filter.
I saw the need to develop my own scripts that would enable me to access live HAOS sensor data in near-real-time. This prevents consistently querying the database to gather live sensor data, which in turn could reduce the sampling rate to below Nyquist frequency depending on the sensor. The websocket API available shows the .json
format for communicating with HAOS, but there didn't seem to be any wrapper available in Python.
Control signals can be sent to HAOS via the websocket by calling services.
This project will be finished when it:
- Can deployed as a container
- Can pull data from TimescaleDB that is set up on HAOS
- Can take user inputs for the optimisation
- Can perform live system identificaiotn
- Can perform adaptive control based on the system identificaiton
- Can adapt to sensor noise
Done via python-dotenv
. Example file:
HASS_IO_AUTH_TOKEN = YOUR AUTH KEY
HASS_IO_HOSTNAME = ws://homeassistant.local:8123/api/websocket
YAML_NAME = subscriptions.yaml
-
Sensor class
Methods for cleaning dataMethods to output numpy and pandas- Create virtual sensors for testing
- Ensure the dataframes for
df
andtimeseries
are exactly the same - Unit test to ensure that the timestep of a virtual sensor is the same as what is returned by the get_timestep() method
- Ensure the dataframes for
Plotting capabilities
-
Actuator Class
- Send commands to HAOS via the websocket/api.
- Implement constraint attributes
-
DatabaseManager class
pull data from TimescaleDB- Get list of database components from TimescaleDB
-
Signal Processing
Implement simple filtering techinques- Implement more filtering techniques
- Functions for optimising filters
- Implement correlation functions
- Manage multi-rate timeseries
-
System Identification
- Use methods from dsp to align different datasets.
- Validate these using stationarity method
-
Real-time data
- Use the websocket functionality of HAOS to allow the system to function live
- Making the sensor class be able to collect real-time data via the websocket