webdeck / homebridge-indigo

Homebridge Plugin for Indigo
Apache License 2.0
13 stars 6 forks source link

Feature Request: Sensor Device Type #10

Closed dougkillmer closed 7 years ago

dougkillmer commented 7 years ago

It would be great to have a treatAsSensor parameter in the config. I've got devices with temperature, humidity and barometer attributes. Right now, my only option is to identify these devices as thermostats so I can access some of these values in HomeKit.

etiennetalbot commented 7 years ago

+1

blysik commented 7 years ago

Ditto for 'ContactSensor' and 'MotionSensor'.

etiennetalbot commented 7 years ago

Made a PR for MotionSensor support https://github.com/webdeck/homebridge-indigo/pull/15

etiennetalbot commented 7 years ago

Another one for ContactSensor support https://github.com/webdeck/homebridge-indigo/pull/16 There you go @blysik , once this is merged, you will have all you wanted. Sorry @dougkillmer I don't have devices with temperature/humidity/barometer attributes so I can't test anything. Would have added it but I don't want to push untested code.

webdeck commented 7 years ago

Thanks for the PR - merged and published to NPM.

dougkillmer commented 7 years ago

@etiennetalbot I don't see a way to access custom attributes with the REST API, so I think I'm stuck with the thermostat device type and its built-in attributes (inputTemperatureVals, inputHumidityVals). I ended up adding a separate device type and then borrowed code from the thermostat to update these attributes.

`function IndigoTemperatureSensorAccessory(platform, deviceURL, json) { IndigoAccessory.call(this, platform, Service.TemperatureSensor, deviceURL, json);

this.service.getCharacteristic(Characteristic.CurrentTemperature)
    .setProps({minValue: -50})
    .on('get', this.getCurrentTemperature.bind(this));  

this.service.addCharacteristic(new Characteristic.CurrentRelativeHumidity)
    .on('get', this.getCurrentRelativeHumidity.bind(this));

} `

The main issue I had with the default thermostat was the minimum value of the CurrentTemperature characteristic. Anything below 0C would cause an error value in Homebridge.

webdeck commented 7 years ago

I added the minValue of -50 to thermostat current temperature.

dougkillmer commented 7 years ago

Perfect, thanks @webdeck!