Issue with command to turn screen off

I’ve been using a software that runs this or similar command that even if I run manually, it no longer works, so it is some issue with my system. 2 things I did. I moved my SSD over from a Intel N5101 based system to a Intel G7400T one. Second, I ran updates on my system which I hadn’t done in awhile.

I had to fix the grub bootloader, but worked after that, but there are actually a few things that aren’t working, but most annoyingly, it’s the command that was automatically issues with this software called LNXlink that turns the screen off whenever I programmed it to via Home Assistant. The command that I run manually to check it this.

xset -display :0 dpms force off

It returns the following.

Maximum number of clients reached
xset:  unable to open display ":0"

This only happens if this is true, which it isn’t always, but if it is and I close some apps down, this bugger will always seem to get me instead.

Error with command: xset -display :0 q (Invalid MIT-MAGIC-COOKIE-1 key

I’ve tried some research to resolve, but came up empty. Any insight please as to how I can resolve this? Thanks.

Edit:
Using KDE Plasma.

Are you running wayland?

echo $XDG_SESSION_TYPE

Sorry, forgot to mention, currently on Wayland, yes, but I was on X11 due to some Wayland issues. I still had the issue there, but I have at least temporarily moved to Wayland as I have a touchscreen and my desktop shortcuts were missing (although not anymore) and the screen was black, so I was touching on the desktop and double tapped and somehow there was some weird occurrence that caused the the taskbar icons to scrunch together and the taskbar itself to appear to be overlapping one beneath, offset a little. Updates and reboots haven’t fixed.

The result of that command was “tty”.

I also have GNOME installed, tried it, still issues.

Don’t think xset works on wayland, try:

kscreen-doctor --dpms off       

Thanks. This is the response I got, wasn’t sure what exactly to install that I might have been missing.

qt.qpa.xcb: could not connect to display
qt.qpa.plugin: From 6.5.0, xcb-cursor0 or libxcb-cursor0 is needed to load the Qt xcb platform plugin.
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: offscreen, vnc, minimal, xcb, eglfs, wayland, wayland-egl, linuxfb, minimalegl, vkkhrdisplay.

Aborted (core dumped)

I get this same error if I run “plasmashell” from an SSH session, too. It runs from the terminal directly from the machine though. I am not sure if this is normal behavior or not with this process.