Elgato from the shell
Once the lamp joined my local WLAN network (and I know the IP address), I use this script for controlling it.
- You must have
cURL
andjq
installed. (sudo apt-get install jq curl
) - The script sets a local
ELGATO_KEY_LIGHT_IPADDRESS
variable. Tweak that part to your needs.
e
turns it on or off- Brightness
e +
increases the brightnesse -
decreases the brightness
- Color tempreature
e 1
selects the coldest color temperaturee 2
selects a medium color temperaturee 3
selects the warmest color temperature
- Identify the light
e i
makes the light blink three times
#!/bin/bash
function _elgatoGet {
local ip="$1"
local path="$2"
curl --silent \
--url "http://${ip}:9123/elgato/${path}"
}
function _elgatoPut {
local ip="$1"
local path="$2"
local msg="$3"
echo "${msg}" | curl --silent --request PUT \
--header "Content-Type: application/json" \
--url "http://${ip}:9123/elgato/${path}" \
--data @-
}
function _elgatoIdentify {
local ip="$1"
local displayName="$( _elgatoGet "${ip}" "accessory-info" | jq -r ".displayName" )"
echo "Light ${displayName} is blinking"
# empty POST
curl --silent \
--request POST\
--url "http://${ip}:9123/elgato/identify"
}
function _elgatoTurnOnOff {
local ip="$1"
local current="$( _elgatoGet "${ip}" "lights" | jq ".lights[0].on" )"
local new="$(( 1-${current} ))"
local state="$( _elgatoPut "${ip}" "lights" "{ \"lights\" : [ { \"on\" : ${new} } ] }" | jq ".lights[0].on" )"
local displayName="$( _elgatoGet "${ip}" "accessory-info" | jq -r ".displayName" )"
echo "$( if [[ "${state}" == "0" ]] ; then echo "Light \"${displayName}\" turned off" ; else echo "Light \"${displayName}\" turned on" ; fi ; )"
}