I use restful sensors quite extensively to update other sensors, but on occasion those REST API calls fail and I then have dozens of other sensors all go to unavailable or error states.
It would be much more helpful if the sensor itself did not update in the event of a failure, and left the previous value unchanged.
This could be an attribute of the restful definition to only update the resulting sensor if the API call succeeds, but is there any way to do that today.
I can’t work out how to make all my other automations and sensors use the last known good value for the sensor in these situations.
has_value takes an entity ID and checks its state (ref).
You’re effectively checking for the state of an entity with an ID of '2024-09-20 14:26:27', which doesn’t exist for obvious reasons, so it returns False.
state_attr will return None if the attribute doesn’t exist.
Thanks, I had just worked that out myself…trying to get my head around what “object” is being evaluated…and in the first example, the state isn’t the thing actually being evaluated it’s the value returned from the state and rendered…
I should know better coming from a java development background, but the documentation seems a bit misleading on this aspect of the language