Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- save () {
- if [ $state == "b" ]; then
- echo "zone=$zone;min=$min;max=$max" > ~/.milight/$zone.bright
- elif [ $state == "e" ]; then
- echo "zone=$zone;min=$min;max=$max" > ~/.milight/$zone.temp
- else
- echo "Unexpected case expression. Exiting"
- exit 3
- fi
- }
- load () {
- if [ $state == "e" ]; then
- source ~/.milight/$zone.bright
- elif [ $state == "b" ]; then
- source ~/.milight/$zone.temp
- else
- echo "Unexpected case expression. Exiting"
- exit 3
- fi
- }
- licon () {
- /usr/local/bin/milight.py --ip 192.168.1.133 --zone $@
- save
- }
- #Gradually changes temperature
- liset () {
- zone=$1
- state=$2
- steps=$3
- sleep=$4
- min=$5
- max=$6
- if [ $min -ge $max ]; then
- echo "Minimum must be lower than maximum. Exiting."
- exit 1
- fi
- if [ $steps -gt 0 ]; then
- licon $zone -$state $min > /dev/null
- echo "Zone:$zone Min:$min Max:$max Steps:$steps Sleep:$sleep Diff:$(($max - $min))"
- while [ $min -lt $max ]; do
- if [ $steps -ge $(($max - $min)) ]; then
- sleep ${sleep}s
- licon $zone -$state $max > /dev/null
- min=$max
- echo "Zone:$zone Min:$min Max:$max Steps:$steps Sleep:$sleep Diff:$(($max - $min))"
- else
- sleep ${sleep}s
- min=$(($min + $steps))
- echo "Zone:$zone Min:$min Max:$max Steps:$steps Sleep:$sleep Diff:$(($max - $min))"
- licon $zone -$state $min > /dev/null
- fi
- done
- elif [ $steps -lt 0 ]; then
- licon $zone -$state $max > /dev/null
- echo "Zone:$zone Min:$min Max:$max Steps:$steps Sleep:$sleep Diff:$(($max - $min))"
- while [ $max -gt $min ]; do
- if [ $steps -le $(($min - $max)) ]; then
- sleep ${sleep}s
- licon $zone -$state $min > /dev/null
- max=$min
- echo "Zone:$zone Min:$min Max:$max Steps:$steps Sleep:$sleep Diff:$(($max - $min))"
- else
- sleep ${sleep}s
- max=$(($max + $steps))
- echo "Zone:$zone Min:$min Max:$max Steps:$steps Sleep:$sleep Diff:$(($max - $min))"
- licon $zone -$state $max > /dev/null
- fi
- done
- else
- echo "Amount of steps cannot be 0. Exiting"
- exit 2
- fi
- }
- # States: e = Temp b = Brightness
- # Zone State Step Sleep Min Max
- #lux 4 $1 1.5 0 50
- liset 4 e -5 .5 0 100
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement