Custom "Swtich" on Hubitat Dashbord controlling external URL

I basically am trying to build an on/off switch button on the hubitat dashboard that would send a command to a particular external URL, one for on and one for off. I assume I'd have to build a custom virtual device driver to do this? The command I send is super simple, I imagine this wouldn't be too hard. I've seen examples of the reverse of this - but can't quite find what I need.

Right now I just control the device with curl on the command line, but it would be nice to do it from the dashboard:

Command for off:
curl -d u=1 -d d=0,0,0,0,0,0,0,0 http://raspberrypi.local:9090/set_dmx

Command for on:
curl -d u=1 -d d=255,255,255,255,255,255,255,255 http://raspberrypi.local:9090/set_dmx

Just create a virtual switch that you surface to your dashboard. Let's call it DoThing. Then in RM, create a rule

When DoThing changes
IF DoThing ON
Send, speak or Log a Message, Send HTTP Request (send the ON URL)
ELSE
Send, speak or Log a Message, Send HTTP Request (send the OFF URL)
ENDIF

1 Like

Fantastic idea!! I seem to be failing.... I can't figure out how to convert the JSON payload I send from curl into how RM wants to send the JSON payload:

What exactly are you seeing in terms of it not working via RM?

At a guess, you may need to include double-quotes around the u, d and list of 255's. You may also need to include curl-braces at the beginning and end.

Also, is the curl command a GET or a POST?

It's a POST.

I'm trying to poke an OLA D that is a DMX controller listening on a Raspberry Pi. The JSON API listens on port 9090.

When I query the Pi's web server for the command, it returns this syntax:

Usage:

POST u=[universe], d=[DMX data (a comma separated list of values)]

I have tried just about every combination of square, curly brackets & quotes and I just can't get it to do anything from the RM. I assume the Run Actions button in Rule Manager will as it says run the action?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.