#!/bin/bash

LIGHT=$1
STATE=$2
BRI=$3

echo ---
curl http://192.168.0.26/state\?light=1
echo
curl http://192.168.0.26/state\?light=2
echo
curl http://192.168.0.26/state\?light=3
echo
curl http://192.168.0.26/state\?light=4
echo
echo ---

if [ "$1" ]; then
    curl -i -X PUT -d '{ "'$LIGHT'": { "on": '$STATE', "bri": '$BRI' } }' http://192.168.0.26/state

    echo
    echo ---

    curl http://192.168.0.26/state\?light=1
    echo
    curl http://192.168.0.26/state\?light=2
    echo
    curl http://192.168.0.26/state\?light=3
    echo
    curl http://192.168.0.26/state\?light=4

    echo
    echo ---
fi

