David Morris – brassedoff.net

Family outings, Geographing, Linux, Java, RC boats, work…

Currentcost energy monitoring – SQL tweaks

Filed under: computer — david at 12:59 pm on Saturday, November 7, 2009

Conscious as I have been for a while that I’ve been collecting a lot of records in my CurrentCost energy log table, I thought I’d better do something to tidy it up a bit as I had a bit of spare time this morning.

A quick check showed a gnats over 1.4million records in the log file (one record every six seconds since July) so something needed to be done! My collector script doesn’t add the per-record cost to the data, so I have to run a quick query first to update the ’slice_cost’:

update energy_user set slice_cost = watts * 0.0016667 / 100 * 0.175

(yes, I know I should cancel some of the zeroes out)

I wanted a table summarised by hour showing total watts and cost per hour. My base table is this:

mysql> describe energy_use;
+-------------+----------+------+-----+---------------------+-------+
| Field       | Type     | Null | Key | Default             | Extra |
+-------------+----------+------+-----+---------------------+-------+
| recordtime  | datetime | NO   | PRI | 0000-00-00 00:00:00 |       |
| temperature | float    | YES  |     | NULL                |       |
| watts       | int(11)  | YES  |     | NULL                |       |
| slice_cost  | double   | YES  |     | NULL                |       |
+-------------+----------+------+-----+---------------------+-------+
4 rows in set (0.00 sec)

I’m not really interested in temperature, so I wanted this for a summary table…

mysql> describe total_energy;
+-------------+---------+------+-----+---------+-------+
| Field       | Type    | Null | Key | Default | Extra |
+-------------+---------+------+-----+---------+-------+
| rdate       | date    | YES  |     | NULL    |       |
| rhour       | int(11) | YES  |     | NULL    |       |
| total_watts | int(11) | YES  |     | NULL    |       |
| total_cost  | double  | YES  |     | NULL    |       |
+-------------+---------+------+-----+---------+-------+
4 rows in set (0.00 sec)

Now let me point out here, I’m not an SQL expert by any stretch of the imagination, so forgive me if this is obvious to some people. An aggregate query on the energy_use table would give me the summarised data I wanted, and wrapping that up with an insert query would summarise and build the total_energy table in one fell swoop:

insert into total_energy (rdate, rhour, total_watts, total_cost)
 select  date(recordtime) as rdate, hour(recordtime) as rhour,
  sum(watts) as total_watts, sum(slice_cost) as total_cost
  from energy_use
  group by date(recordtime),hour(recordtime);

…which appears to do the job quite nicely.

All I have to do now is decide how much data I want toremove from the detail table. Realistically, I don’t need anything before October now I have a summary table, so

delete from energy_use where date(recordtime) < '2009-10-01'

…which removed 989000 records (or thereabouts).

Next job is to write some graphs to display the cost profiles…

Music editing and printing

Filed under: Uncategorized — david at 10:49 am on Saturday, October 24, 2009

Ok, so I’ve got Rosegarden working now and I can play back the music I’ve entered using a soft synthesizer (QSynth) and everything’s working just fine.

I’ve spent a few minutes knocking together a quick two-part arrangement of a Christmas Carol for Dan and myself to play for the Santa  Publicity Day in Retford (there’ll be more, but I have to start somewhere!).

Rosegarden will happily create a multi-line score, but it’s not Dan-friendly. Fortunately, Rosegarden will export Lilypond files. Lilypond is a GNU command-line application for music typesetting and will spit its output out in PDF or postscript format.

So, a few key presses later and this is the result:

O Little Town

Rosegarden should be able to preview and print direct using Lilypond, but for some reason, it isn’t. Not the end of the world because I just exported the file in Lilypond format and processed it on the command line:

david@server:~/Documents/Music> lilypond –pdf Little-Town-1.ly  Little-Town-2.ly

(I had two files to process – one for each part and could combine them on the same command line).

So, concept to hard copy music and not a commercial pay-for bit of software in the loop anywhere.

Rosegarden in full flow

All is fine in the rose garden

Filed under: music, technology — david at 8:13 am on Friday, October 23, 2009

One of the bits of software I’ve never managed to get going on myLinux machine is the music editing and sequencing software, Rosegarden. I’ve been using Linux for years but never managed to crack  this goal… until today.

I was cruising the blogosphere earlier in the week looking for inspiration.  I’ve got some two part Christmas carol arrangements to do for Daniel and myself and I was faced with having to switch the Windows box on for the first time in a couple of months (yes, it’s been that long) and use Sibelius when I found the answer.

What I needed was a soft synthesizer and to pipe the midi output from Rosegarden in to that. It was all so blindingly obvious. I’d been barking up completely the wrong tree trying to get jack working properly.

Into Yast, install QSynth, follow a few simple instructions here and we were nearly off and cooking. the little green light on the QSynth tab was flashing to show that things were happening. The volume was turned up, but something was still missing…

Ah. Soundfonts.

Back to Yast, install the soundfont, a few program restarts and Rosegarden was alive, alive I tell you.

Yet another reason not to turn the Windows machine on at home. Can I think of any more?

