Orvibo S20 plugs integrated successfully into Domoticz!

Moderator: leecollings

pluggin
Posts: 45
Joined: Tuesday 26 May 2015 22:49
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Argentina
Contact:

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Post 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
Razberry + 4 Eversrping HSM02 + 2 Aeotec Multi-Sensor + 1 Aeotec Micro Dimmer + 4 Aeotec Micro Smart Energy Switch, 2nd + 1 Remotec ZXT-120 + 1 Aeotec Smart Energy Monitor + 1 Everspring SE812 indoor Siren + 2 fibaro motion sensor + Aeotec water sensor
Antikton
Posts: 10
Joined: Saturday 26 September 2015 16:33
Target OS: Windows
Domoticz version:
Location: Spain
Contact:

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Post 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.
490123
Posts: 5
Joined: Sunday 25 October 2015 13:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Post 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?
Antikton
Posts: 10
Joined: Saturday 26 September 2015 16:33
Target OS: Windows
Domoticz version:
Location: Spain
Contact:

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Post by Antikton »

And the two sockets you do not see... works fine with the app?
I think it is a wifi related problem.
490123
Posts: 5
Joined: Sunday 25 October 2015 13:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Post 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?
Mightyman
Posts: 2
Joined: Sunday 20 December 2015 15:20
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Post 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.
MatthijsPH
Posts: 15
Joined: Friday 01 May 2015 19:27
Target OS: Linux
Domoticz version: 3.5305
Location: The Netherlands
Contact:

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Post 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.
rtna
Posts: 17
Joined: Monday 06 April 2015 12:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Post 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.
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Post 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
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Post 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
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Post 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.
Last edited by woody4165 on Thursday 28 April 2016 13:38, edited 1 time in total.
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Post 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
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat
wuffer
Posts: 22
Joined: Friday 03 June 2016 18:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Post 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?
jsynxiii
Posts: 3
Joined: Sunday 21 August 2016 21:49
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Post 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
MatthijsPH
Posts: 15
Joined: Friday 01 May 2015 19:27
Target OS: Linux
Domoticz version: 3.5305
Location: The Netherlands
Contact:

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Post 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.
jsynxiii
Posts: 3
Joined: Sunday 21 August 2016 21:49
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Post 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,
jumping
Posts: 14
Joined: Tuesday 19 July 2016 14:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.9227
Location: Italy
Contact:

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Post 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
Domoticz + Mysensors 2.0 ESP8266 GW + RFlink + Philips Hue 2.0 + Netatmo Thermostat
jumping
Posts: 14
Joined: Tuesday 19 July 2016 14:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.9227
Location: Italy
Contact:

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Post 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
Domoticz + Mysensors 2.0 ESP8266 GW + RFlink + Philips Hue 2.0 + Netatmo Thermostat
jsynxiii
Posts: 3
Joined: Sunday 21 August 2016 21:49
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Post 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?
jumping
Posts: 14
Joined: Tuesday 19 July 2016 14:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.9227
Location: Italy
Contact:

Re: Orvibo S20 plugs integrated successfully into Domoticz!

Post 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
Domoticz + Mysensors 2.0 ESP8266 GW + RFlink + Philips Hue 2.0 + Netatmo Thermostat
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests