Eventghost Launch Webcore Piston


#1

I have a weird issue and am hoping someone has seen this before. From all my research today, I haven’t been able to find anything similar. So I am migrating everything from ST to Hubitat (as many of us are), and am going to be using Webcore in Hubitat as well (as I had 100% of my ST setup in webcore).

I am also running Eventghost on my PC’s which control a few things in Webcore. Just to give some examples:
Monitor when PC is on or off by changing virtual switch when PC turns on or off.
Use virtual switch (same one as before) to turn PC on or off
Turn on desk lighting automatically upon PC boot, and off when PC is shutdown.
I also have a simple piston which just toggles lights when I hit certain buttons on my keyboard.

I guess a little background into how I did this is I have Eventghost setup to send an event to a webserver. I would then copy the Piston URL (external URL in Webcore) and use that as the web command URL.

If I wanted to send along a variable I could add a ?VAR=VARSTATUS after the end of the URL, and it would allow me to run the piston and pass along a piece of data too. Very useful as I can tell webcore when my PC is on / off just by manually executing the piston.

So here is where it all gets messed up. The ST URL ended in the Piston ID (:PISTON ID:). I have shortened some stuff from this URL (for security), but it shows the overall layout.
https://graph-na04-useast2.api.smartthings.com/api/token/5dc66c3a/smartapps/installations/49cb5ada/execute/:05a137aebff908de7:

The Hubitat URL ends by sending a variable called access_token. This for some reason creates an issue when being sent from Eventghost which doesn’t allow it to run. Again, shortened some stuff so its different.

https://cloud.hubitat.com/api/ef25364a6b6a/apps/36/execute/:1f053bffe94e09f215:?access_token=1a17a50b--e1a2dd8b34c1

I am seeing this error in Eventghost.
EG%20Error

I have also tried adding a “&” after the end of the URL (which would allow another variable to be added) which works well from a web browser, but not Eventghost.

Anyone have any thoughts? I have been playing around with this for hours and have had no luck. It would be a really big bummer if this quit working for me as I have quite a few pistons setup this way.

I know this isn’t quite a true webcore issue, but I was curious as anyone who may be currently migrating might see this issue and have solved it. Thanks.


#2

I do not own a Hubitat, but I use EventGhost quite a bit…

Have you tested this URL from a normal web browser?


#3

Yes, it works stock in the web browser, and if I were to add a “&” after it. For some reason I was thinking EG was adding a “/” to the end of the URL and when I tried it that way I would see an Oauth error.

So I tried it with a “&/” at the end and it would work in a web browser, but in EG it still wouldn’t work.


#4

I am not trying to be nosy, but are there any symbols or punctuation in the censored URL?


For reference, in EventGhost, I use:
Add Action > EventGhost > Python Command > Python Statement:
import urllib; urllib.urlopen('https://example.com/api/token/abc123/smartapps/installations/def456/execute/:ghi789:?PcLocked=false&PcOff=false')


#5

No, it is very similar to the ST one, but the access_token seems to be sent as a variable rather than included in the link. Besides the ? separating the variables at the end, and the & I added myself, there is no other symbols besides the /


#6

I will play around with the format you use. I have been using the send command to webserver plugin which seemed to work really well.

Can I just copy and paste the statement you have above (and change my URL) into the Python Statement box directly? Or would there be anything else I have to setup?


#7

That string above is 100% identical to all of my EventGhost commands to webCoRE…
(with a slight scramble for censorship, and the ending may each be a bit different… but the structure is spot on)


At the risk of stating the obvious:

  • Make sure Plugin: Webserver is in your Autostart folder
  • Everything is cAsesEnsiTive in the URL
  • That caSeseNsitiVe args must match exactly back in webCoRE as well

#8

Is the 2 lines all part of the same command or is it 2 commands?

I tried it both ways and ended up getting this as a result from EG:


#9

It is one long line.

Note: If you just added Webserver to the Autostart folder, you may have to save, close EG, and reopen the app to properly initialize.


#10

Well I have Plugin: Webserver already there. Does anything within that need configured? I’ll reboot my PC and see if it helps

I have checked case and everything looks good. For this one I just need it to activate the piston, as I am using it to toggle a light. So no variables are being passed, aside from the access_token.

I’m no programmer so I am of quite limited knowledge from the HTML side of things, but could the access token be too long of a variable for EG to handle?


#11

Sorry, I had a blonde moment.

The Webserver lets EG receive outside commands. it has nothing to do with outgoing requests, like urlopen

The other things I said above are true though.


I wonder, can you focus on just this one single command?
(temporarily ignoring all of your logic, can you just create a single (lone) Python command, and execute it via right click?)

Once the URL is working correctly, you should be able to bring it into your real macro.

The reason I am asking this is because some of the errors above look like from a different animal.


#12

I’m sending data to a webcore piston but not in the format you’re trying to use. I may have ran into the same issue you’re encountering because of the HE access token. Send the data you want in a variable with the name as key and variable value as value.

Totally spaced that you’re going from EG to webcore.


#13

So even running it from the test button within the python command window will cause it to fail out. Otherwise I have been selecting the task and hitting the run button, with still no luck.


#14

I understand, but I’d prefer only seeing errors for the one single lone command


#15

Could you copy what one of your commands would be? Be sure to hide your URL and access token though.

What are you using to send the command from EG?


#16

I’m sending a command from node-red with json data. Same format of your piston URL except with the json payload.

Edit: image


#17

Have you tried it this way?

https://cloud.hubitat.com/api/8eff-e1-f5cebdc44c7e/apps/3/execute/:9386600ceb1:?data=ReyData&access_token=my_token

Log $args.data


#18

Got it to work! Tried a bunch of configurations, and this finally decided to cooperate.

Went back to the Send event to another webserver command and it decided to work.

This is the URL format I used that cooperated:
http://192.168.1.97/apps/api/36/execute/:PistonID:?access_token=My Token

Not sure why, but switching out the public IP for my Hub’s IP worked really well.