If  there was a Linux or Mac port of Rail simulator now…

A little something for the winter, Sir?

Filed under: gardening — david at 7:32 pm on Wednesday, October 14, 2009

chillis We’ve not had an awful lot of produce out of the garden this year, but we have had a good crop of chillis of various varieties.

They’ve been dried by hanging them in the kitchen then these have had a blast in the airing cupboard. Consequently, these rattle and there’s absolutely no moisture in them so they should keep for months.

Time for a bit of phishing

Filed under: computer — david at 10:51 am on Tuesday, October 13, 2009

One of our French users received an email regarding a tax issue with the UK tax authorities (HMRC). The URL started off ok, but turned out to be a little nasty:

(Please don’t click it)

http://online.hmrc.gov.uk.nyyyyase.com/SecurityWebApp/httpsmode/statement.php?{other id stuff redacted}

nyyyyase.com turns out to be a cluster of machines

dmlinux2:/home/david # host nyyyyase.com
nyyyyase.com has address 222.113.210.163
nyyyyase.com has address 61.73.96.212
nyyyyase.com has address 67.164.7.67
nyyyyase.com has address 79.175.103.228
nyyyyase.com has address 83.4.187.5
nyyyyase.com has address 89.134.5.8
nyyyyase.com has address 93.172.209.217
nyyyyase.com has address 110.13.183.155
nyyyyase.com has address 114.180.190.76

nyyyyase.com has address 121.174.9.100
nyyyyase.com has address 121.183.6.137
nyyyyase.com has address 190.139.220.38
nyyyyase.com has address 195.56.205.192
nyyyyase.com has address 210.116.200.91
nyyyyase.com has address 221.165.170.71

…and when you try to browse to the IP address, you’re redirected to microsoft.com, presumably in an attempt to cover tracks. The few that I’ve traced all seem to be Eastern Europe (Poland and Hungary)

Browse a little deeper though and you get a site not dissimilar to the HMRC web site in layout and colour.

Be warned!

Of rivers, locks and quays

Filed under: canal — david at 3:31 pm on Saturday, September 26, 2009

The canal trust have recently taken stewardship of an 80-year-old ex British Waterways working boat called Python.

Over a period of a few weeks, she’s been moved from London to up this next of the woods. The last stage of the move before getting to our local canal was a stretch from Torksey to West Stockwith. Torksey is where the Fossdyke canal which runs in to Lincoln joins the Trent. The Fossdyke is attributed to either Henry I or the Romans, but either way, it’s an old waterway and provides a safe stopping off point along the Trent if the tides aren’t in your favour.

It was my first trip out on to the Trent; some of the other Python crew had negotiated the tidal Trent before and we had fellow Trust member Mick Cheshire who’s a Trent veteran riding shotgun in case of mechanical or other problems with Python.

We left Torksey at around slack water (high tide) for the three hour trip, knowing the tide would be in full flow by the time we arrived at West Stockwith.

One thing I’d never realised about the Trent before (I’ve never fished it for instance) was just how much it twists its way through the countryside. It’s not the most visually attractive of rivers, servicing as it does several power stations and industrial wharves around Gainsborough. There’s a fair amount of debris kicking around as well, quite a lot getting washed down from further up stream. The building work going off around West Burton Power Stations as it’s being converted from coal fired to gas powered (just ask now where the gas reserves are coming from!)

The green and red boat in the shots below is Mick’s boat, Phoenix.

Torksey railway viaduct (disused) Littleborough on the Trent - note disused windmill Waiting for West Stockwith lock to be emptied

The ultimate challenge of the day for me was, along with Arthur, getting Python into the lock, across the tidal flow. Mick had gone in first. We had to cross the stream (”Don’t cross the streams!”) and get into an 8′ space along side Mick without losing any paint work. With Arthur on the throttle and yours truly on the tiller (and both West Stockwith virgins!), it was a tense moment, but we managed it with a great bit of teamwork. Even Mick was complementary!

Once in the lock, things were a little more controlled. Being a “big lock”, the paddles and gates are automated, but it’s deep and there’s a lot of water to flood in. It all went off according to plan though, and Python locked up to the Chesterfield Canal in one piece.

It was an excellent day!

Undocumented features

Filed under: car — david at 12:42 pm on Sunday, September 6, 2009

Undocumented features, in my line of work, are usually a euphemism for bugs in applications. Sometimes we’re lucky with them and the ‘undocumented feature’ can be useful to the end user, but generally it’s something wrong that needs to be fixed. Last night, we’d gone out to get a Chinese take-out and I’d been boxed in between a couple of parked cars in the new Mini. I put the car in first then started to roll back (I was facing uphill) to get enough room to drive out. I was a bit surprised when nothing happened. The car didn’t move. “Brick under the wheel” I thought? Funny though. The brake pedal was absolutely solid. More solid than usual.

A little warning chimed at the back of my mind. I tried again and the same happened.

Now, like many IT people (and probably many around the world), I’m not exactly the best at reading manuals when I get new toys, preferring to take a view that technology these days should be easy to use and if it isn’t, I’m not that interested in owning it.

