CestLaGalere/mobilealerts

extremely high values for a sensor

Closed this issue · 6 comments

I have repeatedly received extremely high values for a sensor in Home Assistant. After observing the behaviour, I found out that the API returns five-digit values.
The thermometer itself and https://measurements.mobile-alerts.eu/Home/MeasurementDetails shows --. It looks like the API is returning high values when there is no information from the thermometer/hygrometer for a while.
I know it's not a problem of the plugin, but maybe it can be checked if the return value of the api is a reasonable value (eg percentage <= 100 and temp < 99

API return example:

{
  "devices": [
    {
      "deviceid": "xxxxxxxxxxxx",
      "lastseen": 1701449845,
      "lowbattery": false,
      "measurement": {
        "idx": 3585455,
        "ts": 1701449843,
        "c": 1701449845,
        "t1": 20.8,
        "t2": 0.0,
        "t3": 20.1,
        "t4": 19.5,
        "h1": 46.0,
        "h2": 43530.0,
        "h3": 49.0,
        "h4": 50.0
      }
    }
  ],
  "success": true
}

I guess nobody will have problems with this. I am taking care of this.

That would be awesome. Today I have noticed that another sensor was offline. On MobileAlerts it looks like this:
image

API says:

{
  "devices": [
    {
      "deviceid": "xxxxxxxxxxxx",
      "lastseen": 1702221724,
      "lowbattery": false,
      "measurement": {
        "idx": 3602864,
        "ts": 1702221718,
        "c": 1702221724,
        "t1": 21.1,
        "t2": 5.6,
        "t3": 20.7,
        "t4": 43530.0,
        "h1": 46.0,
        "h2": 92.0,
        "h3": 49.0,
        "h4": 43530.0
      }
    }
  ],
  "success": true
}

in Homeassistant it look like that:
image

maybe 43530.0 is the value for "unknown"?

The value 43530 is verry wierd. I would guess that they normally use signed int with different bit sizes:

  • 8-bit signed integer (int8): maximum value of 127
  • 16-bit signed integer (int16): maximum value of 32,767

Seems somebody had "better idea". Even for the "%" (humidity).

But lets go with it. I would normaly had it done in minutes but ... Previously I merged those all classes together and now because we need to change part of only 2 of them it is not "pretty" solution. I might will just finish it quickly today and other day i will refactor the code.

Released as v1.2.0

Thank you very much! I have installed v1.2.0 and will test it.

@petrleocompel I can confirm that your patch works. Thanks a lot.