UniFi USG Advance Configuration

In our home we have UniFi networking equipment as our backbone for providing WiFi services. We have also been running a home media and ebooks server. The home media server is running a Plex server, and the ebooks server is running Calibre.

In the past, to access these servers we have to use the following format with the browser:

http://hostname:port

This is not very user friendly especially when you forget the port number. It would really be nice if we can access the servers with something like:

http://media.home
http://books.home

At the same time, the kids have been abusing their screen time privileges. Although their iOS devices can be easily managed with the new Screen Time feature, I still need to govern usage time windows on their gaming PC’s and laptops. I would like to configure our firewall so that Internet traffic from their devices are blocked from 12am to 7am.

The above configurations are both possible on the UniFi Secure Gateway (USG) running EdgeOS. However, these configurations are deemed as advance configurations and are not supported on the web user interface. To perform these configurations, I had to create and edit config.gateway.json file. This file will contain all the key / value overrides of the USG device in a JSON structure. Below are my additions to accomplish the above:

 {
    "firewall":
    {
        "name":
        {
            "LAN_IN":
            {
                "default-action": "accept",
                "description": "packets from intranet",
                "rule":
                {
                    "3001":
                    {
                        "action": "drop",
                        "description": "Jason Laptop AM",
                        "protocol": "all",
                        "source":
                        {
                            "mac-address": "84:38:35:50:64:12"
                        },
                        "time":
                        {
                            "starttime": "00:00:00",
                            "stoptime": "07:00:00"
                        }
                    },
                    "3003":
                    {
                        "action": "drop",
                        "description": "Kalen Laptop AM",
                        "protocol": "all",
                        "source":
                        {
                            "mac-address": "e0:ac:cb:8c:32:00"
                        },
                        "time":
                        {
                            "starttime": "00:00:00",
                            "stoptime": "07:00:00"
                        }
                    },
                    "3005":
                    {
                        "action": "drop",
                        "description": "Jason Gaming AM",
                        "protocol": "all",
                        "source":
                        {
                            "mac-address": "1c:1b:0d:70:80:84"
                        },
                        "time":
                        {
                            "starttime": "00:00:00",
                            "stoptime": "07:00:00"
                        }
                    },
                    "3007":
                    {
                        "action": "drop",
                        "description": "Kalen Gaming AM",
                        "protocol": "all",
                        "source":
                        {
                            "mac-address": "1c:1b:0d:72:ed:bf"
                        },
                        "time":
                        {
                            "starttime": "00:00:00",
                            "stoptime": "07:00:00"
                        }
                    }
                }
            }
        }
    },
    "system": {
        "static-host-mapping": {
            "host-name": {
                "media.home": {
                    "alias": [
                        "media"
                    ],
                    "inet": [
                        "192.168.168.9"
                    ]
                },
                "books.home": {
                    "alias": [
                        "books"
                    ],
                    "inet": [
                        "192.168.168.9"
                    ]
                }
            }
       }
   }
}

The above config.gateway.json file had be stored in the directory /var/lib/unifi/sites/default on my Ubuntu box that is running the UniFi Controller software.

The next step is to perform a force provision of the configurations to the actual USG. This can be done with web based controller software.

To double check, I can run the following on the actual USG box itself.

mca-ctrl -t dump-cfg > config.txt
less config.txt

Any JSON path key and its corresponding value can be overridden using this technique.

The USG is truly a hidden source networking gems.

HomePod Setup WiFi Woes

I’ve setup our Apple HomePod plenty of times. All previous setups have gone without any issues.

Tonight I had to reset our HomePod and set it up again because Siri was unresponsive. However, this time around the setup told me that I had an Incompatible WiFi, WTF!

After much Internet research I finally found the problem. I setup my WiFi via a Profile that I created and signed. This apparently was the issue. After I forget my network and rejoined by physically typing in my password, the setup went without any problems.

This may be an edge case. But for those who fell into the same rabbit hole, I hope this blog entry serves you well!

Hello Koodo

Our family was on the Rogers Share Everything Plan. We paid $85 for the primary line and $35 for four additional lines. This is a total of $225 for 6GB of shared data per month.

