Template sensor with input.number

Just cant get this sensor to work, what am I missing here?

{% if states('sensor.vardagsrum_sensor_illuminance') | float > states('input_number.lux_ljust') | float, round %}
Ljust            
{% elif states('sensor.vardagsrum_sensor_illuminance') | float < states('input_number.lux_morkt') | float , round %}
Mörkt
{% elif states('sensor.vardagsrum_sensor_illuminance') | float > states('input_number.lux_morkt') | float, round 
   and states('sensor.vardagsrum_sensor_illuminance') | float < states('input_number.lux_ljust') | float, round %}
Skumt
{% else %}
Error
{% endif %}

I’m stuck here… it just says Ljust no matter what I do. input_number.lux_morkt is at 3, input_number.lux_ljust is at 12, and the sensor itself says 1 lx right now,

in developper tool your " | float , round" does :

'1.32, undefined' #if input_number.lux = 1.32

to get round working i got to add a ‘|’ instead of your ‘,’ :

| float | round %}

As tom commented, you need a pipe | between float and round. Also, your floats on the sensor states will need a default value in case they are “unknown” or “unavailable”.

{% set illum = states('sensor.vardagsrum_sensor_illuminance') | float(0) %}
{% if illum > states('input_number.lux_ljust') | float | round %}
Ljust            
{% elif illum < states('input_number.lux_morkt') | float | round %}
Mörkt
{% elif states('input_number.lux_ljust') | float | round > illum > states('input_number.lux_morkt') | float | round %}
Skumt
{% else %}
Error
{% endif %}

I’ve changed my , to pipes and added a default value.

But still the template engine says it’s listening to changes on:

  • Entity: sensor.vardagsrum_sensor_illuminance
  • Entity: input_number.lux_ljust

Why isn’t Entity: input_number.lux_morkt listed? Isn’t it also supposed to be?

The current template looks like this:

{% if states('sensor.vardagsrum_sensor_illuminance') | float(0) > states('input_number.lux_ljust') | float | round %}
Ljust            
{% elif states('sensor.vardagsrum_sensor_illuminance') | float(0) < states('input_number.lux_morkt') | float | round %}
Mörkt
{% elif states('sensor.vardagsrum_sensor_illuminance') | float(0) > states('input_number.lux_morkt') | float | round 
   and states('sensor.vardagsrum_sensor_illuminance') | float(0) < states('input_number.lux_ljust') | float | round %}
Skumt
{% else %}
Error
{% endif %}

if i past your code in my dev-tools i get:

Error

  • Entité: input_number.lux_ljust
  • Entité: input_number.lux_morkt
  • Entité: sensor.vardagsrum_sensor_illuminance

but without the 3 sensors … maybe it show only entities with if= true
…try to switch between > and < (true-false)
see what happen