-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for Tasmota devices. Homekit accessories converted to TypeScript Support for Tasmota devices Central heating interface added to web app GUI Installer updated to work with latest HAP-NodeJS (TypeScript version) Exported Homekit accessory files updated from JavaScript to TypeScript Improved functionality of Homekit radiators Silent Samba install - no more anoying dialog GUI selection of animated backgrounds
- Loading branch information
Showing
32 changed files
with
1,713 additions
and
1,089 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,61 @@ | ||
/////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// First parameter (Accessory name) : Parm1 | ||
// Second parameter (MAC address) : Parm2 | ||
/////////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
import { Accessory, AccessoryEventTypes, Categories, Characteristic, CharacteristicEventTypes, CharacteristicSetCallback, | ||
CharacteristicValue, NodeCallback, Service, uuid, VoidCallback,} from '..'; | ||
import fs from 'fs'; | ||
|
||
class DoorSensorClass { | ||
name: CharacteristicValue = "Parm1"; | ||
pincode: CharacteristicValue = "031-45-154"; | ||
username: CharacteristicValue = "Parm2"; | ||
manufacturer: CharacteristicValue = "oddwires.co.uk"; | ||
model: CharacteristicValue = "v1.0"; | ||
serialNumber: CharacteristicValue = "12345"; | ||
SensorOpen: CharacteristicValue = true; | ||
outputLogs = true; | ||
|
||
identify() { | ||
if(this.outputLogs) console.log("Identify the '%s'", this.name); | ||
} | ||
} | ||
|
||
const DoorSensor = new DoorSensorClass(); | ||
var lightUUID = uuid.generate('hap-nodejs:accessories:light' + DoorSensor.name); | ||
var DoorSensorAccessory = exports.accessory = new Accessory(DoorSensor.name as string, lightUUID); | ||
|
||
DoorSensorAccessory | ||
.getService(Service.AccessoryInformation)! | ||
.setCharacteristic(Characteristic.Manufacturer, DoorSensor.manufacturer) | ||
.setCharacteristic(Characteristic.Model, DoorSensor.model) | ||
.setCharacteristic(Characteristic.SerialNumber, DoorSensor.serialNumber); | ||
|
||
DoorSensorAccessory.on(AccessoryEventTypes.IDENTIFY, (paired: boolean, callback: VoidCallback) => { | ||
DoorSensor.identify(); | ||
callback(); | ||
}); | ||
|
||
DoorSensorAccessory | ||
.addService(Service.ContactSensor,"Parm1")! | ||
.getCharacteristic(Characteristic.ContactSensorState)! | ||
.on(CharacteristicEventTypes.GET, (callback: CharacteristicSetCallback) => { | ||
fs.readFile("/var/www/data/status.txt", 'utf8', function(err, data) { | ||
if(err) { return console.log(err); } | ||
var lines = data.split('\n'); | ||
for(var i = 0; i < lines.length; i++){ | ||
if ((lines[i].indexOf("zcon") !=-1) && (lines[i].indexOf("Parm1") !=-1)) { | ||
var values = lines[i].split(':'); | ||
if (values[8].toString().trim() === '0') { | ||
if(DoorSensor.outputLogs) console.log('Parm1: Open'); | ||
DoorSensor.SensorOpen = true; | ||
} else { | ||
if(DoorSensor.outputLogs) console.log('Parm1: Closed'); | ||
DoorSensor.SensorOpen = false; | ||
} | ||
callback(null, DoorSensor.SensorOpen); | ||
} | ||
} | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
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,102 @@ | ||
/////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// First parameter (Accessory name) : Parm1 | ||
// Second parameter (MAC address) : Parm2 | ||
// Third parameter (command string to switch accessory on) : Parm3 | ||
// Fourth parameter (command string to switch accessory off) : Parm4 | ||
// Fifth parameter (Address and Channel info) : Parm5 | ||
/////////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
import { | ||
Accessory, | ||
AccessoryEventTypes, | ||
Categories, | ||
Characteristic, | ||
CharacteristicEventTypes, CharacteristicSetCallback, | ||
CharacteristicValue, | ||
NodeCallback, | ||
Service, | ||
uuid, | ||
VoidCallback, | ||
} from '..'; | ||
import fs from 'fs'; | ||
|
||
class FanControllerClass { | ||
name: CharacteristicValue = "Parm1"; | ||
pincode: CharacteristicValue = "031-45-154"; | ||
username: CharacteristicValue = "Parm2"; | ||
manufacturer: CharacteristicValue = "oddwires.co.uk"; | ||
model: CharacteristicValue = "v1.0"; | ||
serialNumber: CharacteristicValue = "Parm5"; | ||
|
||
power: CharacteristicValue = false; | ||
outputLogs = true; | ||
|
||
setPower(status: CharacteristicValue) { | ||
if(this.outputLogs) console.log("%s: switching fan %s", this.name, status ? "on" : "off"); | ||
if (status) { | ||
fs.appendFile("/var/www/data/input.txt", "Parm3", function(err) { | ||
if(err) { return console.log(err); } | ||
}); | ||
} else { | ||
fs.appendFile("/var/www/data/input.txt", "Parm4", function(err) { | ||
if(err) { return console.log(err); } | ||
}); | ||
} | ||
} | ||
|
||
identify() { | ||
if(this.outputLogs) console.log("Identify the '%s'", this.name); | ||
} | ||
} | ||
|
||
const FanController = new FanControllerClass(); | ||
var FanUUID = uuid.generate('hap-nodejs:accessories:Fan' + FanController.name); | ||
var FanAccessory = exports.accessory = new Accessory(FanController.name as string, FanUUID); | ||
|
||
// @ts-ignore | ||
FanAccessory.username = FanController.username; | ||
// @ts-ignore | ||
FanAccessory.pincode = FanController.pincode; | ||
// @ts-ignore | ||
FanAccessory.category = Categories.Fan; | ||
|
||
FanAccessory | ||
.getService(Service.AccessoryInformation)! | ||
.setCharacteristic(Characteristic.Manufacturer, FanController.manufacturer) | ||
.setCharacteristic(Characteristic.Model, FanController.model) | ||
.setCharacteristic(Characteristic.SerialNumber, FanController.serialNumber); | ||
|
||
FanAccessory.on(AccessoryEventTypes.IDENTIFY, (paired: boolean, callback: VoidCallback) => { | ||
FanController.identify(); | ||
callback(); | ||
}); | ||
|
||
FanAccessory | ||
.addService(Service.Fan, FanController.name) | ||
.getCharacteristic(Characteristic.On)! | ||
.on(CharacteristicEventTypes.SET, (value: CharacteristicValue, callback: CharacteristicSetCallback) => { | ||
FanController.setPower(value); | ||
callback(); | ||
}); | ||
|
||
FanAccessory | ||
.getService(Service.Fan)! | ||
.getCharacteristic(Characteristic.On)! | ||
.on(CharacteristicEventTypes.GET, (callback: CharacteristicSetCallback) => { | ||
fs.readFile("/var/www/data/status.txt", 'utf8', function(err, data) { | ||
if(err) { return console.log(err); } | ||
var lines = data.split('\n'); | ||
for(var i = 0; i < lines.length; i++){ | ||
if ((lines[i].indexOf("rcon") !=-1) && (lines[i].indexOf("Parm1") !=-1)) { | ||
var values = lines[i].split(':'); | ||
if (values[6].indexOf("On") !=-1) { | ||
console.log("Parm1: Get status: On"); | ||
callback(err, true); | ||
} else { | ||
console.log("Parm1: Get status: Off"); | ||
callback(err, false); | ||
} | ||
} | ||
} | ||
}); | ||
}) |
Oops, something went wrong.