homedash / kankun-json

A CGI script that provides a simple web interface and RESTful JSON API for the Kankun Small K wifi switch.
http://homedash.org
MIT License
34 stars 25 forks source link

Its only for the KK version 1 #12

Open masterchop opened 8 years ago

masterchop commented 8 years ago

we should check if this is v1 or v2 and then set the correct path:

RELAY_CTRL=/sys/class/leds/tp-link:blue:relay/brightness RELAY_CTRL2=/sys/class/leds/i-konke:red:relay/brightness

for example:

if [ -f $RELAY_CTRL ]; then case "cat $RELAY_CTRL" in 0) echo "$callback$LWRAPPER{\"state\":\"off\"}$RWRAPPER" ;; 1) echo "$callback$LWRAPPER{\"state\":\"on\"}$RWRAPPER" ;; esac fi if [ -f $RELAY_CTRL2 ]; then case "cat $RELAY_CTRL2" in 0) echo "$callback$LWRAPPER{\"state\":\"off\"}$RWRAPPER" ;; 1) echo "$callback$LWRAPPER{\"state\":\"on\"}$RWRAPPER" ;; esac fi

In version 2, we also have the option to light up the dimmer:

DIM_CTRL=/sys/class/leds/i-konke:yellow:light/brightness

This stuff could be addded to the script to expand its range.

Japh commented 8 years ago

Great suggestions, thanks! 😄