Has anyone gotten this package to work? All I keep getting is blank returns no matter what method I use. It also won't write to the brightness file.
2 things...
-
does the account running node-red have access to the file trying to be modified?
/sys/class/backlight/rpi_backlight/actual_brightness
(code) -
You might need to use async or wait for promise to be resolved (see the function code uses
then()
)
I don't think it does since echoing a number to the brightness file from the shell requires the use of
sudo bash -c "echo ### > /sys/class/backlight/rpi_backlight/actual_brightness"
for getting the brightness I can always use the read file node so not too worried about that, it's mostly setting the brightness that's the bigger issue.
Normally, node-red doesnt run under sudo (or root) so the very fact you have to use sudo
(super user do) at the shell to update the file suggests this is the problem.
Some choices are - relax permissions on the file or Run node-red as sudo (NOT recommended)
Yep, that was it. Thanks @Steve-Mcl
In case anyone else runs into this here's the command I ran in the shell to add the permissions
sudo chmod a+rw /sys/class/backlight/rpi_backlight/brightness
Note this gives every user of the pi permissions to read and write
Does that survive a reboot ?
It sure doesn't. I guess I need to figure out how to make it survive a reboot
I added the command to /etc/rc.local and it's all good now