private void Omnilink_OnThermostatStatus(object sender, ThermostatStatusEventArgs e)
 {
     if (!e.EventTimer)
     {
         WebNotification.Send("thermostat", JsonConvert.SerializeObject(e.Thermostat.ToContract()));
     }
 }
Esempio n. 2
0
        protected override void RequestStartup(TinyIoCContainer requestContainer, IPipelines pipelines, NancyContext context)
        {
            var path        = context.Request.Path;
            var method      = context.Request.Method;
            var contentType = context.Request.Headers["content-type"].FirstOrDefault();
            var msg         = string.Empty;

            if (path.ToLower().Contains("/requestlog") && method.ToUpper() == "POST")
            {
                var     json    = ReadBody(context.Request.Body);
                dynamic jsonObj = JObject.Parse(json);
                msg = string.Format("Log request for {0} {1}", jsonObj.Method, jsonObj.Path);
            }
            else
            {
                msg = string.Format("{0} {1}", method, path);
            }

            var feedId = context.Request.Headers["X-socketFeedId"].FirstOrDefault() ?? "required Header not set";

            if (feedId.Contains("required Header"))
            {
                _logger.Error("X-socketFeedId not set");
            }

            var socketServerAccesstoken = context.Request.Headers["X-socketServerAccessToken"].FirstOrDefault() ?? "required Header not set";

            if (socketServerAccesstoken.Contains("required Header"))
            {
                _logger.Error("X-socketFeedId not set");
            }

            WebNotification.Send(socketServerAccesstoken, feedId, msg);
        }
 private void Omnilink_OnThermostatStatus(object sender, ThermostatStatusEventArgs e)
 {
     // Ignore events fired by thermostat polling and when temperature is invalid
     // An invalid temperature can occur when a Zigbee thermostat is unreachable
     if (!e.EventTimer && e.Thermostat.Temp > 0)
     {
         WebNotification.Send("thermostat", JsonConvert.SerializeObject(e.Thermostat.ToContract()));
     }
 }
        private void Omnilink_OnZoneStatus(object sender, ZoneStatusEventArgs e)
        {
            if (e.Zone.IsTemperatureZone())
            {
                WebNotification.Send("temp", JsonConvert.SerializeObject(e.Zone.ToContract()));
                return;
            }

            WebNotification.Send(Enum.GetName(typeof(DeviceType), e.Zone.ToDeviceType()), JsonConvert.SerializeObject(e.Zone.ToContract()));
        }
        private void Omnilink_OnZoneStatus(object sender, ZoneStatusEventArgs e)
        {
            if (e.Zone.IsTemperatureZone())
            {
                WebNotification.Send("temp", JsonConvert.SerializeObject(e.Zone.ToContract()));
                return;
            }

            switch (e.Zone.ZoneType)
            {
            case enuZoneType.EntryExit:
            case enuZoneType.X2EntryDelay:
            case enuZoneType.X4EntryDelay:
            case enuZoneType.Perimeter:
            case enuZoneType.Tamper:
            case enuZoneType.Auxiliary:
                WebNotification.Send("contact", JsonConvert.SerializeObject(e.Zone.ToContract()));
                break;

            case enuZoneType.AwayInt:
            case enuZoneType.NightInt:
                WebNotification.Send("motion", JsonConvert.SerializeObject(e.Zone.ToContract()));
                break;

            case enuZoneType.Water:
                WebNotification.Send("water", JsonConvert.SerializeObject(e.Zone.ToContract()));
                break;

            case enuZoneType.Fire:
                WebNotification.Send("smoke", JsonConvert.SerializeObject(e.Zone.ToContract()));
                break;

            case enuZoneType.Gas:
                WebNotification.Send("co", JsonConvert.SerializeObject(e.Zone.ToContract()));
                break;
            }
        }
 private void Omnilink_OnAreaStatus(object sender, AreaStatusEventArgs e)
 {
     WebNotification.Send("area", JsonConvert.SerializeObject(e.Area.ToContract()));
 }
 private void Omnilink_OnUnitStatus(object sender, UnitStatusEventArgs e)
 {
     WebNotification.Send("unit", JsonConvert.SerializeObject(e.Unit.ToContract()));
 }