Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

homebridge-tcc

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

homebridge-tcc - npm Package Compare versions

Comparing version 0.2.16 to 0.2.17

307

index.js

@@ -13,2 +13,3 @@ /*jslint node: true */

var thermostats;
var outsideSensors = 0;

@@ -34,3 +35,3 @@ module.exports = function(homebridge) {

this.log = log;
this.devices = config['devices'];
this.sensors = config['sensors'];
this.storage = config['storage'] || "fs";

@@ -56,5 +57,13 @@

for (var zone in devices.hb) {
debug("Creating accessory for", devices.hb[zone].Name);
var newAccessory = new TccAccessory(this, devices.hb[zone]);
debug("Creating accessory for", devices.hb[zone].Name + "(" + devices.hb[zone].ThermostatID + ")");
//debug("tccPlatform.prototype.didFinishLaunching()",this.devices)
var newAccessory = new TccAccessory(this, devices.hb[zone], this.sensors);
updateStatus(newAccessory, devices.hb[zone]);
// does user want outside sensors created? if so, only create 1 set
if ((this.sensors == "all" || this.sensors == "outside") && outsideSensors == 0) {
var newSensorsAccessory = new TccSensorsAccessory(this, devices.hb[zone], this.sensors);
updateStatus(newSensorsAccessory, devices.hb[zone]);
outsideSensors = 1;
}
}

@@ -100,7 +109,21 @@ }).catch((err) => {

});
// only attach this to the actual thermostat accessories, not the sensors accessory
accessory.context.ChangeThermostat = new ChangeThermostat(accessory);
debug("configureAccessory", accessory.context.ChangeThermostat);
}
accessory.context.ChangeThermostat = new ChangeThermostat(accessory);
// debug("CA", accessory.context.ChangeThermostat);
// add fakegato logging for
if (accessory.displayName == "Outside Sensors") {
debug(accessory);
debug("FakeGatoHistoryService", this.storage, this.refresh);
accessory.context.logEventCounter = 9; // Update fakegato on startup
accessory.loggingService = new FakeGatoHistoryService("weather", accessory, {
storage: this.storage,
minutes: this.refresh * 10 / 60
});
}
myAccessories.push(accessory);
//debug(accessory.context)
};

@@ -117,4 +140,7 @@

// debug("accessory", accessory);
accessory.getService(Service.Thermostat).getCharacteristic(Characteristic.TargetTemperature)
.updateValue(new Error("Status missing for thermostat"));
if (accessory.getService(Service.Thermostat)) {
accessory.getService(Service.Thermostat).getCharacteristic(Characteristic.TargetTemperature)
.updateValue(new Error("Status missing for thermostat"));
}
}

@@ -133,4 +159,6 @@ }.bind(this));

myAccessories.forEach(function(accessory) {
accessory.getService(Service.Thermostat).getCharacteristic(Characteristic.TargetTemperature)
.updateValue(new Error("Status missing for thermostat"));
if (accessory.getService(Service.Thermostat)) {
accessory.getService(Service.Thermostat).getCharacteristic(Characteristic.TargetTemperature)
.updateValue(new Error("Status missing for thermostat"));
}
});

@@ -145,33 +173,80 @@ });

