mtosin
(Mtosin)
April 21, 2021, 6:13am
1
Hi all
i’m trying to change the value status for a sensor but the value is not changing based on a condition.
Despite that the ICON is working and changing as expected.
the value is set now to OFF and not changing status.
which can be the issue?
this is the sensor:
- platform: template
sensors:
ingressoporta:
friendly_name: "Ingresso Porta"
value_template: >-
{% if is_state("binary_sensor.ingressomovimento", "on") %}
Closed
{% else %}
Open
{%endif %}
icon_template: >-
{% if is_state("binary_sensor.ingressomovimento", "on") %}
hass:remote
{% else %}
mdi:weather-sunset-down
{% endif %}
tom_l
April 21, 2021, 6:42am
2
Is this a binary template sensor or a template sensor?
mtosin
(Mtosin)
April 21, 2021, 6:46am
3
Hi Tom,
thanks for the reply is a binary sensor in a dedicated file binary_sensor.yaml
this is the first i need to customize
the default value are: Clear and Detected, and i would like to put it in my native language, so just replace that value
tom_l
April 21, 2021, 6:51am
4
For binary template sensors the value_template must resolve to true or false. e.g.
value_template: "{{ is_state("binary_sensor.ingressomovimento", "on") }}"
If you want to change the Off/On state display of this in the front end you need to apply a device class .
- platform: template
sensors:
ingressoporta:
friendly_name: "Ingresso Porta"
value_template: "{{ is_state("binary_sensor.ingressomovimento", "on") }}"
device_class: door
This will also change the icons.
You could apply the device class directly to binary_sensor.ingressomovimento
in customize and not need a template binary sensor at all.
mtosin
(Mtosin)
April 21, 2021, 7:00am
5
Tom i read about that that is not what i need because if i change the device class i will use the status value as per it.
what i would like to do is replace on/off, open/closed, clear/detected… with different label in my UI based on a condition.
so if the device class return CLEAR/DETECTED i would like to replace this value with APERTO/CHIUSO so different state.
i tried as well since last 2 days to change also the customize from UI but i cannot change it based on a condition.
hope i clarify the scenario and thanks for helping
Troon
(Troon)
April 21, 2021, 7:10am
6
User Profile (bottom left of main screen) / Language. If that is set to Italian, the displayed states should also be translated. I’ve just changed my language to Italian, and:
tom_l
April 21, 2021, 7:10am
7
You can’t do that for binary sensors. Their sate is always ‘on’ or ‘off’. The only way to change how they are displayed is to apply a device class.
You can make a template sensor though.
sensor:
- platform: template
sensors:
ingressoporta:
friendly_name: "Ingresso Porta"
value_template: >-
{% if is_state("binary_sensor.ingressomovimento", "on") %}
Closed
{% else %}
Open
{%endif %}
icon_template: >-
{% if is_state("binary_sensor.ingressomovimento", "on") %}
hass:remote
{% else %}
mdi:weather-sunset-down
{% endif %}
mtosin
(Mtosin)
April 21, 2021, 7:17am
8
Hi Troon
i know i can change this to Italian, i was simplying the translation for what i want…
for example instead of acceso/spento i would like to put some more different value out of this available from the platform.(like: working/not working etc…)
as this is not available for binary sensor i will keep it in english as i want just some sensor customized and rest can stay as per platform
mtosin
(Mtosin)
April 21, 2021, 7:23am
9
yes if i use as normal sensor it works…
will consider as well you advice
thanks