First of all, I’ve been googling around and reading for a while tryign to figure out the best way to do this but am struggling to understand exactly how to execute.
I’d like to have a button that turns its icon orange if any of the locks in the house are not locked. I could prob do this with a long template statement and 'and’s but would love to have a script (i believe this is the best?) to return a true or false to set the condition of the icon color. (unless there is a better way of course)
If I hit the button, I want it to lock any of the locks that are unlocked.
Any help or direction would be greatly appreciated!
Edit: (more info on what I’ve found/done)
This is currently what I have controlling the icon color:
{% if lock.back_porch|selectattr(‘state’,‘equalto’,‘unlocked’)|list|length > 0 %}
orange
{% else %}
white
{% endif %}
I found that in a template I can do this:
{{ states.lock.back_porch.state == ‘locked’ and states.lock.basement_back.state == ‘locked’ }}
I considered something like this
if states.all_locks|selectattr(‘state’,‘equalto’,‘unlocked’)|list|length > 0
And also was trying to reference code from the template here: Toggle Scene on/off script
{% for entity_ids in scene_entities if is_state(entity_ids, ‘on’)%}
{% if loop.index == 1 %}
true
{% endif %}
{% else %}
false
{% endfor %}