Balena-dash remotely turn display on/off?

I have successfully set up Balena-dash on my official Raspberry Pi 7" display and have been able to give it a custom URL pointing to my Home Assistant interface.

Is it possible to turn the display on and off via a command from my local network (via ssh) for a quick response please? I have a motion sensor linked into Home Assistant and would like to use this to send a command that turns the display on when I walk into the room, and then another off command when no motion is detected.

I currently do this using a HyperPixel 4.0 display which works really well, but I’d like to upgrade to the larger 7" display using Balena-dash instead. Being able to turn the display on and off is key for use with this project.

I have found the following commands that may work but I’m not sure how to check if this path exists within the custom build?

sudo sh -c 'echo "1" > /sys/class/backlight/rpi_backlight/bl_power'
sudo sh -c 'echo "0" > /sys/class/backlight/rpi_backlight/bl_power'

Many thanks!

Hey @jarrah! Welcome to the forums :slight_smile:

You can definitely do this, if you take a look at the scheduler part of balenaDash where we allow you to switch the backlight on and off via a timed schedule, you’ll see that the commands used are very similar:

Here is the on script:

echo -n 0 > /sys/class/backlight/rpi_backlight/bl_power

Here is the off script:

echo -n 1 > /sys/class/backlight/rpi_backlight/bl_power

I hope this helps. It sounds like a cool project and we’d love to see more once you get it up and running!

Great to hear that we can use the same method to switch the backlight on/off.

In my case though I can’t use the scheduler though as it needs to be on-demand. Looking through the guides it looks like I need to set up a local ssh server on the docker client to receive commands? Would I still be able to issue those commands above from within the container - would it have access?


Yes, the scheduler runs the commands from within a container too, so there’s no reason why you wouldn’t be able to use the same technique. You could setup an SSH server within a container, yep, or you could create a basic web interface that runs the same commands triggered from an HTTP request.

Thanks, I’ll give that a go!

Hi chrisys,

i would like to switch the backlight via http command. Unfortunately i don’t how to setup a “basic webinterface” that can be triggered from an http get request.
i would appreciate some help.

Hi, you could add another service in docker-compose.yml which will accept http request and switch backlight. For example You could modify server.js to add a route which will do exec of bash script