I have a nice Wifi Switch from Kankun.
I want to see its status. When I open http://192.168.1.54/cgi-bin/relay.cgi?state . I get "ON" back.
I need a sample LUA script that ask for the state of the wifiswitch and changes the status accordingly. I hope you can help me
Read Kankun Wifi Smart switch status
Moderator: leecollings
-
wmn79
- Posts: 27
- Joined: Monday 13 April 2015 23:19
- Target OS: NAS (Synology & others)
- Domoticz version: 3.5033
- Location: Amsterdam, The Netherlands
- Contact:
Re: Read Kankun Wifi Smart switch status
I bet you have already got it up and running, but otherwise, check the post here https://plus.google.com/112354434499704 ... SYcpXi3Y83. I used that to get the switches available in domoticz.
-
ThinkPad
- Posts: 890
- Joined: Tuesday 30 September 2014 8:49
- Target OS: Linux
- Domoticz version: beta
- Location: The Netherlands
- Contact:
Re: Read Kankun Wifi Smart switch status
Maybe you can use parts of my script: http://domoticz.com/forum/viewtopic.php ... 741#p40343
I do a kind of similar thing with a ESP8266 that serves a webpage.
I do a kind of similar thing with a ESP8266 that serves a webpage.
I am not active on this forum anymore.
-
dijkdj
- Posts: 63
- Joined: Saturday 07 March 2015 22:10
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Read Kankun Wifi Smart switch status
Hi Thinkpad. How can I update the switch status without really switching?
-
ThinkPad
- Posts: 890
- Joined: Tuesday 30 September 2014 8:49
- Target OS: Linux
- Domoticz version: beta
- Location: The Netherlands
- Contact:
Re: Read Kankun Wifi Smart switch status
Not possible, as far as i know. But what happens when you switch it 'On' in Domoticz when it is already turned on? Nothing i guess?
I am not active on this forum anymore.
-
dijkdj
- Posts: 63
- Joined: Saturday 07 March 2015 22:10
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Read Kankun Wifi Smart switch status
That is true, nothing happens. Just want domoticz to show the same state as the switch is. The same way Hue lights do.
Re: Read Kankun Wifi Smart switch status
Hi,
I am new here. This is easy as pie.
1,
Create a Dummy On/Off switch.
On Action:
http://192.168.1.22/cgi-bin/json.cgi?set=on
Off Action:
http://192.168.1.22/cgi-bin/json.cgi?set=off
2,
Create a bash script somewhere on your Domoticz server.
I put mine on my Raspberry Pi in /home/pi/ directory:
pi@raspberrypi:~/$nano /home/pi/domoticz_checkstatus.sh
Modify IP's......
Set correct chmod:
pi@raspberrypi:~/$ chmod +x domoticz_checkstatus.sh
Now create a new crontab job and let run our script every minute:
* * * * * /home/pi/scripts/domoticz_checkstatus.sh
Done.
From now, If you turn off your Kankun elsewhere than in Domoticz, then switch status in Domoticz will be changed to off mode too.
I am new here. This is easy as pie.
1,
Create a Dummy On/Off switch.
On Action:
http://192.168.1.22/cgi-bin/json.cgi?set=on
Off Action:
http://192.168.1.22/cgi-bin/json.cgi?set=off
2,
Create a bash script somewhere on your Domoticz server.
I put mine on my Raspberry Pi in /home/pi/ directory:
pi@raspberrypi:~/$nano /home/pi/domoticz_checkstatus.sh
Code: Select all
#!/bin/bash
#Adrian Mihalko - mihalko.eu
#
KANKUNIP="192.168.1.22"
DOMOTICZIP="192.168.1.14"
STATUS=$( curl "http://"$KANKUNIP"/cgi-bin/json.cgi?get=state" | egrep -m 1 '"state"' | awk -F '"' '{ print $4 }')
#echo "$STATUS"
if [[ "$STATUS" == "on" ]]
then
#echo "Set switch status: ON"
curl "http://"$DOMOTICZIP":8080/json.htm?type=command¶m=udevice&idx=4&nvalue=1"
else
#echo "Set switch status: OFF"
curl "http://"$DOMOTICZIP":8080/json.htm?type=command¶m=udevice&idx=4&nvalue=0"
fiSet correct chmod:
pi@raspberrypi:~/$ chmod +x domoticz_checkstatus.sh
Now create a new crontab job and let run our script every minute:
* * * * * /home/pi/scripts/domoticz_checkstatus.sh
Done.
From now, If you turn off your Kankun elsewhere than in Domoticz, then switch status in Domoticz will be changed to off mode too.
Who is online
Users browsing this forum: No registered users and 1 guest