So it depends only on a “sensor.ac68u_nvram_used”.
This sensor mainly has same value for a long time.
So, the derived “sensor.ac68u_nvram_usage” may stay “unknown” for a looooong time.
After tests I decided to set a “normal” value to the “sensor.ac68u_nvram_usage”.
So I changed a value of the original “sensor.ac68u_nvram_used” & then reverted to the prev. value (61875 → 61874 → 61875).
The “sensor.ac68u_nvram_used” was updated.
But the target “sensor.ac68u_nvram_usage” is still unknown.
I believed that the “sensor.ac68u_nvram_usage” will be re-evaluated - but it did not happen.
Why?
{% set VALUE = 'unavailable' %}
{{ not VALUE in ['unavailable','unknown'] }}
{{ (not VALUE) in ['unavailable','unknown'] }}
{% set VALUE = '111' %}
{{ not VALUE in ['unavailable','unknown'] }}
{{ (not VALUE) in ['unavailable','unknown'] }}
The “unknown” value is probably not permitted to a numerical value.
Although I did not have any messages in Log - I faced similar messages in cases when similar numerical sensors became “unknown” due to some reasons.
Right after reloading templates the “sensor.ac68u_nvram_usage” started working again.
So, imho finally it was MY error - applying the “unknown” value to a numerical sensor…
There’s many reasons set state is not suggested, this is one of them. Technically under the hood, no sensor actually gets the state ‘unknown’ or ‘unavailable’.
These aren’t documented reasons. The set button on the states page just puts a value into the states machine state object. It’s the only place this is possible and it’s a legacy function. In general, you are not meant to set the state of state objects.
This is called a Dev tools and probably purposed to debugging.
This is what I did - debugging.
And I wonder - not mainly “why I cannot apply an unknown state” - but mainly “why my sensor was not re-evaluated from a manually set unknown state”.
Because it’s not actually going into the state machine. It’s like covering a cut with a band aide. Cut still exists even though you only see the bandaide. Same thing is happening when you use set state. The data under the hood isn’t altered, you’re just changing what you see.
FWIW, I have never ever had to use set state in my history with HA. You can debug without it. I’m not sure why so many people rely on it.
Sorry, but without getting into the details of python and how setting/getting properties works, this is going to be too complicated for me to explain. Just know that when you set the state, you are bypassing many things that you normally wouldn’t bypass.
If you understand it - you should be able to explain.
At least this could be useful for other users who understand Python.
(myself never dealt with it, mainly C/C++)
Without going into the details too much, it’s like a cached value. When you use set state, you’re just changing the cached value, not the actual value.
This is why I didn’t want to get into this. You need to understand python and random libraries used by HA.
I wouldn’t say random libraries, this is built-in. But it’s still requires a high level of knowledge versed in coding and/or python. I’m sure other languages have equivalent decorators.