openmotics / home-assistant

OpenMotics Home Assistant integration Beta
GNU Affero General Public License v3.0
15 stars 9 forks source link

Temperature/humidity sensors show zero value when using local #16

Closed tmds closed 1 year ago

tmds commented 2 years ago

I have changed from using the cloud connection to using a local connection. When using the cloud connection, values from temperature and humidity sensors were reported in hass. With the local connection, all these sensors report a value of zero.

cc @woutercoppens

woutercoppens commented 1 year ago

If you connect directly to the local gateway, do the sensors report the correct values? It's not clear from your description if it's a bug in pyhaopenmotics or in the gateway.

tmds commented 1 year ago

Yes, the values show up on the local gateway.

The response for https://openmotics.local./get_sensor_temperature_status for example looks like:

{"status":[20.5,21.5,21.0,null,null,null,19.5,null,20.0,21.0,21.5,21.0,20.0],"success":true}
tmds commented 1 year ago

I'm looking at the code in https://github.com/openmotics/pyhaopenmotics.

I see sensors.py is using get_sensor_configurations and get_sensor_status.

The json for these endpoints looks something like:

{
    "config": [
        {
            "name": "Leefruimte",
            "in_use": true,
            "external_id": "1",
            "virtual": false,
            "source": {
                "type": "master",
                "name": null
            },
            "offset": 0,
            "physical_quantity": "temperature",
            "id": 1,
            "unit": "celcius",
            "room": 0
        },
        {
            "name": "Leefruimte",
            "in_use": true,
            "external_id": "1",
            "virtual": false,
            "source": {
                "type": "master",
                "name": null
            },
            "offset": 0,
            "physical_quantity": "humidity",
            "id": 4,
            "unit": "percent",
            "room": 255
        }
    ],
    "success": true
}

and

{
    "status": [
        {
            "id": 1,
            "value": 22.0
        },
        {
            "id": 4,
            "value": 57.0
        }
    ],
    "success": true
}

This last one doesn't seem to match with what's expected by Status.from_dict.

tmds commented 1 year ago

I patched

            humidity=data.get("humidity", 0),
            temperature=data.get("temperature", 0),
            brightness=data.get("brightness", 0),

to

            humidity=data.get("value", 0),
            temperature=data.get("value", 0),
            brightness=data.get("value", 0),

and now sensor values are reported.

woutercoppens commented 1 year ago

Hi Tom,

I'm currently in the middle of a construction. I'll have a look at in the next weeks. Are you running the last version on the gateway?

tmds commented 1 year ago

Yes, I'm running the latest version (2.25.4).

There's no rush, I can see the values with the patch.