.updateValue(device.Model);
var service = accessory.getService(Service.Thermostat);
service.getCharacteristic(Characteristic.Name)
.updateValue(device.Name);
service.getCharacteristic(Characteristic.TargetTemperature)
.updateValue(device.TargetTemperature);
service.getCharacteristic(Characteristic.CurrentTemperature)
.updateValue(device.CurrentTemperature);
service.getCharacteristic(Characteristic.CurrentHeatingCoolingState)
.updateValue(device.CurrentHeatingCoolingState);
service.getCharacteristic(Characteristic.TargetHeatingCoolingState)
.updateValue(device.TargetHeatingCoolingState);
service.getCharacteristic(Characteristic.CoolingThresholdTemperature)
.updateValue(device.CoolingThresholdTemperature);
service.getCharacteristic(Characteristic.HeatingThresholdTemperature)
.updateValue(device.HeatingThresholdTemperature);
// Fakegato Support
accessory.context.logEventCounter++;
if (!(accessory.context.logEventCounter % 10)) {
accessory.loggingService.addEntry({
time: moment().unix(),
currentTemp: device.CurrentTemperature,
setTemp: device.TargetTemperature,
valvePosition: device.CurrentHeatingCoolingState
});
accessory.context.logEventCounter = 0;
// check if user wants separate temperature and humidity sensors
if (accessory.getService(device.Name + " Temperature")) {
//debug("updateStatus() " + device.Name + " InsideTemperature = true");
var InsideTemperature = accessory.getService(device.Name + " Temperature");
InsideTemperature.getCharacteristic(Characteristic.CurrentTemperature)
.updateValue(device.CurrentTemperature);
}
if (accessory.getService("Outside Temperature")) {
//debug("updateStatus() " + device.Name + " outsideTemperature = true");
var OutsideTemperature = accessory.getService("Outside Temperature");
OutsideTemperature.getCharacteristic(Characteristic.CurrentTemperature)
.updateValue(device.OutsideTemperature);
}
if (accessory.getService(device.Name + " Humidity")) {
//debug("updateStatus() " + device.Name + " insideHumidity = true");
var InsideHumidity = accessory.getService(device.Name + " Humidity");
InsideHumidity.getCharacteristic(Characteristic.CurrentRelativeHumidity)
.updateValue(device.InsideHumidity);
}
if (accessory.getService("Outside Humidity")) {
//debug("updateStatus() " + device.Name + " outsideHumidity = true");
var OutsideHumidity = accessory.getService("Outside Humidity");
OutsideHumidity.getCharacteristic(Characteristic.CurrentRelativeHumidity)
.updateValue(device.OutsideHumidity);
}
// fakegato for outside sensor
if (accessory.displayName == "Outside Sensors") {
accessory.context.logEventCounter++;
if (!(accessory.context.logEventCounter % 10)) {
accessory.loggingService.addEntry({
time: moment().unix(),
humidity: device.OutsideHumidity,
temp: device.OutsideTemperature,
pressure: 0
});
accessory.context.logEventCounter = 0;
}
}
// update thermostat
if (accessory.getService(device.Name)) {
var service = accessory.getService(Service.Thermostat);
service.getCharacteristic(Characteristic.Name)
.updateValue(device.Name);
service.getCharacteristic(Characteristic.TargetTemperature)
.updateValue(device.TargetTemperature);
service.getCharacteristic(Characteristic.CurrentTemperature)
.updateValue(device.CurrentTemperature);
service.getCharacteristic(Characteristic.CurrentHeatingCoolingState)
.updateValue(device.CurrentHeatingCoolingState);
service.getCharacteristic(Characteristic.TargetHeatingCoolingState)
.updateValue(device.TargetHeatingCoolingState);
service.getCharacteristic(Characteristic.CoolingThresholdTemperature)
.updateValue(device.CoolingThresholdTemperature);
service.getCharacteristic(Characteristic.HeatingThresholdTemperature)
.updateValue(device.HeatingThresholdTemperature);
// Fakegato Support
accessory.context.logEventCounter++;
if (!(accessory.context.logEventCounter % 10)) {
accessory.loggingService.addEntry({
time: moment().unix(),
currentTemp: device.CurrentTemperature,
setTemp: device.TargetTemperature,
valvePosition: device.CurrentHeatingCoolingState
});
accessory.context.logEventCounter = 0;
}
}
}
function TccAccessory(that, device) {
function TccAccessory(that, device, sensors) {
this.log = that.log;
// this.log("Adding TCC Device", device.DeviceName);
//this.log("Adding TCC Device", device.Name);
this.name = device.Name;

@@ -183,10 +258,30 @@ this.ThermostatID = device.ThermostatID;

this.refresh = that.refresh;
//debug("TccAccessory()",device);
var uuid = UUIDGen.generate(this.name + " - TCC");
if (!getAccessoryByThermostatID(this.ThermostatID)) {
this.log("Adding TCC Device", this.name);
var createInsideSensors = false;
// need to get config for this thermostat id
switch (sensors) {
case "none":
createInsideSensors = false;
break;
case "all":
createInsideSensors = true;
break;
case "inside":
createInsideSensors = true;
break;
case "outside":
createInsideSensors = false;
break;
}
debug ("createInsideSensors: ",createInsideSensors);
if (!getAccessoryByName(this.name)) {
this.log("Adding TCC Device (deviceID="+this.ThermostatID+")", this.name);
this.accessory = new Accessory(this.name, uuid, 10);
this.accessory.log = that.log;
this.accessory.context.ThermostatID = device.ThermostatID;
this.accessory.context.name = this.name;
this.accessory.context.logEventCounter = 9; // Update fakegato on startup

@@ -201,2 +296,19 @@

this.accessory.addService(Service.Thermostat, this.name);
// check if user wants separate temperature and humidity sensors by zone/thermostat
if (createInsideSensors) {
debug("TccAccessory() " + this.name + " InsideTemperature = true, existing sensor");
this.InsideTemperatureService = this.accessory.addService(Service.TemperatureSensor, this.name + " Temperature", "Inside");
this.InsideTemperatureService
.getCharacteristic(Characteristic.CurrentTemperature)
.setProps({
minValue: -100, // If you need this, you have major problems!!!!!
maxValue: 100
});
debug("TccAccessory() " + this.name + " insideHumidity = true, existing sensor");
this.InsideHumidityService = this.accessory.addService(Service.HumiditySensor, this.name + " Humidity", "Inside");
this.InsideHumidityService
.getCharacteristic(Characteristic.CurrentRelativeHumidity);
}

@@ -269,7 +381,105 @@ // debug("HB", this.device, this.ThermostatID);

} else {
this.log("Existing TCC accessory", this.name);
return getAccessoryByThermostatID(this.ThermostatID);
this.log("Existing TCC accessory (deviceID="+this.ThermostatID+")", this.name);
// need to check if accessory/zone/thermostat already exists, but user added temp/humidity sensors then must declare
this.accessory = getAccessoryByName(this.name);
if (createInsideSensors && !this.accessory.getService(this.name + " Temperature")) {
debug("TccAccessory() " + this.name + " InsideTemperature = true, adding sensor");
this.InsideTemperatureService = this.accessory.addService(Service.TemperatureSensor, this.name + " Temperature", "Inside");
this.InsideTemperatureService
.getCharacteristic(Characteristic.CurrentTemperature)
.setProps({
minValue: -100, // If you need this, you have major problems!!!!!
maxValue: 100
});
}
if (createInsideSensors && !this.accessory.getService(this.name + " Humidity")) {
debug("TccAccessory() " + this.name + " InsideHumidity = true, adding sensor");
this.InsideHumidityService = this.accessory.addService(Service.HumiditySensor, this.name + " Humidity", "Inside");
this.InsideHumidityService
.getCharacteristic(Characteristic.CurrentRelativeHumidity);
}
return this.accessory;
}
}
function TccSensorsAccessory(that, device, sensors) {
this.log = that.log;
//this.log("Adding TCC Sensors Device");
this.name = "Outside Sensors"
this.ThermostatID = device.ThermostatID;
this.device = device;
this.storage = that.storage;
this.refresh = that.refresh;
//debug("TccSensorsAccessory()",device);
var uuid = UUIDGen.generate(this.name + " - TCC");
if (!getAccessoryByName(this.name)) {
this.log("Adding TCC Outside Sensors (deviceID="+this.ThermostatID+")", this.name);
this.accessory = new Accessory(this.name, uuid, 10);
this.accessory.log = that.log;
this.accessory.context.ThermostatID = device.ThermostatID;
this.accessory.context.name = this.name;
this.accessory.context.logEventCounter = 9; // Update fakegato on startup
this.accessory.getService(Service.AccessoryInformation)
.setCharacteristic(Characteristic.Manufacturer, "TCC")
.setCharacteristic(Characteristic.Model, device.Model)
.setCharacteristic(Characteristic.SerialNumber, hostname + "-" + this.name)
.setCharacteristic(Characteristic.FirmwareRevision, require('./package.json').version);
// create outside temp sensor
debug("TccSensorsAccessory() " + this.name + " outsideTemperature = true, existing sensor");
this.OutsideTemperatureService = this.accessory.addService(Service.TemperatureSensor, "Outside Temperature", "Outside");
this.OutsideTemperatureService
.getCharacteristic(Characteristic.CurrentTemperature)
.setProps({
minValue: -100, // If you need this, you have major problems!!!!!
maxValue: 100
});
// create outside humidity sensor
debug("TccSensorsAccessory() " + this.name + " outsideHumidity = true, existing sensor");
this.OutsideHumidityService = this.accessory.addService(Service.HumiditySensor, "Outside Humidity", "Outside");
this.OutsideHumidityService
.getCharacteristic(Characteristic.CurrentRelativeHumidity);
this.accessory.loggingService = new FakeGatoHistoryService("weather", this.accessory, {
storage: this.storage,
minutes: this.refresh * 10 / 60
});
that.api.registerPlatformAccessories("homebridge-tcc", "tcc", [this.accessory]);
myAccessories.push(this.accessory);
return this.accessory;
} else {
this.log("Existing TCC outside sensors accessory (deviceID="+this.ThermostatID+")", this.name);
// need to check if accessory/zone/thermostat already exists, but user added temp/humidity sensors then must declare
this.accessory = getAccessoryByName("Outside Sensors");
if (!this.accessory.getService("Outside Temperature")) {
debug("TccSensorsAccessory() " + this.name + " OutsideTemperature = true, adding sensor");
this.OutsideTemperatureService = this.accessory.addService(Service.TemperatureSensor, "Outside Temperature", "Outside");
this.OutsideTemperatureService
.getCharacteristic(Characteristic.CurrentTemperature)
.setProps({
minValue: -100, // If you need this, you have major problems!!!!!
maxValue: 100
});
}
if (!this.accessory.getService("Outside Humidity")) {
debug("TccSensorsAccessory() " + this.name + " outsideHumidity = true, adding sensor");
this.OutsideHumidityService = this.accessory.addService(Service.HumiditySensor, "Outside Humidity", "Outside");
this.OutsideHumidityService
.getCharacteristic(Characteristic.CurrentRelativeHumidity);
}
return this.accessory;
}
}
function setTargetTemperature(value, callback) {

@@ -330,2 +540,13 @@ this.log("Setting target temperature for", this.displayName, "to", value + "°");

function getAccessoryByName(accessoryName) {
var value;
myAccessories.forEach(function(accessory) {
// debug("getAccessoryByName zone", accessory.name, name);
if (accessory.context.name === accessoryName) {
value = accessory;
}
});
return value;
}
function getAccessoryByThermostatID(ThermostatID) {

@@ -332,0 +553,0 @@ var value;

@@ -181,2 +181,3 @@ // var debug = require('debug')('tcc-libMessage');

response.Model = thermostat.ModelTypeName;
response.OutsideTemperature = toCelcius(thermostat.UI.OutdoorTemp, thermostat);
response.CurrentTemperature = toCelcius(thermostat.UI.DispTemperature, thermostat);

@@ -193,2 +194,4 @@ response.TargetTemperature = toCelcius(targetTemperature(thermostat), thermostat);

response.TargetTemperatureCoolMaxValue = toCelcius(thermostat.UI.CoolUpperSetptLimit, thermostat);
response.OutsideHumidity = thermostat.UI.OutdoorHumidity;
response.InsideHumidity = thermostat.UI.IndoorHumidity;
response.device = thermostat;

@@ -195,0 +198,0 @@ return response;

2

package.json
{
"name": "homebridge-tcc",
"version": "0.2.16",
"version": "0.2.17",
"description": "Honeywell Total Connect Comfort support for Homebridge: https://github.com/nfarina/homebridge",

@@ -5,0 +5,0 @@ "license": "ISC",

@@ -18,2 +18,3 @@ # homebridge-tcc

* MHK1
* Honeywell's Prestige IAQ Thermostat (THX9421R5021WW) and it's accompanying Equipment Interface Module (THM5421R1021)

@@ -28,3 +29,3 @@ # Installation

Please ensure the node-gyp is properly configured for use prior to installing. Error messages like this may appear during installtion if not.
Please ensure the node-gyp is properly configured for use prior to installing. Error messages like this may appear during installation if not.

@@ -60,2 +61,7 @@ ```

* `usePermanentHolds` - If set to `true`, temperature changes will be set as permanent holds, rather than temporary holds. This will allow you to use HomeKit automations to completely replace your thermostat's schedule. If set to `false`, the temperature changes will expire after a certain period of time and resume your normal schedule. By default, this is off.
* `sensors` - Enables temperature/humidity HomeKit sensors (useful for automations), options include:
* `none` - No sensors will be shown (this is default setting)
* `all` - Enables all available temperature/humidity sensors
* `inside` - Enables temperature and humidity sensors for each thermostat
* `outside` - Enables a single set of outdoor temperature and humidity sensors
* `debug` - Enables debug level logging from the plugin, defaults to `false`, to enable set to `true`

@@ -74,1 +80,3 @@

- hakusaro - Added support for permanent temperature holds.
- jcgorla-dev - Validation of Honeywell's Prestige IAQ Thermostat
- kylerove - Added support for separate indoor and outdoor temperature / humidity sensors
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc