Mini Smart Switch with a DIY box or a simple UK Plug to switch box

If a smart power plug is currently overpriced, using a Mini Smart Switch can be an alternative method, especially if it’s going to be a permanent change. However without any case or box it’s a safety risk. Adding a DIY simple plug power box and a socket might make sense, if you’ve got them spare. Essentially making it an extension lead.

Links & References

Simple Plug in Light and Switch – YouTube
https://www.youtube.com/watch?v=ZXaCaA4CEAw

Electrical Wiring Colours – A Complete Guide | RS
https://uk.rs-online.com/web/content/discovery/ideas-and-advice/wiring-colours-guide

Wiring a Mini Smart Switch to control a UK one way lighting circuit

In my case I have one light switch that controls one light bulb. There is 3 bus bars, one 2-slot and the other two 3-slots. The current wiring would basically be like this:

Disclaimer: I am not a qualified electrician. I’m self-taught and this is actually only for my own notes.

Remember, turn off the power anytime you are touching the wiring, I also recommend telling people in the accommodation that you’ll be turning off the power and not to turn it on without informing you.

Power

Live IN (commonly brown wire) to a bus bar (lets label this live bus bar)
Neutral IN (commonly blue wire) to a bus bar (lets label this neutral bus bar)
Ground/Earth (commonly green and yellow striped wire IN to the ground/earth bus bar.

(this is passing the live, neutral & ground to the next room)
Live OUT (commonly brown wire) to the live bus bar
Neutral OUT (commonly blue wire) to the neutral bus bar
Ground/Earth (commonly green and yellow striped wire IN to the ground/earth bus bar.

This means we have 1 slot left on both the live & neutral bus bars

Light Switch

One end connecting to the 2-slot bus bar and the other end connecting to the live bus bar.

Light Bulb

Live (commonly brown wire) (positive end of the light bulb) connects to the 2-slot bus bar (switch).
Neutral (commonly blue wire) (negative end of the light bulb) connects to the neutral bus bar.

Now we should have filled all slots on the 2-slot and both 3-slot bus bars. We’ve basically connected power to the live and neutral bus bars (and the ground/earth connected too).

If unsure which cables are Live and neutral in/out, you should disconnect them and using a multi-metre (set to AC) probe a set of brown and blue wires till you get the 240v, this would be your IN. You can also switch on the light switch and you’ll tell which lines are your switch wires.

Links & References

Wiring Diagram For a One Way Lighting Circuit Using the 3 Plate Method – Connections Explained – YouTube
https://www.youtube.com/watch?v=fixa_1jp55c

Electrical Wiring Colours – A Complete Guide | RS
https://uk.rs-online.com/web/content/discovery/ideas-and-advice/wiring-colours-guide

Installing Android Debug Bridge (adb)

Two ways of installing ADB, the first method is installing via Android Studio which will come with packages you may not ever use. The second option would be to just download the platform-tools

Android Debug Bridge (adb)  |  Android Studio  |  Android Developers
https://developer.android.com/tools/adb

Download Android Studio & App Tools – Android Developers
https://developer.android.com/studio

The second option

SDK Platform Tools release notes  |  Android Studio  |  Android Developers
https://developer.android.com/tools/releases/platform-tools

After installing, extract to somewhere simple, I would recommend C:\ just to avoid any url issues. So it would like like C:\platform-tools, then ensure you’ve set up the system PATH in your environment variables settings as “C:\platform-tools\” it’s as simple as that. Just start a powershell or cmd and type adb to confirm it works.

Other useful guides

How to install ADB on Windows, macOS, and Linux
https://www.xda-developers.com/install-adb-windows-macos-linux/

Commands & Steps

  1. Enable debugging mode on device, then connect device.
  2. Start PowerShell or Command Prompt (CMD)
  3. Type command to see connected devices list:
adb devices
  1. Then type to connect, check the to confirm authorisation:
adb shell

Testing malicious USB Cables

There are currently two ways of testing malicious cables. Pre-made testers and standard USB Testers that you can observe the current draw.

If you don’t know what I mean, check out the O.MG Cable, I will not go into the details of how you can visually tell them apart from other cables, and it depends on the cable brands and I guess both methods are evolving fast.

If you’re serious about making sure it’s malicious, I would recommend getting both or one that includes a current meter. If you’re like me and just want to double check a cable, a USB tester that shows current is enough.

Testers:

How to Detect Malicious USB Spy Cables #TSCM #MurrayAssociatesTSCM – YouTube
https://www.youtube.com/watch?v=nKnZd_1OdsE

O.MG Malicious Cable Detector – Lab401
https://lab401.com/products/o-mg-malicious-cable-detector

The CuVoodoo USB Bug Detector Safely Ferrets Out Those Sneaky Malicious O.MG Cables – Hackster.io
https://www.hackster.io/news/the-cuvoodoo-usb-bug-detector-safely-ferrets-out-those-sneaky-malicious-o-mg-cables-b7f5d961cb5f

USB Testers

FNIRSI-FNB58 Multi-function USB Voltage/Current Meter Type-C Fast Charge Tester

Visually:

How to spot the difference between the O.MG Cable and a standard USB-A Cable – iFixit Repair Guide
https://www.ifixit.com/Guide/How+to+spot+the+difference+between+the+O.MG+Cable+and+a+standard+USB-A+Cable/155496

Other

USB Data Blocker Teardown
https://mg.lol/blog/data-blocker-teardown/

Testing USB Cables – Type C – for Faults

Now days Type C cables require a bit more effort than previously with standard USB A and Macro cables, in addition the pins are so small it’s quite a struggle. To simplify and also check correct negotiations, you should grab a tester.

Test a USB-C Cable for Faults – YouTube
https://www.youtube.com/watch?v=2fIOK8FH3aU

USB-C Cable Testers

Search for:

Treedix USB Cable Tester
….

Mini USB Cable Tester 6 in 1 Cable Diagnostic Tool

Alternatively:

USB-C cable tester – C2C caberQU
https://caberqu.com/home/20-42-c2c-caberqu-746052578813.html#/26-case-without_case

USB-A to USB-C cable tester – A2C caberQU
https://caberqu.com/home/29-40-a2c-caberqu-746052578820.html#/26-case-without_case

FNIRSI-FNB58

[WordPress] Creating custom post type and converting/changing post types of your post/page

Creating a custom post type is as simple as tweaking the code, saving it to your functions.php file or if you prefer to have it not bound to your theme then saving it to a code snippet plugin.

Follow this guide here. If you prefer to have the posts be categorized and taggable, then use the modified code below:

/* Custom Post Type Start */
function create_posttype_services() {
    register_post_type( 'service',
    // CPT Options
    array(
      'labels' => array(
       'name' => __( 'Services' ),
       'singular_name' => __( 'Service' )
      ),
      'public' => true,
      'has_archive' => false,
      'rewrite' => array('slug' => 'services'),
     )
    );
    }
    // Hooking up our function to theme setup
    add_action( 'init', 'create_posttype_services' );
    /* Custom Post Type End */
    
    /*Custom Post type start*/
    function cw_post_type_services() {
    $supports = array(
    'title', // post title
    'editor', // post content
    'author', // post author
    'thumbnail', // featured images
    'excerpt', // post excerpt
    'custom-fields', // custom fields
    'comments', // post comments
    'revisions', // post revisions
    'post-formats', // post formats
);
    $taxonomies = array(
    'category', // post title
    'post_tag', // post content
);
    $labels = array(
    'name' => _x('Services', 'plural'),
    'singular_name' => _x('Service', 'singular'),
    'menu_name' => _x('Services', 'admin menu'),
    'name_admin_bar' => _x('Services', 'admin bar'),
    'add_new' => _x('Add New', 'add new'),
    'add_new_item' => __('Add New Service'),
    'new_item' => __('New Services'),
    'edit_item' => __('Edit Services'),
    'view_item' => __('View Services'),
    'all_items' => __('All Services'),
    'search_items' => __('Search Services'),
    'not_found' => __('No Services found.'),
    );
    $args = array(
    'supports' => $supports,
    'taxonomies' => $taxonomies,
    'labels' => $labels,
    'public' => true,
    'query_var' => true,
    'rewrite' => array('slug' => 'services'),
    'has_archive' => true,
    'hierarchical' => false,
    );
    register_post_type('service', $args);
    }
    add_action('init', 'cw_post_type_services');
    /*Custom Post type end*/

You can simply change “service” and “services” to the singular and plural of your choice. I’ve bolded the only change I did.

Now that you’ve got your custom post added and working, like me you probably wanted to change some of your current posts. There’s a great plugin called Post Type Switcher, however it seems to not be getting updated anymore and failed to work. The next option is to use a SQL Query. Log in to your phpMyAdmin, head over to your wp_posts, find SQL on the menu and run the below command. Look further into this article for more information.

UPDATE wp_posts SET post_type = 'service' WHERE post_type = 'post'

Links & References

How to Create Custom Post Type in WordPress (Easy Guide)
https://www.cloudways.com/blog/wordpress-custom-post-type/

How to convert/change post type in WordPress – QuadLayers
https://quadlayers.com/change-post-type-in-wordpress/

Thunderbird 115 Common Issues

Missing folders/emails in Unified Folders view

Close Thunderbird, go to the profile folder and delete virtualFolders.dat file and Mail folder. Start Thunderbird.

Exporting/Importing Message Filters

When you create a message filter, each filter is saved within the emails folder, in a file called msgFilterRules.dat, so when importing or exporting you’ll need to retrieve the file for every email address.

C:\Users\<USER>\AppData\Roaming\Thunderbird\Profiles\<PROFILE>\ImapMail\<EMAIL>\msgFilterRules.dat

Thunderbird 115 Customizations

Hiding the number of messages under Message List Header

In Thunderbird Config Editor, find and change toolkit.legacyUserProfileCustomizations.stylesheets to “true”. Close Thunderbird.

In your profile folder, create a folder called “chrome”, then a file named “userChrome.css”, edit the file in any editor and add the following line:

#threadPaneFolderCount { display: none !important;}

Start up Thunderbird and it should now be hidden, if not, double check the config editor setting and the other steps if still further issue.

Changing tag background and font colours

Making sure Thunderbird is closed before you do any editing. Simply add on a new line, in the same file mentioned above.

/* Change the background color of tagged messages */
/* Tag name: Important */
treechildren::-moz-tree-cell(Timportant) {
    background-color: red !important;
}
treechildren::-moz-tree-cell-text(Timportant) {
    color: #FFF !important;
}

This should turn your emails, set with the tag “Important” to have a background colour of “red” (can be changed to another colour using HEX colours). Then the font colour to #FFFFFF (white).

Syncing files on Synology using a WebDAV server, with Joplin

My Synology is a bit outdated so the preferred or latest method seems to be with Docker, however I do not have that, so the alternative is the WebDAV method.

The first things you obviously need to do is download Joplin on your clients, installing on the PC and on Android, go to your synchronisation settings and it’ll ask you for a WebDAV URL, username and password.

Next create a location for the WebDAV server, specifically where our Joplin clients will look to when syncing their files.

Before you proceed you should decide on what you require, if this is purely an offline (no access to the internet) kind of syncing solution for yourself then you will not be able to use HTTPS unless you figure out and setup a local self-signed SSL certificate, whether that’s to your IP or an offline hostname.

Install & Setup WebDAV Server

On Synology (6.2), it’s a simple case of heading over to the Package Center and installing the WebDAV Server, once running go to settings and enable HTTPS (5006) and that’s it, at least for me. If you’re going the route where you’d like your notes to be synced via the internet then I wouldn’t turn on the HTTP, just to make it easier on securing the route.

In order for WebDAV to work via the internet, you need to create a DNS to point your dynamic IP or if you’ve got a static IP laying around skip all of that.

Purely HTTPS

FreeDNS, No-IP

Head over to one of the free DNS services/providers below and setup an account.

FreeDNS.com
http://www.freedns.com/

FreeDNS – Free DNS – Dynamic DNS – Static DNS subdomain and domain hosting
https://freedns.afraid.org/

Duck DNS
https://www.duckdns.org/

FreeDNS Alternatives: 25+ Dynamic DNS Services & Similar Apps | AlternativeTo
https://alternativeto.net/software/freedns/

Updating your dynamic IP

If you’ve got an option in your router to automatically update your IP (as it changes) to your dynamic DNS service/provider then you’re all set, simply provide the credentials and details it requires and your router does all the work.

If not you’ll have to either manually update it every time your router resets and changes IP or set up some kind of automation, there are some little apps/programs that keeps track, depending on the DNS service, you can see what’s compatiable.

I used DuckDNS and found that they’ve got a simple vbs script that can be run with Task Scheduler, which you can find out below.

Duck DNS – install
https://www.duckdns.org/install.jsp

I had to use a .bat file to run the command via CMD and get the .vbs script running or it stalled. Be sure to use pause or echo to test.

Add and export your certificate

Via the Synology (6.2) Control Panel, under Security, the Certificate tab, hit add and using the domain (sub domain) you created, fill in the details. Once done you can right click on the certificate and Export.

Install a certificate on Windows 10

Right click on your start menu and hit run, type “mmc” and OK, which should bring up the Microsoft Management Console (MMC), on the top left, under File menu, press Add/Remove Snap In, from the left, add to the right Certificates snap-in for Computer.

On the left, right click “Trusted Root Certification Authorities ” then under All Tasks, choose Import. Go through the process, I personally did automatic also right after.

Setup/add your new domain (sub domain)/hostname on Synology

Via the Synology (6.2) Control Panel, under External Access, press Add on the top and go through the process of adding your dynamic DNS service details. You’ll also have the option to configure your router there, if your router is on the list, if not then the manual way is below.

Install the required certificates for Configure Port Forwarding on your router

You’ll need to point any visitors to your external (public facing) IP that also use the port 5006 to forward to your local IP Synology server. So for example 87.10.33.220:5006 would come to your router, the router will see that it’s got the port 5006 at the end of it and knows that the traffic for this port all must go to your Synology box at 192.168.0.100:5006, 5006 is being the WebDAV server we turned on earlier.

Install a certificate on Android

  1. Open your device’s Settings app.
    • Tap Security and privacy > Other security settings
  2. Under Credential Storage, Tap Install from device storage CA certificate.
  3. Tap where you saved the certificate.

Configuring Joplin

Once you’ve installed the certificates on your devices (to avoid TLS certificate errors), you should be able to input the URL, username and passwords.

Your URL should look something like this:
https://192.168.0.100:5006/vol1/joplinnotes/
https://yoursub.domain.org:5006/vol1/joplinnotes/

You can create a user specifically for Joplin use, but you’ll need to give it access. You’ll need to tweak the permissions where you only give it full access to the Joplin folder, allow it access to the parent folder so it can enter the directory, but not view anything else, other than what it’s been given, which is the joplin folder.

Links & References

Joplin in NAS Synology (webDAV) – Support – Joplin Forum
https://discourse.joplinapp.org/t/joplin-in-nas-synology-webdav/375/16