Running scripts from buttons…?

With the Conbee II can I set it up to run arbitrary scripts from buttons?

What I really wanna do is have a way to start and stop my mpd music player from a button next to my stereo.

I searched for smart buttons and a lot of them need special hubs or apps. I do have an iPad currently and I don’t mind using it for setup, but once I’m set I want a system that doesn’t depend on having an iPad in case it breaks or I lose it.

I also have Debian computers, one AMD64 and one Raspberry, so the Conbee II seemed more appealling to me: a li’l USB stick that doesn’t need its own power supply.

A store in my neighbourhood sells Conbee II and Philips Hue Dim Switch v2 929002398602. It’s specifically meant for lamps like “big sun” → brighter, “small sun” → dimmer, “hue” → change colors etc.

But I don’t have any lamps and I don’t want any. Instead I wanna write li’l scripts so that the “big sun” means “next track” and that the “hue” button plays a different album depending on what day of the week it is or how many times it’s already been pressed recently etc etc. (I mean, as long I can get the buttons to run arbitrary shell scripts or HTTPS requests I’d be set, because I know how to make those; for example I have a script “if this script is run and it’s morning and I’m already playing The Cranberries, put Cornershop on, but if music is paused, instead play some Wishbone Ash” or whatever.)

Is this possible? I saw that there’s a rest API and that maybe I could make my scripts poll the state of the button (although this particular device isn’t listed in the API docs) and push comes to shove, that’ll be OK, but that does sound a li’l backwards since that’d make it hard to make “cycling” buttons that I can rapidly press a couple of times in a row to cycle to a particular state.

So the question is: should I stroll down to my neighborhood store and buy these two li’l gadgets (and no other “hubs” or whatever because the Conbee II will be the hub) and this’ll be possible, and/or am I overlooking an easier and better solution?

I forgot to say that none of the computers are particularly close to my stereo nor is there a power supply near it, so the Hue Dim Switch looked like good with CR batteries and that it can stick to a bookshelf most of the time or I can detach it when I need to use it more as a “remote”.

Thanks to all who took the time to read :pray:t2:

PS: If, down the line, I get lamps or window blinds or whatever and I could make some of the buttons do that also, that’d be great but step one I basically just want a super dwimmy music remote.

All my daydreaming about multiple state cycling etc aside, just a single button would be a heck a lot better than what I have now.

Music turns off in the evening from cron, and that’s great, but I don’t wanna schedule it starting in the morning again because I might not even be home or I might be asleep or whatever. So that’s why I was looking at smart buttons for this.

The Conbee II dongle will need connecting to an always on server of some kind. We use a Raspberry Pi 4 B 4GB, which is plenty powerful enough for this. Make sure to attach the dongle via a USB 2 extension lead to avoid interference issues.

We use this setup with Deconz to control all lights in the house, heating, ventilation, music, etc. For music we’re using Arylic Up2Stream amp boards which are great. Cheap and cheerful and have a decent API you can use to control it.

To control the music we’re using the hue tap dial switch. The rotary dial works great for volume adjustment.

Deconz will let you perform actions against other lights, groups, virtual sensors, etc on the system. But it cannot make arbitrary HTTP requests as actions. There are a number of ways to achieve this, e.g. additionally using Home Assistant, of which Deconz would then be a part. But we wanted to keep it simple, so created a service called “hue-actions” that bridges Deconz virtual sensors over to HTTP requests/command lines. I’ll add a few extra docs and look to open source it soon in case it’s useful.

That sounds awesome :pray:t2:

You can use the websocket to react to button presses. Here is a small example in python. Has no error handling etc but works:

import websocket
import _thread
import time
import rel
import json

def on_message(ws, message):
    jmsg = json.loads(message)
    id = jmsg['id']
    buttonevent = jmsg['state']['buttonevent']
    match id:
        case '18':
            print("sensor 18")

            match buttonevent:
                case 1002:
                    print("short press on")
                case 2002:
                    print("short press off")

        case _:
            print("sensor not handled")

def on_error(ws, error):

def on_close(ws, close_status_code, close_msg):
    print("### closed ###")

def on_open(ws):
    print("Opened connection")

if __name__ == "__main__":
    ws = websocket.WebSocketApp("ws://",

    ws.run_forever(dispatcher=rel, reconnect=5)
    rel.signal(2, rel.abort)
1 Like