Restart companion app from an Automation

Hi,

I have an Android tablet running the companion app, and I want to use it for a wallpanel. To save battery, I want to turn the screen off at night.

I’ve found this post in Reddit (https://www.reddit.com/r/homeassistant/comments/1app4vn/turn_onoff_tablet_using_companion_app/) that explains how to do it by enabling/disabling the ‘Always keep screen on’ option. It also uses command_launch_app to restar the companion app (so it picks the new config for the screen). And that last part is not working for me.

The command I’m using is

  - service: notify.mobile_app_wallboard_entrada
    data:
      message: command_launch_app
      data:
        package_name: io.homeassistant.companion.android
    enabled: true

The command seems to be correct. When looking at the companion app logs, I do see the command being processed.

The package name seems to be correct as well. I’ve found that any other package name (like adding .full or .minimal at the end) results in a dialog saying the package can’t be found. That specific string (“io.homeassistant.companion.android”) doesn’t trigger that error and matches the ID used by the companion app.

However, the app is not restarted. If I have open a submenu in the UI, it stays open forever (I’d assume than an app restart will close the submenu). As such, the setting for enabling/disabling the option to keep the screen always on doesn’t seem to work.

Why the app is not restarting? Am I missing something?

Don’t use the launch app command for the HA app, use the WebView command to dictate what dashboard to load.

https://companion.home-assistant.io/docs/notifications/notification-commands#webview

1 Like

Thanks. That’s indeed what I end up doing.

This is the action code, for anyone looking for a similar solution:

- alias: Turn off wallboard
  action:
  - service: notify.mobile_app_wallboard_entrada
    data:
      message: command_screen_on
      data:
        command: keep_screen_off
  - service: notify.mobile_app_wallboard_entrada
    data:
      message: command_webview
      data:
        command: /lovelace-wallboard
    enabled: true
1 Like