Turn off laptop screen running Hassio

@mateine, thanks for this clean solution. While I managed to properly implement it (no errors when running automation), it fails to dim the screen on a Apple MacBook Retina (2011?). Is this solution Dell-specific? I’m totally new to hassio. Would you have any ideas to port your solution to MacBook?

I don’t think it is dell specific, are you running Home Assistant OS?
to debug this you could:

  1. ssh your_username@homeassistant # access the server via ssh
  2. docker exec -it homeassistant bash # get into the core container
  3. ls /sys/class/backlight/ # check if the display is there
  4. cat /sys/class/backlight/*/max_brightness # see if you can grab the max_brightness
  5. echo 0 | tee /sys/class/backlight/*/brightness # see if you can turn off the backlight anyway
  6. change 0 to something else to turn it on again

If the server is not running HA OS, I suggest you google “how to change display brightness in xxx from the terminal”. Then test your finding like in the bullets above

1 Like

Thanks @mateine for your swift response.

  • I am running HA OS 10.1
  • folder /sys/class/backlight exists, but has no contents.
  • so when trying to grab max_brightness (or trying to set it), I’m getting No such file or Directory.

So I guess HA OS setup requires some tuning, but I wouldn’t have a clue where to start…

Then some drivers may not have been installed.
Maybe you can try doing this instead, I doubt it would work tho:
xrandr --output LVDS-1 --brightness 0.8

Thankyou for this clear walk-through. Works on my old ASUS.

Thank you for this, exactly what I needed and enough detail for a noob to figure out.

This worked on my Dell latitude 5480.

For some reason my Dell Latitude 5590 doesn’t like consoleblank.
Around 10-20 seconds after the screen shuts down the computer freezes and gets unresponsive and needs a hard reboot. If I press any key before that time it comes back as it should.

Anyway I found another solution in the BIOS, you can activate FN+F7 button to kill all sound and light emitting from the laptop. Pressing it again reactivates lights and sounds. So I can just hit FN+F7 and put laptop away, and if I need to acess it again for some reason I can just hit FN+F7 again.

This took me a while to get there… {NOOB here} SO I felt like sharing my process step by step to see if I can help at least one poor soul…

So boot up your laptop an wait until it is ready to accept commands

ha >

1º Step (I remember it didn’t worked on the first try, but don’t know what a did next

ha > login

2º Step (this is where I found my grub.cfg)

# vi /mnt/boot/EFI/boot/grub.cfg

3º go to line where it starts with default_cmdline and go to the end of the line and add, just before the " this argument: ’consoleblank=60’.
Remember to leave space from the previous argument, so the line should look something like this:

default_cmdline="rootwait [bla bla bla bla] $bot_condition consoleblank=60"

To edit the file press the key i to enable text edit. After you add the " consoleblank=60", press ESC once, then just press shift+z+z (two uppercase ZZ) to exit and save.

Next type # reboot, and its done… at least for me.

4 Likes

There is logic in grub.cfg to read a text file /mnt/boot/cmdline.txt that will issue any additional options listed in it along with the default_cmdline string.

Not that it makes any functional difference, but it is a bit cleaner and safer to edit this cmdline.txt file instead of grub.cfg. I’ve tested this and it works as expected (on a Dell Latitude E6500).

New contents of /mnt/boot/cmdline.txt:
console=tty1 consoleblank=60

1 Like

Thanks! For those of you who, like me, read this and have no idea how to get there: You can type “login” on the HA CLI and you get a # prompt. There, you can do “vi /mnt/boot/EFI/boot/grub.cfg” to edit the grub.cfg and find the line that starts with “default_cmdline” and add the “consoleblank=60” there. If you do not know how to use vi, please google.

Will that stick through OS updates? :slight_smile:

Because it would be nice to skip editing in consoleblank in grub.cfg for every OS update…

Maybe some way to automate making of that cmdline.txt in a service call kind of way, like we can automate backlight 0 :thinking::nerd_face:

Thanks.

The edit will need to be redone after an os update. I don’t know if it can be automated, but I doubt it. I’ve since replaced the laptop with a Beelink mini PC running headless, so no longer an issue for me.

Awesome, works like a charm. Thanks! Is it possible to turn on the screen when a key press is detected?

YES! This finally worked on my older HP laptop!

I have the HASS OS installed on it. The key for me was to enter these commands AT the laptop! I was following other instructions similar to this but trying it from the HA terminal and it’s not same thing as the file structure is not the same.

I’m also able to shut the lid of my laptop and it stays on. That must be a HASS OS function by default, I’m not sure.

Anyways, thanks!!!

1 Like

Finally after so many attempts, you sir are a LEGEND bl4ck1c3pt, hats off to you sleep well knowing you saved peoples day

Hello, I know this is an old post. But i have an issue with my laptop running HAS OS.
It is running fine for about 1 or 2 hours, then shut down completely. Is there anywhere i can change that or do you have any ideas of what can be done?
Best regards
Henrik