Release 303

26 replies [Last post]
brett
Offline
Providence, United States
Joined: 9 Jan 2010

Whats Changed

  • Support for the EDF current cost monitor
  • issue 31 - Graph web page did not handle multiple feeds
  • issue 32 - Plugboard not instance aware
  • issue 33 - bscmsg not instance aware
  • issue 36 - Support ID=0 when using xap-pachube as a service
  • Note on instance web page about unique MAC addresses
  • LUA frame:getValue() api call should be case agnostic

Thanks goes out to Karl for his code contributions to this release.

Brett

AlexS
Offline
United Kingdom
Joined: 5 Dec 2011
Yep EDF works

Cheers Brett

Ecomanager manager seems to work.Now have the tumble dryer on an IAM. 

£25 to monitor the Washing machine/ tumble dryer, Home theatre & my PCs. Cool.

Now if people stopped bidding the ECO managers up on eBAY I can drive the wife & family completely mad.

Have you seen this?

http://www.homeofthefuture.tv/

some interesting stuff and EON running a competition, maybe a way to get some publicity?

AlexS
Offline
United Kingdom
Joined: 5 Dec 2011
false start

ECO manager - it sorta works. I have  flat graphs on Pachube. It takes the first reading and repeats.

XAP messages show first reading.

what do you need? debug/ output raw data?

updated as I wasn't very specific.

have rebooted & hit with hammer.

g7pkf
Offline
United Kingdom
Joined: 11 Jan 2011
only certain feeds

Currentcost feeds are fine as are jeenodes.

 

1wire seem to be flatligning at one level.#

https://pachube.com/feeds/15114

 

 

Dean

BoxingOrange
Offline
United Kingdom
Joined: 11 Jun 2010
Any Other Changes?

Dean,

Are you seeing all the 1wire devices in the web GUI, try resetting the 1wire bus, or power off/on the HAH.  It looks like they went off at 12:47, did anything else change at around that time? Your alarm, hot water tank and pump also stopped at this time, could it be a cable issue?

g7pkf
Offline
United Kingdom
Joined: 11 Jan 2011
will try a power off/on when

will try a power off/on when i get home (might phone wife who will groan)  also noticed this

 

 

303/1.0

 

the 1.0 is worrying as i have a 328 chip on 3.4 (memory serves correctly)

I am not at home so nothing has changed, note to self do not upgrade firmware when not at home (250 miles away)

Dean

 

 

 

UPDATE.

 

power off/on resolved the issue.

BoxingOrange
Offline
United Kingdom
Joined: 11 Jun 2010
That's your problem.  The

That's your problem.  The 1wire is on the PCB, and the HAH software is no-longer talking to the PCB, that's why it shows "/1.0", a power reset might sort it out, but you need to get that resolved for the 1wire to work,

Karl

g7pkf
Offline
United Kingdom
Joined: 11 Jan 2011
Yep that fixed it

will be putting in a remote reboot system.

 

wife is not impressed.

 

Dean

brett
Offline
Providence, United States
Joined: 9 Jan 2010
What I need

I need time and I need an EDF currentcost meter.  Neither of those things I posses at the moment.  If you have the skills to troubleshoot the issue yourself that would be grand.   For starters run the daemon in debug mode and examine the output and see if anything obvious occurs to you.  Failing that you'd have to post up the output for me to look at but I can't promise that I'm ever going to get this fixed in the next couple of months.  I really don't have much time.

# killall xap-currentcost      <- shut any running process down first.
# xap-currentcost -s /dev/ttyUSBx -d 6     <- If level 6 is not detailed enough try 7

I believe Kevin9 has the EDF meter working using this code base.  Kevin can you confirm that?

Brett

martynw
Offline
Joined: 18 Feb 2012
Maybe quick to fix?

In looking at the data coming from the ecomanager, the xml is sometimes pretty cr*p!

From (briefly) looking at the source code in currentcost.c I think that what is happening is the SAX parser is failing when the xml is malformed e.g. in the following capture that contains the historic data there is no closing </msg>, opening <d18m02> closes with </d00m02> etc etc

<msg><src>EMC2-v1.79</src><date>18/02/2012</date><time>18:40:00</time><d18m02><kwh>0</kwh></d00m02><d19m02><kwh>0</kwh></d01m02><d20m02><kwh>0</kwh></d02m02><d21m02><kwh>0</kwh></d03m02><d22m02><kwh>0</kwh></d04m02>
<d23m02><kwh>0</kwh></d05m02><d24m02><kwh>0</kwh></d06m02><d25m02><kwh>0</kwh></d07m02><d26m02><kwh>0</kwh></d08m02><d27m02><kwh>0</kwh></d09m02><d28m02><kwh>0</kwh></d10m02><d01m03><kwh>0</kwh></d11m03><d02m03><kwh>0</kwh></d12m03><d
03m03><kwh>0</kwh></d13m03><d04m03><kwh>0</kwh></d14m03><d05m03><kwh>0</kwh></d15m03><d06m03><kwh>0</kwh></d16m03><d07m03><kwh>0</kwh></d17m03><d08m03><kwh>0</kwh></d18m03><d09m03><kwh>0</kwh></d19m03><d10m03><kwh>0</kwh></d20m03><d11
m03><kwh>0</kwh></d21m03><d12m03><kwh>0</kwh></d22m03><d13m03><kwh>0</kwh></d23m03><d14m03><kwh>0</kwh></d24m03><d15m03><kwh>0</kwh></d25m03><d16m03><kwh>0</kwh></d26m03><d17m03><kwh>0</kwh></d27m03><d18m03><kwh>0</kwh></d28m03><d19m0
3><kwh>0</kwh></d29m03><d20m03><kwh>0</kwh></d30m03><msg><src>EMC2-v1.79</src><date>18/02/2012</date><time>18:40:00</time><m02y12><kwh>0</kwh></m02y12><m02y12><kwh>0</kwh></m02y12><m02y12><kwh>0</kwh></m02y12><m02y12><kwh>0</kwh></m02
y12><m02y12><kwh>0</kwh></m02y12><m02y12><kwh>0</kwh></m02y12><m02y12><kwh>0</kwh></m02y12><m02y12><kwh>0</kwh></m02y12><m02y12><kwh>0</kwh></m02y12><m02y12><kwh>0</kwh></m02y12><m02y12><kwh>0</kwh></m02y12><m02y12><kwh>0</kwh></m02y1
2><msg><src>EMC2-v1.79</src><date>18/02/2012</date><time>18:41:00</time><sensor>S</sensor><id>0</id><type>1</type><ch01><watts>0</watts></ch01><ch02><watts>0</watts></ch02><ch03><watts>1</watts></ch03><ch04><watts>0</watts></ch04><ch0
5><watts>0</watts></ch05><ch06><watts>0</watts></ch06><ch07><watts>0</watts></ch07><ch08><watts>0</watts></ch08><ch09><watts>0</watts></ch09><ch10><watts>0</watts></ch10><ch11><watts>0</watts></ch11><ch12><watts>0</watts></ch12><ch13>
<watts>0</watts></ch13><ch14><watts>0</watts></ch14><chH><watts>0</watts></chH></msg>

The xml block we're interested in the above capture is actually well formed:

<msg><src>EMC2-v1.79</src><date>18/02/2012</date><time>18:41:00</time><sensor>S</sensor><id>0</id><type>1</type><ch01><watts>0</watts></ch01><ch02><watts>0</watts></ch02><ch03><watts>1</watts></ch03><ch04><watts>0</watts></ch04><ch0
5><watts>0</watts></ch05><ch06><watts>0</watts></ch06><ch07><watts>0</watts></ch07><ch08><watts>0</watts></ch08><ch09><watts>0</watts></ch09><ch10><watts>0</watts></ch10><ch11><watts>0</watts></ch11><ch12><watts>0</watts></ch12><ch13>
<watts>0</watts></ch13><ch14><watts>0</watts></ch14><chH><watts>0</watts></chH></msg>

