There is probably a better way to do this but I couldn’t figure it out. So for now what I did was update index.html for the TEXT_LIST to only show items that do not have the ‘off’ state.
The html for the TEXT_LIST has a line for ng-repeat. Currently is set to this:
ng-repeat="line in item.list track by $index">
If you update this line you can have it check the ‘value’ of the list item using ng-if. In my case, I don’t want to show if the value is off. So I changed it to this:
ng-repeat="line in item.list track by $index" ng-if="listField('value', item, line) !== 'off'">
What this should do if I understand correctly is loop through the list, but only render the html for list items that don’t have a value of off. This will break lists where you want to show items with the state of off, so to work around that, you can have your value function return something like ‘!hideme’ and instead of checking for ‘off’ check for ‘!hideme’.
Example:
list: (function() {
l = [];
for (i = 1; i < 4; i++) {
l.push({
title: 'Title ' + i,
icon: 'mdi-school',
value: function () {
let currentState = this.states['sensor.bedroom_light'].state;
if (currentState === 'off') {
return '!hideme';
}
return currentState;
}
});
}
return l;
})(),
index.html (original)
<div ng-if="item.type === TYPES.TEXT_LIST"
class="item-entity-container">
<div class="item-list">
<div class="item-list--item"
ng-repeat="line in item.list track by $index">
<div class="item-list--name">
<i class="mdi" ng-class="listField('icon', item, line)" ng-if="line.icon"></i>
<span ng-bind="listField('title', item, line)"></span>
</div>
<div class="item-list--value">
<span ng-bind="listField('value', item, line)"></span><!--
--><span ng-bind="listField('unit', item, line)"></span>
</div>
</div>
</div>
</div>
index.html (modified)
<div ng-if="item.type === TYPES.TEXT_LIST"
class="item-entity-container">
<div class="item-list">
<div class="item-list--item"
ng-repeat="line in item.list track by $index" ng-if="listField('value', item, line) !== 'off'">
<div class="item-list--name">
<i class="mdi" ng-class="listField('icon', item, line)" ng-if="line.icon"></i>
<span ng-bind="listField('title', item, line)"></span>
</div>
<div class="item-list--value">
<span ng-bind="listField('value', item, line)"></span><!--
--><span ng-bind="listField('unit', item, line)"></span>
</div>
</div>
</div>
</div>