Value template issue

I need the value template to indicate not available in case the value is zero (0)
Apreciate any help .

Here is my sensor.yaml file:

linea_12_bus_9:
  value_template: ' {% if states.sensor.origendatos.attributes.posiciones.posicion.43.idsiguienteparada is not defined %}
  No active
  {% else %}
  {{ states.sensor.origendatos.attributes.posiciones.posicion.43.minutos }}:MIN
  {% endif %} '
  friendly_name: Bus Line

I’m confused, you are already checking whether the attribute is defined and set “No active” when this is the case. What else exactly do you need?
do you need another condition, e.g. if attribute value is 0 mark as No active too?

That´s right . I need the value template indicate two conditions :

  • if condition is “0” , mark as “no active” -> (means the bus is not operating)
  • and any other condition( bus arrival time) mark the bus arrival time.

Try:

{% if states.sensor.origendatos.attributes.posiciones.posicion.43.idsiguienteparada is not defined or states.sensor.origendatos.attributes.posiciones.posicion.43.idsiguienteparada | float == 0 %}

Perfect works nice .Now i open another issue to see if it´s posible to change the value of the template by a name .
Thank you very much for your help