android icon indicating copy to clipboard operation
android copied to clipboard

Implement autostart on system startup

Open voed opened this issue 2 years ago • 7 comments

I am using my old tablet as a control panel for Home Assistant and it scheduled to reboot every night for proper work. It would be great to have autostart feature out of the box, without installing 3rd party apps. Maybe even start as a launcher to reduce RAM usage?

voed avatar Nov 26 '23 22:11 voed

please do not combine multiple requests into one, one should be created for each request.

dshokouhi avatar Nov 26 '23 22:11 dshokouhi

Sorry. Fixed.

voed avatar Nov 26 '23 22:11 voed

For this we should make it an option in settings, we also need to do a permission check on certain android versions to autostart.

In the meantime you are more than welcome to use existing app features to automate this already.

  • Use either the last reboot sensor to detect when the device booted or last update sensor when the state contains BOOT_COMPLETED
  • send command_webview notification command to open the app, make sure to test the command first so you can give the app proper permission

Maybe even start as a launcher to reduce RAM usage?

I think making the app into a launcher is a bit out scope for the project and this request :)

dshokouhi avatar Nov 26 '23 23:11 dshokouhi

Interesting solution. Had no idea we can do this:) But for me BOOT_COMPLETED sometimes triggered before WIFI being connected, so i just used "from ACTION_SHUTDOWN" trigger:

alias: Tablet HA start
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.lenovo_yt3_x50fn_last_update_trigger
    from: android.intent.action.ACTION_SHUTDOWN
condition: []
action:
  - delay:
      hours: 0
      minutes: 1
      seconds: 0
      milliseconds: 0
  - service: notify.mobile_app_lenovo_yt3_x50fn
    data:
      message: command_webview
mode: single

Thanks.

voed avatar Nov 27 '23 18:11 voed

Hello, I'm not sure to understand how these sensors can work if the Companion not launched on the Android phone ? Should be great to have an option in the Companion settings.

Regards

sebastienserre avatar Feb 16 '24 08:02 sebastienserre

Hello, I'm not sure to understand how these sensors can work if the Companion not launched on the Android phone ? Should be great to have an option in the Companion settings.

Sensors are scheduled to update periodically if you started the app once. The system will take care of restarting these updates when the device is rebooted / updated, so this already works. The feature request is for opening the app (showing a dashboard) immediately after starting the device.

jpelgrom avatar Feb 16 '24 08:02 jpelgrom