Please, make access to attributes without state_attr(‘sensor.humidity_158d000000c534’, ‘battery_level’), is_state, is_state_attr. I want always access sensor.humidity_158d000000c534.battery_level without keywords. Maybe if device maybe nullable, use sensor?.humidity_158d000000c534?.battery_level nullable keywords like in Kotlin language. Maybe change templates, but it hard to remember all keywords
states.sensor.humidity_158d000000c534.attributes.battery_level
It’s described here:
But in templates, it is not recommended use such syntax, and use is_state
It’s not recommended simply because if the entity doesn’t exist, a function, such as states()
or is_state()
, handles the situation more gracefully than a direct reference.
Your Feature Request would be subject to the same limitation. It’s simply a shorter direct reference.
Maybe HA should store default/last state during startup.