Groups device ID and problems in general


in the groups, i have integer as IDs in the lights section. Problem is, i use the uniqueids for the lights and dont store the normal id. Is it possible to implement this? Also when calling the group, it would be awesome, if i would get the current state of the lights (bri, sat,…) otherwise i have to query a light manually

Hello, so you want a request to have all light state in a group ? But what do you want to do with that ?

Why would you not? I could just query a group and get all the information that i want. Less lines of code. Less API calls.

Because all individual state are already updated by individual websocket event, no need to ask them.

Doesnt help if you use the Rest API and not Websockets.

Websocket are here for that, for user don’t need to query device, and have state in real time.

Is there a reason you’re not using websockets?

I checked out the websockets and its pretty cool… however, it only gives me changes. I need an initial state of all devices (on page load) and could afterwards work with the websockets.

Just to give some more information: i am building an interface to control all lights, see all sensors and so on and there are multiple pages. When i change the page, it needs to load the devices on that page. What i do is i get all devices with the API and then i use pooling to get all device states

Yes, first do a call to “http://host:port/api/self.api_key” to retrieve the complete state of the system, then you do updates from the websocket

thanks a lot, i must have overlooked that in the api docu.

Just one more question. I get this:

e: "changed"
id: "8"
r: "sensors"
state: Object { lastupdated: "2022-08-31T21:24:23.116", open: false }
lastupdated: "2022-08-31T21:24:23.116"
open: false
<prototype>: Object { … }
t: "event"
uniqueid: "00:15:8d:00:08:07:63:88-01-0006"

Is it somehow possible to also get the type of device in that response? For example in this case its a door sensor and i think it would be ZHAOpenClose

No, you will need to look it up from the complete state.

What language are you doing this in?