UNPKG

node-hue-api

Version:
54 lines (53 loc) 1.95 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Sensors = void 0; const ApiDefinition_1 = require("./http/ApiDefinition"); const sensors_1 = require("./http/endpoints/sensors"); class Sensors extends ApiDefinition_1.ApiDefinition { constructor(hueApi) { super(hueApi); } getAll() { return this.execute(sensors_1.sensorsApi.getAllSensors); } getSensor(id) { return this.execute(sensors_1.sensorsApi.getSensor, { id: id }); } searchForNew() { return this.execute(sensors_1.sensorsApi.findNewSensors); } getNew() { return this.execute(sensors_1.sensorsApi.getNewSensors); } renameSensor(sensor) { return this.execute(sensors_1.sensorsApi.updateSensor, { id: sensor, name: sensor.name }); } /** Creates a new Sensor (CLIP based) */ createSensor(sensor) { const self = this; return self.execute(sensors_1.sensorsApi.createSensor, { sensor: sensor }) .then((data) => { // @ts-ignore return self.getSensor(data.id); }); } deleteSensor(id) { return this.execute(sensors_1.sensorsApi.deleteSensor, { id: id }); } /** Will update the configuration attributes of the Sensor in the bridge. */ updateSensorConfig(sensor) { return this.execute(sensors_1.sensorsApi.changeSensorConfig, { id: sensor.id, sensor: sensor }); } /** * Will update the state attributes of the Sensor in the bridge. * @param limitToStateNames list of state attributes to limit the update to (should not be needed in practice, was added to get around a bug). */ updateSensorState(sensor, limitToStateNames) { return this.execute(sensors_1.sensorsApi.changeSensorState, { id: sensor.id, sensor: sensor, filterStateNames: limitToStateNames }); } } exports.Sensors = Sensors;