Better Parenting Time Exchanges with TRMNL

A couple of weeks ago I received my TRMNL order, and TRMNL promptly held a perfectly-timed hackathon for calendar-based plugins, lighting the proverbial fire under my behind to get me to write a plugin to show my kids how long until they go to their other parent’s house, and to give me a countdown until they’re back. While I didn’t win the hackathon, (check out the winners, they’re great), I continue to use and improve my little plugin with the goal of eventually turning it into a public recipe. I am certain there are plenty of parents out there in the same situation that I am, or who simply want to count down to other recurring calendar events.

A screenshot of the TRMNL device showing my private countdown plugin full screen.
This is what the full-screen version of my Calendar Countdown plugin looks like.

Things to Know When Coding for TRMNL

Debug JavaScript Right In Your Browser

TRMNL’s web-based coding environment is a bit weird, but it runs Javascript in the browser, which means that console.log statements appear in your browser’s dev tools.

Watch Out for the Time Zone!

When dealing with Date/Time in Javascript, the device’s timezone might not match your timezone. The user timezone data that supplied in the trmnl.user data should be used to set the appropriate timezone.

Events Not in Chronological Order

Sometimes calendar events don’t appear in chronological order in the data feed. I rectify this by running an Array.prototype.sort() on my array of interesting events once I have identified them.

Wishlist to make TRMNL Even Better

More Data Types for Settings

The ability to have a dictionary or object in settings, with a UI to set key-value pairs, would make it easier to have a list of events that are interesting to the plugin.

Improved Story for Local Development

While the online development system works, I would like a more robust system for local development. There is trmnlp, which is supposed to give a local development environment, but I was never able to get it up and running. I suspect that using trmnlp would allow me to put my Javascript into its own file, not have to copy the same Javascript into the HTML of all four of the layouts for my plugin.

Gallery Captions for WooCommerce 1.10 – Maintenance & Compatibility Release

After a long pause in releasing, I just got Gallery Captions for WooCommerce version 1.10 up on WooCommerce.com. This update brings compatibility with YITH WooCommerce Product Gallery & Image Zoom, changes the way compatibility code is loaded, and bumps the “tested up to” versions of WordPress and WooCommerce to the most recent versions.

Because the last release was in late 2023, this release was my first time using WooCommerce’s Quality Insight Tests. My first impressions: they take longer than the old tests, but give more detailed feedback – I like them!

If you want to have captions under the images in your WooCommerce store, and have somehow landed here before WooCommerce.com, head on over and install Gallery Captions for WooCommerce. It has great reviews and I provide great support!

Disable Rocket in PhpStorm EAP

Rocket gives me fast access to emoji on macOS, but the trigger I use, ::, is also common in PHP. I thought I had Rocket set to be disabled in PhpStorm, but it has been triggering when try do do things like Log::info('some statement');

After confirming that PhpStorm is on the list of Disabled Apps in Rocket, but Rocket was still triggering, I Googled how to disable Rocket for PhpStorm and found Rocket’s help instructions on IntelliJ IDEA. The same logic works for PhpStorm: Once PhpStorm is added to the list of disabled applications, double-click it in the list, and change it to “PhpStorm-EAP” and voila, Rocket stops triggering in PhpStorm.

Gallery Captions 1.6: Now with Custom HTML and Thumbnail Captions

Version 1.6 of my WooCommerce extension, Gallery Captions for WooCommerce, is now live with two new features: HTML is allowed in captions and image thumbnails can now have captions, (if you really want them to).

Basic HTML in Captions

Some support requests have come in since the launch of Gallery Captions for WooCommerce asking how to add links, and occasionally other formatting, to captions. Now people no longer have to ask, they can just add HTML. I’m using the built-in $allowedtags variable in WordPress to allow most formatting tags but not big structural tags that have the potential to break the product image gallery.

Captions on Thumbnails

A while ago there was a support request asking to for a way to add captions to the thumbnails displayed below the full-size image in the product gallery, and instead of saying that’s not how the extension works I made it work and gave the customer a development version of Gallery Captions with captions on the thumbnails with the version number 1.6-dev. In order to release 1.6 without breaking that customer’s site when the extension updates I added thumbnail captions to the release version, but hid it behind a filter. Most of the time it doesn’t make sense to have captions on thumbnails, but when it does site owners can now filter gcw_show_thumbnail_captions to return true and they’ll get thumbnail captions, like this:

add_filter( 'gcw_show_thumbnail_captions', '__return_true' );
A screenshot showing the a WooCommerce product page with captions under the thumbnails. The captions are used to describe the colours of tulips.
Very short captions look pretty good under the thumbnails, but if the captions are long it looks pretty weird.

Both of these changes have the potential to cause trouble by letting people break the image gallery in unexpected ways, so hopefully I’m not making a mistake. Putting thumbnail captions behind a filter that should restrict the use of thumbnail captions to people who really know what they’re doing, and limiting the amount of HTML allowed in captions should prevent the worst disasters, and I can always limit it more in the future if needed.

Make a Pi-Hole Work with a Bell Giga Hub

Due to a recent 10-block move there were shenanigans and my previous ISP was incapable of transferring my service to our new address. As a result, I signed up for the much faster Bell Fibe, fibre-to-the-home service. Now I have a 1.5 Gigabit internet connection, and pay less than I did for the 25 megabit connection. Sweet! I had some trouble getting my Pi-Hole up & running so I’m sharing what I did in case others have similar problems.

The Previous Setup

My old setup consisted of a DSL modem in bridge mode and an TP-Link Archer C7 router V2 that handled all networking tasks except for responding to DNS queries. The C7’s DHCP settings pointed to the Pi-Hole as the main DNS server for the network, and it worked great.

The Plan: Giga Hub + Pi-Hole

Included with my new service is a Bell Giga Hub, which is a combination ONT and router, (with a 10 gigabit ethernet port and wifi 6e!). Despite some complaints in /r/bell it seems like a very capable device, so I planned to use it as the main network device, and try to use it to point all devices on the network to a Raspberry Pi running Pi-Hole.

The Roadblock

Despite a place in the Giga Hub’s admin interface where it looks like I should be able to point the DNS at the Pi-Hole, I couldn’t get it to work. Every time I pointed DNS at the Pi-Hole the Pi-Hole couldn’t access the internet. It couldn’t even ping an IP address.

A screenshot of the Bell Giga Hub's dns settings
It looks like I should be able to set a DNS server here… but it doesn’t work.

Side Quest: Restoring Internet Access to the Pi-Hole

I ended up with a Raspberry Pi that couldn’t access the internet, which wasn’t ideal. The Pi was accessible on the local network, so I initially restored its internet access by changing it’s IP address. I later realized that turning setting the Giga Hub’s DNS back to “Obtain DNS information automatically” and changing or deleting the IP address in the “Manually specify DNS information” would restore the Pi’s internet access. It seemed that even though the router was using external, upstream, DNS, it was still doing something weird with the IP address in the inactive “Manually specify DNS information” screen.

DHCP to the Rescue

The solution ended up being relatively simply. Pi-Hole has the option to use the Pi-Hole as a DHCP server, and it is smart enough to tell connecting devices to also use the Pi-Hole for DNS. So I turned on the Pi-Hole’s DHCP server and configured it to allocate IP addresses in the same range as the Giga Hub, then turned off the DHCP server on the Giga Hub and everything worked. DHCP is a broadcast service so there is no configuration telling clients where to find the server. If there’s a DHCP server on the network the devices will find it.

Some posts in /r/bell had me worried that I would have to either use my C7 or another, faster, router in PPPoE mode, but switching to the Pi-Hole as the DHCP server was enough. That’s great because I didn’t want to buy another fast router, or use my older C7 when there’s a perfectly capable Wifi 6e router in the Giga Hub.

When I set this all up my Giga Hub was on Firmware version 1.14.something. The firmware was recently updated to version 1.16 and is still working. It may be that Firmware 1.16 also fixes the problem I had setting the DNS server on the Giga Hub, but what I have is working, and if it ain’t broke don’t fix it.

A screenshot of my pi hole admin panel showing that it is processing thousands of DNS queries.
My Pi-Hole is processing thousands of DNS queries, (yes, I know blocking is off at the moment).