Plugwise xPL-PERL support
Plugwise xPL-PERL support
For those of you who do not have a subscription to the xpl-perl development mailinglist, I just released the first version of plugwise support for xpl-perl.
It is very basic, only switching on/off of circles is currently supported. Attached to this message is a .ZIP file containing a gzip-ed tar file with all files.
Make sure you are running the SVN version of xpl-perl, or it will not work!
Plugwise circles are recognized by a unique 'mac-address', consisting of 16 digits. Although the last 5 digits of the mac-address are printed on each module, I use 6-digits in the xpl-perl module (That is because the last 6 characters are unique to each circle, not the 5 digits that are printed on a circle!).
<b>Download Attachment:</b> [img]images/icon_paperclip.gif[/img] xpl-plugwise.zip<br />3.6KB
It is very basic, only switching on/off of circles is currently supported. Attached to this message is a .ZIP file containing a gzip-ed tar file with all files.
Make sure you are running the SVN version of xpl-perl, or it will not work!
Plugwise circles are recognized by a unique 'mac-address', consisting of 16 digits. Although the last 5 digits of the mac-address are printed on each module, I use 6-digits in the xpl-perl module (That is because the last 6 characters are unique to each circle, not the 5 digits that are printed on a circle!).
<b>Download Attachment:</b> [img]images/icon_paperclip.gif[/img] xpl-plugwise.zip<br />3.6KB
Plugwise xPL-PERL support
New version. Now also reads power info from a circle.
With the data that is provided by the xpl-perl plugwise plugin you should be able to calculate energyconsumption.
For more info on how to calculate energy consumption, have a look at this thread: http://www.domoticaforum.eu/topic.asp?T ... ge=2#13757
<b>Download Attachment:</b> [img]images/icon_paperclip.gif[/img] xplplugwise.zip<br />5.74 KB
With the data that is provided by the xpl-perl plugwise plugin you should be able to calculate energyconsumption.
For more info on how to calculate energy consumption, have a look at this thread: http://www.domoticaforum.eu/topic.asp?T ... ge=2#13757
<b>Download Attachment:</b> [img]images/icon_paperclip.gif[/img] xplplugwise.zip<br />5.74 KB
Plugwise xPL-PERL support
Hi Jfn,
first of all: thanks for the reference code for interfacing to the Plugwise circles!
I'm planning to buy a set of circles to control the amplifiers of the squeezebox audio players I have installed. Right now I do this manually, but it would be nice to automate this.
Can you please let me know if you can control the circles reliably through perl code, without need for the 'source' application of PlugWise? I assume this is OK, but I'd like to get some real user feedback as some of the reports (on GoT) are not so positive.
My plan would be to create a plugin for the SqueezeCenter software (this is the perl-based server that sends audio data to the Squeezeboxes). This plugin would send an xPL message to switch the circles on when the Squeezebox is enabled and vice versa.
Best regards,
Hollie.
first of all: thanks for the reference code for interfacing to the Plugwise circles!
I'm planning to buy a set of circles to control the amplifiers of the squeezebox audio players I have installed. Right now I do this manually, but it would be nice to automate this.
Can you please let me know if you can control the circles reliably through perl code, without need for the 'source' application of PlugWise? I assume this is OK, but I'd like to get some real user feedback as some of the reports (on GoT) are not so positive.
My plan would be to create a plugin for the SqueezeCenter software (this is the perl-based server that sends audio data to the Squeezeboxes). This plugin would send an xPL message to switch the circles on when the Squeezebox is enabled and vice versa.
Best regards,
Hollie.
Plugwise xPL-PERL support
Hi Jfn,
In the mean time I'm using your Plugwise Perl code to integrate circles with Misterhouse.
I have a bugfix in the status response routine and a suggestion for reporting state information I'd like to share with you.
Can I email you the diffs somewhere? It seems that I'm not able to send you an email through the forum before I create 50 posts here.
Best regards,
Lieven.
In the mean time I'm using your Plugwise Perl code to integrate circles with Misterhouse.
I have a bugfix in the status response routine and a suggestion for reporting state information I'd like to share with you.
Can I email you the diffs somewhere? It seems that I'm not able to send you an email through the forum before I create 50 posts here.
Best regards,
Lieven.
Plugwise xPL-PERL support
Hi Jfn,
until you have time to update your code package, I've made a patched version of your module available here:
http://code.google.com/p/hasy/source/br ... plplugwise
Changes include the bugfix for the status report that incorrectly reported the state of a circle, and an added field in the xpl-trig response message after an on/off command to ensure that every trig message includes an onoff statement.
It rocks: xpl-perl + your module + misterhouse = auto amplifier on when I enable my squeezebox!!
Best regards,
Lieven.
until you have time to update your code package, I've made a patched version of your module available here:
http://code.google.com/p/hasy/source/br ... plplugwise
Changes include the bugfix for the status report that incorrectly reported the state of a circle, and an added field in the xpl-trig response message after an on/off command to ensure that every trig message includes an onoff statement.
It rocks: xpl-perl + your module + misterhouse = auto amplifier on when I enable my squeezebox!!
Best regards,
Lieven.
Plugwise xPL-PERL support
I am really new to this.
How can i use this to read and send commands (on/off) via the terminal?
How can i use this to read and send commands (on/off) via the terminal?
Plugwise xPL-PERL support
Hi Niklas,
you can use this module to send commands form the terminal by first installing xpl-perl, and then adding the plugwise module to your xpl-perl install by copying the files in the package to the appropriate location on your system.
To use xPL messages, you then first need to start a hub application (xpl-hub in the xpl-perl package), then the plugwise application (xpl-plugwise). You can then call a script that sends an xPL message to turn a circle on or off. Such an example script is included in the xpl-plugwise package.
If this sounds a bit complicated, and if you are not using xPL for other applications in your system, you might be better off using the 'plugwise on linux' python script (just search through google). This script communicates directly through the Plugwise stick to control circles.
Hope this helps!
you can use this module to send commands form the terminal by first installing xpl-perl, and then adding the plugwise module to your xpl-perl install by copying the files in the package to the appropriate location on your system.
To use xPL messages, you then first need to start a hub application (xpl-hub in the xpl-perl package), then the plugwise application (xpl-plugwise). You can then call a script that sends an xPL message to turn a circle on or off. Such an example script is included in the xpl-plugwise package.
If this sounds a bit complicated, and if you are not using xPL for other applications in your system, you might be better off using the 'plugwise on linux' python script (just search through google). This script communicates directly through the Plugwise stick to control circles.
Hope this helps!
Re: Plugwise xPL-PERL support
Hello there,
I switched polling Plugwise (from Windows) to Linux using xpl-perl. I am using 35 circles.
Did you find a good strategy for polling ?
I mean, if I poll the status of all the circles, one by one, I might obtain all statuses in about 2 minutes.
If then I poll the energy (power info), i may wait another two minutes or so.
If I poll by packets of 4 or five, I may reduce the time to have a response from all circles.
If I add requests for power buffers, the time to obtain all information increases so I might expect ten minutes for each plug to deliver informations.
On the other hand, in windows I had almost instant response from status, powerinfo and power buffers.
More of it, after 20 hours of polling, the stick doesn't receive any information, I have to unplug it and plug in again.
I would like to know what is the Windows strategy of polling. One circle at a time, all of them and wait for a full answer ? With linux I may ask status for five circles at a time, but no more, because I never receive an answer from the sixth one.
Thank you for your answers/hints and best regards,
Radu
I switched polling Plugwise (from Windows) to Linux using xpl-perl. I am using 35 circles.
Did you find a good strategy for polling ?
I mean, if I poll the status of all the circles, one by one, I might obtain all statuses in about 2 minutes.
If then I poll the energy (power info), i may wait another two minutes or so.
If I poll by packets of 4 or five, I may reduce the time to have a response from all circles.
If I add requests for power buffers, the time to obtain all information increases so I might expect ten minutes for each plug to deliver informations.
On the other hand, in windows I had almost instant response from status, powerinfo and power buffers.
More of it, after 20 hours of polling, the stick doesn't receive any information, I have to unplug it and plug in again.
I would like to know what is the Windows strategy of polling. One circle at a time, all of them and wait for a full answer ? With linux I may ask status for five circles at a time, but no more, because I never receive an answer from the sixth one.
Thank you for your answers/hints and best regards,
Radu
RC
Re: Plugwise xPL-PERL support
Here I my thoughts on this/this is what I use in my own software:
I poll the circles every 5 seconds (this is the default value in Plugwise source) for both power and device information. This works fine for my circles (around 10 of them)
This is done in my code by adding a waitreply boolean variable, I set the variable to true upon sending the power request information (same for device information). Here is that part of my code:
Then after the command has been received, the waitreply value is set to false. So the next request can be sent, etc.
The power buffers in my software are fetched when there are new power buffers available.
This is a simple if statement, if the actual buffer number is bigger then the stored buffer number in the database, we have to fetch buffer information.
I think Plugwise source also has the same type of queue'ing mechanism like I use in my code.
If you have any question let me know.
I poll the circles every 5 seconds (this is the default value in Plugwise source) for both power and device information. This works fine for my circles (around 10 of them)
This is done in my code by adding a waitreply boolean variable, I set the variable to true upon sending the power request information (same for device information). Here is that part of my code:
Code: Select all
def sendcommand(self, command):
"""
Send's command to plugwise stick.
"""
if (self.waitreply == False or (datetime.datetime.now() - self.waitreplytime).seconds > 1):
self.waitreply = True
self.transport.write('\x05\x05\x03\x03' + command + self.crc16(command) \
+ '\x0d\x0a')
self.waitreplytime = datetime.datetime.now()
elif (self.waitreply == True):
self.reactor.callLater(0.010, self.sendcommand, command)
The power buffers in my software are fetched when there are new power buffers available.
This is a simple if statement, if the actual buffer number is bigger then the stored buffer number in the database, we have to fetch buffer information.
I think Plugwise source also has the same type of queue'ing mechanism like I use in my code.
If you have any question let me know.
Re: Plugwise xPL-PERL support
Mdamen, thank you for your answer
Since my post, the Stick died. It is not responsive any more. I contacted the Plugwise Helpdesk, but communication is very slow. I fear I have to send them the stick or the combination Stick, C+. In the windows source, it is checked, but no answer from circles.
Anyway, 35 powerinfo + 35 status poll never finished in less than two minutes (some "circles" answering more quickly than others)
Best regards, Radu
Since my post, the Stick died. It is not responsive any more. I contacted the Plugwise Helpdesk, but communication is very slow. I fear I have to send them the stick or the combination Stick, C+. In the windows source, it is checked, but no answer from circles.
Anyway, 35 powerinfo + 35 status poll never finished in less than two minutes (some "circles" answering more quickly than others)
Best regards, Radu
RC
Re: Plugwise xPL-PERL support
Hello,
I have developed an xPL interface towards the Plugwise hardware that is running firmware v2.37. It is based on the xpl-perl framework.
More info here: http://lika.be/wp/2011/07/plugwise-xpl- ... -firmware/
Best regards,
Hollie.
I have developed an xPL interface towards the Plugwise hardware that is running firmware v2.37. It is based on the xpl-perl framework.
More info here: http://lika.be/wp/2011/07/plugwise-xpl- ... -firmware/
Best regards,
Hollie.
Re: Plugwise xPL-PERL support
I dont seem to get the XPL perl thingy to work on the new sticks. THough i tested on some with firmware from 2009 aswell. And didnt work their either so suspect there is an error on my side. I can get python-plugwise to work on the old ones but not on the ones with latest firmware.
Is there any step by step manual to get it to work on debian/ubuntu? I dont seem to find anyone.
Anyways gonna try some more tonite on it. Need to get it to work. If not i got 34 useless circles...
Is there any step by step manual to get it to work on debian/ubuntu? I dont seem to find anyone.
Anyways gonna try some more tonite on it. Need to get it to work. If not i got 34 useless circles...

