Flexit ventilation
Very briefly described:
Flexit Uni 3
Flexit modbus adapter CI66
Intel NUC running Home assistant and with an USB RS485 adapter
Homeyscript interacting directly with the home assistant API
Here is the homeyscript interacting with the API:
let variables = await Homey.logic.getVariables()
let getVar = (name) => {
let x = _.find(variables, (val, key) => {return (val.name === name) })
if (typeof x === 'undefined') throw new Error("Could not find variable [" + name + "]")
return x
}
// Variables: home,bright,timeperiod,presence-2etg
let home = getVar('home').value
let vent = getVar('vent').value
// home: boolean
// vent: boolean
let fanmode = "Low"
if (home) {
if (vent) {
fanmode = "High"
} else {
fanmode = "Medium"
}
}
let body = {
"entity_id": "climate.flexit",
"fan_mode": fanmode
}
let bodyencoded = JSON.stringify(body)
let token = '-----removed------' // get a token from the home assistant user settings
let response = await fetch("https://home.solweb.no/api/services/climate/set_fan_mode",
{
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + token
},
method: "POST",
body: bodyencoded
})
let json = await response.json()
// console.log("Reponse: ", json)
if (json.length <= 0) {
throw new Error("Empty response....")
}
return true;
Last updated
Was this helpful?