SmartThings Community

TUTORIAL: Using EventGhost for Scheduling

I know you can use negative numbers but my question was, which is correct for the western hemispere.
-75 = 75W

1 Like

I’m in love with EventGhost particularly for integration with my HTPC (home theater) functions … basic stuff like setting the correct speakers and frame rate when I use my existing Virtual Switch to turn on the Projector and Screen, etc…

For general Event handling, I think it would be helpful to write a SmartThings customized Plug-In. That way it could allow configuration and hold the long endpoint address and authentication token information and make it unncessary to use the generic URL call functions with the full URLs. In fact, a customized Plug-In could support the most common Capabilities / Commands (on/off, etc), and Attributes.

This is a great baseline, and I’m very tempted to add this to my project list.

But … well, there may be some more popular third-party event handler standards to follow instead of Event Ghost – perhaps MQTT, for example; IFTTT might also be expanding their functionality, but it is another Cloud…

So it is difficult to give this much personal priority. I’ve tagged this Topic #EventGhost and will do a search and tag others; the next tiny bit of ambition is to add some EventGhost pags to the

Let’s see how the discussion evolves?

For Scheduling, in particular, I think that EventGhost might not be a bad way to implement the “Schedule Driver” Device Type that I proposed here: External Time Source / Schedule Driver for SmartThings

I’m not sure what you’re asking. Google search a latitude and longitude calculator and simply plug in those values into the Twilight settings.

I like the way you think. I personally am a fan of EventGhost because I have an always-on Windows PC. However, none of the functionality I’m using it for currently goes beyond what any connected Linux box could do with cron + scripts.

In fact, someone with knowledge of Linux could easily adapt exactly what I’ve done here with EventGhost and have it running on a Rasberry Pi or similar hardware.

I do think at this juncture that there is great value at having external (preferably non-cloud based) solutions to SmartThing’s scheduler. Since rolling my own scheduler I’ve had exactly zero glitches with my connected home.

1 Like

Indeed… that’s the point of abstracting all or most of SmartThings’s standard scheduling methods into a “Capability” (well, since new Capability is unlike, just into a “Device Type Design Pattern Standard”) is so attractive to me.

This would isolate all SmartApps from the particulars of the actual implementation.

A SmartApp would simply ask the user to select any device instance that provides type “Schedule Driver”, and the SmartApp would be able to use that device for all scheduling.

The Community Developers could implement it using various methods and publish the physical or service code along with the DTH code:

Implementations could be done in:

  • Linux; mostly using cron, but also simple countdown timers.
  • EventGhost schedules, cron plug-in, timers.
  • A ZigBee connected Arduino with a real-time-clock (RTC) chip and some libraries.
  • Various cloud services.

I super encourage feedback on my draft design spec … I’m willing to discuss and finalize the spec for the next phase: Proof of Concept implementations. We’d need 2 or 3 in order to prove the spec is a good abstraction for various different devices / servers / services:

There is an MQTT plugin for EventGhost which can be combined with an MQTT broker (several options available for cloud or local deployment) and the MQTT Bridge. AWS, Azure, and basically everyone else with a dedicated IoT service support it. Further, there are client libraries available for nearly every microcontroller system, so $2 wifi platforms like the ESP8266 can interact directly with MQTT - and thus with EG and ST and Home-Assistant, etc etc.

We’re still working through some bugs in the bridge but it feels like MQTT is probably the most flexible way to import and export events onto a common bus that several other platforms can interact with.

1 Like

I have installed your smartapp and followed the example above but get the following errors in EG

11:47:24 Webserver error /?
11:47:24 Exception ‘utf8’ codec can’t decode byte 0x92 in position 459: unexpected code byte
11:47:24 Webserver: Exception on handle_one_request: ‘utf8’ codec can’t decode byte 0x92 in position 459: unexpected code byte

Any ideas???

Despite the errors, I dragged onto a macro and everything worked as expected

That works but I made the mistake of using his example. Sunset did not fire last night but sunrise did at 7:09PM last night :slight_smile: Finally got it working correctly by tweaking my PC time just before the expected times in my area and watching the EG log.

1 Like

What is the name of the device? Just “Office Door” with a space in the middle?

Yes however your example “http://webserver.local/?This.Is.A.Test” generates the identical error

Weird. In that case it’s likely something internal to the Webserver plugin which is getting way out of my depth.

I try to take a deeper look later … I’m interested in learning more of the guts of EventGhost…

1 Like

Thing is… despite the errors everything still works as I exepect/want it to :slightly_smiling:

Gonna keep looking deeper as well. Now that even runIn() and runOnce() appear to fail regularly I am giving up (for now) on all ST type scheduling. EG scheduling seems pretty straightforward. I just got “Light off after n minutes when door closes” to work on EG. Not sure if there are any routines using time schedules and/or delays that cant be handled by EG.


1 Like

Well I have been playing around with EG for a little over 2 days now and decided, while I quite like it, it is not for the “faint of heart”. While scheduling basic daily routines (i.e. On at 8AM - Off at 5PM) is pretty straightforward, macros (or routines if you prefer) such as “Lights off after 10 minutes when door closes” can be confusing. My problem was with the use of timers. Below I will outline what I ended up doing for the purpose of anyone who may be hitting their head against the wall with the same problem or those with more knowledge of EG to correct and steer us towards a better approach.

I started small with a simple idea of turning on/off a light when a door opened. I used the Luma’s post (as well as his smartapp) above to get me started

I installed the “Timer” plugin. Initially I tried using the “Wait for…” action but it will hang EG until the time has expired. I then created 3 macros as well as 2 timers both named exactly the same (i.e. timeOff). The 1st timer expired after 1 second and has the option “Start new timer…” enabled. What it does is abort any other timer with the same name. Hopefully, the reason for this will be obvious below. The 2nd timer is set to expire after [X] seconds when the door closes.

  1. open macro
    Door Open event
  • Python command “Turn on a light”
  • Timer1.timeOff (the 1 second timer)
  1. closed macro
    Door Closed event
  • Timer2.timeOff (300 seconds )
  1. time expired macro
    Timer2 expired event (this is the event shown in the left pane - log when timer 2 expired)
  • Python command “Turn off the light”

So… when the door closes a timer starts. Once expired the event “timer2 expired” is triggered which turns off the light. However, if the door is (re)opened timer1 (which has the same name as timer2) starts causing timer2 to abort… Make sense???

Really? Now you’ve totally shaken my confidence in EventGhost

Then again … all the plug-ins are Python scripts, right? And the code should be cleaned up if someone took ownership. Is EventGhost deprecated?

The “wait for” thing is by design, it was being used for the wrong use case (and correctly replaced with Timer). EG is for sure an aging code base and the maintainers can’t seem to figure out GitHub which doesn’t help things.

If you know Windows development and GitHub it sure looks like they could use a hand.

edit: holy crap, I hadn’t realized how bad it’s gotten. The EG team needs some serious help!

1 Like

This is fantastic. Thanks for sharing.

I think I’m gonna go with a simple cron based solution. Can that be made reliable? I guess we’ll see.

1 Like

I tried to sign-up to the EventGhost Forum and didn’t even receive my confirmation email (to gmail, so doubt it is spam). I don’t have high hopes for continued development … but, then again, all it takes is one leader to step up and take charge and damn the rest.

No need… It was/is a matter of “right tool for the job”. In this case it was the wrong tool :slightly_smiling: