Not sure i understand what you want.
Show the same entity_picture if the state of the sensor is 1-5? {% if states('sensor.asche_sensor') | int <= 5 %}
should do it.
Thanks for your code but the sensor does not work anymore and in HA unknown is displayed.
Fri Feb 15 2019 19:02:32 GMT+0100 (Mitteleuropäische Normalzeit)
Update for sensor.asche_sensor fails
Traceback (most recent call last):
File “/usr/src/app/homeassistant/helpers/entity.py”, line 221, in async_update_ha_state
await self.async_device_update()
File “/usr/src/app/homeassistant/helpers/entity.py”, line 347, in async_device_update
await self.async_update()
File “/usr/src/app/homeassistant/components/sensor/template.py”, line 215, in async_update
setattr(self, property_name, template.async_render())
File “/usr/src/app/homeassistant/helpers/template.py”, line 140, in async_render
return self._compiled.render(kwargs).strip()
File “/usr/local/lib/python3.6/site-packages/jinja2/asyncsupport.py”, line 76, in render
return original_render(self, *args, **kwargs)
File “/usr/local/lib/python3.6/site-packages/jinja2/environment.py”, line 1008, in render
return self.environment.handle_exception(exc_info, True)
File “/usr/local/lib/python3.6/site-packages/jinja2/environment.py”, line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File “/usr/local/lib/python3.6/site-packages/jinja2/_compat.py”, line 37, in reraise
raise value.with_traceback(tb)
File “”, line 1, in top-level template code
TypeError: ‘<=’ not supported between instances of ‘int’ and ‘str’
Well, the template in your first post ('4') shows me that the sensor returns a string.
With states('sensor.asche_sensor') | int , we convert this string to a number.
Now we want to compare that number <= 5, but when you put a number in quotes, you create a string.
→ TypeError: ‘<=’ not supported between instances of ‘int’ and ‘str’
So remove the quotes around 5 and it should work.
Like i wrote it in my first post.
entity_picture_template: >
{% if states('sensor.asche_sensor') | int <= 5 %}
/local/icons/asche/asche_leer.png
{% endif %}
Also the quotes around the picture path are not needed, i think.