Turn off screen of Android device

the settings will apply when the screen turns off, or the next time you send command_webview which forces the activity to restart. Its by design since the setting can only be read when the webview activity loads or is resumed.

2 Likes

Understood. The current workaround is functioning perfectly for now.

After looking through the Android API doc, I now understand.

It looks like by design the Android system manages the screen based on activity. At first I thought since the phone app can turn off the screen when proximity is detected, surely home assistants app could do the same. But nope, apparently the proximity screen off is a function of the system.

Thanks for the hint! I think this is exactly what I was looking for. Too bad that MQTT is not supported as a trigger.

I just want to keep the screen on from 8 to 23.

Turn on works, after the timeout the screen turns off.
Turn on + keep on works, after turning on remains on no matter what.
Turn off didn’t work for me.
As far as I can understand you can force to keep the screen on but, once forced, you cannot disable it unless you first disable to keep it on and then restart the app?

This is the code, any ideas?

  id: '1690028390586'
  alias: Cuina
  description: ''
  trigger:
  - platform: time
    at: '23:00:00'
  condition: []
  action:
  - service: notify.mobile_app_lenovo_tb125fu
    data:
      message: command_screen_off_timeout
      data:
        command: 1
  - service: notify.mobile_app_lenovo_tb125fu
    data:
      message: command_screen_on
      data:
        command: keep_screen_off
  - service: notify.mobile_app_lenovo_tb125fu
    data:
      message: command_webview
      data: {}