The following has been tested with an Acer H6510BD projector and an x86 device running LibreELEC. LibreELEC does not provide the python-serial package, thus this approach only depends on the light-weight stty binary which can be taken from any Linux distribution where it is usually found under /bin/. All files are created on the storage partition, allowing for persistence even after a LibreELEC upgrade.
You need connect your projector via an ancient serial cable to the LibreELEC host. Look on the attic if you still have a spare one. Unfortunately, as many modern computer boards do not have a serial interface anymore, a USB-Serial adapter might be additionally required. If your projector has a USB port, test if it forwards a serial device over it by checking with lsusb.
Dependency and script
First, log in to KODI via SSH and create a directory for your files, for example /storage/misc. Find /bin/stty on a Linux distribution and copy it via SCP to /storage/misc/stty. In my case, I have copied it from my Ubuntu 18.04 distribution, but be careful that the processor architecture must match, for example a Raspberry Pi is an ARM device - in this case you should fetch it e.g. from a Raspbian Linux installation.
Furthermore, put the following bash script to /storage/misc/projector and make it executable (chmod 755 /storage/misc/projector).
#!/bin/bash SERIALPORT=/dev/ttyUSB0 case $1 in on) SERCMD="* 0 IR 001" ;; off) SERCMD="* 0 IR 002" ;; *) echo "On or off?" exit 1 ;; esac /storage/misc/stty -F $SERIALPORT 9600 printf "$SERCMD\r\n" > $SERIALPORT
Based on your projector brand and model, you might need to adapt the serial commands above based on manuals of your projector you can usually find on the web. You can manually test the scripts by entering /storage/misc/projector on or /storage/misc/projector off and checking if you projector reacts appropriately. If it does not react or errors occur on the command line, check if the USB serial adapter is recognized correctly using lsusb and ls -l /dev/ttyUSB*. You should also check if the serial commands for you projector model are correct.
Autostarting the script
Adapt (or create) the file /storage/.config/shutdown.sh to auto-power off your projector.
#!/bin/bash case "$1" in halt) /storage/misc/projector off ;; poweroff) /storage/misc/projector off ;; reboot) # your commands here ;; *) # your commands here ;; esac
Furthermore, adapt (or create) the file /storage/.config/autostart.sh to auto-power on your projector.
#!/bin/bash /storage/misc/projector on