frontend/js/common/entity/compute_state_name.js
Paulus Schoutsen 912969111f
Move all of hassUtil to JS (#1153)
* Move all of hassUtil to JS

* Fix tests
2018-05-09 21:33:31 -04:00

12 lines
331 B
JavaScript

import computeObjectId from './compute_object_id';
export default function computeStateName(stateObj) {
if (stateObj._entityDisplay === undefined) {
stateObj._entityDisplay = (
stateObj.attributes.friendly_name ||
computeObjectId(stateObj.entity_id).replace(/_/g, ' '));
}
return stateObj._entityDisplay;
}