Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[hue] Add channel for last motion (API v2) #15546

Closed
jlaur opened this issue Sep 4, 2023 · 5 comments · Fixed by #15552
Closed

[hue] Add channel for last motion (API v2) #15546

jlaur opened this issue Sep 4, 2023 · 5 comments · Fixed by #15552
Assignees
Labels
enhancement An enhancement or new feature for an existing add-on

Comments

@jlaur
Copy link
Contributor

jlaur commented Sep 4, 2023

As reported here:
https://community.openhab.org/t/philips-hue-clip-2-api-v2-discussion-thread/142111/216

The Hue API v2 implementation in 4.0 does not support the equivalent of Hue API v1 channel last_updated for thing type 0107.

This is actually supported by the API, so we are simply missing a channel for this:

GET /clip/v2/resource/device/00000000-0000-0000-0000-000000000000

Response:

{
    "errors": [],
    "data": [
        {
            "id": "00000000-0000-0000-0000-000000000000",
            "id_v1": "/sensors/250",
            "product_data": {
                "model_id": "SML003",
                "manufacturer_name": "Signify Netherlands B.V.",
                "product_name": "Hue motion sensor",
                "product_archetype": "unknown_archetype",
                "certified": true,
                "software_version": "2.53.6",
                "hardware_platform_type": "100b-11b"
            },
            "metadata": {
                "name": "Office motion sensor",
                "archetype": "unknown_archetype"
            },
            "identify": {},
            "usertest": {
                "status": "set",
                "usertest": false
            },
            "services": [
                {
                    "rid": "00000000-0000-0000-0000-000000000001",
                    "rtype": "zigbee_connectivity"
                },
                {
                    "rid": "00000000-0000-0000-0000-000000000002",
                    "rtype": "light_level"
                },
                {
                    "rid": "00000000-0000-0000-0000-000000000003",
                    "rtype": "device_power"
                },
                {
                    "rid": "00000000-0000-0000-0000-000000000004",
                    "rtype": "temperature"
                },
                {
                    "rid": "00000000-0000-0000-0000-000000000005",
                    "rtype": "motion"
                }
            ],
            "type": "device"
        }
    ]
}

GET /clip/v2/resource/motion/00000000-0000-0000-0000-000000000005

Response:

{
    "errors": [],
    "data": [
        {
            "id": "00000000-0000-0000-0000-000000000005",
            "id_v1": "/sensors/250",
            "owner": {
                "rid": "00000000-0000-0000-0000-000000000000",
                "rtype": "device"
            },
            "enabled": true,
            "motion": {
                "motion": false,
                "motion_valid": true,
                "motion_report": {
                    "changed": "2023-09-04T20:04:30.395Z",
                    "motion": false
                }
            },
            "sensitivity": {
                "status": "set",
                "sensitivity": 2,
                "sensitivity_max": 4
            },
            "type": "motion"
        }
    ]
}

I believe a new DTO should be created for motion_report, which could then be included in the motion DTO here:

private boolean motion;
private @SerializedName("motion_valid") boolean motionValid;

I now also noticed that motion used in the current DTO is deprecated since it has been moved to motion_report:

https://developers.meethue.com/develop/hue-api-v2/api-reference/#resource_motion__id__get

As a work-around a profile can be used:

DateTime HueMotionSensor_Mailbox_LastMotion "Last motion" <time> { channel="hue:device:home:motion1:motion" [profile="timestamp-change"] }

However, this does not support historical timestamps, i.e. when the binding is started after last motion was detected, the value will obviously not be reflected. Also, it's not accurate or fully corresponding to the timestamps seen in the Hue app.

Your Environment

  • Version used: 4.0.2
@jlaur jlaur added the enhancement An enhancement or new feature for an existing add-on label Sep 4, 2023
@openhab-bot
Copy link
Collaborator

This issue has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/philips-hue-clip-2-api-v2-discussion-thread/142111/256

@andrewfg
Copy link
Contributor

andrewfg commented Sep 4, 2023

Yeah. @jlaur do you want to do it? Or shall I?

@andrewfg
Copy link
Contributor

andrewfg commented Sep 5, 2023

On GETs it would need to use 'motion_report' if that element is present, or 'motion' if it is not. And we would need to check if the SSE event DTO contains either or both elements.

@jlaur
Copy link
Contributor Author

jlaur commented Sep 5, 2023

do you want to do it? Or shall I?

I'll give it a go. I hope assistance can be arranged. 🙂

@jlaur jlaur self-assigned this Sep 5, 2023
jlaur added a commit to jlaur/openhab-addons that referenced this issue Sep 5, 2023
Resolves openhab#15546

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
jlaur added a commit to jlaur/openhab-addons that referenced this issue Sep 6, 2023
Resolves openhab#15546

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
jlaur added a commit to jlaur/openhab-addons that referenced this issue Sep 6, 2023
Resolves openhab#15546

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
jlaur added a commit to jlaur/openhab-addons that referenced this issue Sep 6, 2023
Resolves openhab#15546

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
jlaur added a commit to jlaur/openhab-addons that referenced this issue Sep 10, 2023
Resolves openhab#15546

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
jlaur added a commit to jlaur/openhab-addons that referenced this issue Sep 24, 2023
Resolves openhab#15546

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
@jlaur
Copy link
Contributor Author

jlaur commented Oct 3, 2023

Some context about when this was introduced: https://hueblog.com/2023/03/14/hue-bridge-update-brings-back-popular-feature/

jlaur added a commit to jlaur/openhab-addons that referenced this issue Oct 7, 2023
Resolves openhab#15546

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
jlaur added a commit to jlaur/openhab-addons that referenced this issue Oct 10, 2023
Resolves openhab#15546

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
jlaur added a commit to jlaur/openhab-addons that referenced this issue Oct 10, 2023
Resolves openhab#15546

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
jlaur added a commit to jlaur/openhab-addons that referenced this issue Oct 14, 2023
Resolves openhab#15546

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
jlaur added a commit to jlaur/openhab-addons that referenced this issue Oct 14, 2023
Resolves openhab#15546

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
jlaur added a commit to jlaur/openhab-addons that referenced this issue Oct 17, 2023
Resolves openhab#15546

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
kaikreuzer pushed a commit that referenced this issue Oct 26, 2023
* Add channels for last motion/temperature sensor update (API v2)
* Add channel for last light level sensor update (API v2)
* Add channel for last rotary steps update (API v2)
* Add channel for last button update (API v2)

Resolves #15546

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
austvik pushed a commit to austvik/openhab-addons that referenced this issue Mar 27, 2024
…5552)

* Add channels for last motion/temperature sensor update (API v2)
* Add channel for last light level sensor update (API v2)
* Add channel for last rotary steps update (API v2)
* Add channel for last button update (API v2)

Resolves openhab#15546

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Jørgen Austvik <jaustvik@acm.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature for an existing add-on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants