public void HSEvent(HomeSeerAPI.Enums.HSEvent EventType, object[] parms) { JObject evtData = new JObject(); try { string Source = "Unknown"; evtData.Add("PARAMS", string.Join(", ", parms)); switch (EventType) { case Enums.HSEvent.CONFIG_CHANGE: { Console.WriteLine("Got CONFIG_CHANGE event"); Console.WriteLine(" - HSEvent {0}: {1}/{2}/{3}/{4}/{5}", EventType.ToString(), parms[5].ToString(), parms[0].ToString(), parms[1].ToString(), parms[2].ToString(), parms[3].ToString()); evtData.Add("time", DateTime.UtcNow.ToString()); //mCore.ReloadConfig(15); // Delay atleast 15 seconds to make time for other changes. } break; case Enums.HSEvent.LOG: evtData.Add("typeid", parms[0] as string); DateTime parsedTime; if (DateTime.TryParse(parms[1] as string, out parsedTime)) { evtData.Add("time", parsedTime); } else { // FIXME: Should not happen Console.WriteLine("Failed time parse.. FIXME"); evtData.Add("time", DateTime.UtcNow); } evtData.Add("category", parms[2] as string); evtData.Add("message", parms[3] as string); break; case Enums.HSEvent.STRING_CHANGE: { Source = parms[3].ToString(); string dev_addr = parms[1].ToString(); // if (dev_addr == "") evtData.Add("unique_id", "HS-ID-" + Source); evtData.Add("address", dev_addr); // evtData.Add("address", parms[1].ToString()); evtData.Add("value", parms[2].ToString()); Int32 sid = Int32.Parse(Source); var ta = hsHost.DeviceLastChangeRef(sid); evtData.Add("time", ta.ToUniversalTime()); } break; case Enums.HSEvent.VALUE_CHANGE: { Source = parms[4].ToString(); string dev_addr = parms[1].ToString(); evtData.Add("unique_id", "HS-ID-" + Source); evtData.Add("address", dev_addr); evtData.Add("value", parms[2].ToString()); evtData.Add("oldvalue", parms[3].ToString()); Int32 sid = Int32.Parse(Source); evtData.Add("string_value", hsHost.DeviceString(sid)); var ta = hsHost.DeviceLastChangeRef(sid); evtData.Add("time", ta.ToUniversalTime()); } break; default: evtData.Add("time", DateTime.UtcNow.ToString()); Console.WriteLine("No handler yet for HSEvent type {0}", EventType.ToString()); Console.WriteLine(" - HSEvent {0}: {1}", EventType.ToString(), String.Join(" | ", parms)); break; } } catch (Exception e) { Console.WriteLine("Exception something foo: {0}", e.Message); } }