Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 703681f
Showing
3 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
], | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
] | ||
} |