As our boys use their phones more and more both during the weekend and at school, the 6GB data cap is being surpassed more and more frequently. I wanted to shop for a plan that has more data, preferably staying with Rogers. Rogers has a promotion for 14GB (6GB original) plan for $105, but each supplemental line costs $45 each resulting in a total of $285.

This is an effective increase of $60 per month. Surely with modern advances in data throughput and capacity other carriers can do better. I decided to shop elsewhere.

I first looked at Chatr and Public Mobile. Both give you nice bargain data rates but are limited to 3G speed, something I did not want to entertain.

From Public Mobile’s web site I discovered the possibility of Koodo and found that their $50 per month plan was perfect for us. This will increase our data capacity to 4GB per line. This is 20GB in total although not shareable, which I think we can live with. Another pleasant surprise is that when we activated our new plan in the store, we got a $10 per month discount for each line for the first 12 months! So instead of $250 per month, we are now looking at just $200. For $25 less we enjoy more data per individual!

I am quite happy with this transition. I’ve included a QR code of my referral code as a banner of this post, so that if you decide Koodo is right for you, then use my referral code. This way we can mutually benefit. Make sure you use the referral code before activating your new line. Unfortunately they spelt my name wrong, but the code should still work. Enjoy!

 

External APFS Fusion Drive

Earlier this year and on a previous post, I explained how I constructed and configured an external fusion drive using Apple’s CoreStorage via the diskutil utility. Since I upgraded to macOS Mojave and it has the Apple File System (APFS) with Fusion Drive support, I decided that I want to convert my old external Fusion Drive setup to APFS. Always being an early adopter!

I tried to find online instructions on how to accomplish this, but there were just bits and pieces.  So in case I forget in the future and also someone else may find this useful, I decided to place the instructions here.

First, I did try to convert my old external fusion named, MediaFusion, with the diskutil application. Unfortunately that was unsuccessful and it returned an error. Therefore, I had to backup all the contents in MediaFusion, split the old fusion drive and create a brand new APFS container with multiple drives and partitions. Following are all the command line steps that I executed via the Terminal application.

First, let me show you what I had to begin with:

$ diskutil cs list

CoreStorage logical volume groups (1 found)
|
+-- Logical Volume Group 33383C9C-0CE7-4361-8A72-0DD606CDB079
    =========================================================
    Name:         mediafusion
    Status:       Online
    Size:         4500172365824 B (4.5 TB)
    Free Space:   40960 B (41.0 KB)
    |
    +-< Physical Volume 42A28BA6-0C40-4650-BE03-23FF7F377E58
    |   ----------------------------------------------------
    |   Index:    0
    |   Disk:     disk4s2
    |   Status:   Online
    |   Size:     499762860032 B (499.8 GB)
    |
    +-< Physical Volume E7E51D4E-B65A-44C9-961C-B1ACB70ACF92
    |   ----------------------------------------------------
    |   Index:    1
    |   Disk:     disk3s2
    |   Status:   Online
    |   Size:     4000409505792 B (4.0 TB)
    |
    +-> Logical Volume Family C1F85922-A4C2-42B2-A8FF-BF46ED8B2641
        ----------------------------------------------------------
        Encryption Type:         None
        |
        +-> Logical Volume 6C87BA11-AC3D-449B-B591-D53C99C98078
            ---------------------------------------------------
            Disk:                  disk5
            Status:                Online
            Size (Total):          4499551551488 B (4.5 TB)
            Revertible:            No
            LV Name:               MediaFusion
            Volume Name:           MediaFusion
            Content Hint:          Apple_HFS
            LVG Type:              Sparse

Next, I have to split the two drives, the disk4s2 (SSD 500GB) and the disk3s2 (HDD 4TB) mechanical drive.

$ diskutil cs deleteVolume 6C87BA11-AC3D-449B-B591-D53C99C98078

The Core Storage Logical Volume UUID is 6C87BA11-AC3D-449B-B591-D53C99C98078
Started CoreStorage operation on disk5 MediaFusion
Unmounting disk5
Removing Logical Volume from Logical Volume Group
Finished CoreStorage operation on disk5 MediaFusion

$ diskutil cs delete 33383C9C-0CE7-4361-8A72-0DD606CDB079

