mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
All custom groups in 1 section instead of each their own
This commit is contained in:
parent
dec12be52e
commit
debca88a0d
@ -141,7 +141,7 @@ def setup(hass, config):
|
|||||||
})
|
})
|
||||||
|
|
||||||
# Setup chromecast
|
# Setup chromecast
|
||||||
hass.states.set("chromecast.Living_Rm", "Netflix",
|
hass.states.set("chromecast.Living_Rm", "Plex",
|
||||||
{'friendly_name': 'Living Room',
|
{'friendly_name': 'Living Room',
|
||||||
ATTR_ENTITY_PICTURE:
|
ATTR_ENTITY_PICTURE:
|
||||||
'http://graph.facebook.com/KillBillMovie/picture'})
|
'http://graph.facebook.com/KillBillMovie/picture'})
|
||||||
|
@ -131,6 +131,10 @@
|
|||||||
return found.length > 0;
|
return found.length > 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getCustomGroups: function() {
|
||||||
|
return this.states.filter(function(state) { return state.isCustomGroup;});
|
||||||
|
},
|
||||||
|
|
||||||
_laterFetchStates: function() {
|
_laterFetchStates: function() {
|
||||||
if(this.stateUpdateTimeout) {
|
if(this.stateUpdateTimeout) {
|
||||||
clearTimeout(this.stateUpdateTimeout);
|
clearTimeout(this.stateUpdateTimeout);
|
||||||
|
@ -99,12 +99,7 @@
|
|||||||
selected="0" on-core-select="{{tabClicked}}">
|
selected="0" on-core-select="{{tabClicked}}">
|
||||||
|
|
||||||
<paper-tab>ALL</paper-tab>
|
<paper-tab>ALL</paper-tab>
|
||||||
|
<paper-tab data-filter='customgroup'>GROUPS</paper-tab>
|
||||||
<template repeat="{{group in customGroups}}">
|
|
||||||
<paper-tab data-entity="{{group.entity_id}}">
|
|
||||||
{{group.entityDisplay}}
|
|
||||||
</paper-tab>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
</paper-tabs>
|
</paper-tabs>
|
||||||
</div>
|
</div>
|
||||||
@ -112,7 +107,7 @@
|
|||||||
|
|
||||||
<state-cards
|
<state-cards
|
||||||
api="{{api}}"
|
api="{{api}}"
|
||||||
filter="{{selectedTab}}"
|
filter="{{selectedFilter}}"
|
||||||
class="content"></state-cards>
|
class="content"></state-cards>
|
||||||
|
|
||||||
</core-header-panel>
|
</core-header-panel>
|
||||||
@ -120,17 +115,21 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
Polymer({
|
Polymer({
|
||||||
selectedTab: null,
|
selectedFilter: null,
|
||||||
|
hasCustomGroups: false,
|
||||||
|
|
||||||
computed: {
|
observe: {
|
||||||
customGroups: "getCustomGroups(api.states)",
|
'api.states': 'updateHasCustomGroup'
|
||||||
hasCustomGroups: "customGroups.length > 0"
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// computed: {
|
||||||
|
// hasCustomGroups: "api.getCustomGroups().length > 0"
|
||||||
|
// },
|
||||||
|
|
||||||
tabClicked: function(ev) {
|
tabClicked: function(ev) {
|
||||||
if(ev.detail.isSelected) {
|
if(ev.detail.isSelected) {
|
||||||
// will be null for ALL tab
|
// will be null for ALL tab
|
||||||
this.selectedTab = ev.detail.item.getAttribute('data-entity');
|
this.selectedFilter = ev.detail.item.getAttribute('data-filter');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -154,9 +153,8 @@
|
|||||||
this.api.logOut();
|
this.api.logOut();
|
||||||
},
|
},
|
||||||
|
|
||||||
getCustomGroups: function(states) {
|
updateHasCustomGroup: function() {
|
||||||
return states ?
|
this.hasCustomGroups = this.api.getCustomGroups().length > 0;
|
||||||
states.filter(function(state) { return state.isCustomGroup;}) : [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<polymer-element name="more-info-default" attributes="stateObj" noscript>
|
<polymer-element name="more-info-default" attributes="stateObj" noscript>
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
No further options here yet..
|
The card for '{{stateObj.domain}}' is not there yet..
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</polymer-element>
|
</polymer-element>
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
<div horizontal layout wrap>
|
<div horizontal layout wrap>
|
||||||
|
|
||||||
<template repeat="{{state in getStates(api.states, filter)}}">
|
<template repeat="{{states as state}}">
|
||||||
<state-card class="state-card" stateObj={{state}} api={{api}}></state-card>
|
<state-card class="state-card" stateObj={{state}} api={{api}}></state-card>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -46,27 +46,20 @@
|
|||||||
<script>
|
<script>
|
||||||
Polymer({
|
Polymer({
|
||||||
filter: null,
|
filter: null,
|
||||||
|
states: [],
|
||||||
|
|
||||||
getStates: function(states, filter) {
|
observe: {
|
||||||
if(!states) {
|
'api.states': 'filterChanged'
|
||||||
return [];
|
},
|
||||||
}
|
|
||||||
|
|
||||||
if(!filter) {
|
filterChanged: function() {
|
||||||
|
if(this.filter === 'customgroup') {
|
||||||
|
this.states = this.api.getCustomGroups();
|
||||||
|
} else {
|
||||||
// if no filter, return all non-group states
|
// if no filter, return all non-group states
|
||||||
return states.filter(function(state) {
|
this.states = this.api.states.filter(function(state) {
|
||||||
return state.domain != 'group';
|
return state.domain != 'group';
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
// we have a filter, return the parent filter and its children
|
|
||||||
var filter_state = this.api.getState(this.filter);
|
|
||||||
|
|
||||||
var map_states = function(entity_id) {
|
|
||||||
return this.api.getState(entity_id);
|
|
||||||
}.bind(this);
|
|
||||||
|
|
||||||
return [filter_state].concat(
|
|
||||||
filter_state.attributes.entity_id.map(map_states));
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user