Turn off laptop screen running Hassio

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.

6 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.

1 Like

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

This works great. However would be great if this setting would stay after HA OS updates.

Has anyone found a way to automatically force this after each OS update?

Have to keep doing this too often now :grinning:

Any luck on this? I also want to do it from the webui instead of the laptop itself.

THIS for a 2012 Macbook Air running HA directly installed. I was pulling my hair out trying to do this via the SSH add-on, since I saw the /sys/class/backlight directory. However, when I tried to execute via SSH, the console threw an ownership error. Tried to CHOWN - no luck even though I’m root (whut!) - further research indicated that it might be that the SSH add-on is locked to it’s own container environment (more here) -

After reading about this, I simply went over to my Air and typed in the command

echo 0 | tee /sys/class/backlight/*/brightness

WIN. Thanks Dan for your concise but accurate post. There was no grub.cfg file on my system that I could find - this did the trick for me. Screen off, happy guy here. Thanks @dglwilkins

@bl4ck1c3pt, you legend! Thank you, all other methods I found were over my head, this is working perfectly on my Latitude 7490 running HAOS.

hi, i have the same problem, how did you solve it?

Hi, this takes the writing off my screen but the backlight stays on