Code for Energenie LAN Powerstrip

Moderator: leecollings

Post Reply
whiteduck
Posts: 44
Joined: Tuesday 25 March 2014 23:20
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Berkshire, UK
Contact:

Code for Energenie LAN Powerstrip

Post by whiteduck »

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 16.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

Re: Code for Energenie LAN Powerstrip

Post by SweetPants »

UK only?
whiteduck
Posts: 44
Joined: Tuesday 25 March 2014 23:20
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Berkshire, UK
Contact:

Re: Code for Energenie LAN Powerstrip

Post by whiteduck »

No seen EU devices also… http://energenie.com/item.aspx?id=7557
Domoticz on Ubuntu 16.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

Re: Code for Energenie LAN Powerstrip

Post by SweetPants »

whiteduck wrote:No seen EU devices also… http://energenie.com/item.aspx?id=7557
Great, I ordered one, arrives in 2-3 days
whiteduck
Posts: 44
Joined: Tuesday 25 March 2014 23:20
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Berkshire, UK
Contact:

Re: Code for Energenie LAN Powerstrip

Post by whiteduck »

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 16.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

Re: Code for Energenie LAN Powerstrip

Post by SweetPants »

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.
whiteduck
Posts: 44
Joined: Tuesday 25 March 2014 23:20
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Berkshire, UK
Contact:

Re: Code for Energenie LAN Powerstrip

Post by whiteduck »

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 16.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: 44
Joined: Tuesday 25 March 2014 23:20
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Berkshire, UK
Contact:

Re: Code for Energenie LAN Powerstrip

Post by whiteduck »

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 16.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

Re: Code for Energenie LAN Powerstrip

Post by SweetPants »

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
SweetPants

Re: Code for Energenie LAN Powerstrip

Post by SweetPants »

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.
JohnS
Posts: 4
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 »

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 / ODroid
Domoticz version: 4.10717
Location: Berlin
Contact:

Re: Code for Energenie LAN Powerstrip

Post by FxWork »

Great, it works very well.

Thanks 4 that
Raspberry Pi 3B+
Z-Wave Aeon Stick 2
RfxTrx433
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest