Page 2 of 3

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Posted: Monday 26 October 2015 19:17
by pluggin
Antikton wrote:Hello to everyone, my name is Eduardo and I have a few weeks / months in the world of home automation.
Initially I bought a pair of Orvibo S20 plugs to test the operation through mobile. The truth is that local operation is so-so and thru Internet is very bad.
So I opted for Z-Wave protocol. Although I have some Raspberry Pi, the hardware that I'm using is a miniPC PIPO X7 with Windows 10 and Sigma Z-Wave adapter.
Some of the devices that I have are power consumption meter G2 from Aeon Labs, Multifunctional Movement Detector from Fibaro, power strip 6 outlets from Greenwave and some Fibaro hidden modules.
The fact is that as a result of searching on Internet about the possibility of communicating with plugs Orvibo S20 through the local network, I found the stikonas blog (https://stikonas.eu/wordpress/2015/02/2 ... 20-socket/) with useful information and a Windows application for command line. I spent some time testing in PHP but I could not communicate directly with the plug to turn on and off. These days I have been searching new information on Google again and I've run into two very interesting links that allowed me, with some modifications, to integrate Orvibo S20 plugs to Domoticz.
- First, I found the GitHub repository of pcp135 / Orvibo https://github.com/pcp135/Orvibo where with a simple scripting and using their programmed class, I managed to create a virtual switch that allowed me on Domoticz to turn on and off the plug!
- And thanks to sergejey / majordomo-orvibo https://github.com/sergejey/majordomo-orvibo I could make other changes using their code to update the actual/real status of the plugs to Domoticz when the status is changed manually / physically in the Orvibo S20.
The code is very dirty because I do not have much time but if anyone is interested in it and has some S20 at home you want to use, tell me and I will put the code (as soon as I clean a little) and steps.
The interesting thing is that it saves money in the automation as these plugs (uncontrolled consumption, not always necessary) are 20$ each.
Regards to all!

---

Spanish:

Hola a todos, mi nombre es Eduardo y llevo desde hace unas pocas semanas/meses en el mundo de la domótica.
Inicialmente compré un par de enchufes Orvibo S20 para probar el funcionamiento a través del móvil. La verdad que funcionan regular en local y fatal a través de Internet.
Entonces me decidí por Z-Wave. Aunque tengo algunos Raspberry, el hardware que estoy empleando es un miniPC PIPO X7 con Windows 10 y el adaptador Z-Wave de Sigma.
Algunos de los dispositivos que tengo son Medidor de consumo eléctrico G2 de Aeon Labs, Detector de Movimiento multifunción de Fibaro, Regleta de 6 enchufes Greenwave y algunos módulos ocultos de Fibaro.
El caso es que a raíz de buscar en Internet sobre la posibilidad de comunicarme con los enchufes Orvibo S20 a través de la red local, me encontré el blog de stikonas (https://stikonas.eu/wordpress/2015/02/2 ... 20-socket/) con información muy útil y una aplicación para Windows por línea de comandos muy útil. Estuve un tiempo haciendo pruebas en PHP pero no conseguí comunicarme directamente con el enchufe para poderlo encender y apagar. Estos días he estado buscando nuevamente información en Google y me he topado con 2 enlaces muy interesantes que me han permitido, haciendo unas modificaciones, integrar los enchufes Orvibo S20 a Domoticz.
- Primero me encontré con el repositorio GitHub de pcp135 / Orvibo https://github.com/pcp135/Orvibo donde con un sencillo script y aprovechando su clase programada, conseguí crear un Interruptor virtual en Domoticz que me permitía encender y apagar el enchufe al momento!
- Y gracias al de sergejey / majordomo-orvibo https://github.com/sergejey/majordomo-orvibo pude realizar otras modificaciones aprovechando su código para actualizar el estado real del enchufe a Domoticz por si se cambia el estado manualmente/físicamente en el Orvibo S20.
Ahora mismo todo el código está muy sucio ya que no dispongo de mucho tiempo pero si alguien está interesado porque tiene algún S20 por casa que le quiere dar uso, que me lo indique y pongo el código (tan pronto como lo limpie un poco) y pasos a seguir.
Lo interesante de esto es que permite ahorrar un dinero en el tema domótico ya que estos enchufes sin control de consumo (no siempre es necesario) están a 20$.
¡Un cordial saludo a todos!
Do you know how if possible to control de Orvibo Allone WiWO-R1 Wifi IR Smart Remote Control from Domoticz?

Kind regards

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Posted: Monday 26 October 2015 20:21
by Antikton
Hi,

490123, the ""important"" information is the last:
Array ( [accf234b64e2] => 0 )

It says that it has been found only one orvibo with these mac and off (0).

Run the script several times and tell me (it is not necessary to paste the log) if it show more MAC address. Some times, the orvibo switches lost conectivity for a little time.
If it is not show more MACs, try to increase the line 130:
FROM
if (file_exists('./reboot') || IsSet($_GET['onetime']) || $contador > 12 )
TO
if (file_exists('./reboot') || IsSet($_GET['onetime']) || $contador > 15 )
OR
if (file_exists('./reboot') || IsSet($_GET['onetime']) || $contador > 20 )

It will read the net more time for the responses. Adjust to not have the script running too long time.

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Posted: Friday 30 October 2015 22:35
by 490123
Hi Antonik,

I've tried to increase line 130. unfortunately it didn't work. I have set four sockets in the cron.php, in de script log I see every time the same two sockets. Even if I add // before the line with these sockets above in the script, and I run it, I see the same sockets.

Can you find the problem?

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Posted: Saturday 31 October 2015 15:24
by Antikton
And the two sockets you do not see... works fine with the app?
I think it is a wifi related problem.

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Posted: Tuesday 03 November 2015 19:20
by 490123
Hello Antikton,

All the sockets are working fine. With the original app and with domoticz it will work very good.
Strange is that the cron.php script see every time 2 sockets. (every time the same 2 sockets). Now I delete three sockets. Even then the script see the same 2 sockets?? Do you have any idea?

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Posted: Sunday 20 December 2015 15:39
by Mightyman
Hi All,

I have created a bash script to control the Orvibo (WiWo) S20 switches in domoticz. Making it much easier (and cleaner) to integrate these cheap wifi sockets.

I used the following bash script called "s20Command.sh" in the default bash folder of domoticz:

Code: Select all

#!/bin/bash
action=$1
mac=$2
ip=$3
reversedMac=${mac:10:1}${mac:11:1}${mac:8:1}${mac:9:1}${mac:6:1}${mac:7:1}${mac:4:1}${mac:5:1}${mac:2:1}${mac:3:1}${mac:0:1}${mac:1:1}

# Subscribe to the device:
echo '6864001e636c'$mac'202020202020'$reversedMac'202020202020' | xxd -r -p | nc -u -w1 -p10000 $ip 10000 | xxd -p

case $action in
off)
        # Switch Off
        echo '686400176463'$mac'2020202020200000000000' | xxd -r -p | nc -u -w1 -p10000 $ip 10000 | xxd -p
        ;;
on)
        # Switch On
        echo '686400176463'$mac'2020202020200000000001' | xxd -r -p | nc -u -w1 -p10000 $ip 10000 | xxd -p
        ;;
