Thanks for the suggestion, unfortunately the logs don’t help much. I see the intent being sent by HA but android tells me to “verify command format”.
So the logs don’t provide additional information on why it fails…
Since it says verify command format did you go back to the docs to make sure you followed it precisely? It seems you have spaces after the commas under the group tag but do you see that exact format in the examples? Probably need to remove those extra spaces
Looking more deeply at the logs, I see an exception being returned:
10-03 16:15:35.639 29954 12406 D MessagingService: From: 331041709873
10-03 16:15:35.639 29954 12406 D MessagingService: Message data payload: {tag=android.intent.action.VIEW, channel=net.openvpn.openvpn, message=command_activity}
10-03 16:15:35.640 29954 12406 D MessagingService: Processing device command
10-03 16:15:35.641 29954 12338 E sqlite3_android: ONEPLUS_NAME_PARTS_MATCH SQLITE_OK
10-03 16:15:35.642 29954 12406 E MessagingService: Unable to send activity intent please check command format
10-03 16:15:35.642 29954 12406 E MessagingService: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW flg=0x10000000 pkg=net.openvpn.openvpn }
10-03 16:15:35.642 29954 12406 E MessagingService: at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2258)
10-03 16:15:35.642 29954 12406 E MessagingService: at android.app.Instrumentation.execStartActivity(Instrumentation.java:1914)
10-03 16:15:35.642 29954 12406 E MessagingService: at android.app.ContextImpl.startActivity(ContextImpl.java:1034)
10-03 16:15:35.642 29954 12406 E MessagingService: at android.app.ContextImpl.startActivity(ContextImpl.java:1005)
10-03 16:15:35.642 29954 12406 E MessagingService: at android.content.ContextWrapper.startActivity(ContextWrapper.java:403)
10-03 16:15:35.642 29954 12406 E MessagingService: at io.homeassistant.companion.android.notifications.MessagingService.processActivityCommand(MessagingService.kt:1283)
10-03 16:15:35.642 29954 12406 E MessagingService: at io.homeassistant.companion.android.notifications.MessagingService.handleDeviceCommands(MessagingService.kt:536)
10-03 16:15:35.642 29954 12406 E MessagingService: at io.homeassistant.companion.android.notifications.MessagingService.onMessageReceived(MessagingService.kt:287)
10-03 16:15:35.642 29954 12406 E MessagingService: at com.google.firebase.messaging.FirebaseMessagingService.dispatchMessage(com.google.firebase:firebase-messaging@@22.0.0:13)
10-03 16:15:35.642 29954 12406 E MessagingService: at com.google.firebase.messaging.FirebaseMessagingService.passMessageIntentToSdk(com.google.firebase:firebase-messaging@@22.0.0:8)
10-03 16:15:35.642 29954 12406 E MessagingService: at com.google.firebase.messaging.FirebaseMessagingService.handleMessageIntent(com.google.firebase:firebase-messaging@@22.0.0:3)
10-03 16:15:35.642 29954 12406 E MessagingService: at com.google.firebase.messaging.FirebaseMessagingService.handleIntent(com.google.firebase:firebase-messaging@@22.0.0:3)
10-03 16:15:35.642 29954 12406 E MessagingService: at com.google.firebase.messaging.EnhancedIntentService.lambda$processIntent$0$EnhancedIntentService(com.google.firebase:firebase-messaging@@22.0.0:1)
10-03 16:15:35.642 29954 12406 E MessagingService: at com.google.firebase.messaging.EnhancedIntentService$$Lambda$0.run(Unknown Source:6)
10-03 16:15:35.642 29954 12406 E MessagingService: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
10-03 16:15:35.642 29954 12406 E MessagingService: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
10-03 16:15:35.642 29954 12406 E MessagingService: at com.google.android.gms.common.util.concurrent.zza.run(com.google.android.gms:play-services-basement@@17.5.0:6)
10-03 16:15:35.642 29954 12406 E MessagingService: at java.lang.Thread.run(Thread.java:923)
Currently I’m not able to provide any class name through home assistant to provide additional guidance to android to locate the right endpoint…
Any idea Ho I can fix this?
Okay, doing some further digging, it seems I’m on the right track…
Looking at the implementation of the Intent in the Android app, it seems that the class cannot be provided.
Although Android "does it’s best to find the right one, in case of OpenVPN Connect it does not…
Original code in app:
try {
val packageName = data["channel"]
val action = data["tag"]
val intentUri = if (!data[TITLE].isNullOrEmpty()) Uri.parse(data[TITLE]) else null
val intent = if (intentUri != null) Intent(action, intentUri) else Intent(action)
val type = data["subject"]
if (!type.isNullOrEmpty())
intent.type = type
val extras = data["group"]
if (!extras.isNullOrEmpty()) {
val items = extras.split(',')
for (item in items) {
val pair = item.split(":")
intent.putExtra(
pair[0],
if (pair[1].isDigitsOnly())
pair[1].toInt()
else if ((pair[1].toLowerCase() == "true") ||
(pair[1].toLowerCase() == "false")
)
pair[1].toBoolean()
else pair[1]
)
}
}
Using Automate (similar to Tasker), I experience same error when I remove the Class parameter.
Hence it seems somehow required…
Can this be enhance that we can at least provide the class through the YAML config in HA?
@dshokouhi@tstas
Hey any news on this?
I’ve try this and more or less it works…
The only things is that it will not connect automatically, but you have to press on the switch “connect” of the ovpn App
Hi, I’m also struggling with this. I’m trying to test it via a call service in developer tools. That drops the quotation marks and shows it as per below. Has anyone managed to get this to work and can they provide an example?
Thank you so much. This has it 99% there for me. The bit that still doesn’t seem to work is when I include this intent extra “net.openvpn.openvpn.AUTOSTART_PROFILE_NAME:PC vpn.mydomain.eu [Home]”… I’ve replaced it with “net.openvpn.openvpn.AUTOSTART_PROFILE_NAME:PC Home” (the profile name is ‘Home’) but that still doesn’t work. If I remove that line completely it autoconnects to the last used profile which is much more than it was doing before, but I need to specify which to use in the command. I’ve also tried ‘mydomain.com [Home]’… any tips on what I am doing wrong with that line?
If you go into Openvpn app and edit the profile, you need to use the full profile name defined there.
In my case it includes “vpn.mydomain.com”.
Alternatively, recreate the profile and try again with the correct name.
(I suspect openvpn changes the display name only, but not the full profile name underlying. Renaming after thd fact may cause it to not work)
Tried everything here but still not working for me. It either just opens the openvpn app or even just minimizes whatever is opened.
I have the exact same commands being sent from tasker and they work fine, but via home-assistant it doesn’t. Its as if some of the “extra” is not being sent.