Leggin / dirigera

This repository provides an unofficial Python client for controlling the IKEA Dirigera Smart Home Hub.
MIT License
99 stars 19 forks source link

Support for extended sensors with temperature as float #51

Closed josesa closed 4 months ago

josesa commented 4 months ago

I grabbed a couple of Xiaomi Mijia (LYWSD03MMC) and flashed them with Zigbee firmware. I have then connected them to dirigera hub so I could have the temperature and humidity in the IKEA app as well in HomeAssistant. As I was playing around with it, I've noticed that the values where rounded to Integers although the API seems to send floats.

While this kind of precision is normally not really necessary I was not expecting for the app to crash.

So attached is a partial from the devices request for the environmentSensors in case you would like to support these.

    {
        "id": "c9916e3a-36eb-49e3-9ffe-1029a924ce83_1",
        "type": "sensor",
        "deviceType": "environmentSensor",
        "createdAt": "2024-01-25T18:27:55.000Z",
        "isReachable": true,
        "lastSeen": "2024-02-24T15:45:49.000Z",
        "attributes": {
            "customName": "Living room",
            "model": "LYWSD03MMC",
            "manufacturer": "Xiaomi",
            "firmwareVersion": "3001-0118",
            "hardwareVersion": "15",
            "serialNumber": "A4C1387258CC3FA9",
            "batteryPercentage": 100,
            "currentTemperature": 23.13,
            "currentRH": 48,
            "permittingJoin": false,
            "otaStatus": "upToDate",
            "otaState": "readyToCheck",
            "otaProgress": 0,
            "otaPolicy": "autoUpdate",
            "otaScheduleStart": "00:00",
            "otaScheduleEnd": "00:00"
        },
        "capabilities": {
            "canSend": [],
            "canReceive": [
                "customName"
            ]
        },
        "room": {
            "id": "ca6f044c-583d-4722-b597-d04e646828c5",
            "name": "Living room",
            "color": "ikea_green_no_65",
            "icon": "rooms_sofa"
        },
        "deviceSet": [],
        "remoteLinks": [],
        "isHidden": false
    },
    {
        "id": "c0dceebd-5397-493c-9ea7-743c031f3ba9_1",
        "type": "sensor",
        "deviceType": "environmentSensor",
        "createdAt": "2024-01-25T18:39:35.000Z",
        "isReachable": true,
        "lastSeen": "2024-02-24T15:42:21.000Z",
        "attributes": {
            "customName": "Bedroom ",
            "model": "LYWSD03MMC",
            "manufacturer": "Xiaomi",
            "firmwareVersion": "3001-0118",
            "hardwareVersion": "15",
            "serialNumber": "A4C138341FF3BA8D",
            "batteryPercentage": 87,
            "currentTemperature": 21.55,
            "currentRH": 52,
            "permittingJoin": false,
            "otaStatus": "upToDate",
            "otaState": "readyToCheck",
            "otaProgress": 0,
            "otaPolicy": "autoUpdate",
            "otaScheduleStart": "00:00",
            "otaScheduleEnd": "00:00"
        },
        "capabilities": {
            "canSend": [],
            "canReceive": [
                "customName"
            ]
        },
        "room": {
            "id": "9c591e0c-7f9b-4091-821d-3f6231d4e2e5",
            "name": "Bedroom ",
            "color": "ikea_blue_no_58",
            "icon": "rooms_bed"
        },
        "deviceSet": [],
        "remoteLinks": [],
        "isHidden": false
    }
Leggin commented 4 months ago

Interesting find, thank you, I will change it to float.