Turning Smart Display on / off via SSH to Pi

Hi guys,

been struggling with this the last two days so thought I would share my findings!

I have a Pi3 running DakBoard hooked up to a 2" vertical mounted monitor in my living room. Been trying to get it so that its only on when I am home.

I finally got it working just now;

- platform: command_line
  switches:
    dakboard_screen:
      command_on: ssh -F /config/ssh_config -i /config/id_rsa [email protected] 'vcgencmd display_power 1' 2> /config/command.log
      command_off: ssh -F /config/ssh_config -i /config/id_rsa [email protected] 'vcgencmd display_power 0' 2> /config/command.log
      friendly_name: Dakboard Screen

Its ALMOST working perfectly, its not correctly displaying if the screen is on or off yet…

using the line:

command_state: ssh -F /config/ssh_config -i /config/id_rsa [email protected] './chkdspl.sh' 2> /config/command.log

it should run the script and tell me if it is on or off;

the script contains:

#!/bin/bash
status="$(vcgencmd display_power)"
if [ "$status" != "display_power=0" ]
then
    echo "0"
else
    echo "1"
fi

and works correctly as expected when I execute directly from SSH in hass.io
but the status is always showing as on in the web UI…

otherwise works a charm.

Just ensure that you have permissions set to 400 on the /config/ssh_config and /config/id_rsa files and that the public key is copied to the pi.

the ssh_config file contains:

Host *
    StrictHostKeyChecking no

before disabling a core security feature of ssh I’d rather add -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no to the ssh command

you could add a command line sensor/shell_command for the display state and add that in the UI

Might be late, but I ran into this same issue - I ended up creating a small REST server to handle the status returns - SSH is horrible at returning values.

Created a REST Switch to control a Pi zero W running a calendar display.

I just found this post as I was searching for something else related to Dakboard (they support pulling from a REST API now, so I can display status information!)