Leggin / dirigera

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

Added support for open/close sensors, such as SONOFF SNZB-04 #15

Closed fpb closed 1 year ago

fpb commented 1 year ago

Added support for open/close sensor. Tested with SONOFF SNZB-04.

The Home Smart detected the device but it doesn't allow me to connect any of my devices (just lights) to it. However, I can get notifications of "deviceStateChanged, like this one:

{'id': '8ac676e8-4e40-4be5-9d6b-b497afa63117', 'time': '2023-05-05T19:13:37.000Z', 'specversion': '3.123.0', 'source': 'urn:com:ikea:homesmart:iotc:zigbee', 'type': 'deviceStateChanged', 'data': {'id': '19c7a1b9-cb7e-4fb4-a55f-0962d57ac415_1', 'type': 'sensor', 'deviceType': 'openCloseSensor', 'createdAt': '2023-05-05T17:25:13.000Z', 'isReachable': True, 'lastSeen': '2023-05-05T19:13:37.000Z', 'attributes': {'isOpen': False}, 'remoteLinks': []}}

it is just basically issuing isOpen changes. Thus, I can control whatever lights I want with my raspberry pi running my "man in the middle" software :)

Here is a dump from the device after being added to the Dirigera hub (as an Ikea motion sensor):

 {
        "attributes":{
            "customName":"Wireless Door Sensor",
            "firmwareVersion":"",
            "hardwareVersion":"",
            "isOpen":false,
            "manufacturer":"SONOFF",
            "model":"Wireless Door/Window Sensor",
            "permittingJoin":false,
            "productCode":"SNZB-04",
            "serialNumber":"00124B0029121E50"
        },
        "capabilities":{
            "canReceive":[
                "customName"
            ],
            "canSend":[

            ]
        },
        "createdAt":"2023-05-05T17:25:13.000Z",
        "deviceSet":[

        ],
        "deviceType":"openCloseSensor",
        "id":"19c7a1b9-cb7e-4fb4-a55f-0962d57ac415_1",
        "isHidden":false,
        "isReachable":true,
        "lastSeen":"2023-05-05T17:37:47.000Z",
        "remoteLinks":[

        ],
        "room":{
            "color":"pantone_16_0230_tcx",
            "icon":"rooms_arm_chair",
            "id":"cd65155a-4f9c-4182-bc13-c449c55bf127",
            "name":"Storage room"
        },
        "type":"sensor"
    }