I created a template sensor with a few states that I was hoping to use in automations. I’m no pro at this, so all was done by researching online, looking for some kind of examples, but I cat get the states of the template sensor to show as options when setting an automation.
The code below creates an entity that I can use in automations, but the only options as states are: available or unavailable. Fechado (Closed), Aberto (Open), A abrir/fechar (Opening/closing) do not show up.
Can someone point me in the right direction?
- platform: template
sensors:
portao_exterior_abrir_fechar:
icon_template: mdi:gate-alert
friendly_name: "Portão exterior estado"
value_template: >-
{% if is_state('binary_sensor.portao_exterior_portao_exterior_estado', 'off') and is_state('binary_sensor.portao_exterior_portao_exterior_movimento', 'off') %}
Fechado
{% elif is_state('binary_sensor.portao_exterior_portao_exterior_estado', 'on') and is_state('binary_sensor.portao_exterior_portao_exterior_movimento', 'off') %}
Aberto
{% elif is_state('binary_sensor.portao_exterior_portao_exterior_estado', 'on') and is_state('binary_sensor.portao_exterior_portao_exterior_movimento', 'on') %}
A abrir/fechar
{% endif %}
EDIT: having read @FPro’s response: it hadn’t occurred to me that the sensor might be working fine. Does it correctly show the states you want elsewhere in the system?
Yep, thats how the sensor ID is. Dont know why it’s repeated. And yes, the template is under sensor in the yaml configuration file.
I have no state for when estado is off and movimento is on because if the state (estado) is off it means the gate (reed switch) is closed . With movement (movimento) on the reed switch is open.
In the states tab under programing tools the correct states do show up according to the template sensor. I will enter manually and see if the automation works.