Again something probably quite easy but I can’t seem to find the solution.
I am building a bin day indicator with an OLED screen. It’s supposed to show the icon of the bin type that has to be put out the next day.
I have an integration that shows the “next day type” as text.
The OLED screen i am able to show 5 different images according to a slider in home assistant.
I want “number.afval_display_container” to be set to 1 - 5 according to the state of “sensor.areareiniging_morgen”.
When sensor is “PMD” number needs to be “2”
When sensor is “papier” number needs to be “3”
When sensor is “restafval” number needs to be “4”
When sensor is “GFT” number needs to be “5”
When sensor is “else” number needs to be “1”
Image number 1 is just a blank image to have nothing on the screen.
The if then statments are the easy part. I just cannot finout how to get the states and set the number.
- action: number.set_value
target:
entity_id: number.afval_display_container
data:
value: >
{% set b = states("sensor.areareiniging_morgen") %}
{% set t = {"PMD": 2,"papier": 3,"restafval": 4,"GFT": 5} %}
{{ t.get(b, 1) }}
b is your bin sensor value and t is a lookup table. {{ t.get(b, 1) }} looks up the number you want in the table t based on the sensor value b and defaults to 1 if it can’t find a match.