Homey
  • Homey Automations
  • Aggregated state
    • Person presence
      • Geofency and webhooks
    • Home state
    • Room and floor presence v2
    • Room and floor presence v1
    • Time table
    • Dark or bright
    • TV
    • Ventilation
      • CO2
      • Humidity bathrooms
  • Lighting
    • Scenes
    • Scene activations
  • Rooms
    • Childrens room
    • Guest room
    • Bathrooms
  • Advanced API usage
    • Getting a bearer token
  • Battery
    • Battery tracking
  • Custom integrations
    • Influxdb and Grafana
    • Flexit ventilation
    • Water metering
    • Telia data plan
    • Trondheim folkebibliotek
    • SBanken
    • Badetemperatur
    • Is it rainy? (yr.no)
  • Music
    • Music
  • Voice
    • Setup
    • Overview
Powered by GitBook
On this page

Was this helpful?

  1. Custom integrations

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:

vent.js
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;
PreviousInfluxdb and GrafanaNextWater metering

Last updated 5 years ago

Was this helpful?