#Sending intent from HA to android app

1 messages · Page 1 of 1 (latest)

civic bear
#

I have a location tracking service called Dawarich that uses owntracks location data (similar to Google timeline). I would like to use home assistant zones to automate owntracks to switch monitoring parameters. Is it possible through the HA OS, HA app to send an intent to switch monitoring modes? I am trying to avoid Tasker and other automation tools.

This is from is tracks site on sending intents, I am just not technical enough: https://owntracks.org/booklet/features/android/

thorny rampart
civic bear
#

I have this but triggering it does not update owntracks monitoring mode. Any tips?

description: ""
triggers:
  - device_id: bb5a31b99644cf3445ba397d42318785
    domain: device_tracker
    entity_id: e8c9c093a20f5bc2c01ec02e39e1d985
    type: enters
    trigger: device
    zone: zone.home
conditions: []
actions:
  - action: notify.mobile_app_s21
    metadata: {}
    data:
      message: command_broadcast_intent
      data:
        intent_package_name: org.owntracks.android
        intent_action: org.owntracks.android.CHANGE_MONITORING
        intent_extras: monitoring:0
      target: org.owntracks.android
mode: single```
thorny rampart
#

any errors in the logs?

civic bear
#

None

thorny rampart
#

app logs wont be blank and will at least show the command sent to the app

#

did you confirm the device received the notification too?

civic bear
#

I guess I could be in the wrong logs.

I added an additional notification not noted in the code above that confirmed the device is receiving the code.

Is there somewhere specific to find logs?

#

Home assistant core logs show no errors or warnings. I could try a higher level of monitoring to see more

thorny rampart
civic bear
#

I found it.I see "duplicate location not sending to HA", "Notification is not in a group. Cancel notification..." And "Unable to log event: analytics library is missing"

civic bear
#

From owntracks logs:
11:55:38.766 | MessageProcessor: Received incoming message: MessageUnknown on NOKEY with id=0 11:55:38.767 W MessageProcessor: Unknown message type received 11:55:39.676 | MessageProcessor: Received incoming message: MessageUnknown on NOKEY with id=0 11:55:39.676 W MessageProcessor: Unknown message type received

thorny rampart
civic bear
#

Wrapping it as you described and then saving makes it revert back to no quotations

thorny rampart
#

check the apps notification history, did the format retain as expected?

#

one other thing we can try is to specify the type so intent_extras: "monitoring:0:int" could be what the error was possibly but also depends on what data teh app got

civic bear
thorny rampart
#

ok yea try with specifying the type

civic bear
#

No change adding ":int"

thorny rampart
#

may need to do more trial and error

civic bear
#

I'm fairly certain the owntracks app is not receiving the notification. There is nothing in the logs. The thing I posted does not correspond to notification push times.

thorny rampart
#

the OS would error if the intent was not formatted properly, is the intent a feature you need to enable at the app level? you can try the tasker/adb command to see if that works to rule out an issue

#

an app like logcat reader may be of help to in case there is more logging but that will be quite verbose

civic bear
#

I set up macrodroid and sent the intent that way and it works

civic bear
#

Here are logs from logcat for macrodroid and owntracks. It looks like this shows owntracks receiving a notification and making changes.

thorny rampart
#

the logs dont show the data macdroid sent, try to remove intent_extras and see if that works....according to the docs it should toggle the mode

civic bear
#

I removed it and ran it. Still nothing. I have a feeling the notification isn't reaching owntracks but I have no idea how to fix that

thorny rampart
#

if we dot get an error back then i am not sure what the issue is

#

double check you didnt misspell anything

#

also try to switch to command_activity maybe owntracks does not like command_broadcast_intent

#

they both send intents but depends on how the responding app implemented it

civic bear
#

That was it. Command_activity triggers owntracks. When I add the intent_extras: monitoring:0 back it fails with a toast saying to check command format

thorny rampart
#

check the app logs and the error will give a hint about the formatting hopefully

civic bear
#

2025-03-04 14:40:20.562 6345 6345 io.homeassistant.companion.android E MessagingService : Unable to send activity intent please check command format
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=org.owntracks.android.CHANGE_MONITORING flg=0x10000000 pkg=org.owntracks.android }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2252)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1878)
at android.app.ContextImpl.startActivity(ContextImpl.java:1174)
at android.app.ContextImpl.startActivity(ContextImpl.java:1145)
at android.content.ContextWrapper.startActivity(ContextWrapper.java:445)
at io.homeassistant.companion.android.notifications.MessagingManager.processActivityCommand(MessagingManager.kt:1818)
at io.homeassistant.companion.android.notifications.MessagingManager.handleDeviceCommands(MessagingManager.kt:718)
at io.homeassistant.companion.android.notifications.MessagingManager.access$handleDeviceCommands(MessagingManager.kt:108)
at io.homeassistant.companion.android.notifications.MessagingManager$handleMessage$4.invokeSuspend(MessagingManager.kt:440)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:101)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:230)
at android.os.Looper.loop(Looper.java:319)
at android.app.ActivityThread.main(ActivityThread.java:8919)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)

thorny rampart
#

did you try with specifying the type too?

civic bear
#

Well now I don't know. It's failing with and without intent_extras: monitoring:0

#

I don't know why it worked once after I switched to command_activity but now it fails each time

thorny rampart
#

wonder if your commands are delayed to your phone, add the critical format to speed up deliverys doze does not impact it

civic bear
#

I don't follow

thorny rampart
#

that has an example of what to follow, by default notifications can be delayed untl your screen turns on

#

that may explain the sporadic behavior