Command line switch not working (SSH)

Hello,

I try to switch on and off a screen connected to a Raspberry Pi.

when y send by the terminal: (with OpenSSH module)

sshpass -p <pswd> ssh [email protected] 'export DISPLAY=:0 && xset dpms force on'

it works like expected. but when y try to command it with HA it doesn’t work.
(“create folder” works but not the two others)

command_line:
  - switch:
        name: create folder
        command_on: mkdir ha_tmp
        command_off: mkdir ha_tmp_off
  - switch:
        name: test cmd
        command_on: 'sshpass -p <pswd> ssh [email protected] "export DISPLAY=:0 && xset dpms force on"'
        command_off: 'sshpass -p <pswd> ssh [email protected] "export DISPLAY=:0 && xset dpms force off"'
  - switch:
        name: RPi Screen
        command_on:  sshpass -p <pswd> ssh [email protected] 'export DISPLAY=:0 && xset dpms force on'
        command_off:  sshpass -p <pswd> ssh [email protected] 'export DISPLAY=:0 && xset dpms force off'
        command_state:  sshpass -p <pswd> ssh [email protected] 'export DISPLAY=:0 && xset -q | grep "Monitor is" | cut -c14-17' | grep "On" > /dev/null

the error I get back :

Logger: homeassistant.components.command_line
Source: components/command_line/switch.py:252
Integration: Command Line (documentation, issues)
First occurred: 12:43:00 (1 occurrences)
Last logged: 12:43:00

Command failed: sshpass -p <pswd> ssh [email protected] 'export DISPLAY=:0 && xset dpms force on'

and

Logger: homeassistant.components.command_line.utils
Source: components/command_line/utils.py:29
Integration: Command Line (documentation, issues)
First occurred: 12:43:00 (1 occurrences)
Last logged: 12:43:00

Command failed (with return code 127): <pswd> -p qwe11122 ssh [email protected] 'export DISPLAY=:0 && xset dpms force on'

my config:
Home Assistant 2023.8.4
Supervisor 2023.08.3
Operating System 10.5
Interface utilisateur : 20230802.1 - latest
installed on a PC inside Proxmox

Thanks in advance for your help.

I think you are going to have to setup ssh keys rather than use a password, unless the pi is running HA.

Maybe bc

Thanks for your answers.
I don’t want to waist more time with that and have found a better solution to solve the problem.
I installed Node-Red on the Raspberry. So I can use the GPIO with a presence detector and drive leds.

Best regards