dubocr / homebridge-gpio-device

Homebridge GPIO device expose several HomeKit accessories interacting with GPIO
Apache License 2.0
66 stars 20 forks source link

Duration is missing in HomeKit for valves #87

Closed AndreasPrang closed 4 years ago

AndreasPrang commented 4 years ago

I think for water valve the following Characteristic is missing to have duration variable working properly:

.getCharacteristic(Characteristic.RemainingDuration)

AndreasPrang commented 4 years ago

I realised it with like this:

  sprinkler
  .getService(Service.Valve)
  .getCharacteristic(Characteristic.RemainingDuration)
  .on('get', function(callback) {

    var err = null; // in case there were any problems

    if (SPRINKLER.active) {

      var duration = SPRINKLER.timerEnd - Math.floor(new Date() / 1000);
      console.log(SPRINKLER.typeName + " RemainingDuration: " + duration)
      callback(err, duration);
    }
    else {
      callback(err, 0);
    }
  });
AndreasPrang commented 4 years ago

Fixed the issue with PR #88