Notification ios

in this way I only get notified of the first song or video that plays. because the state is just playing

No… the first solution will output on every state change. The second (which is based off your triggers) will only output when playing is the state.

So use the first if you want it to message you on every change.

@petro

the first automation now notifies me of all the states of the various media players even when they are unavalable and oìquando they are off. I’m only interested when a media player is playing

Then you need a condition to only output when playing.

  alias: 'Home player playing notification'
  trigger:
    - platform: state
      entity_id: media_player.plex_kodi_add_on_localhost
    - platform: state
      entity_id: media_player.plex_tv_ue48ju7500
    - platform: state
      entity_id: media_player.plex_plex_01ad68da_eea9_43a2_8af2_7901942af3fc
    - platform: state
      entity_id: media_player.plex_plex_f872035d665e6f7f_com_plexapp_android
    - platform: state
      entity_id: media_player.apple_tv
    - platform: state
      entity_id: media_player.kodi_i7
    - platform: state
      entity_id: media_player.cucina_home_mini
    - platform: state
      entity_id: media_player.spotify
    - platform: state
      entity_id: media_player.2o_echo_dot_di_matteo
    - platform: state
      entity_id: media_player.multisound
  condition:
    - condition: template
      value_template: >
        {{ states(trigger.entity_id) == 'playing' }}
  action:
    - service: notify.ios_iphone_matteo
      data_template:
        title: "Smart Home Alerts"
        message: >
          {{ state_attr(trigger.entity_id,'friendly_name') }} is playing {{ state_attr(trigger.entity_id,'media_title') }}

now everything seems to work perfectly.
if you want the notifications only for the music what condition should I put?

is that the media_content_type?

yes is media type for all media player

what is it set to when music is playing?

media_content_type: music for all media player

  alias: 'Home player playing notification'
  trigger:
    - platform: state
      entity_id: media_player.plex_kodi_add_on_localhost
    - platform: state
      entity_id: media_player.plex_tv_ue48ju7500
    - platform: state
      entity_id: media_player.plex_plex_01ad68da_eea9_43a2_8af2_7901942af3fc
    - platform: state
      entity_id: media_player.plex_plex_f872035d665e6f7f_com_plexapp_android
    - platform: state
      entity_id: media_player.apple_tv
    - platform: state
      entity_id: media_player.kodi_i7
    - platform: state
      entity_id: media_player.cucina_home_mini
    - platform: state
      entity_id: media_player.spotify
    - platform: state
      entity_id: media_player.2o_echo_dot_di_matteo
    - platform: state
      entity_id: media_player.multisound
  condition:
    - condition: template
      value_template: >
        {{ is_state(trigger.entity_id, 'playing') and is_state_attr(trigger.entity_id, 'media_content_type', 'music') }}
  action:
    - service: notify.ios_iphone_matteo
      data_template:
        title: "Smart Home Alerts"
        message: >
          {{ state_attr(trigger.entity_id,'friendly_name') }} is playing {{ state_attr(trigger.entity_id,'media_title') }}