Auto start HA Companion app on boot

How can I auto start the HA Companion app on boot and bypass the lock screen?
Can this be done with the app alone or do I need something like Fully Single App Kiosk or WallPanel?

I tried Fully Single App Kiosk but I’ll occasionally find it at the lock-screen and I need to swipe the unlock to start the Kiosk. I’ve set the companion app to “Keep Screen On” so I’m guessing it’s going to the lock screen due to something causing my tablet to reboot.

The android lock screen is 1 thing, has nothing to do with the companion app.
Can’t you disable the lock screen?

For automatically starting an app, this? https://play.google.com/store/apps/details?id=com.autostart&gl=US

yes you can disable the lock screen

no need for additional app, one can use the existing Last reboot sensor to detect when the device reboot and then issue a command_webview notification command to start the app.

https://companion.home-assistant.io/docs/core/sensors#last-reboot-sensor

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

2 Likes

I’ve disabled the lock screen and I am able to issue a command_webview notification from Developer Tools / Services

how do you have your Automation set to use the “Last Reboot Sensor” value?

the value will change only when the device reboots so any state change should be fine. You can probably add a condition to make sure the trigger from state and to state do not match.

as a brief example:

trigger:
  platform: state
  entity_id: sensor.last_reboot
condition:
  condition: template
  value_template: '{{ trigger.to_state.state != trigger.from_state.state}}'
1 Like

Here are some notes from my setup which may help the next person.

Enable the reboot sensor in the companion app

  • App Configuration / Manage Sensors / Last Reboot Sensor / Enable Sensor

Set the sensor update frequency from Normal (15 minute interval) to 1 minute

  • App Configuration / Sensor Update Frequency / Fast Always

Disable the Android lock screen

  • Settings / Security / Screen lock - None

Ensure display timeout isn’t too short

  • Settings / Display / Screen Timeout - I set mine to 5 minutes

I had it initially set to 15 seconds so the screen was blanking before the automation would kick in.
The screen needs to be on for the automation to make the call to start the companion app. (at least for my setup)

Here’s my full automation in YAML

alias: Start Kitchen Tablet on reboot
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.nexus_7_last_reboot
condition:
  - condition: template
    value_template: "{{ trigger.to_state.state != trigger.from_state.state}}"
action:
  - service: notify.mobile_app_kitchen_tablet
    data:
      message: command_webview
mode: single
2 Likes

Hi Surge, I came across this thread in the hopes it would solve my issue, however I have done something very similar. The usue I am having is that the automation is not being triggered on the state - sensor reboot? I have disabled the sleep mode, so once rebooted it just sits there on the main screen. The automation has not been triggered even though the time on the sensor has been reset? - stuck :slight_smile:

Update: I found that the reason that HA is not starting automatically is due to the battery notification coming up letting me know that the tablet has “Battery Protection Mode” enabled.
Is there any way of a work around to this?

The correct approach is to disable such features. Or whitelist the app.

Actually after more investigation, it’s due to the screen being locked and displaying the notification. I turned off the battery protection and HA still did not start automatically. I have to swipe up to unlock the screen then HA starts automatically. The tablet is on Android 10 - Is there a way to unlock the screen? I know Fully Kiosk does it however want to stick to the companion app.

Can’t you disable every kind of screen locking/security settings/power savings to see if that makes a difference?

Yep disabled everything, Do you know if there is a way to unlock the tablet through a command? I tried Fully Kiosk and that works, so there must be a way?
At the moment I have fully Kiosk on one tablet and HA on another, Fully Kiosk seems to lag quit a bit so I would prefer HA if I could get around the auto start issue.

the android app is not going to be a device administrator taht can potentially leave a device unlocked if the app crashes. its just not safe.

Oh okay - is that how Fully Kiosk does it? Surely the user should have the option after a warning explaining the risk.
I mean - nearly all devices are open until they are locked with an option to either lock them or not (except these Lenovo Tablets).
I just checked my Samsung phone, even the most current ver has the option to leave it unlocked giving the user a choice, isn’t that the essence of HA which is embedded into the DNA “giving the user a choice” rather than dictating what we should or shouldn’t have?
I really like the app by the way don’t get me wrong :slight_smile: I may have to through out the Lenovo tablets and replace them with Samsung :frowning:

Gary

I use tablets with the app, and all of them has the option to just leave the device unlocked at all time…

Obviously, those are used only for HA