Started CoreStorage operation
Destroying Logical Volume Group
Erasing disk4s2
Initialized /dev/rdisk4s2 as a 465 GB case-insensitive HFS Plus volume with a 40960k journal
Mounting disk
Erasing disk3s2
Initialized /dev/rdisk3s2 as a 4 TB case-insensitive HFS Plus volume with a 311296k journal
Mounting disk
Finished CoreStorage operation

$ diskutil list

/dev/disk3 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *4.0 TB     disk3
   1:                        EFI EFI                     209.7 MB   disk3s1
   2:                  Apple_HFS Untitled                4.0 TB     disk3s2

/dev/disk4 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk4
   1:                        EFI EFI                     209.7 MB   disk4s1
   2:                  Apple_HFS Untitled                499.8 GB   disk4s2

Once the drives are properly split and reverted back to their original partition maps, I can then create my multi-device APFS Container.

$ diskutil ap createContainer disk4s2 disk3s2

Creating container with disk4s2 disk3s2
Started APFS operation on disk4s2 Untitled
Creating a new empty APFS Container
Unmounting Volumes
Switching disk4s2 to APFS
Switching disk3s2 to APFS
Creating APFS Container
FusionLC autodetect: regular Fusion
Created new APFS Container disk5
Disk from APFS operation: disk5
Finished APFS operation on disk4s2 Untitled

$ diskutil ap addVolume disk5 APFS MediaFusion

Exporting new APFS Volume "MediaFusion" from APFS Container Reference disk5
Started APFS operation on disk5
Preparing to add APFS Volume to APFS Container disk5
Creating APFS Volume
Created new APFS Volume disk5s1
Mounting APFS Volume
Setting volume permissions
Disk from APFS operation: disk5s1
Finished APFS operation on disk5

Be sure to specify the faster drive (disk4s2) as the first device! Once both the container and volume is completed I now have two APFS based fusion drives.

$ diskutil ap list

APFS Containers (2 found)
|
+-- Container disk2 1D566DF6-F26A-4E92-BE2F-5C38B62C579B
|   ====================================================
|   APFS Container Reference:     disk2 (Fusion)
|   Size (Capacity Ceiling):      3121506295808 B (3.1 TB)
|   Capacity In Use By Volumes:   1924724002816 B (1.9 TB) (61.7% used)
|   Capacity Not Allocated:       1196782292992 B (1.2 TB) (38.3% free)
|   |
|   +-< Physical Store disk0s2 123F0CDD-E154-4CC6-8F2D-D344166F04E8
|   |   -----------------------------------------------------------
|   |   APFS Physical Store Disk:   disk0s2 (Main)
|   |   Size:                       121123069952 B (121.1 GB)
|   |
|   +-< Physical Store disk1s2 9A6CCF8F-D0A1-4791-9F1C-DBFB1BB38461
|   |   -----------------------------------------------------------
|   |   APFS Physical Store Disk:   disk1s2 (Secondary, Designated Aux Use)
|   |   Size:                       3000383225856 B (3.0 TB)
|   |
|   +-> Volume disk2s1 0C36C0CE-B273-3626-A17C-E04BC605FA25
|   |   ---------------------------------------------------
|   |   APFS Volume Disk (Role):   disk2s1 (No specific role)
|   |   Name:                      Macintosh HD (Case-insensitive)
|   |   Mount Point:               /
|   |   Capacity Consumed:         1913007661056 B (1.9 TB)
|   |   FileVault:                 No
|   |
|   +-> Volume disk2s2 58E58B2A-7F7E-4E02-944B-5F1FF84B0BAF
|   |   ---------------------------------------------------
|   |   APFS Volume Disk (Role):   disk2s2 (Preboot)
|   |   Name:                      Preboot (Case-insensitive)
|   |   Mount Point:               Not Mounted
|   |   Capacity Consumed:         30584832 B (30.6 MB)
|   |   FileVault:                 No
|   |
|   +-> Volume disk2s3 EEF4C40B-75B8-4D86-90A4-85AD764F3BD4
|   |   ---------------------------------------------------
|   |   APFS Volume Disk (Role):   disk2s3 (Recovery)
|   |   Name:                      Recovery (Case-insensitive)
|   |   Mount Point:               Not Mounted
|   |   Capacity Consumed:         509845504 B (509.8 MB)
|   |   FileVault:                 No
|   |
|   +-> Volume disk2s4 CC23597C-9267-4F93-8DE3-73892FEA6ABF
|       ---------------------------------------------------
|       APFS Volume Disk (Role):   disk2s4 (VM)
|       Name:                      VM (Case-insensitive)
|       Mount Point:               /private/var/vm
|       Capacity Consumed:         2147516416 B (2.1 GB)
|       FileVault:                 No
|
+-- Container disk5 2A73D327-63D2-4BFA-973C-B62B00CA5B70
    ====================================================
    APFS Container Reference:     disk5 (Fusion)
    Size (Capacity Ceiling):      4500440801280 B (4.5 TB)
    Capacity In Use By Volumes:   9130835968 B (9.1 GB) (0.2% used)
    Capacity Not Allocated:       4491309965312 B (4.5 TB) (99.8% free)
    |
    +-< Physical Store disk3s2 851807A7-E19E-47CD-85E7-5A6EC82FBFD1
    |   -----------------------------------------------------------
    |   APFS Physical Store Disk:   disk3s2 (Secondary, Designated Aux Use)
    |   Size:                       4000543723520 B (4.0 TB)
    |
    +-< Physical Store disk4s2 1811B401-B8B7-4C49-802F-91F24F535962
    |   -----------------------------------------------------------
    |   APFS Physical Store Disk:   disk4s2 (Main)
    |   Size:                       499897077760 B (499.9 GB)
    |
    +-> Volume disk5s1 AF4C9AE1-1236-4171-8C73-F4BB4387CC8A
        ---------------------------------------------------
        APFS Volume Disk (Role):   disk5s1 (No specific role)
        Name:                      MediaFusion (Case-insensitive)
        Mount Point:               /Volumes/MediaFusion
        Capacity Consumed:         839680 B (839.7 KB)
        FileVault:                 No