mini

This is the replacement for the Cooper S that got stolen a few weeks ago amid piles of broken glass (stick with me – there is a link).

It’s a four month old ex-demonstrator Mini Cooper Clubman, midnight black, Chili pack, half leather carbon black interior, interior chrome lining, 17″ crown spoke alloys. The dealers also fitted the Mini standard iPod interface which interfaces direct with the fitted Boost radio for full track and playlist display.

The undocumented feature was discovered by accident last night.  Somewhere along the line I’d broken with tradition and read the manual for the car. I remembered seeing something about a hill start assist option, and it looks like that’s also on my car.

Whether I’ll actually get much use out of it is debatable . I certainly wouldn’t have paid for it new, and I would gladly have swapped it for the Xenon headlights given a choice, but I’m not going to let it detract from my enjoyment of the car. It’s agreat car and looks stunning.

Bi-xenon headlights?

Filed under: boating, canal, seth ellis — david at 8:33 pm on Sunday, August 30, 2009

I’ll freely admin I’ve become an intermittent blogger since I discovered Twitter. I’m more likely to tweet several times a day than I am to update my blog which is sad, but some things really need a blog post.

After the car got stolen recently, it was a relatively easy decision to go for another Mini. I know some will probably throw their hands up in horror, but it’s me that’s driving it…

The last Mini was an 06 Cooper S. There’s no doubting that the MCS is a cracking car, fun to drive and goes live the brown stuff off a shovel, but to my cost I’ve also found out it’s quite nickable. After much reflection, I decided that something less nickable was probably in order, so I decided to go for a S Clubman. It’s still fun to drive and being that little bit bigger (it really does have boot space!) it’s a bit more practical.

There wasn’t anything I fancied in the second-hand market so I was nearly ready to bite the bullet and go for a brand new build. Unfortunately, the lead time was two months for a new factory build. As I’ve been driving Mrs Woolforbrain’s car for the last three weeks and she woudl need it once the school holidays were over, I had to come up with an alternative solution. Fortunately, the nice people at Sytner Mini Sheffield had an ex-demonstrator, registered less than four months ago in black. It nearly met my ideal spec, but was missing the bi-xenon headlights that my previous MCS had and were on my shopping list, but did have the MFSW (multi-function steering wheel) which incorporates the cruise control and radio remote which was also on the shopping list. The car also had the sports Chili pack. The dealers kindly agreed to fit the Mini approved iPod interface kit free of charge, so we shook on it. I’m now the proud owner of a 09 plate Cooper Clubman and it’s fun again! The bi-xenon headlights would have been nice, but they’re a £420 option. The iPod interface is around £250 and will probably get used more, so we’ll put it down as a result!

I seem to be getting more and more involved with activities centred around the Canal Trust, but even so, it was a pleasant surprise to receive an email from the Chairman inviting me to become a member of Trust board with pretty much immediate effect. Needless to say, I will be accepting. It’s a great honour to be involved in such a campaign I feel so strongly about. The Trust has brought me into contact with some really nice dedicated people and has given me the opportunity to play with some great toys! After all, I get to play with a nice narrowboat taking people out on trips, and today, I’ve been talking to members of the public about the work that the Trust has put in to an 80-year-old ex British Waterway working boat. It’s great for me as well. Most of the time I spend doing volunteer work for the Trust gets me out in the fresh air which is a major departure from my day job, and I get all the positive vibes that result from being involved with a charitable organisation that does so much for the community and the environment. Plus, I get chance to put something back from an IT perspective.

NHS and car

Filed under: general — david at 11:29 am on Friday, August 14, 2009

With all the current hoo-ha about the Amerians slagging of f the NHS, I felt obliged to share this excellent blog post: http://potentialandexpectations.wordpress.com/2009/08/13/this-americans-experience-of-britains-healthcare-system/

Also, I’ve just had the insurance company on the phone. They’ll come up with a settlement within 2-3 working days based on the private sale value of my Mini. Having just had a look at Autotrader, there’s not a hell of a lot of difference between private sale and dealer sale prices which is very good news for me. I’ve just seen a lovely white Cooper S, one lady owner…

Oh the joy of it…

Filed under: family — david at 8:41 am on Saturday, August 1, 2009

Last night was not a good night. We got burgled at around 00:40 whilst we were in bed. Nothing was taken from the house except for my car keys. Of course, it didn’t stop there, and the delicate polite yoof then did away with my rather nice Mini Cooper S from off the drive. So, in the wee small hours of this morning, we were giving statements to the local constabulary and waiting for the boarding up service man to do his business. Kudos to both sets. The police were here promptly and the boarding up man did a stoking job on the rear patio door where the git gained access (picture here).

So now we’re in to reporting mode. Both insurance lots were notified last night, and there’ll no doubt be more phone calls to make this morning. Having lost several hours of sleep, we’re up and about. Dan is still fast asleep thankfully. He was worried in case the thieves came back for his Club Penguin collection which is clearly his (current) pride and joy. Needless to say, we offered all appropriate reassurances that we thought his collection was safe.

Next Page »