Control your Smarthome using Keyboard shortcuts with Home-Assistant & Node-red

Control your Smarthome using Keyboard and Mouse shortcuts with Home-Assistant and Node-red.

Now I’m always interested in increasing the ways that I can interact with my smarthome. If we’re speaking about Home-Assistant (and Nodered), I think I can classify my current ways of controlling elements of the home as follows:

  1. Online i.e. web browser / official HA Companion app (iOS/Android)
  2. Via third party messaging apps i.e. Telegram / Signal / mqtt etc.
  3. Voice Assistants – Alexa and Google Home
  4. Manual Interaction i.e. Aqara Zigbee Buttons, NFC tags, motion sensors, Elgato Streamdeck etc.

That pretty much summed up the way I was interacting with our home. What was missing for me though, was a way to control items via the desktop in a quick and easy manner. If you have a desktop pc or workstation, then the Elgato streamdeck makes for a brilliant remote control and is quick and easy to use. It’s perfect for turning on or off lights, or setting off flows in Node-red, not to mention the way you can fire up applications quickly and easily on your pc. For full set up details, please see my previous article.

Now whilst this works great for a desktop, if you’re on a laptop and portable, then plugging in and carrying around a streamdeck is going to get annoying quickly. So is having to stop what you’re doing to go to the Home-Assistant webpage and click on or off the light you’re looking to control. I’ve been looking for a little widget that would essentially sit in the taskbar and allow me to access my most frequently used entities and routines quickly and easily. Enter the sexy named application: “Home Assistant Taskbar Menu”

This lightweight application is essentially a windows client that sits on the taskbar, connected to your HA instance.

Taskbar Icons
Taskbar Icons

With a left click you can access a small mobile browser window where you can interact fully, or with a right click (my preference) you can access a short list of entities where you can click on and off quickly and easily, before returning to what you were doing.

Example of the Mini Browser
Example of the Mini Browser

The github page for the project can be found here: https://github.com/PiotrMachowski/Home-Assistant-Taskbar-Menu

Installation was quick and simple, simply download the executable file from here. Unzip and run the .exe file (of course you need to trust what you’re downloading and feel comfortable with the code- disclaimer). After a few short moments, you now have a cool and familar looking icon residing on the taskbar.

Downloading the Executable From Github
Downloading the Executable From Github

To configure, you need to create a token in Home-Assistant. You can find the instructions here (Essentially, click on your username on the bottom right menu of HA, then scroll down to the very bottom of the subsequent menu, and create a long token. Copy it as you’ll never be shown it again. Paste it into the taskbar menu app, along with your full IP:Port of your installation.

Long Life Token
Long Life Token

Initially I was a little confused what do to next, but the readme on github is pretty decent. Left clicking brought up the mini browser, whilst right clicking brought up this menu:

Icons are as follows: Settings, HA in a mini window, HA in a browser, About, Exit.
Icons are as follows: Settings, HA in a mini window, HA in a browser, About, Exit.

 

Initially right clicking brought up a whole list of entites which was too much to be useful, but thankfully, adding an entity manually effectively replaced this huge list with just the entity I was opting for.

When looking at the various options in the configuration window think of Node as a folder. You can then divide up the menu as you prefer. i.e. room by room basis or maybe a folder (node) for lighting, one for climate, or media etc. it’s up to you. The separator is  self explanatory.

Home Assistant Taskbar Menu Options
Home Assistant Taskbar Menu Options

These are the domains it can control:

  • automation
  • climate
  • cover
  • fan
  • input_boolean
  • input_number
  • input_select
  • light
  • lock
  • media_player
  • scene
  • script
  • switch
  • vacuum
Adding an Entity to the Home Assistant Taskbar Menu
Adding an Entity to the Home Assistant Taskbar Menu

 

Another nice feature this app supports is the ability to start typing the name of an entity to find what you’re looking for quickly. Just right click the icon, hover over the menu and start typing. As you type, you’ll see the list shorten as you narrow down on your target.

A Quick Selection Tool
A Quick Selection Tool

 

I was very impressed with how quick and responsive the app was. Now I am saving the best until last… Not only can you point and click at the task bar quickly and easily, but you can also set up windows shortcuts that work either via *.lnk files or better yet… KEYBOARD SHORTCUTS!!

To make a clickable icon, select the Home Assistant Taskbar Menu.exe file and create a shortcut and put it on the desktop.

In the target, add the following variable to toggle on or off a switch: call_service switch.toggle {\”entity_id\”: \”switch.xyz\”}

So the full target should look something like this (depending on your installation location:

“C:\Program Files (x86)\Home Assistant Taskbar Menu\Home Assistant Taskbar Menu.exe” call_service switch.toggle {\”entity_id\”: \”switch.office\”}

Apply / Save and now double click the shortcut icon.

Now for the icing on the cake, add a shortcut key. I pressed “O” and windows automatically filled in Ctrl + Shift +…

Apply / Save and prepare for automation nirvana!

Desktop and Keyboard Shortcuts
Desktop and Keyboard Shortcuts

This application, is awesome! I can turn the office light on/off just by pressing ctrl+shift+O

 

Node-red:

Now let’s bring Node-red into this, to really add some flair. Thanks to the Node-red companion integration found under HACS, we can essentially create an entity in Node-red and then expose it directly to HA.

HACS Integration for the Node-red Companion
HACS Integration for the Node-red Companion

 

Creating an Entity Node
Creating an Entity Node

 

Example of a Flow
Example of a Flow

In layman’s terms, I am creating an anchor point in Node-red to then trigger other flows, but I can tie our new application into it.

The Newly Created Entity in HA
The Newly Created Entity in HA

 

By creating the entity switch.taskbar, I am able to link this to a keyboard shortcut as we’ve just done above. Now when I hit ctrl+shift+T, I am now able to turn that taskbar switch on and off directly (and therefore the flow that comes after it) in Node-red. I hooked up my sonoff r3 pro relay to it for testing (I love this thing!).

Example of a Flow
Example of a Flow

 

Couple of key strokes later, and I’m fiddling relay 1 on and off like a nervous teenager. This is great, the flow is triggering perfectly.

 

Thoughts:

Am sure there are probably ways to be able to recreate this feature bypassing Home-Assistant altogether, but as I use it as my front end, this works perfectly fine. In theory, with a few keystrokes , I’m now able to do the following things on my laptop without even leaving the application I’m working in:

  • Turn lighting on / off
  • Set room scenes – (mood lighting, effects using WLED by sending json)
  • Set volume levels / mute/ music stations on Sonos
  • Full control of my Nvidia Shield.
  • And a whole lot more….

This one was easy to set up and has been working flawlessly. There is a caveat. When you use the keyboard shortcuts, there was a minor delay of a couple of seconds, I assume this is down to Microsoft being Microsoft, but the actual shortcut links were pretty instant.

If your interested in sharing your own solutions, tips and tricks with like minded people perhaps you’d consider joining our facebook group. The aim of this group will hopefully be more show and tell rather than support, but that’s not to say we can’t lend a helping hand!

https://www.facebook.com/groups/386238285944105

 

Considering a Renovation? Maybe this will save you money!
Considering a Renovation? Maybe this will save you money! https://books2read.com/thesmarthomebook

Leave a Reply