The first (disk2) is the internal fusion drive converted by the Mojave installation process. The second (disk5) is the newly created drive.

That is it! After I recopy my original contents back onto the newly created APFS, I am good to go.

Another benefit for knowing how to do this is that new Apple hardware configuration is becoming more limiting, only offering internal SSD configurations. This is great for performance but not so great for one’s pocket books. Knowing that we can create an external APFS fusion drive using USB 3 or Thunderbolt 3 is very reassuring that we can still have this frugal compromise, while keeping up with Apple’s latest file system advancements.

I hope you find this useful.

The Hidden Gem to AirPlay 2

A couple of weeks ago I came across a 9to5Mac article indicating that Apple has updated all Airport Express 2nd Gen (A1392) firmware to 7.8. This means that if you have one of these little gems you can pretty well enable any active speakers or receivers that can take RCA, 3.5 mm, and optical toslink inputs (with appropriate cables).

I immediately scour my local Kijiji site and Facebook marketplace for these devices. I ended up buying five of these little devices. One for $25 CAD and the others for $50 CAD. All are in working order and I added all five of them to my network, enabling all of my speakers in the house. Now every speakers on all three floors in my house are AirPlay 2 enabled.

My Airport Utility Status Display

To test the new setup, I ended playing Christmas Carols on all three floors. The songs are all in sync. As I walk around the house, it is pretty surreal to have the same song omnipresent around your head.

The boys are happy because their bedroom speakers are now enabled via AirPlay. This means they can be more lazy by switching songs while laying in bed. Before, they had to plug their iPhones into their receivers.

If these devices are still around, you cannot beat the $50 value to enable any speakers of your choice to be AirPlay 2 compatible. Start looking around!

Nutrition Label for Planet Earth

In Canada when we buy groceries, we can inspect their nutritional make up. The idea is to make better or more fitting diet choices to improve our health. Whether to reduce our saturated fat, sodium or carbohydrates. All of this makes perfect sense. We can extend this concept by having a nutritional label for every item that we purchase. How do we do that?

We can create a new eco-label. This label can consists of a summary of the cost that we impose on our planet to create and make this item available for you to purchase, along with any recyclable or waste disposal characteristics. Instead of making a conscious decision in regards to our own health, this eco-label can be used to help us make good decisions that will improve the health of the planet.

