dkerr64 / homebridge-yolink

Apache License 2.0
12 stars 2 forks source link

Support for X3 SMART TEMPERATURE (YS8006) #62

Open Flip76 opened 1 year ago

Flip76 commented 1 year ago

Is your feature request related to a problem? Please describe: Yes, the plugin throws errors:

[10/13/2022, 4:00:01 PM] [YoLink] MQTT: THSensor.DataRecord for device Repbox (d88b4c0100xxxxxx) not supported. Please report all bugs at https://github.com/dkerr64/homebridge-yolink/issues {"event":"THSensor.DataRecord","time":1665651601414,"msgid":"1665651601414","data":{"records":[{"temperature":29.2,"humidity":63.9,"time":"2022-10-13T08:50:01.000Z"}]},"deviceId":"d88b4c0100xxxxxx"}

Describe the solution you'd like: Seems like more and more Yolink environmental devices are sending THSensor.DataRecord updates. Would be good to just take them as last valid values

Describe alternatives you've considered: n/a

Additional context: n/a

dkerr64 commented 1 year ago

Thank you @Flip76 for reporting this... first time I have seen this MQTT so yes I need to handle it and not report an error. And of course it is not documented at YoSmart's web site.

However I'm not sure I should do anything with the data. The data records is an array which presumably could have a series of temperature and humidity values returned each with a timestamp. Unless the timestamp is more recent than the last update (from a THSensor.Report message) then I should ignore it. And I strongly suspect that we would not receive a MTSensor.DataRecord without having also received a THSensor.Report.

I'll ask YoLink, but I am inclined to ignore the data array as there is nothing I can do to pass what could be an array of multiple values up to Homebridge/HomeKit.

Thanks

Flip76 commented 1 year ago

As far as I can see, it's always 1 record - also in the app it shows only this one timestamp for the last measurement - once you click refresh in the app, you will get a normal THSensor.Report. So if you just ignore the DataRecord, it should be fine as long as you catch the Report. Here is a getState-output were you can see the recordInterval:

{
  "code": "000000",
  "time": 1665666280911,
  "msgid": 1665666280911,
  "method": "THSensor.getState",
  "desc": "Success",
  "data": {
    "online": true,
    "state": {
      "alarm": {
        "lowBattery": false,
        "lowTemp": false,
        "highTemp": false,
        "lowHumidity": false,
        "highHumidity": false,
        "period": false,
        "code": 0
      },
      "battery": 4,
      "batteryType": "Li",
      "humidity": 63.8,
      "humidityCorrection": 0,
      "humidityLimit": {
        "max": 100,
        "min": 0
      },
      "interval": 0,
      "mode": "c",
      "recordInterval": 10,
      "state": "normal",
      "tempCorrection": 0,
      "tempLimit": {
        "max": 35,
        "min": 18
      },
      "temperature": 28.9,
      "version": "0602"
    },
    "deviceId": "d88b4c0100xxxxxx",
    "reportAt": "2022-10-13T12:50:01.000Z"
  }
}

According to the documentation:

Both temperature and humidity values refresh when one of the following conditions are met:

dkerr64 commented 1 year ago

Thanks for the additional detail. I have posted into YoLink's developer support forum asking how this message is supposed to be handled.