#Regex to use same rule for entities matching pattern

1 messages · Page 1 of 1 (latest)

onyx adder
#

I have an ha-floorplan SVG file with many elements matching the names of entities in HA for my solar panel array. I would like to define just one state_action to set the value for all power entities, and eventually other rules for other data types, on all matching elements.

I tried various regex-like patterns for the entity, for example:

rules:
    - entity: sensor.hoymiles_pv_*pv_power   <---- does not match
       state_action:
          action: call-service
          service: floorplan.text_set
          service_data:
              text: '${entity.state ? entity.state + "W" : "—"}'
    - entity: sensor.hoymiles_pv_1164a01504de_pv_1_temperature
       state_action:
           action: call-service
           service: floorplan.text_set
           service_data:
               text: '${entity.state ? entity.state + "C" : "—"}'

but have not succeeded. The temperature rule with the exact entity id works fine.

HA is giving the error
cannot find sensor.hoymiles_pv_*pv_power in Home Assistant entities.

I tried:

sensor.hoymiles_pv_*pv_power  
sensor.hoymiles_pv_.*pv_power
sensor.hoymiles_pv_\S+pv_power   

An example of an actual existing entity is sensor.hoymiles_pv_1164a0150401_pv_4_pv_power