Skip to content

Commit

Permalink
[hue] Recognise grouped_motion and smart_scene resources (#17905)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Fiddian-Green <[email protected]>
  • Loading branch information
andrewfg authored Dec 16, 2024
1 parent 9544767 commit 856fa74
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public enum ResourceType {
GEOFENCE_CLIENT,
GEOLOCATION,
GROUPED_LIGHT,
GROUPED_MOTION,
HOMEKIT,
LIGHT,
LIGHT_LEVEL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ private void putResourceToCache(Resource resource) {
* @param fullResources the full list of resources of the given type.
*/
public void onResourcesList(ResourceType resourceType, List<Resource> fullResources) {
if (resourceType == ResourceType.SCENE) {
if (SUPPORTED_SCENE_TYPES.contains(resourceType)) {
updateSceneContributors(fullResources);
} else {
fullResources.stream().filter(r -> resourceId.equals(r.getId())).findAny()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -914,4 +914,21 @@ void testBehaviorInstance() {
assertNotNull(list);
assertEquals(2, list.size());
}

@Test
void testGroupedMotion() {
String json = load(ResourceType.GROUPED_MOTION.name().toLowerCase());
Resources resources = GSON.fromJson(json, Resources.class);
assertNotNull(resources);
List<Resource> list = resources.getResources();
assertNotNull(list);
assertEquals(1, list.size());
Resource item = list.get(0);
assertEquals(ResourceType.GROUPED_MOTION, item.getType());
Boolean enabled = item.getEnabled();
assertNotNull(enabled);
assertTrue(enabled);
assertEquals(OnOffType.ON, item.getMotionState());
assertEquals(new DateTimeType("2024-12-13T11:01:25.156Z"), item.getMotionLastUpdatedState(ZoneId.of("UTC")));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"errors": [],
"data": [
{
"id": "aab07fb5-b0c1-400b-828f-a9e0a05394f9",
"id_v1": "/sensors/5",
"enabled": true,
"motion": {
"motion_report": {
"changed": "2024-12-13T11:01:25.156Z",
"motion": true
}
},
"owner": {
"rid": "bb9b4bb4-b0c8-4b6a-8dc0-85add8f77964",
"rtype": "bridge_home"
},
"type": "grouped_motion"
}
]
}

0 comments on commit 856fa74

Please sign in to comment.