I have an entity that should have a number in the state
it can be ‘unknown’ or ‘unavailable’ in the state
i have jinja2 script that puts this and other entities just like it, into variable names so i can add them together for later use.
for example:
{%- set ent2 = states(“sensor.mill_panel_control_signal_4”) %}
This of course fails if ent2 has anything but a number.
Ive looked this up and read suggestions of if ent2|int then … but this fails if it cannot convert ent2 to int
So then i tried if ent2 is number… but for some reason when ent2 has numbers in it, the type doesnt seem to be of number so this check also fails, well it doesnt fail but the result is not true so its of no use to me.
So i thought i should look at what type ent2 is when its a number but i find the {{ ent2 | type}} fails as type is not an available filter.
So what to do ? anyone got any ideas so i can always fail safe and have a 0 in my variable when its not a number so i can successfully add this to other vairables.