Re: Plugwise xPL-PERL support
Are you sure you loaded the latest firmware in the Stick and the Circles? If you connect to Source it should state '2011-05-13' in the firmware field of all your devices.
If you have old firmware then my plugwise interface will not be able to connect to the hardware. Plugwise changed the interface protocol from version 1 to version 2.x and I only support the latest firmware.
If you install the xpl-plugwise interface and run it with the '--verbose' option that you should see a diagnostic message that states the software could connect to the Stick. The you know the software can talk to the hardware.
If you have old firmware then my plugwise interface will not be able to connect to the hardware. Plugwise changed the interface protocol from version 1 to version 2.x and I only support the latest firmware.
If you install the xpl-plugwise interface and run it with the '--verbose' option that you should see a diagnostic message that states the software could connect to the Stick. The you know the software can talk to the hardware.
Re: Plugwise xPL-PERL support
I think i missed something brutal on the way
I got the latest firmware.
This is how i start it:
xpl-plugwise --plugwise-tty /dev/ttyUSB0 --ultraverbose
And it says:
and then i issue :
xpl-sender -c plugwise.basic -m xpl-cmnd command=listcircles -w 10 -v
and that one spits out:
Listening on xx.xxx.xxx.xxx:33365
Sending on xx.xxx.xxx.xxx
So probably something i have missunderstood totaly

I got the latest firmware.
This is how i start it:
xpl-plugwise --plugwise-tty /dev/ttyUSB0 --ultraverbose
And it says:
Code: Select all
------- end of device reader -------------------------------
Message queue is:
$VAR1 = undef;
Response queue is:
$VAR1 = undef;
Plugwise connected status is 0
UART RX buffer is now '0000000300C1'
Pointers: RD: 0
Awaiting_response: 0
++++++++++++++++++++++++++++++++++++++
Processing empty queue, returning...
Found frame 0000000300C1BA6E
- remaining: 00110003000D
------- end of device reader -------------------------------
Message queue is:
$VAR1 = {};
Response queue is:
$VAR1 = {
'3' => {
'received_ok' => 1,
'type' => undef
}
};
Plugwise connected status is 0
UART RX buffer is now '00110003000D'
Pointers: RD: 0
Awaiting_response: 0
++++++++++++++++++++++++++++++++++++++
Processing empty queue, returning...
Found frame 00110003000D6F00004697A80101640D6F0000469DC1A264FF12AE
- remaining:
------- end of device reader -------------------------------
Message queue is:
$VAR1 = {};
Response queue is:
$VAR1 = {};
Plugwise connected status is 1
UART RX buffer is now ''
Pointers: RD: 0
Awaiting_response: 0
++++++++++++++++++++++++++++++++++++++
Processing empty queue, returning...
xpl-sender -c plugwise.basic -m xpl-cmnd command=listcircles -w 10 -v
and that one spits out:
Listening on xx.xxx.xxx.xxx:33365
Sending on xx.xxx.xxx.xxx
So probably something i have missunderstood totaly