The eco-label can indicate how much energy in joules was consumed and how much harmful emissions were created to produce and deliver this product. The label can also indicate whether the product is recyclable and what will it take to recycle the product. We can start simple, and does not have to be complete to make a difference. I know that it would affect my purchasing decision if I knew how much CO2 gases were generated by the next pair of running shoes that I will buy.

Having such a label will have ancillary influences on how manufacturers will design and make their products. Businesses will be more accountable in terms of auditing their planetary impact. Perhaps a new dedicate discipline of eco-centric chartered accountants can focus on the auditing of such activities as well. Market forces can also help businesses to be more competitive by attaining certain goals on the eco-labels.

We all need to be actively concern and participate in a continuous fashion if we are to make an impact on how we change our planet. The eco-label can make climate change a topic of concern at every point of purchase. Even if you are not a climate change believer, the eco-label provides more eco transparency in addition to the financial and health costs.

I think this is very powerful. I am willing to bet that most of you will have similar feelings and thoughts on this topic as well. What do you think, a good idea?

3D Printed Qi Wireless Charger

Last year when I purchased the iPhone X, I was curious whether Qi Wireless Transmitters were available. To my surprise, I was able to search for a Qi Wireless Transmitter PCB board from eBay. Out of curiosity I purchased one for about $5 CAD (free shipping). It took awhile to arrive but I was in no hurry.

The intent is to design a 3D printed container for the PCB board and I would have a very cheap functional Qi compliant wireless charger.

Unfortunately, I didn’t get to this project until last weekend. I spent almost an entire day designing the container and printed 4 prototypes before I got the measurements perfect.

This morning, I finally got the two pieces printed, a simple top cover along with a bottom container. It was pure joy when all the pieces fitted perfectly together. Please witness the pieces here, along with a video showing how everything just works!

I have to say, super proud of myself on this one.

 

Creating DVD Video Discs

Recently I created a video to commemorate my mom’s 80th birthday. Of course once the video is created, there is always the challenge of distributing the video. For people who are always online and have a respectable bandwidth, they can simply view the video online, as I have made arrangements to post it here on my blog site. The video is embedded in The Grand Birthday post. What about others who are not online savvy or are still clung to their DVD players.

I usually use a program called Burn on my Mac to burn videos into DVD Video discs. However I find the process unsatisfying. I needed something that can be applied to mass processing. I also did not like the unprofessional DVD menu that Burn applies to the DVD disc. Also the program is quite old and I fear may not work for future versions of macOS.

I came across this Convert any Movie to DVD Video wiki link, and found some really useful information. After reading through their process, I found, practiced, and proven this trimmed down version on my Mac.

First I had to install several utilities through the brew packaging system on my Mac.

brew install ffmpeg dvdauthor cdrtools

I use the above utilities to perform the following steps:

  1. Convert the source video (typically optimized for my Apple devices and my TV’s) to an NTSC DVD compatible format;
  2. Author a DVD directory structure using the video;
  3. Create an ISO from the DVD directory structure for archiving and burning purposes;
  4. Burn the ISO to a physical DVD-R disc.

The first step is to convert the video:

ffmpeg -i original.mp4 -target ntsc-dvd -r 29.97 -s 720x480 -aspect 16:9 -b 8000k -g 12 -mbd rd -flags +aic -trellis 1 -cmp 2 -subcmp 2 video.mpg

I ended up using the above command which supposedly yields the most optimum  quality in terms of viewing. The output video.mpg is DVD compatible. The above command assumes an aspect of 16:9, which is what most home videos are shot at today.

I then use the dvdauthor tool to create the DVD directory structure. Before I use the tool, I first have to create an XML file containing how I like the DVD to be configured. Below is a bare minimum XML file configuration that I used to simply create a DVD disc containing a single movie. The tool gives me the option in the future to add menus, chapters, etc.

    <dvdauthor format="ntsc">
        <vmgm />
        <titleset>
            <titles>
                <subpicture lang="en" />
                <audio lang="en" />
                <pgc>
                    <vob file="/Users/kanglu/Downloads/video.mpg" />
                </pgc>
            </titles>
        </titleset>
    </dvdauthor>

I then proceed to run the tool with the above XML file, which I named dvd.xml.

    dvdauthor -o dvd -x dvd.xml

