ADDED light/candle.fish Index: light/candle.fish ================================================================== --- light/candle.fish +++ light/candle.fish @@ -0,0 +1,12 @@ +#!/usr/bin/fish +# vi:syntax=zsh +source inc.fish + +put state (json on:true) + +while true + put state (json bri:(random 20 100)) + sleep 0.(random 0 2) +end + + ADDED light/inc.fish Index: light/inc.fish ================================================================== --- light/inc.fish +++ light/inc.fish @@ -0,0 +1,30 @@ +#!/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 + ADDED light/pulse.fish Index: light/pulse.fish ================================================================== --- light/pulse.fish +++ light/pulse.fish @@ -0,0 +1,14 @@ +#!/usr/bin/fish +# vi:syntax=zsh +source inc.fish + +put state (json on:true) + +while true + put state (json bri:(random 200 254) hue:(random 35000 65000)) + sleep 0.3 + put state (json bri:0) + sleep 0.3 +end + +