Command line on Ubuntu with Hass

I have a touch screen that needs to be calibrated each time Hass is restarted or when the screen goes black(Im turning of the screen at night).
The line of code that I need to send to the terminal on Ubuntu:

/usr/bin/xinput set-prop 13 307 0.000000, -1.000000, 1.000000, 1.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000 

The pc I have running the touch screen on is the same as the one running Hass, also the same user(with root) but im still struggling to get this thing to work.

This is what I have now:

  -platform: command_line
   switches:
       home_assistant_system_shutdown:
         friendly_name: Sett touch skjerm 
         command_on: '/usr/bin/xinput set-prop 13 307 0.000000, -1.000000, 1.000000, 1.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000'

How did you install?

If you used hass.io I think you would need to SSH into your ubuntu host to make this work.

If you are running from the virtual environment install instructions I would enter that environment and switch to your home assistant user and try running the command and see what the result is.

I think HA has no access to the X-Server to run xinput.
Example:
If i ssh to a remote ubuntu and run xinput:

rk@TPAD:~$ xinput 
Unable to connect to X server

If i set the DISPLAY variable in the ssh session it works

rk@TPAD:~$ export DISPLAY=":0.0"
rk@TPAD:~$ xinput 
⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer              	id=4	[slave  pointer  (2)]
⎜   ↳ Atmel Atmel maXTouch Digitizer          	id=13	[slave  pointer  (2)]
⎣ Virtual core keyboard                   	id=3	[master keyboard (2)]
    ↳ Virtual core XTEST keyboard             	id=5	[slave  keyboard (3)]
    ↳ Power Button                            	id=6	[slave  keyboard (3)]
    ↳ Video Bus                               	id=7	[slave  keyboard (3)]
    ↳ Power Button                            	id=8	[slave  keyboard (3)]
    ↳ Sleep Button                            	id=9	[slave  keyboard (3)]
    ↳ TGT TGT DIGITIZER                       	id=10	[slave  keyboard (3)]
    ↳ USB 2.0 Camera : USB 2.0 Camera         	id=11	[slave  keyboard (3)]
    ↳ USB 2.0 Camera : USB 2.0 Camera         	id=12	[slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard            	id=14	[slave  keyboard (3)]

Thanks for replaying.

So I can’t do this from command line in hass? But is there another way, maybe make a .sh file and have hass triggering this?

This is how I manage it from standard HA docker (not Hass.io). I ssh from the container into the host and send the command.
There’s a way to do it in Hass.io. have a look at this post
SSH keys - Permission denied (publickey,keyboard-interactive)

Give it a try.
Make a script:

#!/bin/bash

export DISPLAY=":0.0"
/usr/bin/xinput set-prop 13 307 0.000000, -1.000000, 1.000000, 1.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000

make it executable

chmod +x /path/to/your/script.sh

Change your switch

command_on: '/path/to/your/script.sh'

thanks, I will give it a try when I’m back home!

or even simpler

command_on: 'DISPLAY=:0.0 /usr/bin/xinput set-prop 13 307 0.000000, -1.000000, 1.000000, 1.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000'