Need a way to trigger an automatic mouse-click in the middle of my screen!

Hi all,

Currently looking for a way to trigger a mouse-click in the middle of my screen.
I’m building a screen behind a mirror for my bathroom.
I already integrated a gesture sensor (PAJ7620 with ESP32), sending data via MQTT into HA.
I also integrated a news-stream from my local TV station, so I can watch the news while shaving and brushing my teeth)


I can’t/will not use any other device like touch etc … because of the humidity in a bathroom. PAJ7620 with gesture recognition is the only way to go. (I’m already using it to “swipe” between dashboards, and to “move” between cards and make selections etc … all within HA)
I can use helpers / MQTT / Pyscript, or something else that I’m not aware of. (I’m running HA 2022.12.8 - Supervisor 2022.11.2 - Operating System 9.4 - Frontend-version: 20221213.1 on a RPI4, and the screen is also using a RPI with a bare metal fullscreen version of Chromium)

Any toughts/ideas/help is much appreciated :slight_smile:
Best regards from Belgium,

In the meanwhile I found a solution :slightly_smiling_face:
Under linux, there is a tool called “xdotool”.
I can trigger a shell command from within HA via SSH, to the machine that is running the browser.

This does the trick:

export DISPLAY=:0
xdotool mousemove 960 540 click 1

I can even hide the mouse-pointer (while still using it) with:
unclutter idle 0 &

Of course you first need to install both tools:

sudo apt-get install xdotool
sudo ap-get install unclutter

You also need to copy the RSA key from HA to the remote machine,
( ssh-copy-id) and add the user to the suoers group (sudo visudo).
Next you can create a shell-command in configuration.yaml like:
click_middlescreen: ssh -i /config/ssh/id_rsa -o ‘StrictHostKeyChecking=no’ [email protected] sudo xdotool mousemove 960 540 click 1

Then, you will have a service available “shell_command.click_middlescreen”, that you can use in automations and scripts :slightly_smiling_face:

Hello Would it be possible to have the code used for esp32 (mqtt + PAJ7620)?
Thanks in advance

Hi Will,

Sorry for the way-to-late reply.
Download it here:

Best regards,

1 Like