SSH'ing from a command line sensor or shell command

Hi @all, I could use some help with this.

I’m running HA core on Proxmox (LXC) and also have a RPi with 7" touchscreen that I use as a dashboard (running Raspbian desktop).
I would like to be able to switch the touchscreen on/off from HA when nobody is home & overnight.

From the HA shell I can achieve this with:

 ssh rpi 'echo 1 | tee /sys/class/backlight/rpi_backlight/bl_power'

and

 ssh rpi 'echo 0 | tee /sys/class/backlight/rpi_backlight/bl_power'

I have created this switch:

- platform: command_line
  switches:
    rpi_screen:
      command_off: "ssh rpi echo 1 | tee /sys/class/backlight/rpi_backlight/bl_power"
      command_on: "ssh rpi echo 0 | tee /sys/class/backlight/rpi_backlight/bl_power"

But this doesn’t work.
Don’t know if this is of any importance: in HA I’m logged with my own name, the command on the shell is as root.

Any idea what might be wrong?
Thanks for looking at this.