My Christmas Tree Tells me when it's Thirsty

December 4, 2021 10:46 pm

This year I cobbled together a water-level sensor for the Christmas-tree stand. For several years I've looked for such a sensor, but never found anything that could do the job. I've found water sensors, but they're designed to "trigger" when wet and often times emit an alarm. Other water sensors might have given me an acceptable wet/dry signal, but were built as a single unit which can't be submerged in the stand.

So I used a standard Zigbee door sensor to accomplish the task. I used this one by Third Reality. It uses 2 AAA batteries, which I preferred over a button battery model since I'll only use it for about a month each year and I can use rechargeable batteries.

The premise is to use a float which will fall into range of the sensor when the water level drops and rise up out of range when water is added. So when the sensor signals that it is "closed" that means the tree needs water.

This sensor is connected to my Home Assistant smart-home manager which I have running on a Raspberry Pi 3. It uses the Zigbee Home Automation integration which I'm using with a ConBee II dongle. I've been really happy with this set up so far, I've had zero issues pairing devices or keeping their connections active.

The sensor, as shown, is made up of two pieces. The actual electronics are in the left part and the piece on the right is just plastic housing around a magnet. I removed the magnet and hot-glued it to a Ping-Pong ball which acts as a float. I also cut a piece of a plastic straw and glued that to the Ping-Pong ball which will be the guide for the float. Using the rest of the straw I slit it length-wise which caused it to curl into itself just a little allowing the float-guide to slip over it and slide smoothly up and down.

I attached one more piece of straw to the float to prevent it from spinning (which would pull the magnet away from the sensor). Then I hot-glued the long piece of straw into the tree stand along one of the support posts, which are hollow.

I paired the sensor to my Home Assistant set up and then used some Velcro stickers to stick the sensor to the inside of the support post and then adjusted the height through trial and error to get the "dry" alert when I wanted it. I didn't want it to be actually dry because I wanted there to be a grace period from when it says, "I need water" before it actually goes dry.

I don't have a picture of this part because I got it set up and didn't take a picture and now the tree's in the stand and there's no way to see the bottom. Which also means there's no way to change the batteries while the tree is up. The manufacturer claims "up to 2 years" battery life, so getting a month shouldn't be a problem. The sensor also reports battery level, and it hasn't dropped a single percentage since I installed it.

Next I reconfigured the "device" in Home Assistant and told it to treat it as a "moisture sensor" instead of an "open/closed sensor." So now instead of saying "open/closed" in the user interface it says "wet/dry." I used the "Configuration -> Customizations" GUI to set this up:

The generated YAML (in customize.yaml):

binary_sensor.third_reality_inc_3rds17bz_XXXXXXXX_ias_zone:
device_class: moisture

And, finally, I added an "automation" which triggers when the sensor detects the magnet (indicating "dry") and uses the "call service" action to send an alert to my tablet and/or phone which says "I'm Thirsty." I used the "Configuration -> Automations" GUI to set this up:

The generated YAML:

alias: Notify when tree needs water
description: ''
trigger:
- type: not_moist
platform: device
device_id: 5bca35081c2232eaXXXXXXXXXXXXXXXX
entity_id: binary_sensor.third_reality_inc_3rds17bz_XXXXXXXX_ias_zone
domain: binary_sensor
for:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
condition: []
action:
- service: notify.mobile_app_kyle_s_tablet
data:
message: '"I''m Thirsty" --Tree'
mode: single

All of this is running entirely local to my own home. No Internet required, no external servers in the mix and I don't have to wonder whether some company will decide to shut down their systems and break all my stuff.

I am greatly amused by this set up, especially because it actually just worked with almost no fussing around. And now I'll be going about my day and get a notification on my tablet from my tree asking for water. I live in the future.

The Weather Station Lives Again

December 21, 2019 9:56 am

