Reputation: 21
I have a Hue Dimmer Switch that toggles between a few different scenes when tapping the "on" button repeatedly. I would like to be able to "press" the buttons on the switch programmatically - in essence manipulating a physical press via an API call to the Hue API.
The button (sensor) is registered with these possible events in the API:
{
"state": {
"buttonevent": 1002,
"lastupdated": "2023-08-03T20:36:51"
},
"productname": "Hue dimmer switch",
"capabilities": {
"inputs": [
{
"repeatintervals": [
800
],
"events": [
{
"buttonevent": 1000,
"eventtype": "initial_press"
},
{
"buttonevent": 1001,
"eventtype": "repeat"
},
{
"buttonevent": 1002,
"eventtype": "short_release"
},
{
"buttonevent": 1003,
"eventtype": "long_release"
},
{
"buttonevent": 1004,
"eventtype": "long_press"
}
]
},
{
"repeatintervals": [
800
],
"events": [
{
"buttonevent": 2000,
"eventtype": "initial_press"
},
{
"buttonevent": 2001,
"eventtype": "repeat"
},
{
"buttonevent": 2002,
"eventtype": "short_release"
},
{
"buttonevent": 2003,
"eventtype": "long_release"
},
{
"buttonevent": 2004,
"eventtype": "long_press"
}
]
},
{
"repeatintervals": [
800
],
"events": [
{
"buttonevent": 3000,
"eventtype": "initial_press"
},
{
"buttonevent": 3001,
"eventtype": "repeat"
},
{
"buttonevent": 3002,
"eventtype": "short_release"
},
{
"buttonevent": 3003,
"eventtype": "long_release"
},
{
"buttonevent": 3004,
"eventtype": "long_press"
}
]
},
{
"repeatintervals": [
800
],
"events": [
{
"buttonevent": 4000,
"eventtype": "initial_press"
},
{
"buttonevent": 4001,
"eventtype": "repeat"
},
{
"buttonevent": 4002,
"eventtype": "short_release"
},
{
"buttonevent": 4003,
"eventtype": "long_release"
},
{
"buttonevent": 4004,
"eventtype": "long_press"
}
]
}
]
}
}
I would've thought I would be able to manipulate the button state with something like this:
HTTP PUT
http://{bridge_ip}/api/{username}/sensors/1/state
{
"buttonevent": 1002
}
But the API responds with
[
{
"error": {
"type": 8,
"address": "/sensors/30/state",
"description": "parameter, buttonevent, is not modifiable"
}
}
]
Which leads me to believe its not possible to achieve what I want to. Is there any other way of triggering a button press via the API? Or should this be implemented in a completely different manner?
I know I can just hardcode the scenes and set it for the lights, but I would like for it to behave just like the switch does, with the lights and scenes setup for it.
Upvotes: 1
Views: 685
Reputation: 379
I double-checked also with the Hue CLI API V2, and the button resource does not seem to allow any modification:
As you mentioned, the only way would be to re-implement the button behavior manually.
Upvotes: 0