ah ok so
availability: >
{{ ‘sensor.smoke_detector_2_by_wood_stove’ | has_value }}
means it checks for unknown or unavaliable if neither the avaliablity gets a value
availability: >
{{ states(‘sensor.smoke_detector_2_by_wood_stove’) | is_number }}
this checks for a number if it doesnt see a number its false but if it sees a number is true and avaliablty for a value is ok
is basiclly how i understand it…
are there docs that break down all the codes. that make it simple like for dummies as i assume this is all specific to home assistant and not to another coding language
only reason i say sometimes with my dislexia and learning disablity i find that the home assistant docs not always easy to understand sometimes not like a teacher teaching in class explaining things
for future knowledge
i appreciate the help as i only know basiclly templating and never know when you need to use avaliablity or when not to as i have templates that have avaliablity and some that dont …
wish this stuff was around in the 90s when i was programming PLCs in machine code this is alot easier now then back then doing lots of cool stuff
Thank you for trying to explain it and I do not really disagree with the use of is_number().
However, your logic is a bit flawed in that while those four integrations might use NumPy internally, Python has native float('nan') and float('inf') constants. You do not need NumPy to encounter these “objects” in a template.
It is true that this would be extremely rare but it could happen none the less - for example:
so does that mean you float 0 as nan or unavaliable as you dont use -1 and if it does get a value of 0 then pass it as a nan else calculate the value … is that how that works
I did not mention those constructs because they still produce False with is_number. The only one that produces true with is_number is np.NaN. Try it yourself. Takes 2 seconds:
In the world of computing and Home Assistant, it is a special value used to represent a result that is undefined or unrepresentable. It’s the computer’s way of saying, “I tried to do the math, but the answer doesn’t exist in the world of numbers.”
Examples of when this occurs:
Divide by zero.
Subtracting infinity from infinity.
Square root of a negative number
Trying to find the “Average” of an empty list (The Statistics integration does this often when sensors are offline).