Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
chee committed Oct 5, 2019
0 parents commit 703681f
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
@@ -0,0 +1,16 @@
# Little Warmth for homebridge

Get temperature from a command, and present it as a temperature for the cosy
bedroom

## example config

```json
"accessories": [
{
"accessory": "LittleWarmth",
"name": "Little Warmth",
"command": "/bin/get_temperature"
}
],
```
36 changes: 36 additions & 0 deletions index.js
@@ -0,0 +1,36 @@
let readline = require("readline")
let {exec} = require("child_process")

let Service, Characteristic, HomebridgeAPI

module.exports = homebridge => {
Service = homebridge.hap.Service
Characteristic = homebridge.hap.Characteristic
homebridge.registerAccessory("homebridge-little-warmth", "LittleWarmth", LittleWarmth)
}

class LittleWarmth {
constructor (log, config) {
this.log = log
this.name = config.name || "Little Warmth"
this.command = config.command || "get_temperature"

this.service = new Service.TemperatureSensor(this.name)

this.service
.getCharacteristic(Characteristic.CurrentTemperature)
.on("get", this.getState.bind(this))
}

getState (callback) {
exec(this.command, (error, temp) => {
this.log(temp)
this.temp = Number(temp)
callback(error, this.temp)
})
}

getServices () {
return [this.service]
}
}
21 changes: 21 additions & 0 deletions package.json
@@ -0,0 +1,21 @@
{
"name": "homebridge-little-warmth",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://git.snoot.club/chee/homebridge-little-warmth.git"
},
"engines": {
"homebridge": "*"
},
"author": "chee <chee@snoot.club>",
"license": "GPL-3.0",
"keywords": [
"homebridge-plugin"
]
}

0 comments on commit 703681f

Please sign in to comment.