This will result in a folder called dvd which will contain the contents of the DVD disc. Once I have the folder, I can then create the ISO file.

    mkisofs -dvd-video -udf -o dvd.iso dvd

The resulting dvd.iso file is a good archiving format in case I want to make more DVD discs in the future. At this point, I no longer need video.mpgdvd.xml, and the dvd folder. The ISO file is all I need to create a DVD Video disc containing my video. After sticking in a blank DVD-R disc, I executed the following command.

    hdiutil burn dvd.iso

I repeated the above hdiutil command with several more blank discs to make a bunch of discs for distribution. The resulting DVD Video disc contains a single video without any confusing menu system; the way I like it — keep it simple and stupid.

Too bad not everybody has Plex or Kodi. Even a Raspberry Pi with OSMC installed would be wonderful. That will make future distribution of family videos a lot easier!

However, I am now happy to have a workflow that works for me. I hope you will find this helpful.

A Grand Birthday

This past weekend on October 6th, 2018, we celebrated my mom’s 80th birthday. We invited many friends and family to come to Richmond Hill at a restaurant called Emperor’s Chinese Fine Cuisine restaurant for a casual dinner, along with some light entertainment.

Family from Mauritius and around Canada came to join us in celebrating my mom’s 80th birthday. I am super thankful for the great turn out, and we all participated in making some great memories. Special thanks to the performers, who also made the event that much more special. The lion dance from Sammy Cheng was spectacular. The traditional dancers made our venue magical, while Kalen’s guitar performance brought the celebration close to heart. Of course, the line dancers also added a fun and coordinated touch to the dance floor. The beat of Sega music brings out the joy in us all.

With the help of some high tech toys, people were able to record and contribute some wonderful moments. I took the past couple of days to put these media snippets together in this twenty-three and a half minutes long video.

So when you have a moment, sit back, and enjoy. I know that I will cherish this moment and will use this video to remind me of this grand, happy occasion.

Your Internet speed may not be fast enough and you may experience freezes or stuttering when playing the above video. If you have such an experience, it may be better to download the movie first and then play it locally on your computer. Sorry for the inconvenience.

Press one of the buttons below to download the movie of the quality you wanted.


Updated October 16: You can also download all the source media, original photos and videos from here:

Note that the original media will only be available for about 60 days from the time of this posting, so if you want it, then please download it now.

Switching Sides

Yesterday in a surprising announcement from our MP Leona Alleslev (@LeonaAlleslev), MP Alleslev decided to resign from the Liberal party and join the Conservative party of Canada.

Her reasons and quotes are publicly available and I will not comment on them. As a member of her constituent, my immediate reaction is one of betrayal, and now with more time thinking about it, I hope to articulate my reasons for feeling as such, for that feeling continues to persist.

Leona Alleslev campaigned on the Liberal platform, with the support of the Liberal party. As a voter in her riding, I supported the platform (not all but most) and voted for her. The Liberal party did not have multiple candidates in my riding, so the only way to support the Liberal agenda during a federal election in my riding is to vote for her. The Liberal party could have picked a different candidate with different values, qualities, and beliefs. It would not have mattered. If I wanted to support the federal Liberals, then I have no choice but to vote for her. Therefore it is my interpretation that my vote is in support of the Liberal red and not the Conservatives blue.

I want to repeat what I just outlined. I did not vote for her. I had no choice but to vote for her if I want to support Liberal.

We can have the debate about whether my vote should be based on the merits of the individual representative or the party. The substance or outcome of such a debate is irrelevant because as a qualified voter in Canada, I should be allowed and have the right to vote however I want, and the meaning of my vote resides in my sole interpretation, as I have outlined above.

Her decision to switch to the opposing team is in direct negation of my vote. I am  not saying that she did not have the right. I am simply justifying my feeling of betrayal.

She can justify her actions to our riding, to the media, and to the country. In today’s political climate, words offered by politicians are a simple commodity. Her action to cross the floor not only canceled my vote but reversed my decision in the last election without a discussion or debate. This is the action that I will remember in the next federal election as a proxy for her values. It is irrelevant whether these are her true or real values, but they are the values that she has chosen to project by carrying out such an action.

Leona Alleslev, you will be remembered.