How to turn off/on hdmi.
Moderator: leecollings
- capman
- Posts: 157
- Joined: Friday 12 July 2013 20:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Belgium
- Contact:
How to turn off/on hdmi.
What I want is to turn off my kitchen screen when nobody is home or when we go to sleep.
I have found the command to do this. On putty a login to my raspberry pi 3 for my kitchenscreen (not domoticz) and
type 'vcgencmd display_power 0' to power the screen down and 'vcgencmd display_power 1' to get it back on. This is working.
Installed is latest raspbian jessie with pixel.When raspberry start up , automatic start chrome full screen with some frontpage for domoticz.(dashticz)
So in the script I want something like , if nobody is home OR if sleep = ON then 'vcgencmd display_power 0'.
I know how to ecexute a script with a dummy script in the command line from domoticz. But what kind of scripting should working best ?
LUA, Perl ,Python ? Domoticz running on my nas server so I must give the right adress from my kitchen screen to in the script.
Is there somebody who can help me to put me in the right direction ? Hope you understand my question.
Thanks.
I have found the command to do this. On putty a login to my raspberry pi 3 for my kitchenscreen (not domoticz) and
type 'vcgencmd display_power 0' to power the screen down and 'vcgencmd display_power 1' to get it back on. This is working.
Installed is latest raspbian jessie with pixel.When raspberry start up , automatic start chrome full screen with some frontpage for domoticz.(dashticz)
So in the script I want something like , if nobody is home OR if sleep = ON then 'vcgencmd display_power 0'.
I know how to ecexute a script with a dummy script in the command line from domoticz. But what kind of scripting should working best ?
LUA, Perl ,Python ? Domoticz running on my nas server so I must give the right adress from my kitchen screen to in the script.
Is there somebody who can help me to put me in the right direction ? Hope you understand my question.
Thanks.
-
mivo
- Posts: 80
- Joined: Friday 21 April 2017 8:58
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Czechia
- Contact:
Re: How to turn off/on hdmi.
Hi,
you need to execute some command or script remotely on RPi3 (Domoticz not running there, but on NAS), if I understand correctly.
Are you able to start SSH connection from NAS to RPi ? You can then start ssh connection with command as SSH argument. For example:
On RPi, in /scripts/hdmi-off.sh you can then start vcgencmd display_power 0 command or something. For unattended run, you should also create user, generate SSH keys and configure authentication. Not so difficult, but not easy 
Another option is to check status of Virtual (Dummy) Domoticz switch on RPi side by some scripting. Shell script called from Cron for example, with some curl ... and parsing should do it. You can do same for sure with another advanced scripting language (Python, LUA...)
Your choice ?
you need to execute some command or script remotely on RPi3 (Domoticz not running there, but on NAS), if I understand correctly.
Are you able to start SSH connection from NAS to RPi ? You can then start ssh connection with command as SSH argument. For example:
Code: Select all
$ ssh user@rpi-address /scripts/hdmi-off.shAnother option is to check status of Virtual (Dummy) Domoticz switch on RPi side by some scripting. Shell script called from Cron for example, with some curl ... and parsing should do it. You can do same for sure with another advanced scripting language (Python, LUA...)
Your choice ?
My toys:
Raspberry Pi 3 + UPS PIco HV3.0 A Stack
Minibian (Raspbian Jessie) + Domoticz beta
RFLink 433 Gateway, 1wire DS18B20 temp sensors (GPIO)
RaZberry module + 2x Comet Z-Wave + Z-wave socket
---
Plugins: WeMo Switch, UPS PIco HV3.0A on GitHub
Raspberry Pi 3 + UPS PIco HV3.0 A Stack
Minibian (Raspbian Jessie) + Domoticz beta
RFLink 433 Gateway, 1wire DS18B20 temp sensors (GPIO)
RaZberry module + 2x Comet Z-Wave + Z-wave socket
---
Plugins: WeMo Switch, UPS PIco HV3.0A on GitHub
Re: How to turn off/on hdmi.
Put a script in /etc/profile.d called savepower.sh an see to it that it is executable.
Take away the 2 '#' to turn off the leds too, if you want.
Or put "vcgencmd display_power 0" instead of the '/opt/vc/bin/tvservice -o'
Take away the 2 '#' to turn off the leds too, if you want.
Or put "vcgencmd display_power 0" instead of the '/opt/vc/bin/tvservice -o'
Code: Select all
#!/bin/sh
# Turn OFF the LED's led0 = green and led1 = red
#sudo echo 0 | sudo tee /sys/class/leds/led0/brightness
#sudo echo 0 | sudo tee /sys/class/leds/led1/brightness
# Turn OFF HDMI
/opt/vc/bin/tvservice -o
- capman
- Posts: 157
- Joined: Friday 12 July 2013 20:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Belgium
- Contact:
Re: How to turn off/on hdmi.
@mivo and @EddyG , first of all thanks 4 thinking about my 'problem'.
I have try the solution from EddyG and make a file called kitchscreen_off.sh and kitchenscreen_on.sh.
In both scripts I have this code:
Exept for 'hdmi ON' I use '1' 
So far so good this script is on the RPi of my kitchenscreen and it's executable 'sudo chmod -x filename.sh'.
But now, how can I execute this script when a switch is turning on or off , because my domoticz server is on my nas.
I can make a lua script in the script map from domoticz with device:
So what code can I use to execute.
Or maybe also a bash script with curl ? But I don't know how this works.
Pfff....
It's proberly simple but I have not enough coding skills.
I have try the solution from EddyG and make a file called kitchscreen_off.sh and kitchenscreen_on.sh.
In both scripts I have this code:
Code: Select all
#!/bin/sh
# Turn OFF the LED's led0 = green and led1 = red
#sudo echo 0 | sudo tee /sys/class/leds/led0/brightness
#sudo echo 0 | sudo tee /sys/class/leds/led1/brightness
# Turn OFF HDMI
vcgencmd display_power 0So far so good this script is on the RPi of my kitchenscreen and it's executable 'sudo chmod -x filename.sh'.
But now, how can I execute this script when a switch is turning on or off , because my domoticz server is on my nas.
I can make a lua script in the script map from domoticz with device:
Code: Select all
commandArray = {}
if (devicechanged['MyDeviceName'] == 'On' then
'execute script on my kitchenscreen named 'kitchenscreen_on'
end
return commandArrayOr maybe also a bash script with curl ? But I don't know how this works.
Pfff....
- capman
- Posts: 157
- Joined: Friday 12 July 2013 20:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Belgium
- Contact:
Re: How to turn off/on hdmi.
@mivo
I can start the ssh command in putty login from my nas server with command ssh [email protected] /etc/profile.d/keukenscherm_off.sh
Then my screen goes off. How to use this command in a script ?
I can start the ssh command in putty login from my nas server with command ssh [email protected] /etc/profile.d/keukenscherm_off.sh
Then my screen goes off. How to use this command in a script ?
- capman
- Posts: 157
- Joined: Friday 12 July 2013 20:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Belgium
- Contact:
Re: How to turn off/on hdmi.
OK, a little bit further now
I have found the execute command in lua , so it this now.
This command is working terminal window from my nas , but after giving the password from my raspberry pi kitchen screen. It must be possible to give the password in the command itself. Something like this?
Or maybe with a ssh key ?
Give it up 4 this evening
O yes, this is my setup
, so 2 understand what I want 2 accomplish.
https://www.domoticz.com/forum/viewtopi ... 00#p134385
I have found the execute command in lua , so it this now.
Code: Select all
commandArray = {}
if (devicechanged['test'] == 'On') then
os.execute ('ssh pi:@192.168.178.42 vcgencmd display_power 0')
end
return commandArrayCode: Select all
ssh pi:[email protected] vcgencmd display_power 0Give it up 4 this evening
O yes, this is my setup
https://www.domoticz.com/forum/viewtopi ... 00#p134385
-
mivo
- Posts: 80
- Joined: Friday 21 April 2017 8:58
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Czechia
- Contact:
Re: How to turn off/on hdmi.
Hi,
great
scripts on RPi side works, LUA on Domoticz side will work probably after SSH keys config. Try these steps to setup SSH key auth:
http://www.linuxproblem.org/art_9.html
great
http://www.linuxproblem.org/art_9.html
My toys:
Raspberry Pi 3 + UPS PIco HV3.0 A Stack
Minibian (Raspbian Jessie) + Domoticz beta
RFLink 433 Gateway, 1wire DS18B20 temp sensors (GPIO)
RaZberry module + 2x Comet Z-Wave + Z-wave socket
---
Plugins: WeMo Switch, UPS PIco HV3.0A on GitHub
Raspberry Pi 3 + UPS PIco HV3.0 A Stack
Minibian (Raspbian Jessie) + Domoticz beta
RFLink 433 Gateway, 1wire DS18B20 temp sensors (GPIO)
RaZberry module + 2x Comet Z-Wave + Z-wave socket
---
Plugins: WeMo Switch, UPS PIco HV3.0A on GitHub
- capman
- Posts: 157
- Joined: Friday 12 July 2013 20:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Belgium
- Contact:
Re: How to turn off/on hdmi.
This is workingmivo wrote:Hi,
greatscripts on RPi side works, LUA on Domoticz side will work probably after SSH keys config. Try these steps to setup SSH key auth:
http://www.linuxproblem.org/art_9.html
I have deleted the .ssh map on my nas , and give this command on my pi.
Code: Select all
sudo rm /etc/ssh/ssh_host_*
sudo dpkg-reconfigure openssh-server- capman
- Posts: 157
- Joined: Friday 12 July 2013 20:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Belgium
- Contact:
Re: How to turn off/on hdmi.
Working again from cli on my nas. Having delete the .ssh map on my pi also and start all over again.
Given from my terminal window on my nas set the screen off from my pi on the given ip adress.
Now 2 figure it out with the code on lua
That's still not working 
Code: Select all
ssh [email protected] vcgencmd display_power 0Now 2 figure it out with the code on lua
Code: Select all
commandArray = {}
if (devicechanged['testje'] == 'On') then
os.execute ('ssh pi:@192.168.178.42 vcgencmd display_power 0')
end
return commandArray- cyberclwn
- Posts: 105
- Joined: Thursday 20 August 2015 22:53
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: The Netherlands
- Contact:
Re: How to turn off/on hdmi.
Hi,
try if this works for you:
or try:
Maybe your line works also, but without the ":" after pi in
Good luck.
try if this works for you:
Code: Select all
os.execute ('runuser -l pi -c "ssh -n -f [email protected] 'vcgencmd display_power 0'"')
Code: Select all
os.execute ('ssh -n -f [email protected] "vcgencmd display_power 0"')Code: Select all
pi:@192.168.178.423xPi 2B (Domoticz "live", Domoticz "sandbox", PhotoFrame)
RFXCom433(E), KaKu, Oregon Scientific, Keyes 2-relay, Logitech Media Server, MiLight, Smartwares heating controller(2x), IR Send/Receive, Keyes PIR, XH-M131 DuskSensor, DHT22/11
RFXCom433(E), KaKu, Oregon Scientific, Keyes 2-relay, Logitech Media Server, MiLight, Smartwares heating controller(2x), IR Send/Receive, Keyes PIR, XH-M131 DuskSensor, DHT22/11
- capman
- Posts: 157
- Joined: Friday 12 July 2013 20:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Belgium
- Contact:
Re: How to turn off/on hdmi.
Still no luck. Must try it with another scripting like bash or pyhton I think. Because lua can't handle os.execute with ssh so far.
-
mivo
- Posts: 80
- Joined: Friday 21 April 2017 8:58
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Czechia
- Contact:
Re: How to turn off/on hdmi.
Hi,capman wrote: Saturday 12 August 2017 0:00 Still no luck. Must try it with another scripting like bash or pyhton I think. Because lua can't handle os.execute with ssh so far.
try to catch command output and exit codes in LUA - try first with LS command. Anyway user@host in ssh command should be without colon:
Code: Select all
local cmd = 'ssh [email protected] ls -al'
local f = assert(io.popen(cmd, 'r'))
local s = assert(f:read('*a'))
local ex1, ex2, ex3 = f:close()
print('s: ' ..tostring(s))
print('ex1: ' ..tostring(ex1))
print('ex2: ' ..tostring(ex2))
print('ex3: ' ..tostring(ex3))My toys:
Raspberry Pi 3 + UPS PIco HV3.0 A Stack
Minibian (Raspbian Jessie) + Domoticz beta
RFLink 433 Gateway, 1wire DS18B20 temp sensors (GPIO)
RaZberry module + 2x Comet Z-Wave + Z-wave socket
---
Plugins: WeMo Switch, UPS PIco HV3.0A on GitHub
Raspberry Pi 3 + UPS PIco HV3.0 A Stack
Minibian (Raspbian Jessie) + Domoticz beta
RFLink 433 Gateway, 1wire DS18B20 temp sensors (GPIO)
RaZberry module + 2x Comet Z-Wave + Z-wave socket
---
Plugins: WeMo Switch, UPS PIco HV3.0A on GitHub
-
SweetPants
Re: How to turn off/on hdmi.
Why not create a dummy switch and use "On/Off Action" bash script? You can control the switch from LUA
- capman
- Posts: 157
- Joined: Friday 12 July 2013 20:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Belgium
- Contact:
Re: How to turn off/on hdmi.
Yes I thought something 2 do like this , but what are the commands in the bash script ?SweetPants wrote: Saturday 12 August 2017 14:19 Why not create a dummy switch and use "On/Off Action" bash script? You can control the switch from LUA
Who is online
Users browsing this forum: No registered users and 1 guest