hobbyquaker / homekit2mqtt

HomeKit to MQTT bridge 🏡📱
MIT License
349 stars 71 forks source link

Temperature Sensor #28

Closed raufis27 closed 7 years ago

raufis27 commented 7 years ago

Hello and thanks for project!

For some reason temperature sensor displays wrong value. F.e openHAB reports 65.60 to MQTT topic but HomeKit displays 150. Any ideas ?

hobbyquaker commented 7 years ago

Seems to be the wrong unit. 65.6°C is 150°F. I guess the Home App and Siri respect the setting in iOS language preferences, there you can choose between Fahrenheit and Celsius.

raufis27 commented 7 years ago

Well, I have other temp sensor in homekit - Ecobee - and it displays °F. iOS settings also setup for °F. Also when I ask siri what is temperature she says 160 °F (not celsius ).

raufis27 commented 7 years ago

So I switched from F to C in iOS settings and got 66 instead of 150. So looks like it reversed.

hobbyquaker commented 7 years ago

hmm... So the 65° OpenHAB reports is the correct value in Fahrenheit but homekit2mqtt treats it like it's Celsius. Have to see if there is a TemperatureDisplayUnits Characteristic for the TemperatureSensor, I know the Thermostat has this, but I'm not sure if TemperatureSensor can use this too... Will have to try and if it works I will create a config option for that.

raufis27 commented 7 years ago

ok, thank you! Also there is a problem with outlet item. I'll open another topic for it.

hobbyquaker commented 7 years ago

as far as i understood homekit is internally working with celsius only. So I added an optional conversion to the TemperatureSensor Accessory. Just add the config option fahrenheit like this:

  "TemperatureSensor": {
    "service": "TemperatureSensor",
    "name": "TemperatureSensor",
    "topic": {
      "statusTemperature": "TemperatureSensor/Temperature"
    },
    "config": {
      "fahrenheit": true
    },
    "manufacturer": "Generic",
    "model": "TemperatureSensor"
  },

Would be glad to hear if this works for you, Regards, Sebastian

raufis27 commented 7 years ago

Here is an error:

/usr/local/lib/node_modules/homekit2mqtt/accessories/TemperatureSensor.js:5
        log.debug('converting', value, '°F to °C');
        ^

ReferenceError: log is not defined
    at convertTemperature (/usr/local/lib/node_modules/homekit2mqtt/accessories/TemperatureSensor.js:5:9)
    at sensor.addService.getCharacteristic.setProps.on.callback (/usr/local/lib/node_modules/homekit2mqtt/accessories/TemperatureSensor.js:27:37)
    at emitThree (events.js:116:13)
    at emit (events.js:194:7)
    at Characteristic.getValue (/usr/local/lib/node_modules/homekit2mqtt/node_modules/hap-nodejs/lib/Characteristic.js:129:10)
    at Bridge.<anonymous> (/usr/local/lib/node_modules/homekit2mqtt/node_modules/hap-nodejs/lib/Accessory.js:650:20)
    at Array.forEach (native)
    at Bridge.Accessory._handleGetCharacteristics (/usr/local/lib/node_modules/homekit2mqtt/node_modules/hap-nodejs/lib/Accessory.js:614:8)
    at emitMany (events.js:127:13)
    at HAPServer.emit (events.js:201:7
hobbyquaker commented 7 years ago

Sorry. My fault. Just pushed an update (v0.6.8) that should fix this.

raufis27 commented 7 years ago

Same error, what should I do to get updates ? I am updating using - sudo npm install -g homekit2mqtt --unsafe-perm

raufis27 commented 7 years ago

Sorry, rushed. I got update.

hobbyquaker commented 7 years ago

Did you get the 0.6.8? Perhaps there is some lag in npmjs's cdn, you could also try to install this specific version by doing sudo npm install -g homekit2mqtt@0.6.8 --unsafe-perm

hobbyquaker commented 7 years ago

seems we're both too fast ;-))

raufis27 commented 7 years ago

:) you are awesome! Looks like it works. I am waiting for OH to push update from sensor. Thank you. I have another question regarding "GarageDoor", may I ask here or open another topic ?

hobbyquaker commented 7 years ago

i would prefer separate issues :)

raufis27 commented 7 years ago

Confirmed. Fixed. Thank you!