When controlling physical systems I try to limit the damage they can do with simple interlocks. For instance, the relay I added to control my central heat is in series with a conventional thermostat which is set for a few degrees above pleasant.
Likewise, you can splice a float switch in line with the pump's power cable, positioned so it will cut off power if the water level nears the top of the tree stand. This will prevent the flood when the software decides to rebel against you.
My familiarity with float switches is limited to boats. Any you would recommend for this application?
I just noticed that you're using a mains-powered pump, so don't splice its wires directly. Instead, insert the float switch on one of the wires between the QT Py and the relay.
Something like this: https://www.supplyhouse.com/Beckett-Pumps-1502UR-Float-Safet...
or
https://www.supplyhouse.com/Little-Giant-599124-ACS-3-Auxili...
I wanted to make an electronic solution, but I think this fared better than whatever code I could write.
My design has an optical water level sensor and a cheap peristaltic pump, plus an ESP8266 for sanity ("if on for more than 5 mins, sound the alarm").
Sensor: https://a.aliexpress.com/_mtzF1L6 Pump: https://a.aliexpress.com/_mrGsfVO
https://www.amazon.com/HoHoHoH2o-Automatic-Christmas-Waterin...
HoHoHoH20 has been ok but not perfect. I had to 3D print a secure mount for the probe to fit my tree stand. They don't really include any kind of mount, the probe kind of hangs on hope and prayers.
The pump doesn't develop enough head pressure to lift water more than 8" or so, which it needs to in order to get over the rim of my tree stand. So when the reservoir is getting low, but not empty enough to trigger the low water level alarm, the pump just runs continuously but water does not flow. Found this out because my cat was curious about the pump noise. The easy solution was to put it on an 8" pedestal.
Anecdotally - we have found that Nordsman Fir trees consume a lot less water, drop a lot fewer needles, and have strong branches that can withstand heavy ornaments and cats. Worth seeking out.
I’ve thought about doing the same thing for years. But in my experience, those cheap capacitive sensors fail quickly. Might be worse when the water gets all sappy or filled with needles.
What sort of fail safe do you have for when the sensor becomes inaccurate?
No fail-safe besides the limit of only running the pump for 10 seconds at a time. I will continue to keep an eye on the data being pumped to Home Assistant and look to add a condition if/when the sensor fails.
Part of the joy of process control is thinking about all of the ways that things can fail. Adding to your woes...
Relays can fail, and it's actually a common failure mode for them to get stuck in the "closed" position, meaning that your pump runs forever. I learned this the hard way controlling heaters.
Amusing anecdote: I wanted to set something up to water my tree while my family was on a trip, and I ended up with a large pail of water next to the tree and a siphon tube running between them. Totally passive.
Edit: I’m from Europe so for me that feels twice as dangerous. (Don’t know if double the voltage means double the danger though)
You can do this with a IFTTT routine and a smart plug.
Or use a toilet water tank kind of mechanism so that it turns off the thing manually through a switch if the water level is too high?
I hope there will be an effort to collect and replant Christmas trees, as the cultural practice of cutting down tree and letting them die slowly in front of us (just for our seasonal enjoyment!) strikes me as barbaric.
From a carbon capture perspective, you could argue planting, cutting then burying trees is a net positive - but cutting is killing.
From a moral perspective, financially helping an industry based on planting and cutting trees while not using them for shelter (wood is used in housing) or even heat (in a stove or a fireplace) strikes me as barbaric, because it's the purposeless killing of a living creature.
Killing and eating animals (if not vegan) or plants (if vegan) is necessary as we can't opt out of food (but maybe there will be a fully synthetic replacement someday)
Yet I can opt out of killing trees for ornamental purposes - and this tech may help other people save trees, if they can't opt out of having a live Christmas tree, say for cultural or familial reasons (tradition, etc)