nat
(phoniclynx)
July 4, 2022, 2:47pm
1
For some time now I’ve been using the intent command to set my alarm on my phone. In the previous update that has apparently been changed and now it only sends me a message if the intent instead of doing the command.
What is the change that I need to make?
service: notify.mobile_app_mobile
data:
message: command_activity
data:
tag: android.intent.action.SET_ALARM
group: >-
android.intent.extra.alarm.HOUR:{{ (state_attr('sensor.google_alarm',
'getReady').split(':')[0]) }},android.intent.extra.alarm.MINUTES:{{
(state_attr('sensor.google_alarm', 'getReady').split(':')[1]) }},android.intent.extra.alarm.MESSAGE:Get Ready,android.intent.extra.alarm.RINGTONE:Roller Disco,android.intent.extra.alarm.SKIP_UI:true
Beta version I assume? This is the PR you should read:
home-assistant:master
← dshokouhi:notif_command_param_change
opened 03:26AM - 08 Oct 21 UTC
## Summary
This PR addresses the issue of notification commands hijacking o… ther notification parameters which were used for standard notifications. Now commands will use a unique parameter. There is really no way around this breaking change but given that its a parameter name change it should be relatively simple for all to change.
The biggest change is going to be that `title` will no longer be used for any command including TTS, this means all additional command data will need to be in the `data` element underneath `message`. In most cases `title` was switched to `command`. Providing examples below and in the docs to remove any confusion.
TTS
change `title` to `tts_text`
change `channel` to `media_stream`
```yaml
automation:
- alias: "Fire Detected TTS alarm"
trigger:
...
action:
- service: notify.mobile_app_<your_device_id_here>
data:
message: TTS
data:
ttl: 0
priority: high
media_stream: "alarm_stream"
tts_text: "The house is on fire and the cat's stuck in the dryer!"
```
Device Commands
For DND, Ringer Mode, bluetooth, ble transmitter, high accuracy, webview
Change `title` to `command`
```yaml
automation:
- alias: Command ringer mode
trigger:
...
action:
- service: notify.mobile_app_<your_device_id_here>
data:
message: "command_ringer_mode"
data:
command: "vibrate"
```
Broadcast Intent
change `channel` to `intent_package_name`
change `title` to `intent_action`
change `group` to `intent_extras`
Volume Level
change `title` to `command`
change `channel` to `media_stream`
Media
change `title` to `media_command`
change `channel` to `media_package_name`
Activity
change `channel` to `intent_package_name`
change `tag` to `intent_action`
change `title` to `intent_uri`
change `subject` to `intent_type`
change `group` to `intent_extras`
## Screenshots
## Link to pull request in Documentation repository
Documentation: home-assistant/companion.home-assistant#589
## Any other notes
FCM: https://github.com/home-assistant/mobile-apps-fcm-push/pull/61
Leaving as a draft so we can merge this for the next release. I don't think it makes sense to do backwards compatibility here as most of the changes are straight forward
I assume there will be a larger announcement with guidance when these changes move to stable. But the PR spells it out for now.
1 Like
yup we will have a blog post for this once a stable release is cut but the docs have also been updated to include examples of the latest beta changes.
nat
(phoniclynx)
July 5, 2022, 4:52am
4
Yes I am using the beta version; OK, so I gave it a shot and it didn’t seem to work. Can you please advise me on where I went wrong?:
service: notify.mobile_app_nathaniel_mobile
data:
message: command_broadcast_intent
data:
intent_action: android.intent.action.SET_ALARM
intent_package_name: android.intent.extra.alarm
intent_extras: >-
HOUR:{{ (state_attr('sensor.google_alarm','getReady').split(':')[0]) }},
MINUTES:{{ (state_attr('sensor.google_alarm', 'getReady').split(':')[1]) }},
MESSAGE:Get Ready,
RINGTONE:Roller Disco,
SKIP_UI:true
This seems to stop it from sending a message as a text message now, but it doesn’t seem to actually add the alarm like it used to.
The remove intent works without any issue (if I add the alarm manually), but adding the alarm doesn’t seem to appear (the important part)
Well you changed it. You had this:
nat:
service: notify.mobile_app_mobile
data:
message: command_activity
data:
tag: android.intent.action.SET_ALARM
group: >-
android.intent.extra.alarm.HOUR:{{ (state_attr('sensor.google_alarm',
'getReady').split(':')[0]) }},android.intent.extra.alarm.MINUTES:{{
(state_attr('sensor.google_alarm', 'getReady').split(':')[1]) }},android.intent.extra.alarm.MESSAGE:Get Ready,android.intent.extra.alarm.RINGTONE:Roller Disco,android.intent.extra.alarm.SKIP_UI:true
According to the PR I linked here’s how the old fields mapped to the new ones for the activity notification command:
change channel
to intent_package_name
change tag
to intent_action
change title
to intent_uri
change subject
to intent_type
change group
to intent_extras
So all you had to do was replace tag
with intent_action
and group
with intent_extras
. Instead you seem to have changed a bunch of other stuff. In particular you seem to have dropped the prefixes off the params in the intent extras which is probably the main reason it broke. But really all you had to do was change the fields, nothing else.
Not part of the topic per se…
but what is the command to remove the alarm without needing to accept the command via the UI?
And where does someone find the info generally on how to construct the command activities, broadcast intents etc that can be used with the mobile app?
there is no native intent to do that, its up to each app to provide its own services there. Sleep as android has a custom intent to enable/disable an alarm by its label but not remove it.
Every app is going to be different, the companion docs offer some live examples of Sleep as Android and Googles own apps. You’ll find links to the corresponding docs there too, outside of that its best to contact the app developer or look up their docs to see if they support it.
There is a thread that lists all the apps taht we have found to offer some type of example but largely if its not mentioned in the forums/docs you’ll need to do a bit of trial and error to get the command right. Its a bit of an advanced topic as some commands will require more trial and error than others, especially if you need to use a manifest reader to try and guess how things work.
Hey Everyone,
We have added a few features that are currently available in the latest Beta version of the app, if you don’t see some of the below features check that you have the latest beta per GitHub. As of this post you want to be on at least beta-573. There are a couple of features that are currently in beta and also been released to help you further integrate other apps from your android phone.
For those who are new an Intent is something that Android uses to allow the system and other …
1 Like