Code for Energenie LAN Powerstrip

Post Reply
whiteduck
Posts: 97
Joined: Wednesday 26 March 2014 0:20
Target OS: Raspberry Pi
Domoticz version:
Location: Berkshire, UK
Contact:

Code for Energenie LAN Powerstrip

Post by whiteduck » Sunday 30 March 2014 22:01

All,

Not implemented this yet but wanted to share something that could be useful:
https://energenie4u.co.uk/index.php/cat ... ct/ENER019

Found it cheapest at:
http://www.hitari.co.uk/energenie-lan-p ... ystem.html

You don't need this if you have RFXCom as I've seen elsewhere on this forum that you can control a cheaper unit via 433MHz RF.

However to control over the LAN from Linux the HOWTO states:
To login:

Code: Select all

$ wget --post-data 'pw=smartlab' 'http://nn.nn.nn.nn/login.html' -O foo.html --delete-after
To switch Socket3 ON:

Code: Select all

$ wget --post-data 'cte1=&cte2=&cte3=1&cte4=' 'http://nn.nn.nn.nn' -O foo.html --delete-after
To switch Socket3 OFF:

Code: Select all

$ wget --post-data 'cte1=&cte2=&cte3=0&cte4=' 'http://nn.nn.nn.nn' -O foo.html --delete-after
To logout:

Code: Select all

$ wget 'http://nn.nn.nn.nn/login.html' -O foo.html –-delete-after
Best regards
Ian
Last edited by whiteduck on Saturday 05 April 2014 17:56, edited 1 time in total.
Domoticz on Ubuntu 14.04 LTS VM
RFXCom USB transceiver
Aeon Labs V2 USB (Zwave)
Various HomeEasy, Oregon devices and sensors. Now using Z-Wave Fibaro FGMS-001, TKB TZ88Es
TP-Link IP310 Cameras

SweetPants
Posts: 2251
Joined: Friday 12 July 2013 21:24
Target OS: Linux
Domoticz version: V4.9999
Location: The Netherlands
Contact:

Re: Code for Energenie LAN Powerstrip

Post by SweetPants » Monday 31 March 2014 16:56

UK only?
Ubuntu 16.04.3 LTS, Intel NUC, MySensors 2.3.0-alpha, Pro Mini 3.3/8M RFM69(HW), ESP8266 (SDK2.2.0), Sonoff, RFLink, RFXcom, MQTT, NodeRed, Domoticz Beta (from source)

whiteduck
Posts: 97
Joined: Wednesday 26 March 2014 0:20
Target OS: Raspberry Pi
Domoticz version:
Location: Berkshire, UK
Contact:

Re: Code for Energenie LAN Powerstrip

Post by whiteduck » Monday 31 March 2014 23:59

No seen EU devices also… http://energenie.com/item.aspx?id=7557
Domoticz on Ubuntu 14.04 LTS VM
RFXCom USB transceiver
Aeon Labs V2 USB (Zwave)
Various HomeEasy, Oregon devices and sensors. Now using Z-Wave Fibaro FGMS-001, TKB TZ88Es
TP-Link IP310 Cameras

SweetPants
Posts: 2251
Joined: Friday 12 July 2013 21:24
Target OS: Linux
Domoticz version: V4.9999
Location: The Netherlands
Contact:

Re: Code for Energenie LAN Powerstrip

Post by SweetPants » Wednesday 02 April 2014 18:49

whiteduck wrote:No seen EU devices also… http://energenie.com/item.aspx?id=7557
Great, I ordered one, arrives in 2-3 days
Ubuntu 16.04.3 LTS, Intel NUC, MySensors 2.3.0-alpha, Pro Mini 3.3/8M RFM69(HW), ESP8266 (SDK2.2.0), Sonoff, RFLink, RFXcom, MQTT, NodeRed, Domoticz Beta (from source)

whiteduck
Posts: 97
Joined: Wednesday 26 March 2014 0:20
Target OS: Raspberry Pi
Domoticz version:
Location: Berkshire, UK
Contact:

Re: Code for Energenie LAN Powerstrip

Post by whiteduck » Saturday 05 April 2014 14:19

Cool - let me know how you get on. I guess we should also poll the device to ensure Domoticz shows current status.
Domoticz on Ubuntu 14.04 LTS VM
RFXCom USB transceiver
Aeon Labs V2 USB (Zwave)
Various HomeEasy, Oregon devices and sensors. Now using Z-Wave Fibaro FGMS-001, TKB TZ88Es
TP-Link IP310 Cameras

SweetPants
Posts: 2251
Joined: Friday 12 July 2013 21:24
Target OS: Linux
Domoticz version: V4.9999
Location: The Netherlands
Contact:

Re: Code for Energenie LAN Powerstrip

Post by SweetPants » Saturday 05 April 2014 16:10

Damn, received the LAN Powerstrip unit today, but it does not show any signs of live on the LAN interface. it looks like it is DOA. Will ask for a new one next week.
Ubuntu 16.04.3 LTS, Intel NUC, MySensors 2.3.0-alpha, Pro Mini 3.3/8M RFM69(HW), ESP8266 (SDK2.2.0), Sonoff, RFLink, RFXcom, MQTT, NodeRed, Domoticz Beta (from source)

whiteduck
Posts: 97
Joined: Wednesday 26 March 2014 0:20
Target OS: Raspberry Pi
Domoticz version:
Location: Berkshire, UK
Contact:

Re: Code for Energenie LAN Powerstrip

Post by whiteduck » Saturday 05 April 2014 17:39

Did you try resetting it - also may be the cable as the RJ45 is quite tight on this one - needs a straight through cable.
Domoticz on Ubuntu 14.04 LTS VM
RFXCom USB transceiver
Aeon Labs V2 USB (Zwave)
Various HomeEasy, Oregon devices and sensors. Now using Z-Wave Fibaro FGMS-001, TKB TZ88Es
TP-Link IP310 Cameras

whiteduck
Posts: 97
Joined: Wednesday 26 March 2014 0:20
Target OS: Raspberry Pi
Domoticz version:
Location: Berkshire, UK
Contact:

Re: Code for Energenie LAN Powerstrip

Post by whiteduck » Saturday 05 April 2014 17:51

I have written a (basic) Bash script to control this - feel free to use and modify at your own risk :)
Note: I assume wget is in default path and do no error checks...

Firstly you need to define 4 dummy switches in Domoticz. I called mine Ener1,2,3,4
I then have four lua scripts - ener1,2,3,4 - the example below is for the first - just change the parameters for 2,3,4 - but I guess you could use a single script.

I put my installation under /root so modify this for your own setup.

script_device_ener1.lua

Code: Select all

commandArray = {}
if (devicechanged['Ener1'] == 'On') then
	os.execute('/root/domoticz/scripts/energenie 1 on')
end
if (devicechanged['Ener1'] == 'Off') then
	os.execute('/root/domoticz/scripts/energenie 1 off')
end
return commandArray
Then the Bash code looks like this - note this doesn't do any error checking!

Code: Select all

#!/bin/bash
exec > /dev/null 2>&1 # Redirect all output to null

IP=192.168.0.254
URL=http://$IP
SOCK=$1
CMD=$2
PASS=yourpass

if [ "$CMD" = "on" ]
then
 ACTION=1
else
 ACTION=0
fi

# Login first
wget --post-data pw=$PASS $URL/login.html -O foo.html --delete-after

# Send command
case $SOCK in
 "1" ) wget --post-data "cte1=$ACTION&cte2=&cte3=&cte4=" $URL -O foo.html --delete-after ;;
 "2" ) wget --post-data "cte1=&cte2=$ACTION&cte3=&cte4=" $URL -O foo.html --delete-after ;;
 "3" ) wget --post-data "cte1=&cte2=&cte3=$ACTION&cte4=" $URL -O foo.html --delete-after ;;
 "4" ) wget --post-data "cte1=&cte2=&cte3=&cte4=$ACTION" $URL -O foo.html --delete-after ;;
