CestLaGalere / mobilealerts

Retrieves sensor data for Mobile Alerts sensors for Home Assistant
Apache License 2.0
15 stars 6 forks source link

extremely high values for a sensor #8

Closed florianutz closed 9 months ago

florianutz commented 9 months ago

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
}
petrleocompel commented 9 months ago

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

florianutz commented 9 months ago

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"?

petrleocompel commented 9 months ago

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

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.

petrleocompel commented 9 months ago

Released as v1.2.0

florianutz commented 8 months ago

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

florianutz commented 8 months ago

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