Advertisement
pqpxoxa

HA - custom:button-card filter P1

Sep 5th, 2021
599
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. platform: template
  2. sensors:
  3. motion_name_last_activated:
  4. friendly_name: 'Motion Name Last Activated'
  5. value_template: >
  6. {% set sensors = [states.binary_sensor.m_0_garage_motion,
  7. states.binary_sensor.m_0_ground_hallway_motion,
  8. states.binary_sensor.m_0_kitchen_motion,
  9. states.binary_sensor.m_0_outdoor_motion,
  10. states.binary_sensor.m_0_snug_motion,
  11. states.binary_sensor.m_1_first_hallway_motion,
  12. states.binary_sensor.m_1_living_room_motion,
  13. states.binary_sensor.m_2_master_bedroom_motion,
  14. states.binary_sensor.m_2_second_hallway_motion,
  15. states.binary_sensor.master_bedside_sam_pir_sensor,
  16. states.binary_sensor.motion_swk_cr_uniuvc1,
  17. states.binary_sensor.motion_swk_cr_uniuvc2,
  18. states.binary_sensor.motion_swk_cr_uniuvc3,
  19. states.binary_sensor.motion_swk_cr_uniuvc4] %}
  20. {% set time = sensors | map(attribute='last_changed') | max %}
  21. {% set sensor = (sensors | selectattr('last_changed','eq', time) | list)[0] %}
  22. {{sensor.name}}
  23.  
  24. ###### This is to capture the name ( {{sensor.name}} ) of the latest entity to be triggered from the list
  25. ###### To capture the state, change {{sensor.name}} to {{sensor.state}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement