snowdd1 / homebridge-knx

KNX platform shim for homebridge
https://github.com/nfarina/homebridge
GNU General Public License v2.0
97 stars 56 forks source link

Problem with float values transmitted from HomeBridge to KNX #107

Closed brice81 closed 5 years ago

brice81 commented 6 years ago

Hello,

I recently tried to add Thermostat service to my accessories managed by Homebridge-KNX.

From the doc, it seems that TargetTemperature characteristic is a float, but the doc does not say if it is an eis 5 float type (2 bytes float, with specific KNX format) or an eis 9 float type (4 bytes, IEEE 754 format).

I scanned the KNX EMI frames sent by the application and what is sent does not match any of the two formats :

  1. the size of the frame does not match none of the formats (1 byte too long for eis 5, 1 byte too short for eis 9.
  2. one of the bytes transmitted in the data is always 0. I tried to decode the frame as if it was not present, supposing an eis 5 float type. I get values that are not totally abberant, but that are not correct. If I configure target temperature to 10° on my IPhone, I get a value of 8.96. If I configure a target temperature of 21°, I get a value of 23.04. I have exactly the same temperature if I configure a target of 22°.

Note that floats sent by KNX devices to Homebridge are properly interpreted by my IPhone. For example, if I configure a TemperatureSensor service and link it to my Hager temperature sensor equipment, temperatures are properly interpreted and displayed by my IPhone.

I could try to investigate this problem myself, if needed, but I would need some help to understand what is the supposed format of the float value, where this float value is converted, and where is the CEMI frame generated ?

Many thanks in advance,

Brice

brice81 commented 6 years ago

After some additional checks, abberant values come from a bug in my code that managed the additional null byte in the CEMI frame. Now, if I remove the additional null byte and consider the transmitted data as an eis 5 float type, I get exactly the value sent by my IPhone.

With this workaround, this is no more a blocking issue for me, as I am able to manage properly data exchange with IPhone, but I think there remains a bug with this additional null byte sent before the float value in the CEMI frame.

Regards, Brice

snowdd1 commented 6 years ago

Hi Brice, I have to admit that I did not completely got what you did and where the fault occurs.

In which direction happen the extra 0-bytes? From homebridge-knx to knx bus or from the physical application device to homebridge-knx?

The EIS5 float is IMHO the DPT9 type, and that's what homebridge-knx defaults to when handling a homekit float value. The actual packing of the frame is done in node-eibd and the sending to the physical bus device bei knxd. You might try if the groupsend of node-eibd results in the same frames in your installation. I have to admit that I currently do not have a device that requires floats to be send to. Have to think about that. Maybe I can fake something on the weekend.

snowdd1 commented 5 years ago

stale

coinraiser commented 5 years ago

any progress on 4 byte? would like to use it for power consumption,also can u add service PowerMeter type and Characteristics type Watts and KilowattHours? From https://github.com/sprut666666/new-types-for-homekit