But all the rubbish before it causes the parser to fail.

The logic in the source code in "serialInputHandler" looks for </msg> and then searches for <msg> from the start of the buffer, which then includes all the rubbish xml and passes it to "parseXml".

If the logic could be changed to "look for </msg> and then for the first <msg> working backwards" and then pass *just* that block of xml to "parseXml" I think it would solve the problem.

My knowledge of C is limited, so I've not been able to fix it myself (other than I added some warning, error and fatalError handlers for SAX) but in perl (for example) it would be relatively trivial to use a regex to grab just the section of xml that is needed.

Hope this helps!

 

M

brett
Offline
Providence, United States
Joined: 9 Jan 2010
Not well formed

How the f*** can the unit be transmitting non-well formed XML surely EDF can get this right?  really!?  Are you sure is not the way that you are viewing the data and somehow its getting truncated in places?   Are you getting this XML from debug in my currentcost code or directly from the unit?   Note my code has a buffer limit and will wrap on buffer overflow.

Bad XML - this would certainly cause the SAX parser to have a little bit of a hernia no wonder its not working for you.

The serial detection scanner is a bit screwy - what I shoud be doing is feeding the datastream from the serial port straight into the SAX parser and let it figure out the TAGS and where things should or should't start/end as it would get it right.  However I don't want to play around with that too much as its working for all the other units, even if its is a little ugly.

The only saving grace is that I'm not using a DOM parser because at this point it would be game over.   SAX handles messy XML much more elegantly.

Brett

martynw
Offline
Joined: 18 Feb 2012
Hi Brett,I've got 2 of the

Hi Brett,

I've got 2 of the ecomanager units, they both do the same :-( Not sure if it's bad programming on EDF / CurrentCost part, or something wrong with how they're squirting the data out over serial....

The capture above was direct from minicom - I noticed the data in the other thread about the ecomanager is the same.

I grabbed a debug capture from your app and attached it.  Note that I added an "errorSAX" handler so I could see the SAX parser throwing errors. 

You can see that when presented with the badly formed XML the SAX parser throws errors and therefore the "good" bit of the XML is never seen.

 

Martyn

AttachmentSize
debug.zip 82.51 KB
brett
Offline
Providence, United States
Joined: 9 Jan 2010
I see what you mean

Martyn,

That debug is just the business.  I wonder if this is a flow control issue with how the serial port is configured?  Not sure what minicom uses if anything.

What happens if you use something like Putty on your PC where you can specify the Flow Control?   Perhaps the unit has hardware flow control?  That would be a plus on my side as I could just enable it when I setup the serial port for an EDF device.  I do find these data overruns highly irregular even a BAD programmer would understand welformed XML you'd think!

Failing that I can put in a small state machine to watch for <msg> and reset the serial input buffer when it occurs.  In fact this might just be as easy anyway.  Let me look into that.

Brett

martynw
Offline
Joined: 18 Feb 2012
Hi Brett,I did try all sorts

Hi Brett,

I did try all sorts of combinations of flow control settings and such like on a PC but the captured xml was always malformed where the historic data is concerned...

Your idea of re-setting the input buffer gave me some inspiration and I came up with some (likely badly written) code that fixes things for me:

