Upstart and Python

I’ve got a Currentcost Envi device connected to my Viglen MPC-L. A python script runs on a loop parsing the data from the serial cable and sending it to a remote Mosquitto instance. The problem is that the exception catching bits aren’t very good..in fact they are rubbish. I should just take some time and effort to improve the script, but I’ve got the attention span of….oooh, there’s a birdy out of the window. Anyway, at the moment the script falls over once a day or so, and stays that way until I restart it (via a screen session).

I’ve looked at a number of approaches, including monit, but have never got any of them to work very well. So step forward Upstart. From the website -

Upstart is an event-based replacement for the /sbin/init daemon which handles starting of tasks and services during boot, stopping them during shutdown and supervising them while the system is running.

You can add a service to upstart by adding a configuration file to /etc/init/ and then running “sudo initctl reload”.

Here’s my config file for my python script

description “CurrentCost Monitor”
author “meeee!”
start on runlevel[234]
stop on runlevel[0156]
script
chdir /usr/bin/scripts
exec /usr/bin/python currentcost.py
end script
respawn

There’s probably more in there than there needs to be, but so far it’s been working for a week with no problems, so I guess I’ve got a working solution.

Anyway, a big thanks to Upstart and the team that are working on it!

 

Posted in ubuntu | Leave a comment

Watering the Garden OSS style – A Year with (some) Open Hardware

It all started with the seemingly simple question – “How can I water the garden without leaving my laptop/phone/sofa using tech?”. So during the last year I’ve been looking at a number of low cost, low power and partially open source hardware devices for home automation and monitoring. I’ll share my opinions and thoughts on each of them.
In no particular order I’ve checked out -

  • 1-wire
  • arduino and jeenode
  • currentcost
  • the joggler
  • a cheapo USB controlled 8 way relay from ebay

Continue reading

Posted in arduino, home_automation, ubuntu | 7 Comments

GU10 halogen bulbs are bad

When we moved into our current house we refurbished the kitchen and living area extensively. As was/?still is the fashion then, halogen down-lighters were duly installed – 12 in total. Not the low voltage ones, but the 240v GU10′s. In retrospect, not the best idea to be honest. Each used 40w making a total draw of 480w. Additionally they blew at the rate of about 1 a week. Say they were on 25% of the time on average, and £1/watt/year (at 100% usage), meant that these lights are costing near enough £120 to run (+ the cost of 52 replacement bulbs/year).

I tried LED GU10′s about 2 years ago and found them expensive and the light emitted far too ‘cold’. A couple of months ago I decided to give them another go and things seem to have progressed nicely. An eBay search coughed up a number of suppliers with a wide array of light colors and led numbers/bulb. In the end I went with this http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&item=170565002537#ht_1468wt_907 (disclaimer – I have no commercial interest or connection with this seller!) and chose the 48 led ‘warm white’ at the very reasonable price of £4.29. They draw only 3w each and I actually prefer the light from these compared to the halogens. The seller claims that the bulbs last for 50,000 Hours. I’ve only been using them for 2 months, so I have a long way to go before I can confirm that claim (25 years!). In summary, from a total estimated annual electricity cost of £120 (+ cost of replacement bulbs), we’ve now gone to an annual bill of £9! By my estimations, the bulbs will have paid for themselves within 6 months.

Posted in home_automation | 2 Comments