Don't limit brightness to 255 to support tablets with finer control
Home Assistant Android app version(s): 2025.8.7-full
Android version(s): 15 (kernel 6.6.57)
Device model(s): Lenovo T311FU Tablet
Home Assistant version: 2025.9.1
Last working Home Assistant release (if known): N/A
Description of problem, include YAML if issue is related to notifications: Notification commands - Screen Brightness Level Valid values are between 0 and 255, but my brand new Lenovo Tablet has a max level of 3556. Should not limit the value to 255 when multiple tablet manufacturers are providing finer control, even if the official spec is only up to 255.
Screenshot or video of problem:
Image showing results of setting screen brightness to 255 from app and setting it to 100% from the tablet. Tablet 100%=3556. App 100%=255, which is very dim.
Additional information: This would mean changing "255" in line 2127 of MessagingManager.kt to allow a max of 4096, for example, and updating the documentation to state that the standard is 0 to 255, but values above 255 are supported for devices that use them.
https://github.com/home-assistant/android/issues/3356 Was closed with "spec only lists up to 255 so we won't do anything." That makes sense if values over 255 would crash regular tablets, but not otherwise. Unfortunately this limitation prevents me from being able to automatically brighten/dim for use as a display at night. :-(
Thank you!
Like @dshokouhi mentioned in his comment before closing we decided to follow the official documentation https://developer.android.com/reference/android/provider/Settings.System#SCREEN_BRIGHTNESS
The screen backlight brightness between 1 (minimum) and 255 (maximum)
We cannot ignore this documentation, since we cannot assume it is going to go "well" (on all the devices) if a user set a value outside of these bounds.
But the second part of the documentation is
Use WindowManager.LayoutParams.screenBrightness to set the screen brightness instead.
Which is a value from 0 to 1. Unfortunately I'm not sure this can be use outside of the app, and it might only set the brightness when the app is open a bit like when an app shows a QR code it turns the screen brightness to the maximum.
@dshokouhi might know more about this API.
Admittedly I havent done anything with the second API listed, seems like that one will need a separate notification command as it adjusts something else 🙃
@TimoPtr Could one provide an explicit "unsafe" command that doesn't have the limitation? I understand both the overhead of having more API entry points and testing, and the desire to protect the user, but this is an advanced enough command (and hard to use from the UI) so I feel erroring on the side of more usability might be appropriate.
@TimoPtr Could one provide an explicit "unsafe" command that doesn't have the limitation? I understand both the overhead of having more API entry points and testing, and the desire to protect the user, but this is an advanced enough command (and hard to use from the UI) so I feel erroring on the side of more usability might be appropriate.
It needs to be investigated first if it does really work with your device. Then I would rather go with the other sensor that is normalized. Someone needs to look at it. At the moment I can't unfortunately.
Thanks @TimoPtr It looks like WindowManager.LayoutParams.screenBrightness is actually a better way in general since it doesn't require system privileges as it just temporarily sets the brightness for the window.
WindowManager.LayoutParams requires there to be a view from the app to set it on though - think: an actual window with content for the app, either full screen (which is what almost everyone uses on phones/tablets) or like an app window on your computer. Notification commands are received and executed in the background where there is no window. I don't see that as something that could work, I've tried.