Over Thanksgiving a big storm blew through. We were out of town but I noted that my weather station reported a bunch of rain and then stopped transmitting. When we got home, I climbed up on the roof to investigate. I replaced the batteries (which hadn't been changed in 2.5 years) and the station started reporting again.

This guy hung out with me for a bit while I was replacing batteries and cleaning sensors:

However, next time it rained it stopped again. Then it dried up and started again. Then rained again, etc. So it was dying when wet. And the humidity reading was stuck at 99%. I tried all the troubleshooting procedures I could find but was unable to restore functionality.

So, I bought a new sensor array and installed it today. The new array is an upgraded design. It's easier to take apart and clean. They reduced the power requirements so it runs on 2 AA batteries instead of 3. And they added a super capacitor to the solar array so it can run off sunlight without pushing any current through the batteries (the previous version pushed the solar current through the batteries to both stabilize the power and trickle-charge the batteries).

So the my weather station is up and running again!

http://weather.serindu.com

First LED bulb failure

December 1, 2019 4:38 pm

We had an LED bulb fail for the first time. We put 5 Philips bulbs in our over-the-table chandelier when we moved into our house. A week or two ago one of the bulbs began shutting off after being on for ~30 minutes and it would then cycle on and off. That suggests to me an overheating problem. Now the bulb doesn't light at all.

It lasted almost exactly 7 years and the other 4 bulbs in the fixture are still going just fine. I expected it to last longer and maybe it was flawed (we'll see what happens with the other 4 bulbs). But 7 years is pretty good since it paid for itself in reduced electrical usage after about 1.5 years.

Mercury Transits the Sun 2019

November 11, 2019 8:22 am

The transit started before sunrise in California, but I thought I'd try to get a picture before heading to work.

My first shot overexposed the sun, but is kind of neat anyway. It's wisteria below and our tree off to the right.

Pentax K-7, 200mm, f/32, 2s. (ND filters)

I took a few other shots and realized my lens has a number of spots that need to be cleaned. I thought they were mercury, but across several shots determined they were moving with the lens and not across the sun.

Looking closer I believe I did manage to get Mercury, smaller than my dirt spots. I believe the spot just above dead-center of the sun is Mercury:

Pentax K-7, 200mm, f/32, 1/25s. (ND filters)

Applying TK Themes to Git Gui

March 7, 2019 2:43 pm

Stashing this here for my own future information since it took me some time to figure out. How to change how Git Gui / Gitk look using different TK themes and how to install and use an external TK theme (such as one of these: https://wiki.tcl-lang.org/page/List+of+ttk+Themes).

How to Check Installed Themes

In Linux, you probably already have everything you need to adjust the TK theme used by Git Gui without installing anything new. To check what themes are available we can use the TK tool "wish". Running "wish" will popup a window into which you can build widgets, we'll just ignore it for our purposes.

We can check the TK version with "info patchlevel" and then list out the built-in themes with "ttk::style theme names":

$ wish
% info patchlevel
8.6.8
% ttk::style theme names
clam alt default classic
% exit
$

We currently have the built-in themes: clam, alt, default, and classic

How to Switch Themes

We can temporarily switch the theme to see if we like it using this magic:
echo '*TkTheme: [insert theme name here]' | xrdb -merge -
For example:

$ echo '*TkTheme: clam' | xrdb -merge -

And then if we run git gui it will be styled slightly differently than the default:

$ git gui

To make the change stick we need to adjust our user settings. Create or edit the file .Xresources in your home directory:

$ nano ~/.Xresources

And add to that file:

*TkTheme: clam

Now when you reboot (or restart the X server), git gui will use the "clam" theme.

How to Install External TK Theme

I grabbed the awthemes.tcl file from the above-linked list of themes. Awthemes provides the "awdark" and "awlight" themes. But then you have to figure out what to do with it to actually use them.

First, let's stash it somewhere useful:

$ mkdir ~/.local/share/tk-themes
$ mkdir ~/.local/share/tk-themes/awthemes
$ mv ~/Downloads/awthemes.tcl ~/.local/share/tk-themes/awthemes/

And now we create a package index file:

$ nano ~/.local/share/tk-themes/awthemes/pkgIndex.tcl

And put in there:

package ifneeded ttk::theme::awdark 2.3 [list source [file join $dir awthemes.tcl]]

Make sure you match the version number you put into pkgIndex.tcl to the one set in awthemes.tcl.

And, finally, we need to let TCL know where to find our external themes. We do this by setting an environment variable in our profile.

$ nano ~/.profile

Add the following to the end of that file:

# TK Themes
export TCLLIBPATH=$HOME/.local/share/tk-themes

Now logout and log back in (or use "source ~/.profile").

In order to see our theme we have to request it so that TK will go look for it:

$ echo '*TkTheme: awdark' | xrdb -merge -

If we check our installed themes again we'll see the "awdark" and "awlight" themes are now available.

$ wish
% ttk::style theme names
awlight clam alt default awdark classic
% exit
$
If we set the theme in ~/.Xresources it will be found and loaded when the X server starts.
$ nano ~/.Xresources

And change it to:

*TkTheme: awdark

Reboot your machine and when you log back in you should be using the new theme when you run git gui or gitk.

Unfortunately, I have not yet figured out how to adjust the ListBoxes and Text widgets using the
::ttk::theme::awdark::setTextColors and
::ttk::theme::awdark::setListboxColors procs as described in the awthemes documentation.