Skip to main content

Home Assistant

Home Assistant is an open source platform for home automation. It provides integrations with many devices and supports a Home Assistent Rest API for reading and setting parameters.

Web service

If you do not have a running instance of Home Assistant you can deploy one on your cluster.

helm install homeassistant spacetime/homeassistant

Configuration

Open a web browser to http://[IP_ADDRESS]:8123 where the IP_ADDRESS is the the address of the server where kubernetes is installed. Follow the onboarding procedure. Go to the user profile and create a long lived access token.

Secret

Create a secret with name 'Homeassistant' and the following fields:

fieldvalue
typescript
token[TOKEN]
scriptHomeassistant

Script

Create a script with a get and set function that calls the Home Assistant REST API. The Home Assistant API can be accessed via the name of the service in the cluster homeassistant.

const get = async (object, context) => {
let options = {
url: 'http://homeassistant:8123/api/states/' + object,
headers: {
'Authorization': 'Bearer ' + context.token
}
}
let response = await http.request(options);
return response.data
}

const set = async (object, key, value, context) => {
let options = {
url: 'http://homeassistant:8123/api/services/climate/set_temperature',
method: 'POST',
data: {
'entity_id' : object,
},
headers: {
'Authorization': 'Bearer ' + context.token
}
}
options.data[key] = value
let response = await http.request(options);
return response.data
}

Connector

Create a connector with name Homeassistant and data source Homeassistant. To read temperature from an object in Homeassistant with entity_id climate.woonkamer, add the following object mapping:

topicvalue
home.hvacclimate.woonkamer

To read the temperature setting and actual temperature add the following key mapping:

keyvalue
thermostatattributes.temperature
temperatureattributes.current_temperature