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

Question about the VALLHORN PIR #75

Closed nipsgur closed 1 month ago

nipsgur commented 2 months ago

Hi Nicolas thanks a lot for sharing this nice library. I got interested in it for the air quality sensors and it works like a charm.

So, now I also got one of the new motion sensors, but I'm struggling a little. (I have to say I don't have any bulb or outlet connected to it) Looks like the motion sensor does not send any events by itself. I also never saw the is_on attribute change to True when I trigger the motion sensor, the only thing that changes is the last_seen attribute.

I have read the other topic about triggering a scene from a remote, but I couldn't figure out if a motion sensor can trigger a scene? So to me it looks like a motion sensor needs to be hard wired to an on/off device?

So my question would be, in the event system, would an on/off device know which other device switched it? In this as a workaround, I could get just one outlet and use it as a dummy to be triggered by all the motion sensors? But maybe a on/off device can only be controlled by one motion sensor?

Would be glad about any suggestions, Torben

Leggin commented 2 months ago

So to me it looks like a motion sensor needs to be hard wired to an on/off device?

I sadly don't know since I don't have one but the Ikea app also only shows action button as trigger for a scene.

So my question would be, in the event system, would an on/off device know which other device switched it? In this as a workaround, I could get just one outlet and use it as a dummy to be triggered by all the motion sensors? But maybe a on/off device can only be controlled by one motion sensor?

I just tested this by switching a light on, first in the app which gave this event:

{
  "id": "53963fa6-8587-4dc3-96fa-3b2fa6a05eb7",
  "time": "2024-05-14T05:50:33.000Z",
  "specversion": "3.150.0",
  "source": "urn:com:ikea:homesmart:iotc:zigbee",
  "type": "deviceStateChanged",
  "data": {
    "id": "d58a09a1-537c-467c-9bcf-1c4be0c2185e_1",
    "type": "light",
    "deviceType": "light",
    "createdAt": "2024-05-02T16:12:36.000Z",
    "isReachable": true,
    "lastSeen": "2024-05-14T07:50:33.000Z",
    "attributes": { "isOn": true },
    "remoteLinks": ["99e6be90-12f0-4708-9c63-b45ed64824d8_1"]
  }
}

and then switching it back off with an Ikea switch, which gave this event:

{
  "id": "57bfff69-fb95-4fe1-9eac-3b56debfa976",
  "time": "2024-05-14T05:51:07.000Z",
  "specversion": "3.150.0",
  "source": "urn:com:ikea:homesmart:iotc:zigbee",
  "type": "deviceStateChanged",
  "data": {
    "id": "d58a09a1-537c-467c-9bcf-1c4be0c2185e_1",
    "type": "light",
    "deviceType": "light",
    "createdAt": "2024-05-02T16:12:36.000Z",
    "isReachable": true,
    "lastSeen": "2024-05-14T07:51:07.000Z",
    "attributes": { "isOn": false },
    "remoteLinks": ["99e6be90-12f0-4708-9c63-b45ed64824d8_1"]
  }
}

I don't see any difference in this data except for the timestamp so I doubt that it is possible to see which real source triggered the action. Although there is a small chance that motion sensors in combination with an outlet behave differently, so if you get a change to verify your hypothesis let me know 😉

Leggin commented 2 months ago

@nipsgur

I have read the other topic about triggering a scene from a remote, but I couldn't figure out if a motion sensor can trigger a scene?

I found a way! In the app when you go to the system settings and scroll down you will see the feature test center. There you can toggle using sensors as triggers for a scene.

nipsgur commented 2 months ago

I found a way! In the app when you go to the system settings and scroll down you will see the feature test center. There you can toggle using sensors as triggers for a scene.

That sounds like a solution, very cool.

I quickly checked, but I only found these three in this "Workshop" test center.

"Matter Bridge integration" "Presets for smart lights" "Pin your favorites"

Maybe I have to wait a little to see the new feature? (I have android app 1.25.1 and dirigera 2.556.0 firmware)

On the other side, if I poll the is_detected Attribute I can see it change to True if a motion is detected and I did not associate any lights or outlets.

nipsgur commented 2 months ago

Maybe I have to wait a little to see the new feature? (I have android app 1.25.1 and dirigera 2.556.0 firmware)

ok, the “Start scenes by sensor activity” has not arrived on android jet.

https://www.reddit.com/r/tradfri/comments/1bzb99x/comment/kyw5kel/

nipsgur commented 1 month ago

little update, The "Workshop" feature also arrived on android with the last update and now it shows motion events in the listener. I also get an event for the "empty" scene, that I put the motion sensor in, when it was triggered.

{'id': '4d56a98a-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
    'time': '2024-05-24T19:39:38.000Z',
    'specversion': '3.150.0',
    'source': 'urn:com:ikea:homesmart:iotc:zigbee',
    'type': 'deviceStateChanged',
    'data': {'id': 'c26d2377-xxxx-xxxx-xxxx-xxxxxxxxxxxx_1',
                'type': 'sensor',
                'deviceType': 'motionSensor',
                'createdAt': '2024-05-08T17:57:48.000Z',
                'isReachable': True,
                'lastSeen': '2024-05-24T21:39:38.000Z',
                'attributes': {'isDetected': True,
                                'sensorConfig': {'scheduleOn': False,
                                                    'onDuration': 60,
                                                    'schedule': {'onCondition': {'time': '22:00'},
                                                                    'offCondition': {'time': '06:00'}
                                                                }
                                                },
                                'circadianPresets': []
                                },
                'remoteLinks': []
            }
}

{'id': 'b1b8b244-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
    'time': '2024-05-24T19:40:38.000Z',
    'specversion': '3.150.0',
    'source': 'urn:com:ikea:homesmart:iotc:zigbee',
    'type': 'deviceStateChanged',
    'data': {'id': 'c26d2377-xxxx-xxxx-xxxx-xxxxxxxxxxxx_1',
                'type': 'sensor',
                'deviceType': 'motionSensor',
                'createdAt': '2024-05-08T17:57:48.000Z',
                'isReachable': True,
                'lastSeen': '2024-05-24T21:40:08.000Z',
                'attributes': {'isDetected': False,
                                'sensorConfig': {'scheduleOn': False,
                                                    'onDuration': 60,
                                                    'schedule': {'onCondition': {'time': '22:00'},
                                                                    'offCondition': {'time': '06:00'}
                                                                }
                                                },
                                'circadianPresets': []
                                },
                'remoteLinks': []
            }
}