Latest blog entries

An interference coincidence?

Monday, April 8th, 2019 at 7:30 pm

Many years ago I started monitoring the power consumption of my house via a ZigBee dongle that communicates with my smart meter. The quick and dirty solution I did at the time stayed in place for a long time, until it started to play up…

The first symptom I noticed was that my script would hang, in itself not that bad, except that I was calling it directly from MRTG… which would cause the entire MRTG polling loop to hang, so I wouldn’t get any monitoring. In response I split the script, one to read the usage to write to a log, and another (called by MRTG) to read the latest entry in the log.

The reading script would still get stuck, so I added a generous timeout and stopped thinking about it. Until I thought it would be a good idea to also drop the usage data onto MQTT for Home Assistant to grab. Nothing wrong with this, except that I upped the frequency from once every five minutes to every minute. Sometimes it would fail for hours, sending an email with the error every minute…

I initially noticed the increase in timeouts around the same time that I upgraded the hardware in my linux box and did a fresh install of Ubuntu. Due to default permission changes I found that I could no longer simply cat the serial port, I needed to connect using Device::SerialPort, so I was thinking that there was something wrong with the usb-serial chipset or the driver.

That was until a few weeks ago, when I upgraded the hardware in my Windows desktop.

For a long time I have been aware of a slight ticking sound coming from that computer, you know the sound of a fan slightly hitting something or being slightly off balance?

The new build went great and although I didn’t really need the upgrade it let me do an upgrade that was required, to my parent’s computer. As I was handing down parts I thought that I could replace the power supply fan instead of buying a whole new power supply, so I powered it up and heard the same noise…

… coming through my speakers.

Oh, this is not a bad fan, this is a failing power supply.

So what does serial port problems in one computer have to do with a bad power supply in another one? Probably nothing, but since replacing that power supply I haven’t had a single timeout error, it is as stable as when I first picked up the adapter. I guess it is possible that the power supply was generating interference at around 2.4GHz…

Another thing I didn’t think was related was that the UPS that these two computers run from had started to shut down. Not in any graceful manner, but with a sudden power off followed by a loud continuous beep. I suppose it is also possible that a bad power supply could also trip the UPS…

Tagged with: , ,

The Linux of Things

Saturday, January 26th, 2019 at 3:49 pm

As is becoming a habit, January for me means attending linux.conf.au which this time around was held in Christchurch, New Zealand.

The theme this year was “The Linux of Things” and rather than paraphrase the definition I will simply quote part of it:

“Building on the role that Linux plays in our everyday lives, we will address IoT-related opportunities and concerns from the purely technical through environmental, health, privacy, security and more.”

Those who know or follow me should immediately spot that that this is strongly aligned with my recent enthusiasm for home automation. I lost count of how many conversations I had with people about what I had done and what they had done, then there were a number of relevant talks that added more information into the mix. It is a lot to think about…

A few of the bigger takeaways are:

  • Home Assistant is good for automation and displaying recent history, but store long term history elsewhere.
  • Use what you are comfortable with. For others this may mean off the shelf devices, but for me this means I will continue building simple functionality into arduinos.
  • What you actually do is also highly personalised. Just because someone triggers the aircon in their office to turn on when they make their first cup of coffee doesn’t mean that you have to as well.
  • Always learn from what other people have done, and just as importantly share what you have done so others can learn from you.

That last point isn’t really new or home automation related, it is part of the philsophy underpinning open source itself, so not surprising that it came up (a lot) at an open source conference ;)

As is also becoming a habit, I am not going to travel to another country just for one week, in a similar way that I followed up Hobart 2017 with a road trip, I am also following up Christchurch 2019 with a road trip:

I will need to hold off (for now) the planning a road trip from the Gold Coast, because that is where LCA will be in 2020…

Tagged with: , ,

Those slow flashes

Thursday, December 6th, 2018 at 10:21 pm

Today was was my first time riding to work in too long and although there was plenty of light, as I rode on the suspended section under the freeway near Kooyong I was reminded of something that annoys me because it can be dangerous: a slow flashing front light.

So what am I talking about? Consider this road rule:

259. Riding at night
    The rider of a bicycle must not ride at night, or in hazardous weather
    conditions causing reduced visibility, unless the bicycle, or the rider, displays -
    (a) a flashing or steady white light that is clearly visible for at least 200 metres
        from the front of the bicycle; and
    (b) a flashing or steady red light that is clearly visible for at least 200 metres
        from the rear of the bicycle; and
    (c) a red reflector that is clearly visible for at least 50 metres from the rear of
        the bicycle when light is projected onto it by a vehicle's headlight on low-beam

On its face this is all reasonable, my particular issue is with the word “flashing” because it doesn’t indicate how slow or fast the flash should be.

I prefer a fast flash as it draws your attention, but is still continuous enough that you can follow where it is, especially when there is a bend or obstructions.

On the other hand a slow (where you can notice the delay) flash I find to be dangerous as you may not have seen enough flashes to get an idea of the direction and speed the bike is moving, before you need to allow for the direction to be changing because of a bend or curve in the path.

The compounding factor with this morning’s example was that it was also a super bright light. The sun wasn’t quite up and the freeway casts a decent shadow, it isn’t good to be faced with a blinding intermittent light on a narrow path with metal railings on both sides.

For the record I had my lights on, if I want to see I have the front on steady, but I wanted to be seen so today was the fast flash…