diff currentcost.c currentcost.c.old
402,406d401
< static void errorSAX(void *user_data, const char *msg, ...)
< {
<         debug("</%s>", msg);
< }
<
424,426d418
<       handler.warning = errorSAX;
<       handler.error = errorSAX;
<       handler.fatalError = errorSAX;
463,473d454
<
<                       if(strstr(serial_xml, "<msg>")) {
<                               debug("BOM");
<                               //reset serial_xml
<                               serial_cursor = 0;
<                               serial_xml[0] = 0;
<                               //set a new tag
<                               strcpy(serial_xml, "<xml>");
<                               serial_cursor = 5;
<                               debug("xmlmw1:%s", serial_xml);
<                       }
475,478c456
<                       char * found;
<                       found = strstr(serial_xml,"</msg>");
<
<                         if(found) {
---
>                         if(strstr(serial_xml,"</msg>")) {
480,486c458
<                               debug("xmlmw2:%s", serial_xml);
<                               //set new end tag
<                               strncpy(found, "</xml>", 6);
<                               debug("xmlmw3:%s", serial_xml);
<
<                                 if(strncmp(serial_xml,"<xml>",5) == 0) {
<                                       debug("FULL XML");
---
>                                 if(strncmp(serial_xml,"<msg>",5) == 0) {
491d462
<
496d466
<

 

I also attached the new currentcost.c file.

 

So far it seems to work well for me!

 

Martyn

AttachmentSize
currentcost.zip 5.65 KB
brett
Offline
Providence, United States
Joined: 9 Jan 2010
I have a better idea

All this string searching and string comparising is really HEAVY, even in my original implementation, so I 've replaced all this with TWO very simple FSM's that correctly handle the START and END tag conditions for a message.  This is MUCH nicer even for the CurrentCost and it handles the EDF crapness well too.

I've pushed this into a BETA so you can give this a spin before I go production with it - I've bench tested this code but I'd like to see it working for real  :)

Martyn grab the BETA build, and try that out - I've check the code into the SVN if you want to "svn update" and see it for yourself.

/etc_ro_fs/update-dev hah-beta.dbzoo.com

Brett

AlexS
Offline
United Kingdom
Joined: 5 Dec 2011
looks a lot better

Brett

Just grabbed the beta and my pachube graphs are now updating a treat!

https://pachube.com/feeds/41007

Thanks.

The local graph seems stuck but I guess thats just impatience? -yep impatience

Alex

martynw
Offline
Joined: 18 Feb 2012
all good here

Hi Brett,

I checked out the latest version, compiled and have it working - much more efficient than my feeble effort ;-)

 

Thanks,

 

Martyn

kevin9
Offline
Lincolnshire, United Kingdom
Joined: 24 May 2010
catching up....

"I believe Kevin9 has the EDF meter working using this code base.  Kevin can you confirm that?"

After the capture I sent you, I did run the beta for a short while, but my xap-livebox.ini became corrupt, so I reverted to standard release as I had to go away for a bit.

Clearly the edf xml is a mess, never seems to stop sending history, always seems to append the 'realtime'  message to the end of a history message, etc

Probably worth pointing out, for the record

The edf device does support an optional, extra cost, whole house transmitter/clamp, you can use a Currentcost one.

The edf device only supports a single clamp on  the whole house transmitter (3 on the Envi)

There is no on board temperature sensor on the eco manager

The edf IAMs (Individual Appliance Monitors) are different to the CC IAMs, are capable of switching on and off and do not use  the proprietry currentcost C2 protocol at all

The eco manager does not support the use of any of the currentcost development boards, or transmitters or mini transmitters ( other than the whole house one)

There are 14 IAM channels on the eco manager compared to 9 on the CC Envi

 

To me functionality of these devices are sufficiently different to suggest that having interfaces for both on the HAH would be useful.

The similarities of the xml interfaces means this could be an easy "win". 

For example I could see that it would be useful to have an EDF IAM on the TV's and media centres etc, so I could monitor the consumption and switch them off. On the other hand, I would like to be able to monitor the consumption of my fridge and freezer but would not want  there to be any possibility of them being turned off inadvertantly.

Any volunteers for decoding the RF commands to the edf IAMs?

kevin9

AlexS
Offline
United Kingdom
Joined: 5 Dec 2011
Its very cool.

I was blown away by the holy grail of energy management switching off sockets & measuring them as well. Having a cool interface like HAH with XAP flash  (which I had already bought) as well was the icing.

£50 later and I have 6 EDF IAMs and 2 displays, gotta love eBay.

Mine seems to be working fine now, apart from the rather poor rf range. I think this weekend a tear down is called for and making the controllers arial a bit meatier. Derek & Co would you mind if I leant on you for advice?

Agree with Kevin multiple Current cost devices on HAH would be really useful. I have already allocated most of the 14 channels mentally.  Would like to put the read only stuff on the CC128.

Agree would love to see a C2 TX, however from what I have read on a few blogs Currentcost don't seem that keen on people developing it publicly. Maybe worth running it past them first?

 

Thanks Kevin - that info was really useful, came to the same conclusion last night about needing measurement only.

The EDF IAM's I have are labelled as

Model=IAM

manufacturer=Current Cost ltd

serial numbers =IAM0076827a - 29a etc.

So not sure if its a lack of the EDF manager that stops them being switchable or the Current cost supplied ones are truly different?

Or is it only the MK1 IAMs that are read only? They did one with an external arial according to some of their press releases. They have announced a new on off controller so maybe the EDF ones are MKII IAMs and Current cost will be supplying those from now on? In which case I need to get on eBay/Amazon.

Ordered another transmitter tonight for the oven & hob. Now I won't just moan about the tumble dryer I can winge about the cooker as well! Should make me popular not much in the way of WAF.

I was originally thinking I would need to buy normal transmitters and create breakout plugs but if the current cost IAM's can be set measure only then the Freezer & fridge are getting those. I can take my 1 wire on/off sensors out or use them just for lights/ fans.

derek
Offline
Glasgow, United Kingdom
Joined: 26 Oct 2009
Antenna boost

I found that moving from the '6.48" piece of wire' antenna to an external magmount unit made a big diffference. As much as anything else, it is a load easier to experiment with various antenna positions.

I currently use the one that is in the shop & can reliably control an RF socket in my garage (external to the house).

RF is such a fickle thing .. lots of variables to play with. Best to allow time to experiment.

Cheers,
Derek. 

kevin9
Offline
Lincolnshire, United Kingdom
Joined: 24 May 2010
EDF Ecomanager, EDF IAM's/RF Plugs CC IAMS

AlexS

As Derek says, RF range with module like these can be problematic and depends very much on your environment. Certainly adding an aerial to the head unit is a viable way of improving things. I have done much as Derek suggested with a CC128 Envi, the only difffernce is the type of plug I used:-

http://www.flickr.com/photos/netcompsys/sets/72157625058490399/

I have done a similar mod on my weather station with success

The original CC IAMs did have an 'aerial' as seen here

http://www.flickr.com/photos/netcompsys/sets/72157625168084766/

The IAMs were a long time announced so I made my own from Mini transmitters

http://www.flickr.com/photos/netcompsys/sets/72157624901424769/

and

http://www.flickr.com/photos/netcompsys/sets/72157624985430957/

but don't be fooled by the smart looking aerial in any of these devices, it is just the wire inside a plastic tube!

I would not advise modifying the IAM itself, for safety and insurance reaons

I still think there is a place for using mini transmitters in place of IAMS on those high current items like hobs and cookers. Not sure I want to trust these things to an in line device made in china even if they are rated to 16A

From my brief dialog with CC tech support

CC IAMS use the C2 protocol, are purchaseable from CC, are incapable of switching and are not compatible with the EDF Eco manager

EDF IAMS do not use the C2 protocol at all , are not purchasable from CC who made them for EDF, you buy them from EDF and they are not comptible with the Envi etc

The newer CC IAMs use the same molding as the EDF IAMs, that is all

The C2 protocol will only be released to partners under non disclosure agreements

Since the Ecomanager and its IAMs do not use C2 then it should be possible to decode the commands sent to switch the plugs. I have read somewhere that the RF module in the EcoManager is an RFM12B variant

Could you pass on the link to the announcement of the CC on/off controller?

HTH

kevint

AlexS
Offline
United Kingdom
Joined: 5 Dec 2011
Thanks Kevin.So the CC IAMs

Thanks Kevin.

So the CC IAMs are non switchable. Thats where some of this months 'given up the smokes' cash goes! Freezer & Fridge.

announcement:

http://www.ceesquared.com/?p=118

http://www.ceesquared.com/?m=201201

 

and a picture, Looks actually quite stylish, might even get that into the lounge if SWMBO agrees.

http://www.currentcost.com/media-centre-downloads/catalogue.php

From the looks of that switchable IAM's are coming.

 

Agree no playing with the IAM. I have a Trec & transmitter coming for the hob - ebay again. 

Kevin & Derek cheers for the Aerial modification, Look forward to a 'Franken ECO Manager' variant.

 

I found this today, RC switch coding for Kilk un Klak looks interesting.

http://code.google.com/p/rc-switch/wiki/KnowHow_LineCoding

and it sort of provides a raw output.

http://code.google.com/p/rc-switch/source/browse/trunk/examples/ReceiveDemo/ReceiveDemo.pde

On Ken Sheriffs Blog IR & Arduino.

http://www.arcfn.com/2009/08/multi-protocol-infrared-remote-library.html

One of his users came up with this:

http://sui77.wordpress.com/2011/05/27/use-any-arduino-pin-for-transmission-with-the-irremote-libary-by-soft-pwm/

 

 

right bed now, watched Rising Sun - again!

 

 

Thanks Alex

kevin9
Offline
Lincolnshire, United Kingdom
Joined: 24 May 2010
"From the looks of that

"From the looks of that switchable IAM's are coming"

On past performance (IAM's and Optismart) it takes 12 months plus for CC to get from published artwork to available product, so don't hold your breath!

Of course you probably  know the Trec has no RJ45, so no serial output, but also that you can sync transmitters/mini-transmitters/dev boards and IAMS (all of the CC variety as opposed to EDF) to multiple receivers at the same time. After a bit it can get confusing if you don't keep track of what is where though unless you write it down.

kevint

AlexS
Offline
United Kingdom
Joined: 5 Dec 2011
Some more
AlexS
Offline
United Kingdom
Joined: 5 Dec 2011
Ah yes the more I read, the

Ah yes the more I read, the more I realise they are a marketing led company. 

Now if only they did a Bridge with XAP or similar. Keeps the C2 protocol private but gives them a way to keep us happy.

Maybe we should ask?

 

The Trec has the option of daisy chain CT's I can use it to sense Hob/oven.

The display will be popped in the Hallway on the wall and show top 9 offenders.

So it ticks 2 boxes! For less than 1 transmitter.

kevin9
Offline
Lincolnshire, United Kingdom
Joined: 24 May 2010
"Pictures of shiny new EMC/c2

"Pictures of shiny new EMC/c2 Touch

http://hotzone.org.uk/edf-ecomanager/"

Of course, the top picture is of the Eco Manager, then the EDF IAM

the EMC/c2 device circled was only in public in limited numbers and was withdrawn, at about the same time as the early edf IAMs were recalled after a few went up in smoke. Stuarts post is dated September 2010

BTW the xAP Bridge for currentcost is otherwise called the HAH lIvebox(!) no point asking about opening up the C2 protocol, plenty have asked but are refused or just ignored

On the daisy chain clamps to a single transmitter, they show up as one value on the display but are available as 3 vaules in the xml. When the transmitter is linked to an Envi channel it also reports 3 values in the xml but i don't know if the HAH parser supports this confiuration

If you check out my Flickr Photostream you will see a series of Photo Sets covering CC device unboxing, teardowns, comparisons of different devices, mods (handheld battery aerial), devboards, IAMs, Pseudo IAM's, appliance monitoring, etc.  Ecomanager photos will probably be next

http://www.flickr.com/photos/netcompsys/sets/  and

http://www.flickr.com/photos/netcompsys/sets/?&page=2

kevint

AlexS
Offline
United Kingdom
Joined: 5 Dec 2011
Have you seen this ? EDF ECO receive code..
Hardware Info