UNPKG

homebridge-smartsystem

Version:

SmartServer (Proxy TCP sockets to the cloud, Smappee MQTT, Duotecno IP Nodes, Homekit interface)

49 lines 1.96 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Temperature = void 0; const accessory_1 = require("./accessory"); const logger_1 = require("../duotecno/logger"); // Johan Coppieters Jan 2019 // // Temperature Sensor // - only has a "get", not sure if homekit likes this. // class Temperature extends accessory_1.Accessory { constructor(homebridge, unit) { super(homebridge, unit); } getAccessoryServices() { const temperatureService = this.makeService(this.homebridge.Service.TemperatureSensor); temperatureService .getCharacteristic(this.homebridge.Characteristic.CurrentTemperature) .setProps({ minValue: -100, maxValue: 100 }) .on('get', this.getTemperature.bind(this)); return [temperatureService]; } getTemperature(next) { if (this.unit) { this.unit.reqState(unit => { try { if (!unit) { return next(new Error("Unit state not available")); } (0, logger_1.log)("accessory", "reqState/getTemperature returned a value for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.value); next(null, unit.value / 10.0); } catch (err) { next(err); } }) .catch(err => next(err)); } else { next(new Error("accessory -> getTemperature needs a unit.")); } } updateState() { this.me.getCharacteristic(this.homebridge.Characteristic.CurrentTemperature).updateValue(this.unit.value / 10.0); (0, logger_1.log)("accessory", "Received updateState -> Homekit Temperature -> " + this.unit.getName() + " -> temp = " + this.unit.value / 10.0); } } exports.Temperature = Temperature; //# sourceMappingURL=temperature.js.map