Use friendly_name for entityDisplay if available
parent
b686f04121
commit
523cd8249f
|
@ -98,8 +98,14 @@
|
||||||
var parts = state.entity_id.split(".");
|
var parts = state.entity_id.split(".");
|
||||||
state.domain = parts[0];
|
state.domain = parts[0];
|
||||||
state.entity = parts[1];
|
state.entity = parts[1];
|
||||||
state.entityDisplay = state.entity.replace(/_/g, " ");
|
|
||||||
state.stateDisplay = state.state.replace(/_/g, " ");
|
state.stateDisplay = state.state.replace(/_/g, " ");
|
||||||
|
state.canToggle = state.state == "on" || state.state == "off"
|
||||||
|
|
||||||
|
if(state.attributes.friendly_name) {
|
||||||
|
state.entityDisplay = state.attributes.friendly_name;
|
||||||
|
} else {
|
||||||
|
state.entityDisplay = state.entity.replace(/_/g, " ");
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// call api methods
|
// call api methods
|
||||||
|
|
|
@ -88,12 +88,7 @@
|
||||||
|
|
||||||
<div class='info'>
|
<div class='info'>
|
||||||
<div class='name'>
|
<div class='name'>
|
||||||
<template if="{{state_attr['friendly_name']}}">
|
{{stateObj.entityDisplay}}
|
||||||
{{state_attr['friendly_name']}}
|
|
||||||
</template>
|
|
||||||
<template if="{{!state_attr['friendly_name']}}">
|
|
||||||
{{stateObj.entityDisplay}}
|
|
||||||
</template>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="time-ago">
|
<div class="time-ago">
|
||||||
|
@ -106,13 +101,13 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<template if="{{!stateUnknown}}">
|
<template if="{{!stateUnknown}}">
|
||||||
<template if="{{stateObj.state == 'on' || stateObj.state == 'off'}}">
|
<template if="{{stateObj.canToggle}}">
|
||||||
<div class='state toggle' self-center flex>
|
<div class='state toggle' self-center flex>
|
||||||
<paper-toggle-button checked="{{toggleChecked}}">
|
<paper-toggle-button checked="{{toggleChecked}}">
|
||||||
</paper-toggle-button>
|
</paper-toggle-button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template if="{{stateObj.state != 'on' && stateObj.state != 'off'}}">
|
<template if="{{!stateObj.canToggle}}">
|
||||||
<div class='state text'>{{stateObj.stateDisplay}}</div>
|
<div class='state text'>{{stateObj.stateDisplay}}</div>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
|
|
Loading…
Reference in New Issue