Closed Mariusthvdb closed 5 years ago
answering myself and for reference:
sensor.moon:
templates:
_stateDisplay: >
function capitalizeFirstLetter(string) {return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();}
string = state.replace('_',' ');
return capitalizeFirstLetter(string);
Checklist
Browser + Version: Safari on Mac
CustomUI version: 20180831 Home Assistant release (
hass --version
): 0.81.6 Problem-relevantconfiguration.yaml
entries:please see https://community.home-assistant.io/t/strange-different-template-behavior-between-hassio-instances/77444
I am trying to change the regular display of these 2 sensors in a capitalized way (only cap the first character of the state, and remove the _ and replace that with a space.
Somehow my 2 systems with the exact same sensor, show differently. I know now that my above customization isn't correct, as explained i the community thread by @petro and shown in the inspector, but I can't get the correct format for it.
regular template would be:
{{states('sensor.moon').capitalize().replace('_',' ')}}
and{{ states('sensor.season').capitalize() }}
please let me know how to adapt that for custom-ui.
Problem-relevant Home Assistant log entries:
Any errors from browser Javascript console: