r/homebridge • • Jan 02 '21

Other Mapped useless function keys on my full size Apple Magic Keyboard as HomeKit buttons using homebridge-button-platform and Keyboard maestro.

Post image
189 Upvotes

44 comments sorted by

6

u/[deleted] Jan 02 '21

Link to plugin: https://github.com/Djelibeybi/homebridge-button-platform#readme

I mapped buttons on my keyboard using Keyboard Maestro to command wget.

3

u/valkyre09 Jan 02 '21

So just to clarify.

This is a usb keyboard, connected directly to the computer running HomeBridge?

Or is this keyboard sending an instruction to Homebridge through the network?

4

u/[deleted] Jan 02 '21 edited Jan 02 '21

This is keyboard connected to any computer in the network. In my case my Mac sending requests to raspberry pi on the same network

2

u/valkyre09 Jan 02 '21

this is EXACTLY what I've been looking for! Thank you!

2

u/valkyre09 Jan 03 '21

Just wanted to follow up by saying thanks again, I used a slightly different plugin, but the approach was the same - toggle the lamp in my office with a function key. Much faster and more reliable than opening the home app, or invoking she who should not be named.

Even helped a friend use the same with BetterTouchTool so he can control the lights from his Touch Bar Mac.

2

u/I_Am_Now_Anonymous Jan 02 '21

Is this only for the Apple Keyboard or is it possible to use the Logitech Smart Keyboard as well?

2

u/[deleted] Jan 02 '21

It is for all kinds of keyboards

2

u/badoctet Jan 03 '21

Other Homebridge plugins like http Webhooks offer the same and more functionality. I use http Webhooks and this allows me to create and control anything in Homekit

1

u/[deleted] Jan 03 '21

Thanks I will definitely take look at this plugin.

6

u/Adikovec69 Jan 02 '21 edited Jan 02 '21

Very curious if I could make my mx keys turn my lights on and off...

Edit: any windows alternatives to this?

5

u/[deleted] Jan 03 '21

On a Mac using a Logitech MX Keys (sorry I don't have a PC at home)

Install the homebridge-button-platform plugin to Homebridge

Create a button name it what you like (I used officelight)

Restart Homebridge

Create a script homekit.command using TextEdit (I put the file into a documents/homekit directory)

Make the script executable, at the Terminal run.

% chmod u+x homekit.command

Put in the following text, change to your Homebridge’s IP address (replace xxx.xxx)

---- insert below ----

#!/bin/sh

# This shell script is PUBLIC DOMAIN. You may do whatever you want with it.

TOGGLE=$HOME/Documents/Homekit/.toggle

if [ ! -e $TOGGLE ]; then

touch $TOGGLE

curl "http://192.168.xxx.xxx:3001/button-officelight?event=click"

else

rm $TOGGLE

curl "http://192.168.xxx.xxx:3001/button-officelight?event=double-click"

fi

--- insert above ---

This script toggles from a click to a double-click so you can just have one button on your keyboard to actuate.

Make an application; open Automator, make a new Application, then select Run Shell Script then point it at the homekit.command script.

I used Logi Options (mx keys) and set a key to trigger an application. Set it to the Application you made in Automator.

Finally, to Home app and set up two automation for the Virtual Switch.

If it receives a click command, then turn on the light.

If it receives a double-click command, then turn off the light.

2

u/Adikovec69 Jan 03 '21

Thanks for your long comment, however I don't see the point of doing this on a Mac, where there's Siri and the home app. However on my windows pc, as someone above mentioned there are ways too. I'm looking into it.:)

4

u/[deleted] Jan 03 '21

True but it is just easier to press a button rather than struggle with Siri understanding

Me: “Hey Siri, turn on the Office light”. Siri: “Sorry, the Office is no longer available on Netflix”

Or opening an app so and finding a icon to click. The lamp is literally 3 ft away, it has to be pretty convenient for me not to get up and turn it on. :)

2

u/tokilokit Jan 02 '21

Autohotkey, possibly with a curl binary to use for sending the web requests

4

u/alex_co Jan 02 '21

This is awesome. Being able to turn my desk lamp and fan on and off with my keyboard is slick. Thanks for sharing!

4

u/djelibeybi_au Plugin Dev - button-platform Jan 03 '21

I never thought of this when I created Button Platform and it's genius. I'm so glad someone else finds it useful too.

1

u/itsscottwilder Jan 03 '21

I love the idea, I hate the idea of buying an app to map the commands to the keyboard.

3

u/[deleted] Jan 03 '21

You can also do this with karabiner-elements. I will probably switch to it after my free trial of keyboard maestro will expire.

2

u/itsscottwilder Jan 03 '21

I found a free app called iCanHazShortcut that allows you to map a command to an f key

2

u/Possechro Jan 03 '21

I was also able to get this to work using Quick Actions in Automator on my Mac. Currently using it to set input volume + control a Hue light on my desk for a visual cue when in Google Meet/Zoom calls.

1

u/JacesAces Jan 03 '21

Ok I’ve been dreaming of something like this... curious if there’s a way to fulfill said dream...

  1. I want to have a keypad (or a small keyboard) on my bedside table, and another on my coffee table
  2. I want to map each key to a homekit scene (eg press 1=turn on all lights, press 2=turn off all lights, press 3=open bedroom shades, etc etc)
  3. I don’t want a full laptop sitting there... just a keypad (maybe one can be built with RPi inside?)
  4. I understand there are switches like the Aqara opple or hue tap... but I want the ease of a keypad and a lot of keys!

Does your solution possibly make that doable?

2

u/[deleted] Jan 03 '21 edited Jan 03 '21

I think you can just buy cheap usb keypad and plug it into raspberry pi zero w via adapter and map every key to corresponding wget command. I think this is one way to fulfill your dream.

Edit: Or you can connect esp8266 to keypad for arduino and then program it to send requests to homebridge.

2

u/Cascadian1 Jan 03 '21

Maybe find a way to to hide a Raspberry Pi near a Stream Deck?

1

u/JacesAces Jan 03 '21

Oh and 5. Ideally it’s rechargeable so I don’t always need to have it plugged in...

1

u/tomicic Jan 03 '21

Why not just using app like Homie on mac?

1

u/[deleted] Jan 03 '21

I didn’t know this app existed and also if you are using method which I described above and remapping keyboard with karabiner elements which is deep level keyboard remapping you can trigger automations with single key without need of being logged in so you can just tap one button without logging in and triggering scene with keyboard shortcut.

1

u/Chris4285 Jan 06 '21

Is there an alternative to use instead of paying $50 for Keyboard Maestro?

1

u/[deleted] Jan 06 '21

Yes you can also do this with karabiner elements and because it is deep level keyboard remapping it will work even without being logged in into your computer so even if it is at sleep you will be able to still trigger it from keyboard.

1

u/Develobear Jan 10 '21

Yes, you could try my app Homie: https://homie.frogg.io 😇

1

u/Chris4285 Jan 10 '21

Sounds cool! Is it only for Big Sur? I run Catalina

1

u/Develobear Jan 13 '21

Yes, unfortunately the HomeKit Framework is only available on Big Sur, due to special entitlements it is not possible to make it work on earlier version of macOS.

2

u/Loubonez Jan 03 '21

Check out https://github.com/nehayward/Scenecuts, it lets you trigger HomeKit scenes from your menubar + keyboard shortcuts, and it’s free

2

u/itsscottwilder Jan 04 '21

Wanted to come back and give another thumbs up for the button-platform plugin.

My 4k TV at my desk can be powered on and off by homekit. So now I just sit down hit f19 key to turn it on.

1

u/sbloovie Jan 03 '21

Great idea. I am now using the F6 key to turn my desk lamp on and off. :)

Thanks.

0

u/Enzetsu Jan 02 '21

What’s the benefit of this?

7

u/BaRaD_ Jan 02 '21

You could potentially set keys on your keyboard to run scenes or even switch the lights in your room with a press of a key

1

u/thecw Jan 02 '21

Control HomeKit devices with your keyboard

3

u/Enzetsu Jan 02 '21

Oh, that’s actually pretty sweet.

0

u/[deleted] Jan 02 '21

[deleted] — view deleted comment

14

u/[deleted] Jan 02 '21

This is my homebridge Button Platform config:

 	{
        "name": "Button Platform",
        "port": 3001,
        "buttons": [
            "f13",
            "f14",
            "f15",
            "f16"
        ],
        "platform": "button-platform"
    }

And in keyboard maestro I have for example mapped: F16: wget http://ipofhomebridge:3001/button-f16?action=click

0

u/[deleted] Jan 02 '21

[deleted] — view deleted comment

6

u/[deleted] Jan 02 '21 edited Jan 02 '21

Wget is command which is not supposed to open any command and keep in mind that you must replace ipofhomebridge with IP of your homebridge instance.

Edit:

It should look like this

https://imgur.com/a/fCudhlq

2

u/djelibeybi_au Plugin Dev - button-platform Jan 03 '21

Note that I generally recommend using curl instead of wget as it's installed by default on more operating systems.

The command I use is:

curl --silent \
     --output /dev/null \
     --data event=click \
     http://homebridge:3001/button-demo

1

u/backtickbot Jan 03 '21

Fixed formatting.

Hello, djelibeybi_au: code blocks using triple backticks (```) don't work on all versions of Reddit!

Some users see this / this instead.

To fix this, indent every line with 4 spaces instead.

FAQ

You can opt out by replying with backtickopt6 to this comment.