#If you're moving from Node Red, I highly
1 messages · Page 1 of 1 (latest)
I curently use a lot of Regex in node-red, is anything like this possible with HA automations?
Just make a Group helper which can then be expanded to individual entities if you need.
But to answer your specific question, wildcard #templates-archived or Jinja regex_search filter are what you are looking for. You can test your templates in the /developer-tools/template section.
Thanks for the info!
It seems like the template trigger only triggers when going from off to on.
Any way to get it to detect motion for all regexed entities?
I currently got this to regex all my motion entities:
{% if states.binary_sensor
|selectattr('entity_id', 'search', 'occupancy')
|selectattr('entity_id', 'search', 'motion')
|selectattr('state', 'eq', 'on')
|map(attribute='entity_id')
|list | length +
states.binary_sensor
|selectattr('entity_id', 'search', '(sensor_[a-zA-Z]*_fp2_occupancy)')
|selectattr('state', 'eq', 'on')
|map(attribute='entity_id')
| list | length > 0 %}
true
{% else %}
false
{% endif %}
Again, a group helper is gonna be easier in this instance. There's simply an "all" toggle in there. Unless I'm misunderstanding and you just want any of those two regex group'd to trigger, in which case you just need some bracketing around your logical statements. The + and the > 0 need to be seen as separate components. So just bracket around each group of logic.
Sometimes easier is not the best way.