Closed danzada1 closed 6 years ago
Scenes from the cache don't have the light states populated by default. If you run full config or scenes heartbeat, that json will also not contain the light state info. To get the light states, you need to call fetch() first, which will get the complete scene information from the bridge.
Thanks Johnny! I ended up successfully creating a GSON class to parse through the GET JSON straight from the bridge, as I'm still confused on how to retrieve the Scene info from the BridgeResponseCallback used in the fetch operation.
When the callback is called, the scene object where you called fetch on should be updated with the latest information.
Ah great, thanks again Johnny!
Hi Guys, maybe I'm missing something here that somebody can point out to me. I use the below command to get Scenes one at a time per the new API documentation, however it only seems to retrieve Light States from Scenes that are created with the new API, not the old one, even though I was creating the Post (Version 2) scenes with the old API.
Scene scene = bridge.getBridgeState().getScene(identifier);
Using HTTP GET retrieves all the LightStates regardless of which API was used to create them, here are the HTTP responses:
Created with New API (this is the only one out of these 3 which retrieves Light States via new API call, others = null): {"name":"New Sceneasdf","lights":["1","34"],"owner":"6QqXaDCrJ77PbZafcUc4IOP0RDphAArVUv4w4hnS","recycle":false,"locked":false,"appdata":{},"picture":"","lastupdated":"2018-04-25T20:47:05","version":2,"lightstates":{"1":{"on":true,"bri":254,"effect":"none","xy":[0.3223,0.3287]},"34":{"on":true,"bri":254,"effect":"none","xy":[0.3223,0.3287]}}}
Created with Old API: {"name":"8149","lights":["1","2","8","9","12","15","17","21","22","29","34","35","36"],"owner":"none","recycle":false,"locked":false,"appdata":{},"picture":"","lastupdated":"2018-01-07T09:12:18","version":2,"lightstates":{"1":{"on":true,"bri":1,"ct":500,"transitiontime":2},"2":{"on":true,"bri":1,"ct":500,"transitiontime":2},"8":{"on":true,"bri":254,"ct":366,"transitiontime":2},"9":{"on":true,"bri":254,"xy":[0.1540,0.0776],"transitiontime":2},"12":{"on":true,"bri":254,"xy":[0.1540,0.0776],"transitiontime":2},"15":{"on":true,"bri":1,"ct":500,"transitiontime":2},"17":{"on":true,"bri":1,"ct":500,"transitiontime":2},"21":{"on":true,"bri":1,"ct":500,"transitiontime":2},"22":{"on":true,"bri":254,"xy":[0.1540,0.0776],"transitiontime":2},"29":{"on":true,"bri":254,"xy":[0.1540,0.0776],"transitiontime":2},"34":{"on":true,"bri":1,"ct":500,"transitiontime":2},"35":{"on":true,"bri":254,"xy":[0.1540,0.0776],"transitiontime":2},"36":{"on":true,"bri":1,"ct":500,"transitiontime":2}}}
Created with Old API: {"name":"5947","lights":["1","2","8","9","12","15","17","21","22","29","34","35","36"],"owner":"4DToEwo0MJhiuR9Gxl00hqMmifWSzBiwAyz6VZtk","recycle":false,"locked":false,"appdata":{},"picture":"","lastupdated":"2018-01-07T03:46:37","version":2,"lightstates":{"1":{"on":true,"bri":254,"xy":[0.4215,0.1775],"transitiontime":2},"2":{"on":true,"bri":254,"xy":[0.4215,0.1775],"transitiontime":2},"8":{"on":false,"transitiontime":2},"9":{"on":true,"bri":254,"xy":[0.3028,0.3386],"transitiontime":2},"12":{"on":true,"bri":254,"xy":[0.3028,0.3386],"transitiontime":2},"15":{"on":true,"bri":254,"xy":[0.4215,0.1775],"transitiontime":2},"17":{"on":true,"bri":254,"xy":[0.4215,0.1775],"transitiontime":2},"21":{"on":true,"bri":254,"xy":[0.4215,0.1775],"transitiontime":2},"22":{"on":true,"bri":254,"xy":[0.3028,0.3386],"transitiontime":2},"29":{"on":true,"bri":254,"xy":[0.3028,0.3386],"transitiontime":2},"34":{"on":true,"bri":254,"xy":[0.4215,0.1775],"transitiontime":2},"35":{"on":true,"bri":254,"xy":[0.3028,0.3386],"transitiontime":2},"36":{"on":true,"bri":254,"xy":[0.4215,0.1775],"transitiontime":2}}}
I can get around this by using the JSON responses but I'd prefer to use the API.
Thanks!!!