Re: Plugwise xPL-PERL support
Hello,
Cool, you're almost there as far as I can see
Maybe a note first, could you please provide example output with just the option --verbose instead of ultraverbose? The ultraverbose output is for debugging the xpl-plugwise code and the output is a bit ugly/not so readable.
What you see in the output log is the init request and the response from the stick. All seems to be fine what that is concerned.
If you don't get any extra logging from the xpl-plugwise client after you issued the xpl-sender command, then it means that the xpl message did not arrive at the xpl-plugwise client. Assuming you're executing the commands on the same computer, can you please assure that the xpl-hub is running? I find it useful to run both 'xpl-hub -verbose' and 'xpl-logger -v class=plugwise' next to each other to see what is going on at the level of the xPL network.
Good luck,
Lieven.
Cool, you're almost there as far as I can see

Maybe a note first, could you please provide example output with just the option --verbose instead of ultraverbose? The ultraverbose output is for debugging the xpl-plugwise code and the output is a bit ugly/not so readable.
What you see in the output log is the init request and the response from the stick. All seems to be fine what that is concerned.
If you don't get any extra logging from the xpl-plugwise client after you issued the xpl-sender command, then it means that the xpl message did not arrive at the xpl-plugwise client. Assuming you're executing the commands on the same computer, can you please assure that the xpl-hub is running? I find it useful to run both 'xpl-hub -verbose' and 'xpl-logger -v class=plugwise' next to each other to see what is going on at the level of the xPL network.
Good luck,
Lieven.