Template loop detected while processing event

{{ states.sensor 
   | selectattr('object_id', 'search', '^(benbedroom|susiebedroom|masterbedroom)')
   | selectattr('object_id', 'search', '(_energy)$')
   | rejectattr('state', 'in', ['unavailable', 'unknown'])
   | map(attribute='state') | map('float', none)
   | reject('==', none)
   | sum | round(2) }}

EDIT: I just realized you’re using this on a group set. This has to be an entity_id list, not the actual math you want to employ…

{{ states.sensor 
   | selectattr('object_id', 'search', '^(benbedroom|susiebedroom|masterbedroom)')
   | selectattr('object_id', 'search', '(_energy)$')
   | map(attribute='entity_id') | list }}

Then your template sensor that calculates the group will be

{{ expand('group.master_bedroom_energy')
   | map(attribute='state') 
   | map('float', none)
   | reject('==', none)
   | sum | round(2) }}
1 Like