esac

exit;


For this to work you must know the MAC and IP address for the socket. There are multiple ways to do this of course, Fing on android is one of my favorites, look for "Hi-flying electronics technology" or "HF-LPB100".
I also fixed the IP given to the device (through my DHCP server).

In my case:
MAC = accf238d1fe2
IP = 192.168.0.175

Then I created a dummy switch and provided the following actions:
On Action: script://bash/s20Command.sh on accf238d1fe2 192.168.0.175
Off Action: script://bash/s20Command.sh off accf238d1fe2 192.168.0.175

Hope this works for others, I am glad to help if you run into problems.

p.s. There is a 1 second delay in the current command (nc -u -w1 ... ), I will try to eliminate this in the near future.

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Posted: Sunday 28 February 2016 10:36
by MatthijsPH
Mightyman wrote: [...]
Hope this works for others, I am glad to help if you run into problems.
[...]
I just ordered one S20 to play around with and I will give your script a go as soon as I have it. This maybe a more reliable alternative for my KAKU plugs.

This could be a stupid question (I'm not an expert on bash scripting), but does this script receive information about the current state of the switch? In other words: will Domoticz know when the plug missed the on/off command or was switched on/off outside Domoticz? I see something about a 'subscription' but I can't figure out what exactly happens there.

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Posted: Friday 11 March 2016 18:26
by rtna
Just implemented a S20 switch with the shell script. Works perfectly. There is no feedback of the state of the switch however for as far as I can see.

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Posted: Tuesday 19 April 2016 18:09
by woody4165
Hi all

just got this plug from China, very nice and affordable.
I'm trying to use the php script and the On/Off commands work well.
One strange thing happen when I use the cron.php to get the status.
It does not change the status.
So I put an echo to see the json command that is going to be launched and here it is:

Code: Select all

http://192.168.xx.xx:8080/json.htm?type=command¶m=switchlight&idx=xx&switchcmd=On
As you can see I get a ¶m instead of &param.

I haven't touch the code (a part the echo), only the first lines as written in this 3d.

This is the script part regarding the json command

Code: Select all

if ( $switchcmd != '' ) {
	$url = $domoticz_server.'/json.htm?type=commando&param=switchlight&idx='.$mienchufe[$k].'&switchcmd='.$switchcmd;
	echo $url;
	$respuesta = send_url($url);
	$respuesta_json = json_decode($respuesta, true);
print_r($respuesta_json);
$mensaje = urlencode("Orvibo S20 - idx: ".$mienchufe[$k]." - mac: ".$k." - status: ".$switchcmd." - response: ".$respuesta_json['status']);
$url = $domoticz_server.'/json.htm?type=command&param=addlogmessage&message='.$mensaje;
$respuesta = send_url($url);

What can be to cause this and how can I fix it??

Thanks

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Posted: Wednesday 20 April 2016 6:37
by woody4165
I've tried in several browser, but I get the same problem.
I found that some browser think that "&para", part of "&param=", means "¶" and so it replace it.

I did it work replacing "&param" with "&dparam" and it's working!!

Thanks

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Posted: Wednesday 20 April 2016 6:42
by woody4165
How can I check the status of the S20 from within a Lua script using curl ?

I tried with

Code: Select all

status = os.execute('curl "http://192.168.xx.xx/s20folder/cron.php"')
but I don't get nothing in status.

Thanks

PS: Solved. I have to call the cron.php via crontab or manually to have the device set properly in Domoticz if manually modified.

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Posted: Thursday 28 April 2016 13:37
by woody4165
Is it normal that if I set cron.php in the crontab I get all these messages everytime (in my case every minute)?

Code: Select all

User: Admin initiated a switch command
2016-04-28 13:33:02.442 (various) Light/Switch (Presa1)
Orvibo S20 - idx: xxx - mac: xxxxxxxx - status: Off - response: OK
User: Admin initiated a switch command
Executing script: /home/osmc/domoticz/scripts/orvibo.sh
Executing script: /home/osmc/domoticz/scripts/orvibo.sh
2016-04-28 13:33:02.967 (various) Light/Switch (Presa2)
Orvibo S20 - idx: xxx - mac: xxxxxxxx - status: Off - response: OK
Thanks

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Posted: Friday 03 June 2016 18:49
by wuffer
I'm new to this and trying to get a orvibo s20 working with domoticz. Im using the script from https://github.com/franc-carter/bauhn-wifi

Is there more in the script i need to change other than mac address?

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Posted: Saturday 27 August 2016 23:42
by jsynxiii
Mightyman wrote:Hi All,

I have created a bash script to control the Orvibo (WiWo) S20 switches in domoticz. Making it much easier (and cleaner) to integrate these cheap wifi sockets.

I used the following bash script called "s20Command.sh" in the default bash folder of domoticz:

Code: Select all

#!/bin/bash
action=$1
mac=$2
ip=$3
reversedMac=${mac:10:1}${mac:11:1}${mac:8:1}${mac:9:1}${mac:6:1}${mac:7:1}${mac:4:1}${mac:5:1}${mac:2:1}${mac:3:1}${mac:0:1}${mac:1:1}

# Subscribe to the device:
echo '6864001e636c'$mac'202020202020'$reversedMac'202020202020' | xxd -r -p | nc -u -w1 -p10000 $ip 10000 | xxd -p

case $action in
off)
        # Switch Off
        echo '686400176463'$mac'2020202020200000000000' | xxd -r -p | nc -u -w1 -p10000 $ip 10000 | xxd -p
        ;;
on)
        # Switch On
        echo '686400176463'$mac'2020202020200000000001' | xxd -r -p | nc -u -w1 -p10000 $ip 10000 | xxd -p
        ;;
