Stream Deck + Hubitat + Maker API = Finally got it working!

Hi.

I've been wanting to integrate my Stream Deck and Hubitat for a while now. It's been burning cycles in my brain like a minimized program running in the background, taking up cycles for a long time.

Finally, I was able to get it done today.

I was searching the net and found ripnet's GitHub repo for a custom plugin to the Stream Deck. I set it up, and after getting it added to the Stream Deck app, the toggle and set switch functions weren't working as the documentation indicated.

No offense to ripnet, but the documentation was sparse and it wasn't clear as to how to make the actions in the custom plug to work.

You can look at his GH repo and download the latest release if you want to add it to your Stream Deck. There is a post here in the Hubitat Community pointing to it as well.

I added an issue in his repo with suggested edits for the readme. I forked his repo and updated the readme as well. You can find that here.

Now that I was committed, I searched in the Hubitat Community and found this post where @christian.busch and @aaiyar figured out how to use the Maker API to turn a device on an off.

I took that information, re-swizzled it, and was able to create two multistep buttons (on & off) for 2 sets of LED curtain lights that I use when doing video calls.

Requirements:

  • Maker API needs to be installed
  • Maker API app ID
  • Maker API Access Token
  • ID of the device you want to turn on or off.

With these ingredients, you can combine them all to create the URL that will need to be added to the Stream Deck button you want via the System > Website feature in the Stream Deck App.

Here are the URLs that I created for my specific setup. Be sure to modify the API ID, Device ID and Access Token for your setup.

Stream Deck App > System > Website > URL - Turn On outlet to control lights:

http://192.168.x.x/apps/api/[maker API ID]/devices/[device id]/[command]?access_token=[access_token]

Example System > Website URL to turn on an outlet to control lights:

http://192.168.20.93/apps/api/[maker API id]/devices/[device id]/[command]?access_token=[access token]
  • Note: you can run an API call to your specific device ID to get the commands. For my setup, it was simply on and off.

I've pasted the same URLs as above, but this time the [command] place holder is replaced with the actual command that I pulled when I polled the specific device API:

turn on:

http://192.168.x.x/apps/api/[maker API ID]/devices/[device id]/on?access_token=[access_token]

turn off:

http://192.168.x.x/apps/api/[maker API ID]/devices/[device id]/off?access_token=[access_token]

Copy and paste these URLs into your Website Button in the URL field and you should be good to go.

I'm late for a round of golf, so I don't have screenshots or videos. If anyone would like me to share those, I can do it later this evening (2021/09/18) or tomorrow (2021/09/20).

Reply to this post and I'll take care of it.

Really hope this helps others get their SD & HE integrations working.

:v:t2:, :heart: & :hugs:,

--Shawn

1 Like

Looking forward to testing this out when I get back to my desk!

Works great for me. I previously had the same setup using IFTTT plugin but this is good because it's local/free.

1 Like

Glad it worked for you!

Now that ingot the basics done, the next step is to add a few more steps to the multi step buttons to turn on other Elgato lights, and open apps that I use when I'm on video calls.

It'll be great to press one button and open apps on the Mac, turn on lights, and set the audio in & outs with one button press!

1 Like

There is one thing I thought about. There is no way to have two way communication with the stream deck. In other words the stream deck won't know if the lights are on/off so it could be out of sync with the current state.

I can't think of a workaround other than to toggling the button again to get lights in sync and turn on/off,

When using the API URLs the POST response includes the previous status or state (on/off) of the target device.

Example: When you send the OFF command to a device, the POST response provides the state before the OFF command is executed. The device state In the POST response example below is "currentValue":"on"

{"id":"259","name":"Zooz Power Strip Outlet Component","label":"zen204-01 - Northeast Curtain Lights","type":"Zooz Power Strip Outlet Component","attributes":[{"name":"switch","currentValue":"on","dataType":"ENUM","values":["on","off"]},{"name":"powerLow","currentValue":0,"dataType":"NUMBER"},{"name":"switch","currentValue":"on","dataType":"ENUM","values":["on","off"]},{"name":"energyTime","currentValue":1598436655644,"dataType":"NUMBER"},{"name":"powerHigh","currentValue":89.8,"dataType":"NUMBER"},{"name":"power","currentValue":8.8,"dataType":"NUMBER"},{"name":"energy","currentValue":9.34,"dataType":"NUMBER"},{"name":"energyDuration","currentValue":"390.48 Days","dataType":"STRING"}],"capabilities":["Actuator","Refresh","PowerMeter",{"attributes":[{"name":"power","dataType":null}]},"EnergyMeter",{"attributes":[{"name":"energy","dataType":null}]},"Outlet",{"attributes":[{"name":"switch","dataType":null}]},"Switch",{"attributes":[{"name":"switch","dataType":null}]},"Sensor"],"commands":["off","on","refresh","reset"]}

