Creating a Value Template to trigger everything to be clear to trigger action

Trying to setup a trigger where if all motion (3) shows clear, that it will trigger an action. I found this code and tried to make it my own but doesn’t look like it’s working. Any thoughts??

platform: template
value_template: >
{{ expand(‘binary_sensor.ms_kitchen_motion’,
‘binary_sensor.ms_dining_motion_detection’,
‘binary_sensor.mmw_main_presence_sensor_1’) | selectattr(‘state’, ‘eq’,
‘Clear’) | list | count == 3 }}
id: MAIN-OFF

A binary sensor can be on or off. „Clear“ is jaust what is displayed in the UI.

In addition to @pedolsky’s comment, with the somewhat recent addition of is_state() as a selection filter you don’t need to expand the entities’ states.

platform: template
value_template: >
  {{ ('binary_sensor.ms_kitchen_motion', 'binary_sensor.ms_dining_motion_detection',
  'binary_sensor.mmw_main_presence_sensor_1') | select('is_state', 'off') | list | count == 3 }}
id: MAIN-OFF
1 Like

thanks… gets confusing with the additional features added to the code, i don’t know what is optimal and what is obsolete.

Will get it a shot and report back.