esac

exit;


For this to work you must know the MAC and IP address for the socket. There are multiple ways to do this of course, Fing on android is one of my favorites, look for "Hi-flying electronics technology" or "HF-LPB100".
I also fixed the IP given to the device (through my DHCP server).

In my case:
MAC = accf238d1fe2
IP = 192.168.0.175

Then I created a dummy switch and provided the following actions:
On Action: script://bash/s20Command.sh on accf238d1fe2 192.168.0.175
Off Action: script://bash/s20Command.sh off accf238d1fe2 192.168.0.175

Hope this works for others, I am glad to help if you run into problems.

p.s. There is a 1 second delay in the current command (nc -u -w1 ... ), I will try to eliminate this in the near future.
Should this script with with a Synology NAS runing domoticz? I've added the script in my scripts directory and added the commands with my S20's MAC and IP address, but didn't have any luck

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Posted: Sunday 28 August 2016 7:45
by MatthijsPH
I've had the same problem. Synology is not running bash but ash. I changed #! /bin/bash to #! /bin/sh but that didn't fix the problem.
I'm on a i5 running Ubuntu now so I stopped trying.

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Posted: Sunday 28 August 2016 20:15
by jsynxiii
Thanks for the response MatthijsPH. I've also tried using the franc-carter pearl script (https://github.com/franc-carter/bauhn-w ... r/bauhn.pl), but didn't have any luck there either. I've copied the script into the domoticz/scripts/ directory as "orvibos-20.pl" but can't get them to execute with the command "script://orvibos-s20.pl (MY MAC ADDRESS) on" or "script://orvibos-s20.pl (MY MAC ADDRESS) off". Any help would be appreciated.
Thanks,

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Posted: Wednesday 14 September 2016 22:51
by jumping
Hello,
I 've tried the franc-carter pearl script and the Mightyman bash script, but they don't work.
Maybe is there a new version of Orvibo S20?

bye

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Posted: Sunday 18 September 2016 11:29
by jumping
Hello,
now Orvibo script works well:
my WIFI range extender changes the Orvibo S20 MAC address, so now I use the correct MAC and the script is OK!!
bye

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Posted: Sunday 09 October 2016 19:38
by jsynxiii
jumping wrote:Hello,
now Orvibo script works well:
my WIFI range extender changes the Orvibo S20 MAC address, so now I use the correct MAC and the script is OK!!
bye

Jumping, which script did you use to get it to work?

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Posted: Monday 14 November 2016 20:22
by jumping
jsynxiii wrote:
jumping wrote:Hello,
now Orvibo script works well:
my WIFI range extender changes the Orvibo S20 MAC address, so now I use the correct MAC and the script is OK!!
bye

Jumping, which script did you use to get it to work?
the franc-carter pearl script, as I wrote the problem was the wifi range extender! bye