Per the Maker API documentation (search for key word: events and you'll find it).

The events API (/devices/[device id]/events) will return the current state value for the target device.

Depending on the device type and its capabilities, the response may contain more than you want. The example events response below is for a Zooz Power Strip that also has energy monitoring features, you can ignore the first two energyDuration indexes and see the current state of the switch is off.

I've separated the part of the RAW response that has the switch state:

[{"device_id":"498","label":"zen201-05 - North Curtain Lights","name":"energyDuration","value":"238.75 Days","date":"2021-09-20T21:51:16+0000","unit":null,"isStateChange":null,"source":"DEVICE"},{"device_id":"498","label":"zen201-05 - North Curtain Lights","name":"energyDuration","value":"238.74 Days","date":"2021-09-20T21:36:16+0000","unit":null,"isStateChange":null,"source":"DEVICE"},

{"device_id":"498","label":"zen201-05 - North Curtain Lights","name":"switch","value":"off","date":"2021-09-20T21:35:31+0000","unit":null,"isStateChange":null,"source":"DEVICE"}


{"device_id":"498","label":"zen201-05 - North Curtain Lights","name":"power","value":"0","date":"2021-09-20T21:35:30+0000","unit":"W","isStateChange":null,"source":"DEVICE"},{"device_id":"498","label":"zen201-05 - North Curtain Lights","name":"power","value":"9.4","date":"2021-09-20T21:35:29+0000","unit":"W","isStateChange":null,"source":"DEVICE"},{"device_id":"498","label":"zen201-05 - North Curtain Lights","name":"switch","value":"on","date":"2021-09-20T21:35:29+0000","unit":null,"isStateChange":null,"source":"DEVICE"},{"device_id":"498","label":"zen201-05 - North Curtain Lights","name":"power","value":"0","date":"2021-09-20T21:35:25+0000","unit":"W","isStateChange":null,"source":"DEVICE"},{"device_id":"498","label":"zen201-05 - North Curtain Lights","name":"switch","value":"off","date":"2021-09-20T21:35:25+0000","unit":null,"isStateChange":null,"source":"DEVICE"},{"device_id":"498","label":"zen201-05 - North Curtain Lights","name":"energyDuration","value":"238.73 Days","date":"2021-09-20T21:26:16+0000","unit":null,"isStateChange":null,"source":"DEVICE"},{"device_id":"498","label":"zen201-05 - North Curtain Lights","name":"energyDuration","value":"238.72 Days","date":"2021-09-20T21:11:16+0000","unit":null,"isStateChange":null,"source":"DEVICE"},{"device_id":"498","label":"zen201-05 - North Curtain Lights","name":"energy","value":"14.8","date":"2021-09-20T21:06:16+0000","unit":"kWh","isStateChange":null,"source":"DEVICE"},{"device_id":"498","label":"zen201-05 - North Curtain Lights","name":"power","value":"9.5","date":"2021-09-20T21:01:15+0000","unit":"W","isStateChange":null,"source":"DEVICE"},{"device_id":"498","label":"zen201-05 - North Curtain Lights","name":"power","value":"9.4","date":"2021-09-20T21:00:06+0000","unit":"W","isStateChange":null,"source":"DEVICE"},{"device_id":"498","label":"zen201-05 - North Curtain Lights","name":"switch","value":"on","date":"2021-09-20T21:00:04+0000","unit":null,"isStateChange":null,"source":"DEVICE"},{"device_id":"498","label":"zen201-05 - North Curtain Lights","name":"energyDuration","value":"238.71 Days","date":"2021-09-20T20:56:16+0000","unit":null,"isStateChange":null,"source":"DEVICE"},{"device_id":"498","label":"zen201-05 - North Curtain Lights","name":"power","value":"0","date":"2021-09-20T20:42:02+0000","unit":"W","isStateChange":null,"source":"DEVICE"},{"device_id":"498","label":"zen201-05 - North Curtain Lights","name":"switch","value":"off","date":"2021-09-20T20:42:02+0000","unit":null,"isStateChange":null,"source":"DEVICE"},{"device_id":"498","label":"zen201-05 - North Curtain Lights","name":"energyDuration","value":"238.7 Days","date":"2021-09-20T20:41:16+0000","unit":null,"isStateChange":null,"source":"DEVICE"},{"device_id":"498","label":"zen201-05 - North Curtain Lights","name":"energyDuration","value":"238.69 Days","date":"2021-09-20T20:26:16+0000","unit":null,"isStateChange":null,"source":"DEVICE"},{"device_id":"498","label":"zen201-05 - North Curtain Lights","name":"power","value":"9.5","date":"2021-09-20T20:21:15+0000","unit":"W","isStateChange":null,"source":"DEVICE"}]

I use an app to help me whenever I'm messing around with APIs called PAW. Postman is another one.

Here's an annotated screenshot showing the state using formatted JSON:

The net-net is you could structure a couple of API calls to do what you want:

1 - Get events for target device;
2 - depending on the state (i.e., off) - turn on target device
3 - Get status to ensure it was turned on

For my setup, I'm in the room where the lights are being turned on or off, so I have the visual feedback to know it all works.

I was playing around this afternoon and discovered the Multi Action Switch Function under the Stream Deck menu:

The Multi Action function does a single action, the Multi Action Switch toggles between two states that you configure (e.g. turn on & turn off)

Said another way, with Multi Action you have to create two separate & distinct buttons to get the turn on/turn off function. The Multi Action Switch gives you a toggle (on/off) in a single button using tabs 1 & 2 to configure the two states you want. I've programmed Turn On events under Tab 1:

And here's the Turn Off events under Tab 2:

This graphic should help explain the difference (I hope):

The cool thing is that the Stream Deck lets you assign a different icon for each of the Multi Action Switch states. The image above show the yellow filled light bulb giving the visual of what the current state is and what pressing the button will do (current state is off, button press turns lights on).

The screenshot below shows the 2nd state (current state on, button press turns lights off):


Here's a GIF showing the difference:

Multi Action vs Multi Action Switch

First, thank you for this! My stream deck is finally getting some good use. Second, is it possible to push text to the buttons? Treat as if it were a "notification" type device. For example, I use "Follow Me" (by Brian). Would be nice to change the button color to red and show a msg for example.

Just curious if you'd already considered that.