[OBSOLETE] Send Events to EventGhost

EventGhost is an open source tool for Windows automation that has been in use by HA and HTPC folks for well over a decade. EventGhost allows the user to take actions in response to events triggered by various programs and devices in your environment. EventGhost can be used as a general rule engine, scheduler, or device handler that is run locally and as such isn’t dependent upon the ST cloud. Programming actions in response to events is done through a simple drag-and-drop interface that is reliable and easy to use.

This SmartApp allows you to send events from SmartThings to an EventGhost server running the Webserver plugin. The result is that events from your SmartThings switches, dimmers, motion sensors, etc can now trigger actions in EventGhost.

Version 1.0.0 - 2015-09-13 - Initial release
Version 1.1.0 - 2015-09-15 - Changed handling of binary(ish) vs non-binary values to allow sending value data to EG to be handled via Python and eg.event.payload[]
Version 1.2.0 - 2016-04-18 - Added support for individual button values

I’ve modified the code to better handle binary-ish events vs events that have usable data attached. Events that are mostly binary (or at least have a fixed set of values returned) include the value within the event string. This makes it easy to drag/drop an event like “Light Switch.switch.on” and handle it separately from “Light Switch.switch.off” in EG. For events where the value is actually variable, the value is passed to EG as a payload where it can be handled via Python in EG using eg.event.payload[]. In this case, you’d receive an event in EG similar to “Light Switch.level” with a payload of “50”.

Currently “color” values are not working which I think is due to the # character screwing up the REST call to EG. An event is triggered in EG when the color changes but the value doesn’t carry over yet.

Here’s a random sampling of events happening in my home as it appears in EventGhost:

Do you know if its possible to send events from eventghost to ST?

If you mean sending actual events into the ST event queue… I have no idea how to make that work. What I do wind up doing quite a bit of is using the REST endpoint application and then using Python commands in EventGhost to directly control devices in SmartThings.

That looks like a good way to go if you want eventghost to communicate with ST! Thanks! Do you got a example how you send your Python commands?

Create a Python Script action, then add the following two lines:

import urllib;

Thanks once again! Do you mind sharing your code for REST Endpoint smartapp? I am getting “Metadata definition not found” when trying to add the smartapp.

Your best bet for setting up the REST endpoint is to simply browse to a deployed instance of this code here:

You’ll be redirected to ST to authenticate, you’ll need to select the devices you want the app to control, the access token will be handed back to that script, and it will then show you a page full of on/off/toggle buttons for each device. Copy the URL for each of those buttons, and use them in Python script above to control ST from EventGhost.

Do you have any examples of that PHP file that support dimmer switches and setLevel?
Is setLevel still broken?

After I select my device and try to push the button authorize i get the message “Client is not associated with a SmartApp in location Home.”

Did you create the SmartApp “Endpoint”?

Specifically: SmartThings API Endpoint Example · GitHub

I am getting “Metadata definition not found” when trying to add the smartapp :confused:

That example doesn’t include the required metadata SmartApp definition. It’s also very old, and likely not updated with any required changes.

You should check out the web services SmartApp docs here. It also includes a walkthrough tutorial of the example found here.

I`ve tried to install the web service example you linked to and it worked alright! Then i activate OAuth.

Then i tried calling the API from the Pyton Script supplied by luma like this:

import urllib;

Still it doesnt work…

The URL should look something like this:

https://graph.api.smartthings.com/api/smartapps/installations/<installation ID>/switches/<device ID>/on?access_token=<access token>

In your example above, I don’t see anything after the installation ID.

Still can´t get it to work…

My python script looks like this:

import urllib;
urllib.urlopen('https://graph-eu01-euwest1.api.smartthings.com/api/smartapps/installations/a9cf307b-e16f-4f85-b868-69dccedf5943/switches/7B78/on access_token=xxxxxx-xxxxx-xxx-xxxxxxxx');

When I simulate my smartapp “Web Services Tutorial” I toggles my switches on and off so it seems that its setup OK.

I get this [{"name":"Läslampa Soffan","value":"off"},{"name":"Z-Wave Metering Switch","value":"off"}] when I enter the URL.

This is the code I use


  • Web Services Tutorial
  • Copyright 2015 SmartThings
  • Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except
  • in compliance with the License. You may obtain a copy of the License at:
  •  http://www.apache.org/licenses/LICENSE-2.0
  • Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
  • on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
  • for the specific language governing permissions and limitations under the License.

name: “Web Services Tutorial”,
namespace: “smartthings”,
author: “SmartThings”,
description: “web services tutorial”,
category: “”,
iconUrl: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png”,
iconX2Url: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png”,
iconX3Url: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png”,
oauth: [displayName: "web services tutorial ", displayLink: “http://localhost:4567”])

preferences {
section (“Allow external service to control these things…”) {
input “switches”, “capability.switch”, multiple: true, required: true

mappings {
path(“/switches”) {
action: [
GET: “listSwitches”
path(“/switches/:command”) {
action: [
PUT: “updateSwitches”

// returns a list like
// [[name: “kitchen lamp”, value: “off”], [name: “bathroom”, value: “on”]]
def listSwitches() {

def resp = []
switches.each {
    resp << [name: it.displayName, value: it.currentValue("switch")]
return resp


void updateSwitches() {
// use the built-in request object to get the command parameter
def command = params.command

if (command) {
    // check that the switch supports the specified command
    // If not, return an error using httpError, providing a HTTP status code.
    switches.each {
        if (!it.hasCommand(command)) {
            httpError(501, "$command is not a valid command for all switches specified")
    // all switches have the comand
    // execute the command on all switches
    // (note we can do this on the array - the command will be invoked on every element

def installed() {}

def updated() {}

Making slow progress…

curl -H “Authorization: Bearer ” -k -X PUT “https://graph-eu01-euwest1.api.smartthings.com/api/smartapps/installations/f3f74480-c832-4c04-8e5a-b75643e5e6cd/switches/on

I turn on all switches.

But if I try to turn on a specific switch I get a error message back. What identifier should you use?

{“error”:true,“type”:“SmartAppException”,“message”:“Not Found”}

Updated code to 1.2.0 to support controllers with multiple buttons. The SmartApp now sends unique events in response to individual buttons and also indicates button press or hold (if the device supports it).

1 Like

Hi @luma, thanks for the app. It works great. I have a doubt regarding the switch button within smartings app to turn off my computer

The question here is, is there a way to send an update to smartings app when the pc is turn on. I want the switch in the app to turn on when the pc powers on.


I’m not sure if this is helpful, but I recently added event ghost functionality to a smart switch device handler so I’d be able to easily turn on and off my computer and use my Amazon Echo to change the volume, pause shows, etc.

The off command sends a command to the computer and EventGhost shuts it down. Once the switch reports that no power is being used, it turns the switch off.

I have my computer set to turn on when power is restored so turning the switch on also turns my computer on.