A little more info on the LED bars. I tried to get the SSH integration to send multiple parameters (separated by newlines), but it simply wonāt work for me. Itās very slow, and also seems to occasionally set them to a value randomly much later (minutes later).
So instead I worked on getting the shell script from above working. I had to modify it to use a key to login, rather than the password. This is safer, anyway, so hereās roughly the steps I took to get this working. I canāt give exact step-by-step instructions, so if it seems too confusing, it probably isnāt worth the hassle.
- First, generate a new key on your desktop
- Then send the public key to the screen, for example:
scp .ssh/crestron.pub [email protected]:/User/crestron
- Now you have to add the key to your user, so SSH into the screen, and run this:
SSHSERVER ADDUSERKEY -N:admin -K:crestron
(Note: Iām only 50% sure this will work without changes. If you need to move the file after uploading it, you can use DIR
and CD
to find it, and MOVEFILE fromfile tofile
to move it.)
- Now copy the file to HomeAssistant, using something like
scp .ssh/crestron homeassistant.local:/config/.ssh/crestron
- Finally, you can modify the script above from @UserHA8021 , mine is now similar to below. Note that I also always switch the digital values, because Iāve found those can get disabled on reboot.
# Hardcoded SSH user and password (use at your own risk; consider using key-based authentication for better security)
SSH_USER="admin"
# Debug mode (set to true to only echo the commands without executing)
DEBUG=false
# Function to display usage information
usage() {
echo "Usage: $0 -i <IP_ADDRESS> -r <RED_VALUE> -g <GREEN_VALUE> -b <BLUE_VALUE>"
echo "Where <RED_VALUE>, <GREEN_VALUE>, and <BLUE_VALUE> are between 0 and 100."
exit 1
}
# Parse command-line options
while [[ $# -gt 0 ]]; do
case $1 in
-i)
IP_ADDRESS=$2
shift 2
;;
-r)
RED_VALUE=$2
shift 2
;;
-g)
GREEN_VALUE=$2
shift 2
;;
-b)
BLUE_VALUE=$2
shift 2
;;
-d)
DEBUG=true
shift 1
;;
*)
usage
;;
esac
done
# Check if all required arguments are provided and values are in range
if [ -z "$IP_ADDRESS" ] || [ -z "$RED_VALUE" ] || [ -z "$GREEN_VALUE" ] || [ -z "$BLUE_VALUE" ]; then
usage
fi
# Validate that the values are between 0 and 100
if ((RED_VALUE < 0 || RED_VALUE > 100)) || ((GREEN_VALUE < 0 || GREEN_VALUE > 100)) || ((BLUE_VALUE < 0 || BLUE_VALUE > 100)); then
echo "Error: The values for -r, -g, and -b must be between 0 and 100."
exit 1
fi
# Build the SSH command using a heredoc to send multiple commands with -t flag for pseudo-terminal allocation
SSH_COMMAND="ssh -i /config/.ssh/crestron -t -t -o StrictHostKeyChecking=no \"$SSH_USER@$IP_ADDRESS\" <<EOF
setdigitaljoin 30025 1
setdigitaljoin 30026 1
setdigitaljoin 30027 1
SETANALOGJOIN 33354 $RED_VALUE
SETANALOGJOIN 33355 $GREEN_VALUE
SETANALOGJOIN 33356 $BLUE_VALUE
bye
EOF"
# If debug mode is enabled, echo the command and exit
if [ "$DEBUG" = true ]; then
echo "Debug mode is ON. The command that would be run is:"
echo "$SSH_COMMAND"
exit 0
fi
# Execute the SSH command
# echo "Connecting to $IP_ADDRESS with user $SSH_USER..."
eval "$SSH_COMMAND"
Once all this is done, you will need to set up the actual shell commands within configuration.yml
, which looks something like:
shell_command:
crestron_backlight_color: /bin/bash /config/shell_commands/crestron_screen.sh -i "{{ip}}" -r "{{red}}" -g "{{green}}" -b "{{blue}}"
crestron_kitchen_backlight_alert: /bin/bash /config/shell_commands/crestron_screen.sh -i "192.168.1.105" -r "100" -g "15" -b "0"
crestron_kitchen_backlight_off: /bin/bash /config/shell_commands/crestron_screen.sh -i "192.168.1.105" -r "0" -g "0" -b "0"
Note that I have both a shell command I can send info to generically (for custom values), and also a few commands that target a specific screen with a specific color. You can mix-and-match hard-coded properties with dynamic ones, as you can imagine. The dynamic properties are sent using a data
key, like so:
action: shell_command.crestron_backlight_color
data:
ip: 192.168.1.105
red: 50
green: 50
blue: 100
If you have any questions, I can try to help, but I basically muddled my way through this as it wasāand now I have to repeat this on the other 3 screens myself!