My sensor name is sensor.temperature_158d0001f54788
What is the easiest way to make a easier name for the entity.
Im not talking about the friendly_name
but the actual name to be used in configuration files. ie sensor.kitchentemp
Template sensor and hide the other one in customize
1 Like
Okey. How would that look like with my example names given?
See here…
and here
- platform: template
sensors:
kitchentemp:
friendly_name: 'Kitchen Temp'
value_template: {{ states.sensor.temperature_158d0001f54788.state | float) }}
Thx for your answer but im missing something, this is my file xiaomisensor.yaml, and the other sensors in this file works.
platform: template
sensors:
front_door:
friendly_name: "Front Door"
value_template: >-
{% if is_state('binary_sensor.door_window_sensor_158d0001f3cc19', 'on') %}
Open
{% else %}
Closed
{% endif %}
icon_template: >
{% if is_state('binary_sensor.door_window_sensor_158d0001f3cc19', 'on') %}
mdi:door-open
{% else %}
mdi:door-closed
{% endif %}
balkong_door:
friendly_name: "Balkong Door"
value_template: >-
{% if is_state('binary_sensor.door_window_sensor_158d0001ef3410', 'on') %}
Open
{% else %}
Closed
{% endif %}
icon_template: >
{% if is_state('binary_sensor.door_window_sensor_158d0001ef3410', 'on') %}
mdi:door-open
{% else %}
mdi:door-closed
{% endif %}
edwardtemp:
friendly_name: 'Edward Temp'
value_template: {{ states.sensor.temperature_158d0001f54788.state | float) }}
And the error i get is:
Testing configuration at /home/homeassistant/.homeassistant
2018-02-19 05:48:23 ERROR (Thread-2) [homeassistant.util.yaml] invalid key: "OrderedDict([('states.sensor.temperature_158d0001f54788.state | float)', None)])"
in "/home/homeassistant/.homeassistant/sensors/xiaomisensor.yaml", line 37, column 0
2018-02-19 05:48:23 ERROR (MainThread) [homeassistant.bootstrap] Error loading /home/homeassistant/.homeassistant/configuration.yaml: invalid key: "OrderedDict([('states.sensor.temperature_158d0001f54788.state | float)', None)])"
in "/home/homeassistant/.homeassistant/sensors/xiaomisensor.yaml", line 37, column 0
You have the above in the code and no matching ‘(’, tho’ you don’t need the ‘)’ anyway.
1 Like
edwardtemp:
friendly_name: 'Edward Temp'
value_template: {{ states.sensor.temperature_158d0001f54788.state | float }}
still gives:
Testing configuration at /home/homeassistant/.homeassistant
2018-02-19 11:13:32 ERROR (Thread-2) [homeassistant.util.yaml] invalid key: "OrderedDict([('states.sensor.temperature_158d0001f54788.state | float', None)])"
in "/home/homeassistant/.homeassistant/sensors/xiaomisensor.yaml", line 37, column 0
2018-02-19 11:13:32 ERROR (MainThread) [homeassistant.bootstrap] Error loading /home/homeassistant/.homeassistant/configuration.yaml: invalid key: "OrderedDict([('states.sensor.temperature_158d0001f54788.state | float', None)])"
in "/home/homeassistant/.homeassistant/sensors/xiaomisensor.yaml", line 37, column 0
Any ideas?
{{ (states.sensor.temperature_158d0001f54788.state | float) }}
Try it with both () in there I just tried in the template editor and it works
Okey so code works in template editor at my place to but not in my file, (???). i post it in complete: (First two sensors DO work)
platform: template
sensors:
front_door:
friendly_name: "Front Door"
value_template: >-
{% if is_state('binary_sensor.door_window_sensor_158d0001f3cc19', 'on') %}
Open
{% else %}
Closed
{% endif %}
icon_template: >
{% if is_state('binary_sensor.door_window_sensor_158d0001f3cc19', 'on') %}
mdi:door-open
{% else %}
mdi:door-closed
{% endif %}
balkong_door:
friendly_name: "Balkong Door"
value_template: >-
{% if is_state('binary_sensor.door_window_sensor_158d0001ef3410', 'on') %}
Open
{% else %}
Closed
{% endif %}
icon_template: >
{% if is_state('binary_sensor.door_window_sensor_158d0001ef3410', 'on') %}
mdi:door-open
{% else %}
mdi:door-closed
{% endif %}
edward_temp:
friendly_name: 'Edward Temp'
value_template: {{ (states.sensor.temperature_158d0001f54788.state | float) }}
I think in the code it needs to be in single quotes.