What would be the best way to track input_boolean’s in bulk within an automation?
I’ve built out a “habit tracker” which uses input_boolean’s. Upon true, the habit count increases by 1. This resets every night back to 0.
Within my automations, I have to add each input_boolean on it’s own and whenever I add a new “habit” I have to go back to multiple automations to add the new input_boolean.
Is there any easier way to scale this that I may be missing? All of them have “habit” in the name, is there some kind of scripting approach I could use instead?
Here is an example of part of 1 of the automations. I need to add a trigger for each input_boolean. Can these be grouped somehow?
This will create a sensor that reports the number of input booleans that are “on” and contain the search term “.habit_”. As long as your future input booleans follow the naming criteria they will automatically be included.
You will still need your nightly automation to reset all your booleans, but we can make it smart as well…
@Didgeridrew Using something similar, would I be able to create a notification automation that notifies after each completion? Something that would be dynamic: “X out of Y total habits completed”.
Right now i’m doing this manually with an automation at every level when sensor.habit_boolean_count changes. Ex:
Notice that by not assigning a to: or from: to the State trigger, the automation will trigger on every state change*. Then, by adding a condition to only execute the actions when the trigger’s new state is greater than the previous state, you avoid notifications from the nightly reset or manual reset of individual input booleans.
* Technically it fires whenever the value of any attribute changes, but this sensor only has a state.