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 apps to communicate to each other. Not all apps supports these features let alone have them documented. The purpose of this post to help consolidate a list of those so users can see all that is possible.
I chose a forum post so we can keep a discussion and so I can update the list of links to help everyone out. Just remember there is no easy answer as to what to do for an app, we have to get the proper data to build out the command. The docs provide a real world example for you to use and get familiar with.
So to get started you will need to familiarize yourself with the documentation around this. To send an intent from HA to another app you will need to follow command_broadcast_intent
.
https://companion.home-assistant.io/docs/notifications/notification-commands#broadcast-intent
To add on to this you can also launch an activity using command_activity
https://companion.home-assistant.io/docs/notifications/notification-commands#activity
To receive an intent for another app you will need to make use of the Last Update Sensor as it has settings to allow you to register for any intent. Long story short go to App Configuration > Manage Sensors > Last Update Sensor > Toggle add intent (wait a few seconds for the page to update and the toggle to turn off) > Select the new item that just appeared and clear out the field, then add in the intent string you wish to register for > Repeat last 2 steps for each and every intent you wish to register for. Once you are done adding intents, force stop the app and open it again so the app can register for them.
https://companion.home-assistant.io/docs/core/sensors#last-update-trigger-sensor
Once you register for the intent and restarted the app you will then need to listen for the android.intent_received
event
https://companion.home-assistant.io/docs/integrations/app-events
To get you started here is an example of how to listen for events in an automation and notify you when its been received. The below will send a notification with the person who fired the event and the intent that was sent with the event data.
- alias: Intent received
trigger:
- platform: event
event_type: android.intent_received
action:
- service: notify.mobile_app_dannys_pixel_4_xl
data_template:
message: "Intent received by user {% set person = states.person|selectattr('attributes.user_id', 'eq', trigger.event.context.user_id)|first %}{{ person.attributes.friendly_name }} with action {{ trigger.event.data.intent }}"
data:
ttl: 0
priority: high
Now here is the consolidated list:
-
Mi band and Notify Fitness (enable Tasker)
-
Sleep as Android (Note: the app has since been updated with support for webhooks and MQTT, keep in mind this is only for receiving intents and not for sending)
-
TinyCam Pro
-
Official Google examples
-
Google Maps
-
Youtube - https://stackoverflow.com/questions/574195/android-youtube-app-play-video-intent
-
Spotify
-
Gadgetbridge
-
Waze
-
Netflix
-
Torque
-
VLC
-
WiGle
-
Event Sensor - In case you just want to save data this custom component may save you time
As you can see a lot of this is going to be trial and error. Again the docs have some good examples to show you how to translate things from what you find online (refer to the example and provided links to make the connection). If you are stuck on a command make sure to give us the full example you tried so we can help out Don’t be afraid to reach out to your favorite app developers asking if they support these things or if they can add them, you will be surprised how many already do or will add it for you.
Looking forward to all of the use cases everyone is going to come up with!
Personally I am doing a few things thus far:
- Mi Band and Fitness to send intents to track steps, heart rate, falling asleep and waking up (there is more too just peep the link up above). Just started using these so need to find a good use case but cool nonetheless!
- Sleep as Android, starting sleep tracking when
scene.goodnight
is ran. Reacting to sleep tracking turning off. I use the start and stop sleep tracking events to automatearmed_night
as it makes life easier. Also the stop tracking event is useful if you like to have a script ran after you wake up.