Tagged with: ,

From broadcast to stream

Saturday, December 1st, 2018 at 9:02 pm

Once I had my central heating controlled by Home Assistant based on a schedule in Google Calendar I started to think about how I could also control my stereo that I use as my alarm clock. This 25 cd stacker double tape desk stereo (purchase from Brashs gives an idea of how long I have had it) was the final clock in my house (I’m considering my car stereo to be out in the garage) that I would need to adjust for daylight saving.

My first thought was to find a manually tuned radio that I could just control the power of via a relay. I was able to find a few cheap radios, but they all had electronic tuners, so you couldn’t just kill the power. I also didn’t want to use an old radio, because it wouldn’t be as nice.

Next I started looking into playing back the infrared codes from the remote control for my stereo. This looked promising, but I was starting to like the idea of getting rid of the reasonably large stereo.

I briefly looked into a radio tuner module controlled by the Arduino. This would give me the ability to remotely tune to different stations, but it would also need some form of powered speakers that turned of/off at the same time.

Another option was a network speaker and I considered some cheap wifi speakers, but dismissed them when I found that nobody had integrated with them, I also didn’t find anything good said about the phone app they use for control. Also on the network speaker approach were options like a Sonos or a Google Assistant speaker. These are a lot more expensive and require cloud integration that I didn’t like.

The solution I went with was a network speaker somewhere in the middle, a speaker with integrated Chromecast. These have been discontinued in favour of more expensive models with Google Assistant, (I was able to find a new one on ebay for a very reasonable price) but with the advantage over a cheap speaker of there being a Google Cast component in Home Assistant.

Once setup on my wifi network it was again fairly straightforward to create automations to trigger playback from a network URL, the tricky part turned out to be finding the streaming URL for the radio station I wanted. If you go to there website the stream is provided by iheartradio which I couldn’t get to work, but I found a different source for the same station from the website of the radio network.

This has been working well (and I reclaimed space where the old stereo used to sit) but it does feel a bit wrong to change from receiving a broadcast over the air to downloading a network stream, it goes against one of my goals of not relying on internet/cloud services, although it can be rightly pointed out that using Google Calendar for the schedule already violates that goal…

Tagged with:

Controlling the heating

Tuesday, November 27th, 2018 at 9:52 pm

After achieving my first long term goal of a clock that I do not need to adjust for Daylight Saving, I moved onto remote control of my central heating. Thanks to some Home Assistant components this came together quite easily.

I have gas ducted central heating with a controller mounted in a central location. You could say I didn’t need to change a thing as it was already “smart”:

Yeah, nah…

This is what is referred to as a 5+2 programmable thermostat, there are two sets of schedules, one for the five days of the week and another for the two days of the weekend. The interface between this thermostat and the heating unit itself a pair of wires carrying around 25VAC, close the circuit to turn the unit on, this would be done instead by a relay connected to an Arduino.

On the user interface side I was planning to use a Google Calendar as I could put in events to represent the schedule and I could already manipulate it from my phone the the web interface which covers off remote access. The regular schedule would be in as repeating events, but I could adjust them as needed if I knew I wasn’t going to be home until later than usual.

My original plan had been to write something that would query the google calendar and push that information to the thermostat Arduino which would compare the target temperature against the current temperature and set the state of the relay appropriately. This approached changed when I saw that there was a Generic Thermostat component in Home Assistant that would handle the logic of being a thermostat. I wouldn’t need to implement that on an Arduino, it could just be a dumb relay control for Home Assistant to turn on or off. As Home Assistant can use any type of switch component for this and I was already basing things around MQTT I looked at the MQTT Switch component.

I don’t really know how a switch should be implemented, but from the desired behaviour it was easy to work out that the Arduino would listen on a topic for a state (OFF/ON) and ideally it would publish the new (or current) state on another topic. An additional thing I added was a failsafe, the relay would timeout after five minutes, if something went wrong (eg wireless went down or Home Assistant crashed) I didn’t want the heating to run forever.

I did encounter one snag with the relay shield that I had, it was hardwired to have the relay on pin D1, but that was one of the default I2C pins. While I wasn’t using one of the I2C displays in this situation, I was trying to share code between my devices. Later versions of this relay shield let you configure which pin it uses, so in my case my I pulled out the D1 pin (I had already soldered it up) and ran a wire around to another pin.

Adding the switch logic to the Arudino sketch didn’t take long, nor did adding the configuration to Home Assistant, so it wasn’t long until I has it connected up for testing:

This worked well, so I moved onto implementing the scheduling aspect using the Google Calendar Event component and automations.

Despite parts of the documentation not matching the implmentation (I need to follow that up, possibly asking on the forum or even submitting a patch…) it wasn’t long until I had automations configured to set the target temperature when a calendar event started, and to then turn off the thermostat when the event ended.

It was now a waiting game as I needed to let the automations trigger over time, and I also needed the weather to cooperate. Fortunately I am in Melbourne where despite it almost being summer we had a week or so of cool enough weather for this to happen:

I was quite happy with this, just in time for summer to really kick in and I no longer have a need for central heating… but that does give me time to sort out a proper mounting and power supply. I was initially thinking about finding some kind of unobtrusive box to mount on the wall, but the idea of featuring the electronics (such as a Tripler Base mounted to a blank plate) is growing on me…

Tagged with: