PLUGIN: HttpSwitch (for Cheap WiFi Switches like KK-SR3)

Further to this, EventWatcher tracks changes to device code “X”, SwitchPower1. My current configuration tracks all the switch state changes in my network but it does NOT catch manual changes to the state of the KK-SR3 Wi-Fi Switch Plugin.

Thanks for that, that is probably because i use a function to flip the switch and update the status variable according to the response of the switch itself
So failure to flip it would not change the status, thats also the reason it takes longer for the icon to change as the script cheks if the action has been executed, i have an idea to bypass that already

[quote=“nullx8, post:36, topic:188358”]Thanks for that, that is probably because i use a function to flip the switch and update the status variable according to the response of the switch itself
So failure to flip it would not change the status, thats also the reason it takes longer for the icon to change as the script cheks if the action has been executed, i have an idea to bypass that already[/quote]

Updating based on the actual result make sense, tracks with the ZWave handling. I don’t have my switches yet, they are in the country somewhere though :grinning: so I can’t confirm anything beyond that yet

I have three of the four units working. They all show as online, show the WiFi signal strength and properly switch ON and OFF and reflect the change of state. A before, they do NOT show up in ImperiHome and EventWatcher does NOT report the state change for a device “SwitchPower:1” which is type “X”.

I haven’t sorted out the fourth one, is apparently getting the correct advocates DHCP address for some reason.

Ill install eventwatcher and check on it, as for imperyhome, im clueless since the switches do act like any other zwave switch.

I’ve sent my data dump to ImperiHome at their request so they can see why it doesn’t and what they can do on their end. We may get a clue from that.

I got the fourth unit working but I had to allocate it a different IP address, it simply refused to work with the one I tried.

The only thing i could think of, is that i not provide the Target variable messes with things

I’ve sent my data dump to ImperiHome at their request so they can see why it doesn’t and what they can do on their end. We may get a clue from that.

I got the fourth unit working but I had to allocate it a different IP address, it simply refused to work with the one I tried.[/quote]

Update: The fourth switch is a case of the incredible shifting MAC. I got it working at the address I wanted. This morning I moved the switch to another room and it stopped working. Fiddling with my router showed the IP did not get allocated because the switch had changed its MAC!!! I unplugged/plugged back in and the MAC reverted the “correct” value and it got the right IP address. So I unplugged it again and when I plugged it back in the MAC had once again shifted to the earlier value so the IP did not get allocated.

I’ve written to the eBay supplier in hopes I can get a replacement.

That is odd indeed, i have reset and hard-reset my test switch serval times,
The mac address never changed.
But openwrt supports virtual mac adresses which you can set, or even better use client id instead of mac

for static IP

ssh to the Switch:

edit /etc/config/network

it should look like this

config interface 'wwan'
        option proto 'dhcp'

remove "option proto ‘dhcp’

and put somethings like this:

config interface 'wwan'
        option proto 'static'
        option ipaddr '1.1.1.1'
        option netmask '255.255.255.0'

where 1.1.1.1 is the ip adress you would like it to get :wink:

or to hard-set the mac adress
edit /etc/config/wireless
and add macaddr option

config wifi-iface
        option device 'radio0'
        option macaddr xx:xx:xx:xx:xx:xx

Thanks.

It is strange as the other three appear to be fine.

I’m not a UNIX type so I appreciate the step-by-step :slight_smile: I may do that depending on whether or not the vendor helps out :slight_smile:

[quote=“nullx8, post:43, topic:188358”]That is odd indeed, i have reset and hard-reset my test switch serval times,
The mac address never changed.
But openwrt supports virtual mac adresses which you can set, or even better use client id instead of mac

for static IP

ssh to the Switch:

edit /etc/config/network

it should look like this

config interface 'wwan'
        option proto 'dhcp'

remove "option proto ‘dhcp’

and put somethings like this:

config interface 'wwan'
        option proto 'static'
        option ipaddr '1.1.1.1'
        option netmask '255.255.255.0'

where 1.1.1.1 is the ip adress you would like it to get :wink:

or to hard-set the mac adress
edit /etc/config/wireless
and add macaddr option

config wifi-iface option device 'radio0' option macaddr xx:xx:xx:xx:xx:xx [/quote]

I ended up doing this, setting a Fixed IP and freezing the MAC

Thanks
John

Quote from: stefaanbolle on August 10, 2015, 11:33:07 pm
Could your plugin be modified so it can read status/control openhab switches, which can also be controlled/read with REST calls?
This would make an excellent link from Vera to Openhab (and not vice versa as existing today via an openhab binding)

thats a good idea … i played with openHAB … but iam allergic to Java (unless its in my Cup)
i made something semilar already as vera controller … (php based)

