Stormy weather

The recent storms gave me an idea for a new automation…

I have a security light covering my driveway. It’s the type that predates the smart home – just a motion sensor attached to a light that comes on for a fixed time when motion is detected. It does the job, and I don’t really need anything more sophisticated. There’s only one drawback – there’s a tree in range, and in windy weather movement of the tree can trigger the light. It’s a rare occurrence, as it only happens in very strong winds.

When storm Ciara was raging I was aware that the light was being triggered almost constantly. Aside from being inefficient, and probably not good for the bulb, it could potentially annoy the neighbours. I decided to switch it off at the plug socket for the duration of the storm.

Unfortunately, it’s connected to a socket in my garage and I don’t have an internal door to the garage. Switching it off at the socket is a pain. It’s an obvious candidate for a smart plug, and luckily I had one going spare. It’s one of my 433MHz switches that was connected to a lamp that now has a Hue bulb instead.

The 433MHz switches have the disadvantage that you can only send the signal to switch on or off and can’t read the current state, but that doesn’t matter. The controls aren’t a toggle, so sending the on signal to a plug that’s already on just does nothing. Their advantage is a longer signal range than Z-Wave devices, which was a plus for this case given that the socket was out in the garage.

That done, I thought about the next step. Why control it manually? Could I tie it to the forecast for wind speed?

The answer is, of course, yes, but it sent me down a rabbit hole…

Wind speed is an attribute of the weather entity. To use it as a trigger for automations I first had to expose it as a template sensor. I also converted it from km/h to mph in the process:

- platform: template
      value_template: '{{ (state_attr("weather.home", "wind_speed") | float * 0.62137119) |round}}'
      friendly_name: "Wind speed"
      unit_of_measurement: 'mph'

Having it as a separate sensor also allowed me to add it to the front end and view the history:

The only problem was that the wind speed seemed a little low. The default weather provider for Home Assistant is the Norwegian Meteorological Institute, and it was predicting 27mph winds when the BBC website had speeds in the mid 40s. Comparing with a third source, the Met Office, gave me the answer. From the BBC, I got:

And from the Met Office:

The Met Office showed both wind speed and wind gust speed. Wind speed was in line with the Norwegian figures:

The BBC figures seem to take a mix, using the gust speed when winds are high. I assume that’s to show a worst case scenario for safety, and that makes sense.

As an aside, what doesn’t make sense to me is that the BBC no longer uses the Met Office as its data source. The BBC was forced to open the contract out to tender, but given that both the Met Office and the BBC are largely taxpayer funded it would make more sense to me to keep the money within the system. The money paid to a private sector forecaster is just an additional cost to the taxpayer…

Back to the automation, and I decided that the wind gust speed was what I needed. There’s an integration available for Home Assistant, so I only had to register for a free API key on the Met Office site to pull the data into Home Assistant. Using the Met Office Sensor integration, rather than the basic Met Office integration, also meant that I didn’t need a template sensor – each metric is exposed as a separate sensor:

So far so good. I could switch the socket off when speeds were over a threshold and back on again when the speed dropped:

The light comes on for the time threshold when it is first switched on, regardless of motion, so I wanted to avoid repeatedly switching it on and off. In order to avoid that, I decided to set the threshold for switching it back on to be lower than the threshold for switching it off. I chose 30mph as the wind gust speed at which the light is switched off and 20mph as the threshold for switching it back on, so it only comes back on when the wind has really dropped.

The thresholds I’ve chosen are guesses and I may need to adjust them. I suspect they might be a bit on the low side, but it’s hard to experiment – unfortunately I can’t control the wind to do proper testing!

in Home Automation

Add a Comment

Your email address will not be published. All comments will be reviewed.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Posts