This where I’m going to keep my personal notes on how to work around various issues on Home Assistant, but why not make them public ha ha.
I recently started getting an error when trying to update HA “update blocked from execution, no host internet connection”. After confirming the host did in fact have an internet connection, I tried numerous solutions (disabling IPV6 on HA – which doesn’t actually disable IPV6, disabling IPV6 on my router – which also didn’t help, changing the DNS settings in HA etc) and absolutely none of that worked. In the end I found this hacky solution which is kind of annoying but it does work:
ha jobs options --ignore-conditions internet_host// go back to the UI and install your updatesha jobs reset// job done!
C++17 added a useful extension to the if-statement syntax, by making it possible to include initialisation inside the if-statement. This is called “if statement with initializer”. You can use it like this:
if (int spuds = getNumberOfSpuds()) {bakeSpuds(spuds);}
Providing spuds != 0 it will obligingly bake them for us (in fact, it will even bake negative spuds… very handy in the current financial climate). Better yet, you can also add a condition, like this:
if (int spuds = getNumberOfSpuds(); spuds > 10) {std::cout << "we have plenty of spuds" << std::endl;}
This is often used to check pointers before dereferencing them:
if (auto* car = getCar()) {car->setHandbrake(true);car->setSteeringAngle(70.f);}
Obviously these are very useful features, as it brings the variable instantiation into the scope of the if-statement and makes for neater code. We love it and use it a lot!
Unfortunately, this also seems to have led to a common misconception in how the condition can be used. In working on some fairly large C++ projects, we found quite a few instances of this type of code:
if (auto* car = getCar(); car->hasWheels()) { // DANGER: if car is nullptr, will dereference nullptr}
The intent of this code is obvious: the developer clearly expected it to only execute the condition if car != nullptr. Essentially, they expected it to check that car != nullptr, then execute the condition, and only enter the if-statement if car is valid, and the car has wheels. However, it doesn’t work like that. It will always execute the condition and will dereference the car pointer, regardless of whether it is nullptr or not, so this code is quite likely to crash.
Usually this is fairly easily fixed by doing something like this:
if (auto* car = getCar(); car && car->hasWheels()) {std::cout << "we have a car, and it has wheels" << std::endl;}
But the really nasty thing about buggy code like this is that it can often appear to work fine, until one day it blows up. This can lead to really nasty intermittent bugs, which are exceedingly hard to debug. Worse still, static code analysis tools might not spot this issue, and we had obviously missed some of these in code reviews also. If you suspect bugs like this are present, it’s also quite hard to grep your code base to find them. For example: searching for lines containing “if” and a semicolon will bring up a huge number of hits, which have to be searched manually. This makes it especially important not to introduce them in the first place 🙂
Here’s an example of some such code which appears to work (at least, it doesn’t crash), but is obviously not correct:
structCar {boolhasWheels() {returntrue; }};Car* nullCar = nullptr;if (auto* car = nullCar) {std::cout << "we have a car" << std::endl;}if (auto* car = nullCar; car->hasWheels()) {std::cout << "car has wheels" << std::endl; // Spoiler: this may be a lie}
If you run this, it won’t output “we have a car”, but it probably will output “car has wheels”, even though car is nullptr. It does that because hasWheels is just returning a constant value, so the compiler doesn’t actually need to use our pointer. Although this is a somewhat contrived example (because our function could have been static, and we are using raw pointers etc), I hope it illustrates the point: that just because code appears to work when you test it, that doesn’t necessarily prove the code is correct.
Another misconception I’ve seen in practice is when people put initialisation in both the initialisation and condition, assuming that the compiler will check both conditions (it doesn’t):
if (auto* foo = getFoo(); auto* bar = getBar()) { // DANGER: if foo == nullptr and bar != nullptr}
It will enter the if statement if bar != nullptr, even if foo == nullptr. For example, this code would result in a nullptr dereference, because it only cares whether the condition on the right hand side is true, and doesn’t care whether car is nullptr or not:
if (auto* car = nullptr; auto* driver = new Driver) { // DANGER: if car == nullptr, it will dereference the nullptrcar->setDriver(driver);}
It’s worth saying that this code wasn’t introduced by inexperienced C++ developers. In fact, some of it was written by very capable, experienced and knowledgeable C++ developers, some with many years of experience. It just goes to show how easy it is to slip up and introduce this kind of bug. I suspect this is a fairly common issue, and something that it is useful to be aware of.
Finally, if you want to search for this kind of issue in a large code base, it is somewhat possible by using regular expressions. For example, in Visual Studio’s “Find in Files” option, you can select “Use regular expressions”. To find lines that contain both “if” and a semicolon you can do something like this:
if.*;
This expression should find lines that contain “if” and a semicolon, but the semicolon can’t be at the end of the line:
\bif\b.*;(?!\s*$)
Don’t ask me about regular expressions, because I am no expert – just sharing one that worked for me 🙂
Either way, this will bring up a fairly long list of search results that you will have to sift through manually. All the more reason to take care not to introduce them in the first place…
It’s obvious that a lot of names are also going to be valid words in Scrabble (Bob, Peter etc) and this made me wonder just how many there are…
Now, Scrabble has a ridiculously large dictionary, allowing all sorts of silly words that are frowned upon in our house 🙂 For example, there are apparently 124 playable two letter words (!) and, ridiculously, you can play Aargh, Aarrgh and even Aarrghh (!) Well, if you don’t believe me, you can check here.
I’m no authority, and there are several dictionaries including OSPD and SOWPODS, no doubt with differences between them. They are regularly revised to remove hate speech and, no doubt, so they can add some even more ridiculous words.
Anyway, I digress. After some tinkering around, I was able to intersect a list of names with a list of Scrabble words, to arrive at a total of… 1244 names. There’s a good chance yours will be in there 🙂
I was driving on the motorway in heavy rain, when my windscreen wipers started working intermittently, then suddenly stopped completely! This was pretty scary as visibility was almost zero. Fortunately I was close to a slip road and services, and pulled off into the service station car park. Ultimately I had to call my breakdown insurance and, as they couldn’t fix the fault at the roadside, had to get the vehicle recovered.
Assuming this was a wiring fault, I decided to take a look at it myself…
To gain access to the windscreen wiper motor and its wiring, you first need to remove the plastic scuttle panel beneath the windscreen. It’s worth watching the video linked above before attempting this, to know what you are getting into!
There are two plastic trim panels covering the wiper arms, which need to be removed (pull up on the right side of the panels, as the left side hooks in). You need to remove the dust covers on the wiper arms, and undo the two nuts to remove the wiper arms. The panel itself is secured with two plastic clips and a small Torx screw in the front centre. There are another two clips holding the panel at the top left and right, and further plastic clips secure it to the window. Too much to explain here, so please do watch the video linked above before you attempt it!
Having removed that, you can access the wiper motor as shown below:
The whole wiper motor assembly is held on with two bolts, and easily removed with a 10mm socket. There’s a 4-pin connector which unclips and pulls free. The connector has a Ground connection, two Motor connections (for the two speeds), and a sensor output (pulled to Ground when the motor is at the start position).
After disconnecting the motor, I used a Multimeter to check for 12V on the two motor pins, and found there was power on both pins when selecting the appropriate wiper speeds on the stalk. On mine, the Ground wire is black, and you can spot the Sensor wire because it is thinner than the others. The two thicker wires on the outside of the connector are the Motor connections:
As there was obviously power on the connector, this seemed to confirm it was the motor itself at fault, rather than the wiring as I had first suspected.
The motor is made by DENSO and the part number is MS159200-8660. The same part appears to be used on Fiat 500 and the Ford Ka Mk2. Used ones cost about £25 and new ones cost about £80-£120.
I ordered a secondhand one, but was still curious to know why the motor had failed, so decided to open it up. The plastic cover clips on and you need to be really careful not to break the plastic clips when removing it as they are very weak. Inside, I found that the Ground connection had a poor solder joint on the PCB, which had caused it to fail, and it was no longer physically attached to the PCB.
Here’s a picture of the underside of the PCB, showing where the Ground connection was originally (supposed to be) attached:
Here’s the ground connection pin, which is supposed to be located in the black plastic pillar at the top of the board, next to the two motor connections:
Here are some images of the PCB front and rear (taken before the repair, so the ground connection is missing in these photos. Is just my strange sense of humour, or does this PCB look like a bit like a cow?
This actually looks like a pretty well designed part, but it was sadly let down by one poor solder joint. The circuit is very simple: the pins are connected directly to the motor and switch contacts, and each motor has a capacitor and what looks like a TVS diode to suppress voltage spikes.
To fix it, I cleaned up the tip of the Ground connection carefully with a small file on both sides, then soldered it back into the board. I also applied some new grease to the motor worm drive and the plastic gear wheel. After reassembling it, the unit works fine again.
I enjoy playing Wordle over breakfast every day. It’s a wonderful little game, but the US spellings sometimes cause me some pain!
This made me wonder how many US words were in its dictionary. I had a look at the JavaScript source and found it uses a dictionary of 2315 words. That’s a lot to look through manually, so I ran it through a spell checker (MS Word UK English) and found the following 21 words:
apnea
fecal
moldy
arbor
fetal
rumor
ardor
fiber
savor
armor
furor
tumor
boney
honor
valor
color
humor
vigor
favor
labor
wooly
It would be easy enough to substitute a different dictionary of course (and I suspect someone probably already has).
I’ve been a fairly happy user of Visual Studio over the years. For all it’s faults, I’d probably even go so far as to say it’s probably the best Microsoft product I’ve ever used – including their OS! But with 2022, we are not off to an auspicious start…
Typically, I’ve always bought the next major release as a standalone version (2013, 2017, 2019 etc) and activated with a Product Key. When VS 2022 came out, I was pretty excited and naturally assumed I could just buy a standalone copy again…
How wrong I was!
The whole sorry saga started back in November 2021 when we contacted one of our usual resellers and asked them for a quote. Initially there was some confusion because it only seemed possible to get the subscription version at the time but, after a lot of back and forth with the reseller, we eventually got a quote for the standalone version late in December. The ordering slipped into the New Year due to holidays and issues with the reseller.
When it came time to order, the reseller sent us a link to some videos explaining how to use “Microsoft Cloud Services”. I was a bit perplexed to find that we needed to watch 3 videos before we could order the software, but they assured me they were very short videos!
So, I got a cup of tea and sat down to watch the videos on “Setting up a new online services tenant” then “How to align an existing online services tenant” then “How to purchase online services” without any real idea what an “online services tenant” was, or why I needed one to just install Visual Studio. Then I thought… what the hell, why is this so complicated? Can’t I just buy this from the Microsoft Store?
So, after some digging, I found this link on the Microsoft Store, so I went ahead and added 10 copies to my basket. Job done! …or so I thought.
The Microsoft Store sent me an e-mail saying thank you for your order then, a few minutes later, another e-mail saying it had been cancelled! What?
So I tried again. This time of course, my bank flagged it as card fraud, having seen two big transactions with the same supplier. So I had to call them and get the card unblocked.
Then I tried again – third time lucky as they say! This time it seemed to go through OK. I got another order confirmation and, eventually, received an e-mail with an “Install” link for the software. However, this “Install” link just took me to the order page on Microsoft Store, with no way to download the software, no way to obtain the Product Keys and no way to activate it.
Two of us then spent 6 days on the ‘phone to Microsoft. We tried calling the Microsoft Store support, exploring every department available from their ‘phone menu. Everyone we spoke to was unable to help, and either put us on hold, redirected us to another department, or opened a ticket, only to close it later with a message to call the same number we had already tried 50+ times before. In many cases, the departments we were connected to were closed, and they simply disconnect you!
Although polite, literally nobody we spoke to at Microsoft seemed able to help us, they just bounced us around from one department to another.
We tried online chats, e-mails and creating support cases with various Microsoft teams, all to no avail. In the end, over a week later, we resorted to cancelling the order and asked them for a refund.
Now I am waiting for a refund to my credit card, which can apparently take 5-10 days.
I have since spoken to Microsoft Store support again, and they have suggested ordering 10 copies as 10 individual orders, rather than as a single order!
So, I have been trying to buy this software since November, and still don’t have it. It’s the most incredibly frustrating experience. I can’t think of any other business that we work with who could get away with this kind of service, it really is something to behold!
This idea is either genius…. or maybe I’ve finally lost my marbles? I’ve been using a “zero discard” method for my Sourdough starter, where you just pile some flour on the starter and leave it in the fridge (for days at a time, without feeding it). Then, when I want to use it, I just add water and leave it for a few hours to ferment. There’s only so many sourdough discard recipes 2 people can eat, and I can’t bear to throw it away, so this “zero discard” method is a good compromise (I am no expert on Sourdough, still experimenting…)
Anyway, it was a cold morning, I’d just taken the glass jar out of the fridge, added cold filtered water and wanted to get this thing moving quickly, so I thought… why not put it on my 3D printer’s heated bed, and set the temperature to something like 20ºC – 30ºC to get the party started!
Glass jars aren’t very thermally conductive, so I set the bed to 30ºC for an hour or so then, when the jar got up to a balmy 24ºC, reduced the bed temperature to 25ºC and left it until doubled in size. It works a treat! Got a nice bubbly, active starter – ready to rumble!
AvE does a nice line in warning stickers for machine tools. I was about to order some (probably still will) then realised they were going to take 4 weeks to arrive. In this age of instant gratification, I can’t wait so long… so I cracked open Inkscape and set about making some of my own. They arrived in a few days, and I’m really pleased with the result!
Few things more exciting than opening a pack of fresh stickers! One is on my garden shredder, and another is going on my Lathe…
The minimum order means that I now have 50 of these, so I decided to take a punt by listing them here on Etsy.
My shower plate had become badly clogged, with two of the holes pretty much completely blocked. When I tried to remove it, I found it was really badly stuck… I tried soaking in descaling solution, tapping it with a soft faced hammer, levering it from the side with wood (mindful of damaging the shower plate)…. but it wouldn’t budge.
Then I stumbled on a tip in a forum: simply insert a longer screw in the central hole, and tighten this until it pulls the shower plate free! So, I used an M5x20mm socket head cap screw (pictured above) and, with a few turns of an allen key, the plate popped straight off.
I tried cleaning and descaling the shower plate, but it was pretty badly stained. Having neglected my machine so badly, I felt slightly ashamed and decided it deserved an upgrade with a shiny new brass shower plate…