I just found a way to trigger when the phone alarm (Android standard clock app) has been ringing for a duration.
Just figured I would share it if anyone needs/wants it.
You need to create a boolean that will be on when the alarm is ringing on the phone.
trigger:
- platform: state
entity_id:
- sensor.andreas_last_notification
attribute: category
to: alarm
id: ringing
- platform: state
entity_id:
- input_boolean.phone_alarm_ringing
to: "on"
id: TTS
for: # change here to set how long the alarm should be ringing before it triggers
hours: 0
minutes: 0
seconds: 30
- platform: template
value_template: >-
{{ state_attr('sensor.andreas_last_removed_notification', 'category') == 'alarm' and
state_attr('sensor.andreas_last_removed_notification', 'channel_id') == 'Firing' and
state_attr('sensor.andreas_last_removed_notification', 'package') == 'com.google.android.deskclock' }}
id: silence
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: ringing
- condition: state
entity_id: sensor.andreas_last_notification
attribute: channel_id
state: Firing
- condition: template
value_template: >-
{{ 'com.google.android.deskclock' in
state_attr('sensor.andreas_last_notification', 'android.appInfo')
}}
sequence:
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.phone_alarm_ringing
- choose:
- conditions:
- condition: trigger
id: TTS
sequence:
- repeat:
while:
- condition: state
entity_id: input_boolean.phone_alarm_ringing
state: "on"
sequence:
- service: tts.cloud_say
data:
entity_id: media_player.all_speakers
message: "Your alarm is ringing"
- delay:
hours: 0
minutes: 0
seconds: 10
milliseconds: 0
- choose:
- conditions:
- condition: trigger
id: silence
sequence:
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.phone_alarm_ringing
mode: parallel
max: 4