#If you're moving from Node Red, I highly

1 messages · Page 1 of 1 (latest)

neon sparrow
#

I curently use a lot of Regex in node-red, is anything like this possible with HA automations?

wheat cloud
#

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.

neon sparrow
#

Thanks for the info!

neon sparrow
#

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 %}

wheat cloud
neon sparrow
#

Sometimes easier is not the best way.