JosefJantzen / MMM-AlexaControl

Control your MagicMirror with Alexa
MIT License
45 stars 10 forks source link

Monitortoogle comand xrandr works only. #66

Closed Chazsec closed 10 months ago

Chazsec commented 1 year ago

Hello everyone, and a big thank you to the developer of Alexa Control. I’ve successfully installed it, and the Alexa commands are being recognized.

Is it possible to ask Alexa to refresh or initialize the commands?

Additionally, I’ve been testing the monitor on/off mode. Here’s what I’ve observed: I need to set the DISPLAY environment variable first using “export DISPLAY=:0,” and then the “xrandr” command works.

The monitor can be turned off via SSH using the command “xrandr --output HDMI-1 --off” successfully. However, it’s not possible to turn it back on with “xrandr --output HDMI-1 --on.” To turn the monitor back on, I need to use “xxx@raspberrypi:~/MagicMirror $ xrandr --output HDMI-1 --auto --rotate right” because the monitor rotates to the left. Can you please assist me in developing a solution to control this via Alexa?

As additional information, I am using a Raspberry Pi 3B with a 32GB SD card, and I have a 17.3-inch LED display with a matte finish that is compatible with the B173RW01 V.4 TOP NHD. To go along with this, I am using the controller: HDMI VGA AV USB LCD Control Panel for 17.3-inch LP173WD1 B173RW01 LTN173KT01-A01 N173FGE-L21 N17306-L02 1600x900 with a 40-pin LCD screen.

JosefJantzen commented 1 year ago

Hi, thank you :) I'm not sure what you mean with refresh or initialize, but if you are looking for a way to use some other commands to control your monitor, the easiest way would be to modify node_helper.js in the MMM-AlexaControl folder. From line 231-290 the monitor device is created. You could take just one e.g. the vcgencmd one l. 236-248. There for action == 1 use your turn on command and for action == 0 use your turn off command. If you are fimiliar with JS you maybe also can create a whole new option and make a pull request and we can add it to the module.

Chazsec commented 1 year ago

Thanks to Sam's assistance, I managed to fix it for myself. I used the following lines of code in the Node_helper.js file: else if (this.config.vcgencmd == 'xrandr') { device.handler = function (action) { if (action === 1) { exec("xrandr --output HDMI-1 --auto --rotate right", opts, (error, stdout, stderr) => { _this.checkForExecError(error, stdout, stderr); }); } if (action === 0) { exec("xrandr --output HDMI-1 --off", opts, (error, stdout, stderr) => { _this.checkForExecError(error, stdout, stderr); }); } } } I'm a complete beginner, so I need clear instructions. I thought I'd let you know in case you ever update the module.