Comments (6)
@dermarder Please remove all ._ files under ./accessories/
from hap-nodejs.
Looks like a syntax error, could you attach the complete .js file?
from hap-nodejs.
There are no ._ files. There are only the Light_accessory.js and types.js files.
It worked after i installed everything, then i tried to pair the light with the iOS app and everything worked as it should.
After restarting the HomeKit server the error appeared.
Thanks for your help
Content of the Light_accessory.js:
// HomeKit types required
var types = require("./types.js")
var exports = module.exports = {};
var execute = function(accessory,characteristic,value){ console.log("executed accessory: " + accessory + ", and characteristic: " + characteristic + ", with value: " + value + "."); }
exports.accessory = {
displayName: "Light 1",
username: "1A:2B:3C:4D:5E:FF",
pincode: "031-45-154",
services: [{
sType: types.ACCESSORY_INFORMATION_STYPE,
characteristics: [{
cType: types.NAME_CTYPE,
onUpdate: null,
perms: ["pr"],
format: "string",
initialValue: "Light 1",
supportEvents: false,
supportBonjour: false,
manfDescription: "Bla",
designedMaxLength: 255
},{
cType: types.MANUFACTURER_CTYPE,
onUpdate: null,
perms: ["pr"],
format: "string",
initialValue: "Oltica",
supportEvents: false,
supportBonjour: false,
manfDescription: "Bla",
designedMaxLength: 255
},{
cType: types.MODEL_CTYPE,
onUpdate: null,
perms: ["pr"],
format: "string",
initialValue: "Rev-1",
supportEvents: false,
supportBonjour: false,
manfDescription: "Bla",
designedMaxLength: 255
},{
cType: types.SERIAL_NUMBER_CTYPE,
onUpdate: null,
perms: ["pr"],
format: "string",
initialValue: "A1S2NASF88EW",
supportEvents: false,
supportBonjour: false,
manfDescription: "Bla",
designedMaxLength: 255
},{
cType: types.IDENTIFY_CTYPE,
onUpdate: null,
perms: ["pw"],
format: "bool",
initialValue: false,
supportEvents: false,
supportBonjour: false,
manfDescription: "Identify Accessory",
designedMaxLength: 1
}]
},{
sType: types.LIGHTBULB_STYPE,
characteristics: [{
cType: types.NAME_CTYPE,
onUpdate: null,
perms: ["pr"],
format: "string",
initialValue: "Light 1",
supportEvents: false,
supportBonjour: false,
manfDescription: "Bla",
designedMaxLength: 255
},{
cType: types.POWER_STATE_CTYPE,
onUpdate: function(value) { console.log("Change:",value); execute("Test Accessory 1", "light service", value); },
perms: ["pw","pr","ev"],
format: "bool",
initialValue: false,
supportEvents: false,
supportBonjour: false,
manfDescription: "Turn On the Light",
designedMaxLength: 1
},{
cType: types.HUE_CTYPE,
onUpdate: function(value) { console.log("Change:",value); execute("Test Accessory 1", "Light - Hue", value); },
perms: ["pw","pr","ev"],
format: "int",
initialValue: 0,
supportEvents: false,
supportBonjour: false,
manfDescription: "Adjust Hue of Light",
designedMinValue: 0,
designedMaxValue: 360,
designedMinStep: 1,
unit: "arcdegrees"
},{
cType: types.BRIGHTNESS_CTYPE,
onUpdate: function(value) { console.log("Change:",value); execute("Test Accessory 1", "Light - Brightness", value); },
perms: ["pw","pr","ev"],
format: "int",
initialValue: 0,
supportEvents: false,
supportBonjour: false,
manfDescription: "Adjust Brightness of Light",
designedMinValue: 0,
designedMaxValue: 100,
designedMinStep: 1,
unit: "%"
},{
cType: types.SATURATION_CTYPE,
onUpdate: function(value) { console.log("Change:",value); execute("Test Accessory 1", "Light - Saturation", value); },
perms: ["pw","pr","ev"],
format: "int",
initialValue: 0,
supportEvents: false,
supportBonjour: false,
manfDescription: "Adjust Saturation of Light",
designedMinValue: 0,
designedMaxValue: 100,
designedMinStep: 1,
unit: "%"
}]
}]
}
from hap-nodejs.
This is the content of the Core.js:
var storage = require('node-persist');
var accessory_Factor = new require("./Accessory.js");
var accessoryController_Factor = new require("./AccessoryController.js");
var service_Factor = new require("./Service.js");
var characteristic_Factor = new require("./Characteristic.js");
var targetPort = 51826;
// Get the accessories data
var fs = require('fs');
var path = require('path');
var accessoriesJSON = []
// Get user defined accessories from the accessories folder
// - user defined accessory filenames must end with "accessory.js"
fs.readdirSync(path.join(__dirname, "accessories")).forEach(function(file) {
if (file.split('').pop()==="accessory.js") {
accessoriesJSON.push(require("./accessories/" + file).accessory);
};
});
console.log("HAP-NodeJS starting...");
storage.initSync();
var accessories = [];
var accessoryControllers = [];
//loop through accessories
for (var i = 0; i < accessoriesJSON.length; i++) {
var accessoryController = new accessoryController_Factor.AccessoryController();
//loop through services
for (var j = 0; j < accessoriesJSON[i].services.length; j++) {
var service = new service_Factor.Service(accessoriesJSON[i].services[j].sType);
//loop through characteristics
for (var k = 0; k < accessoriesJSON[i].services[j].characteristics.length; k++) {
var options = {
type: accessoriesJSON[i].services[j].characteristics[k].cType,
perms: accessoriesJSON[i].services[j].characteristics[k].perms,
format: accessoriesJSON[i].services[j].characteristics[k].format,
initialValue: accessoriesJSON[i].services[j].characteristics[k].initialValue,
supportEvents: accessoriesJSON[i].services[j].characteristics[k].supportEvents,
supportBonjour: accessoriesJSON[i].services[j].characteristics[k].supportBonjour,
manfDescription: accessoriesJSON[i].services[j].characteristics[k].manfDescription,
designedMaxLength: accessoriesJSON[i].services[j].characteristics[k].designedMaxLength,
designedMinValue: accessoriesJSON[i].services[j].characteristics[k].designedMinValue,
designedMaxValue: accessoriesJSON[i].services[j].characteristics[k].designedMaxValue,
designedMinStep: accessoriesJSON[i].services[j].characteristics[k].designedMinStep,
unit: accessoriesJSON[i].services[j].characteristics[k].unit,
}
var characteristic = new characteristic_Factor.Characteristic(options, accessoriesJSON[i].services[j].characteristics[k].onUpdate);
service.addCharacteristic(characteristic);
};
accessoryController.addService(service);
};
//increment targetport for each accessory
targetPort = targetPort + (i*2);
var accessory = new accessory_Factor.Accessory(accessoriesJSON[i].displayName, accessoriesJSON[i].username, storage, parseInt(targetPort), accessoriesJSON[i].pincode, accessoryController);
accessories[i] = accessory;
accessoryControllers[i] = accessoryController;
accessory.publishAccessory();
};
from hap-nodejs.
@dermarder Can you run "rm /home/pi/HAP-NodeJS/accessories/._*" and start HAP Server again?
from hap-nodejs.
@KhaosT It works! My server is now up and running! Thank you very much
from hap-nodejs.
Related Issues (20)
- Accessories states in Home App does not update when controlled manually HOT 12
- handleSnapshotRequest reason sometimes passed in as "undefined" HOT 2
- allow to specify a different IP in mDSN advertisement HOT 2
- Special Characters in Name HOT 6
- Node 16 to 18 update - Alpine - Docker - Synology
- node.js update HOT 1
- Node.js Update HOT 1
- Minimum Current Ambient Light Level warning HOT 1
- Lot of mDNS queries HOT 7
- Doesn't fallback from systemd-resolved advertiser if MulticastDNS is disabled. HOT 12
- Readme Text is ambiguous
- "ControllerStorage for accessory XXX was already initialized!" HOT 1
- How to run HAP-NodeJS inside Docker container HOT 5
- How to update the device status HOT 5
- TypeError: crypto_1.default.getCiphers is not a function at Object../node_modules/hap-nodejs/dist/lib/util/hapCrypto.js HOT 6
- v0.11.0 fails on Synology HOT 15
- VOC Density characteristic incorrectly set as a float and limited to 1000 HOT 4
- Setting Characteristic minValue via setProps results in debug error if the current value is lower than the new minValue HOT 6
- TypeScript plugins do not build with noImplicitAny: true in 1.6.0 HOT 11
- Interpreting Siri Commands HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hap-nodejs.