Notify Android device and overwrite ringer mode to always play a sound

I’m following the instructions in the documentation: Critical notifications | Home Assistant Companion Docs saying that:

You can also force the notification to play from the alarm stream so it will make the device ring even if on vibrate/silent ringer mode.

However for my Samsung S9 device with Android 10 this does not work when the device is in vibration mode. The notification is shown immediately, the LED will turn on red but there is a vibration only sporadically. A notification sound is never played though.
This is the current configuration:

service: notify.mobile_app_sm_g960f
data:
  title: Wake up!
  message: "The house is on fire and the cat's stuck in the dryer!"
  data:
    ttl: 0
    priority: high
    channel: alarm_stream
    media_stream: alarm_stream

What is interesting though, that the TTS method seems to work - at least it worked once…
Do I need to set the ringer mode and volume as described in the documentation first (see Notification Commands | Home Assistant Companion Docs and Notification Commands | Home Assistant Companion Docs)?
At least for the volume-level I tried it but I only get a notification with the message “command_volume_level” which does not seem right…

Do I miss something somewhere, or is this a general limitation of Samsung phones?

known issue with some samsung devices, unfortunately nothing the app can do to solve the issue.

You can however use a workaround to change ringer mode, send notification and change it back. Can also do this with Do Not Disturb mode.

ah thanks for the hint. Again the phone let me down :confused:

is there maybe also the possibility to use custom sounds instead of TTS? According to the documentation that should work for Apple devices, but I could not find something for Android.
Because, if the TTS works - why should a custom sound not work? Or is this something completely different from the technical PoV? This seems to be discussed in the github issue, but without any hint that it actually works.

You can import your sounds into Android. There are other apps that do it. Then you can select the sound for the notification channel.

But how does this work? The documentation says it is for iOS only: Sounds | Home Assistant Companion Docs

It’s a native Android feature unrelated to the app so it’s not documented there. Android has notification channels which work entirely different than what iOS does. The are some apps out there that can add the files in the correct location. Your device may also have something in settings to let you import it.

@reox this is what works me. Instead of making the phone ring, I make it play a message at full volume. When you find the phone and check it, you will the your set volume level remains unaffected. I use this all the time. I actually just added a trigger to my bedroom light switch so that when I press the down dimmer button 5x it triggers the Find My Phone script. I’m going to add the same thing to a couple more wall switches so that as I walk from room to room looking for it i could re-trigger it as needed.

alias: Find My Phone
icon: mdi:cellphone-marker
sequence:
  - service: notify.mobile_app_samsung_galaxy_s22_ultra
    data:
      message: TTS
      data:
        ttl: 0
        priority: high
        importance: high
        media_stream: alarm_stream_max
        tts_text: >-
          Hey dumbass. Did you lose your phone? I'm over here. Hurry the hell up
          and come get me.
mode: restart
2 Likes

Thanks for the code, I’ll try that! Back then, I had no luck with my Samsung S9, but have bought a Pixel 7 in between… Maybe it works better on that device.

Is it possible to play a specific sound file instead of the TTS? As I asked earlier, that is only described for iOS but not for Android…

There is a known Samsung issue for some of their devices where they deliberately stop apps from overriding the sound of a notification. Nothing the app can do but provide a way for the user to turn up the volume and/or change ringer mode/DND to send the notification in those cases. A pixel device will always follow Android developer documentation more closely.

yes thats precisely what a notification channel is used for on Android.

https://companion.home-assistant.io/docs/notifications/notifications-basic/#notification-channels

Maybe I missed that, but how? The documentation says, that this is a iOS feature: Sounds | Home Assistant Companion Docs

The iOS app allows you to use your own custom sounds in push notifications.

I played around with it again and I get the following things working:

  • Using channel: alarm_stream, the vibration is two long vibrations, and it is overriding DND mode. However, it does not play a sound.
  • TTS works fine now on the Pixel 7
  • The option vibrationPattern seems to have no effect, I always get two short pulses when not using the alarm_stream or two long pulses when using alarm_stream *

What I want to do is to provide a .wav or .mp3 with the sound to play and it will play no matter how the device is currently configured. It seems to be possible to do this with the TTS, as it also overrides DND and vibration mode but I’m limited to TTS…

*) reading the documentation again, that is to be expected, as the vibration pattern is fixed to the channel.

yes we dont support sound in that particular tab as Android does not support it, you need to use the channel like I linked to and configure the channel in your device settings to use the desired sound.

check that your alarm stream has the volume set above 0, if its at 0 then yes you wont hear anything :slight_smile:

per the docs this can only be set once a channel has been created and cannot be changed once created. You either need to clear data in the app and set it up properly from the start if you wish to use alarm_stream or use a different channel that wont use alarm_stream. The only way to reset channel settings is to clear app data, removing a channel is a soft delete in android and it will retain all settings once enabled again.

1 Like

ohhhh okay… Sorry, now I understand!

Settings → Companion App → Notification Channels → alarm_stream → Edit → Select the sound.

That is something that did not worked on the S9 but works flawlessly on the Pixel!

Thanks!

1 Like

Thanks so much.