i’ll install openHAB somewhere to test …
give me a few days :wink:

Hi Nullx8
Did you have any change to look into controlling Openhab items via REST API already?

could you replace this files on your vera and test with Imperihome of it does show now properly ?

Sorry, no joy, still doesn’t see the device.
John

Can somebody help me… I don’t really know what I am doing wrong…

I use WinSCP in SCP mode
1- I create the directory in /www /cgi-bin
2- I create this file json.cgi with Win SCP and copy the following…


#!/bin/sh
echo “Content-Type: application/json”
echo “Cache-Control: no-cache, must-revalidate”
echo “Expires: Sat, 26 Jul 1997 05:00:00 GMT”
echo

RELAY_CTRL=/sys/class/leds/tp-link:blue:relay/brightness
LINKQ = iw dev wlan0 link | grep signal

case “$QUERY_STRING” in
state)
case “cat $RELAY_CTRL” in
0) STATE=“0”
;;

  1. STATE=“1”
    ;;
    esac
    ;;
    on)
    echo 1 > $RELAY_CTRL
    STATE=“1”
    ;;
    off)
    echo 0 > $RELAY_CTRL
    STATE=“0”
    ;;
    esac
    echo “{"state":$STATE,"link":"iw dev wlan0 link | grep signal ","uptime":"23:50"}”

3- I checked the wireless file, here what I have…

/etc/config/wireless

config wifi-device ‘radio0’
option type ‘mac80211’
option hwmode ‘11ng’
option path ‘platform/ar933x_wmac’
option htmode ‘HT20’
list ht_capab ‘SHORT-GI-20’
list ht_capab ‘SHORT-GI-40’
list ht_capab ‘RX-STBC1’
list ht_capab ‘DSSS_CCK-40’
option disabled ‘0’
option country ‘CN’
option channel ‘1’

config wifi-iface
option device ‘radio0’
option network ‘wwan’
option ssid ‘XXXXXXX’
option mode ‘sta’
option encryption ‘psk2’
option key ‘XXXXXXX’

4- I checked /etc/config/network, here what I have…

config interface ‘loopback’
option ifname ‘lo’
option proto ‘static’
option ipaddr ‘127.0.0.1’
option netmask ‘255.0.0.0’

config globals ‘globals’
option ula_prefix ‘fd5a:5111:fb4a::/48’

config interface ‘lan’
option ifname ‘eth0’
option type ‘bridge’
option proto ‘static’
option ipaddr ‘192.168.10.253’
option netmask ‘255.255.255.0’
option ip6assign ‘60’

config interface ‘wwan’
option proto ‘static’
option ipaddr ‘192.168.1.XXX’
option gateway ‘192.168.1.1’
option netmask ‘255.255.255.0’

I did an update with my Vera Edge… to get the latest apps…

I create a device… and I put the IP adress… you can see in the files below what I have with the device…

NOTE: I can control the device with my iPhone… I can not with Vera Edge…

One more thing I like to talk about… as soon as I try to connect those small K switch… I loose my IP address from my router… instead I receive IP address from the switches… All my computers, cellulars, iPad loose their IP’s address… and received a bad IP giving by the switches 192.168.22.240 “I think” and a router dress 192.168.22.53 instead of 192.168.1.1. Even if I disconnect the switches and remove the apps from my I phone I still have that bug. The only way I can get it back on my network was to give a static IP and on the 2 PC’s I had to remove the network driver and reinstall it. I even did a factory reset on my router and I was given the same IP’s address… what a mess. I try to reconnect those switches two times and the problems came back each time…
Anybody knows anything about it…

Note: I try to connect threw a SSID from my router…

Hey Nullx8
Did you already have any change to look into controlling Openhab items via REST API?
I’m trying to sync openhab with vera switches by combining both bindings to 1 openhab switch, but the feedbacks of the nikobus binding are not correct.
The only option I see now is having the vera send immediate commands to openhab via the openhab REST interface.
For this I need a virtual vera switch which reads openhab switch statuses and writes openhab switch commands.

Null8x

Have you had a chance to consider why these things aren’t tracked in EvenTWatcher and populated in ImperiHome?

Pardon the “Blonde” moment here. Installing the plugin from the App Store under UI5 The requirements say
Requirements

  • UI5 only: akb-json need to be on the vera to parse json responses (use I_HttpSwitch1_UI5.xml)

Where do I find “I_HttpSwitch1_UI5.xml”

Thanks
Update:
Blonde moment gone and all working :slight_smile:

I received the switch, tried testing with plugin, use static IP in router, update both IP(Parma Tab) and Address(Variable Tab), shows offline,

however I’m able to control the switch from its native app doesn’t work with Vera Plugin.

I am not a programming guy so I can’t look into the code for further troubleshooting.