Broadcast TTS based on movement

Hi,

I was wondering if someone can help me with a template (if it is possible to create a template to achieve what I want to achieve), to broadcast tts messaged based on media_player status ( =! playing) and motion within a certain time ( 10min for example).

I’m not expert in template or macro and this is what I made so far ( I don’t know if even is correct).

  {%- macro broadcast_movement() -%}
  {%- set players = expand('group.media_player_google')|map(attribute='entity_id')|list %}
  {%- set exclusions = states.media_player | selectattr('state','!=','playing') | selectattr('entity_id', 'in', players) | map(attribute='entity_id') | join(', ') -%}
  {%- set device_types = ['motion'] -%}

But how to combine them? Can somehow area_id be useful? Every media_player and binary_sensor have a area_id attribute in my config. I’m not that good in templating so I definitely ask your support to understand if this is possible and how to do that.

Thank you in advance

maybe @petro has the knowledge to know if this is even possible?