Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import storage from 'node-persist';
import { Accessory, AccessoryEventTypes, Camera, Categories, uuid, VoidCallback } from './';
console.log("HAP-NodeJS starting...");
// Initialize our storage system
storage.initSync();
// Start by creating our Bridge which will host all loaded Accessories
var cameraAccessory = new Accessory('Node Camera', uuid.generate("Node Camera"));
var cameraSource = new Camera();
cameraAccessory.configureCameraSource(cameraSource);
cameraAccessory.on(AccessoryEventTypes.IDENTIFY, (paired: boolean, callback: VoidCallback) => {
console.log("Node Camera identify");
callback(); // success
});
// Publish the camera on the local network.
cameraAccessory.publish({
username: "EC:22:3D:D3:CE:CE",
function init(storagePath) {
// initialize our underlying storage system, passing on the directory if needed
if (typeof storagePath !== 'undefined')
storage.initSync({ dir: storagePath });
else
storage.initSync(); // use whatever is default
}
import path from 'path';
import storage from 'node-persist';
import { Accessory, AccessoryEventTypes, AccessoryLoader, Bridge, Categories, uuid, VoidCallback } from './';
console.log("HAP-NodeJS starting...");
// Initialize our storage system
storage.initSync();
// Start by creating our Bridge which will host all loaded Accessories
const bridge = new Bridge('Node Bridge', uuid.generate("Node Bridge"));
// Listen for bridge identification event
bridge.on(AccessoryEventTypes.IDENTIFY, (paired: boolean, callback: VoidCallback) => {
console.log("Node Bridge identify");
callback(); // success
});
// Load up all accessories in the /accessories folder
var dir = path.join(__dirname, "accessories");
var accessories = AccessoryLoader.loadDirectory(dir);
// Add them all to the bridge
accessories.forEach((accessory: Accessory) => {
import path from 'path';
import storage from 'node-persist';
import { AccessoryLoader } from './';
console.log("HAP-NodeJS starting...");
// Initialize our storage system
storage.initSync();
// Our Accessories will each have their own HAP server; we will assign ports sequentially
var targetPort = 51826;
// Load up all accessories in the /accessories folder
var dir = path.join(__dirname, "accessories");
var accessories = AccessoryLoader.loadDirectory(dir);
// Publish them all separately (as opposed to BridgedCore which publishes them behind a single Bridge accessory)
accessories.forEach((accessory) => {
// To push Accessories separately, we'll need a few extra properties
// @ts-ignore
if (!accessory.username)
throw new Error("Username not found on accessory '" + accessory.displayName +
"'. Core.js requires all accessories to define a unique 'username' property.");
constructor(roomName) {
this.roomName = roomName;
// to store the playlist
Winston.debug('Reading from', `./playlistStoredData_${this.roomName}`);
storage.initSync({
dir: `./playlistStoredData_${this.roomName}`
});
Winston.debug('Reading finish');
this.songPlayer = new SongPlayer();
this.clientActions = {
serverTime: () => new Date(),
currentTrack: () => this.playlist.getCurrentSong(),
timeCurrentTrack: () => ({
trackTime: this.songPlayer.getCurrentTime(),
playing: this.songPlayer.playing,
serverTime: new Date()
}),
addSong: data => (
Promise.resolve(data.url).then((songUrl) => {
this.anyoneSensor = config['anyoneSensor'] === false ? false : true
this.statePollingInterval = (config['statePollingInterval'] * 1000) || false
this.debug = config['debug']
// special settings for zones
this.manualControlSwitch = config['manualControl'] || config['manualControlSwitch'] || false
this.disableHumiditySensor = config['disableHumiditySensor'] || false
this.extraHumiditySensor = config['extraHumiditySensor'] || false
this.autoFanOnly = config['autoOnly'] || config['autoFanOnly'] || false
this.disableFan = config['disableFan'] || false
this.forceThermostat = config['forceThermostat'] || false
this.cachedSettingsOnly = config['cachedSettingsOnly'] || false //new
this.historyStorage = config['historyStorage'] || false //new
this.forceHeaterCooler = config['forceHeaterCooler'] || false //new
this.disableAcAccessory = config['disableAcAccessory'] || false //new
storage.initSync({
dir: HomebridgeAPI.user.persistPath()
})
this.storeToken = tadoHelpers.storeToken.bind(this)
tadoApi.getToken = tadoApi.getToken.bind(this)
this.tadoSettings = storage.getItem("tadoCachedSettings")
//Get Token
if (this.debug) this.log('Getting Token')
tadoApi.getToken(this.username, this.password, this.storeToken)
setInterval(() => {
if (this.debug) this.log('Getting Token')
tadoApi.getToken(this.username, this.password, this.storeToken)
}, 500000)
constructor() {
storage.initSync();
this._debugMode = false;
logHelper.setLogFile('./cli.log');
}
function init() {
storage.initSync();
loadAccessories();
}
init(options) {
storage.initSync(options);
this.initialized_ = true;
}
static start( directory ) {
brain.initSync({
dir: directory
});
}