Custom Widget: Questions regarding ng-repeat

Hey guys,

I am trying to make a custom widget which shows me all items for certrain groups.
I am using a syntax as follows, which is working fine so far for most of my items:
< div ng-repeat=“item in itemsInGroup(‘gBedroom’)” >

My first problem is that it does not catch hue lights. So as long as I have no bindingconfig information is working ok, but as soon as the item geht the {channel=hue:…} information it’s not displayed anymore.
Am I missing something?

My second question is regarding ng-repeat for groups in groups.
At the moment I have the copy&paste the “< div ng-repeat=“item in itemsInGroup(‘gBedroom’)” >” section for each room/group. But I would like to have this automated aswell, so I am looking for something like
< div ng-repeat=“group in groupsInGroup(‘gAll’)” > so that the section will be generated for all rooms itself. But I cannot find the correct way to do this.

Any help and insight on this would be appreciated!

Not sure about the Hue thing.
You can dump the results of the ng-repeat with the json filter and inspect what’s going on:

<div ng-repeat="item in itemsInGroup('gBedroom')">
  <pre class="text-left">{{item | json}}</pre>

To filter an array and retrieve only items of the type Group there is another filter named… filter.

So you would do: ng-repeat="group in itemsInGroup('gAll') | filter:{type:'Group'}"

1 Like

Yannick, you nailed it! Thank you very much… The filter thing was just too simple so I missed it, but it’s working like a charm now!

And thanks a lot for the json filter, wasn’t aware of that but helped me already 4 times in the last 2 hours finding my mistake.
The problem I had with the hue bulbs was due to my ng-if statement, was matching for strings like ON, OFF, NULL. But the state for the bulbs is obviously a number hence I wasn’t able to see them. But got it running now…

Much appreciated!

1 Like