theone
(Dan)
October 7, 2018, 5:31pm
1
I want to use “item in itemsInGroup(groupname)” and would like to do an ng-if on the item.name if it contains a certain string.
How can I do this?
Is there a reference to all the functions and methods available in the Widget coding?
For example:
itemsInGroup
item.name
etc…
mjcumming
(Michael Cumming)
October 7, 2018, 5:34pm
2
theone
(Dan)
October 7, 2018, 5:49pm
3
I have read it and am using it for items and rules.
But I need the functions/methods that can be used in Widget.
Other functions I came across in the examples:
itemState
itemValue
itemValue.split
sendCmd
I also read this:
Hi all,
Since HABPanel went official, the added exposure has made more people try it and, as a result, there has been a number of requests for specialized widgets. While I don’t think I’m done with adding new widgets, I also believe the standard set should remain simple and focused to generic tasks, and match openHAB concepts, like items, as closely as possible.
Still, I understand the appeal of having specialized, more complex displays, which may make sense in a lot of situations. I also thin…
theone
(Dan)
October 7, 2018, 7:12pm
5
OK, so I have used the split to find the right item in the group and have created a button as needed.
My complete code is:
<div>{{config.groupitem}}</div>
<div> </div>
<div ng-init="data = {Temperature: '0', HeatCool: '1', FanSpeed: '2'};"></div>
<div ng-repeat="item in itemsInGroup(config.groupitem)">
<div ng-hide="true" ng-if="item.name.split('_')[2]=='Temperature'">{{data.Temperature = itemState(item.name)}}</div>
<div ng-hide="true" ng-if="item.name.split('_')[2]=='HeatCool'">{{data.HeatCool = itemState(item.name)}}</div>
<div ng-hide="true" ng-if="item.name.split('_')[2]=='FanSpeed'">{{data.FanSpeed = itemState(item.name)}}</div>
<!--<div>{{item.name.split("_")[2]}} --- {{itemState(item.name)}}</div>-->
</div>
<div ng-repeat="item in itemsInGroup(config.groupitem)">
<div ng-if="item.name.split('_')[2]=='Set'">
<button class="btn btn-success" ng-click="sendCmd(item, 'ON')"><span>ON: {{data.Temperature}},{{data.HeatCool}},{{data.FanSpeed}}</span></button>
</div>
</div>
<div> </div>
<div ng-repeat="item in itemsInGroup(config.groupitem)">
<div ng-if="item.name.split('_')[2]=='Off'">
<button class="btn btn-danger" ng-click="sendCmd(item, 'ON')"><span>OFF</span></button>
</div>
</div>
The Widget looks like this:
though, when I press either button, the ON command is not send to the item/rule (I have a log in the rule that checks for ON for these 2 specific items).
Am I missing something?
ysc
(Yannick Schaus)
October 8, 2018, 7:24am
6
item
in your ng-repeat
has the complete structure (use {{item | json}}
inside a div to show it as JSON).
=> ng-click="sendCmd(item.name, 'ON')"
1 Like
theone
(Dan)
October 8, 2018, 4:49pm
7
Thanks it works.
I though I was supposed to pass an item object to the SendCmd function and not a string of the item name.