esac

# Logout
wget ${URL}/login.html -O foo.html --delete-after

exit 0;
Something to do would be to check the status of the sockets and update Domoticz if something else changes them to on or off.

Good luck!
Domoticz on Ubuntu 14.04 LTS VM
RFXCom USB transceiver
Aeon Labs V2 USB (Zwave)
Various HomeEasy, Oregon devices and sensors. Now using Z-Wave Fibaro FGMS-001, TKB TZ88Es
TP-Link IP310 Cameras

SweetPants
Posts: 2251
Joined: Friday 12 July 2013 21:24
Target OS: Linux
Domoticz version: V4.9999
Location: The Netherlands
Contact:

Re: Code for Energenie LAN Powerstrip

Post by SweetPants » Monday 28 April 2014 16:45

whiteduck wrote:Did you try resetting it - also may be the cable as the RJ45 is quite tight on this one - needs a straight through cable.
It was broken, received another one today. This one is working
Ubuntu 16.04.3 LTS, Intel NUC, MySensors 2.3.0-alpha, Pro Mini 3.3/8M RFM69(HW), ESP8266 (SDK2.2.0), Sonoff, RFLink, RFXcom, MQTT, NodeRed, Domoticz Beta (from source)

SweetPants
Posts: 2251
Joined: Friday 12 July 2013 21:24
Target OS: Linux
Domoticz version: V4.9999
Location: The Netherlands
Contact:

Re: Code for Energenie LAN Powerstrip

Post by SweetPants » Monday 28 April 2014 17:04

whiteduck wrote:I have written a (basic) Bash script to control this - feel free to use and modify at your own risk :)
Great, this works fine for now, thanks.
Ubuntu 16.04.3 LTS, Intel NUC, MySensors 2.3.0-alpha, Pro Mini 3.3/8M RFM69(HW), ESP8266 (SDK2.2.0), Sonoff, RFLink, RFXcom, MQTT, NodeRed, Domoticz Beta (from source)

JohnS
Posts: 24
Joined: Friday 12 July 2013 19:37
Target OS: -
Domoticz version:
Location: High Wycombe, UK
Contact:

Re: Code for Energenie LAN Powerstrip

Post by JohnS » Thursday 26 November 2015 22:54

My system runs on a Raspberry Pi 2. I have one of these Energenie LAN controlled adapters and here is another way of controlling it in Linux, using a utility I found.

1. Download and install the egctl utility written by unterwulf

Code: Select all

cd ~
git clone https://github.com/unterwulf/egctl.git
cd egctl
make
sudo make install
2. Create the config file:

Code: Select all

sudo nano /etc/egtab
enter one line for each device you have, in the format
devicename protocol ipaddress port password
for example:

Code: Select all

4way pms21 192.168.1.56 5000 pa55w0rd
Now ctrl-X and write the file.

3. Check it works

Code: Select all

egctl devicename

The response will indicate the current status of the switches

4. Using in Domoticz

You must always provide instructions for each of the switches 1 to 4
on = turn switch on regardless
off = turn switch off regardless
left = leave switch as is
toggle = change switch to the opposite state

eg: egctl 4way on off on toggle

In domoticz, create a dummy hardware device.
Create a dummy switch
In the "on action" or "off action" fields enter for example

Code: Select all

script:///home/pi/egctl/egctl 4way on left left left
Hope that helps!

FxWork
Posts: 2
Joined: Friday 29 August 2014 8:28
Target OS: Raspberry Pi
Domoticz version: 3.5877
Location: Berlin
Contact:

Re: Code for Energenie LAN Powerstrip

Post by FxWork » Tuesday 17 January 2017 13:18

Great, it works very well.

Thanks 4 that

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests