util  Artifact [2bb384df8e]

Artifact 2bb384df8e81fd8b543397b9beb0e03cd7b57f5d578713f4548d3d3937fd7b3a:


#!/usr/bin/fish
# vi:syntax=zsh
set apikey eoBeM0xXhuJ8oRjIqTmrx9fuuUVPH0uyKseiYHNf
set bridge 192.168.43.254
set api http://$bridge/api/$apikey
set lights 1 2

function put
	for light in $lights
		echo "$argv[2..-1]" | curl -sS -T - $api/lights/$light/$argv[1] >/dev/null
	end
end
function json
	echo -n "{"
	set start 1
	for i in $argv
		test $start -eq 0; and echo -n ,
		echo -n $i | sed 's;^\(.*\):\(.*\)$;"\1":\2;g'
		set start 0
	end
	echo -n "}"
end

function die
	put state (json bri:112 hue:60954 sat:254)
	exit 0
end

trap 'die' USR1