Example #1
0
        public override void ParseData(string command)
        {
            var jObject = JObject.Parse(command);

            if (jObject["status"] != null)
            {
                Status = jObject["status"].ToString();

                if (Status == "motion")
                {
                    OnMotion?.Invoke(this, EventArgs.Empty);
                }
            }

            if (jObject["no_motion"] != null)
            {
                NoMotion = int.Parse(jObject["no_motion"].ToString());

                OnNoMotion?.Invoke(this, new NoMotionEventArgs(NoMotion));
            }

            if (jObject["voltage"] != null && float.TryParse(jObject["voltage"].ToString(), out float v))
            {
                Voltage = v / 1000;
            }
        }
Example #2
0
        public override void ParseData(string command)
        {
            var jObject = JObject.Parse(command);

            if (jObject["status"] != null)
            {
                Status = jObject["status"].ToString();

                if (Status == "motion")
                {
                    MotionDate = DateTime.Now;
                    OnMotion?.Invoke(this, EventArgs.Empty);
                }
            }

            if (jObject["lux"] != null)
            {
                Lux = int.Parse(jObject["lux"].ToString());
            }

            if (jObject["no_motion"] != null)
            {
                NoMotion = int.Parse(jObject["no_motion"].ToString());

                OnNoMotion?.Invoke(this, new NoMotionEventArgs(NoMotion));
            }

            if (jObject["voltage"] != null && float.TryParse(jObject["voltage"].ToString(), out float v))
            {
                Voltage = v / 1000;
            }

            Debug.WriteLine($"Sid: {Sid}, Type: {GetType().Name}, Command: {command}, Sensor: {this}");
        }
Example #3
0
        public override void ParseData(string command)
        {
            var jObject = JObject.Parse(command);

            if (jObject["status"] != null)
            {
                Status = jObject["status"].ToString();

                if (Status == "motion")
                {
                    MotionDate = DateTime.Now;
                    OnMotion?.Invoke(this, EventArgs.Empty);
                }
            }

            if (jObject["no_motion"] != null)
            {
                Status = "no motion";

                NoMotion = int.Parse(jObject["no_motion"].ToString());

                OnNoMotion?.Invoke(this, new NoMotionEventArgs(NoMotion));
            }

            Voltage = jObject.ParseVoltage();
        }
Example #4
0
        public override void ParseData(JObject data)
        {
            if (data["status"] != null)
            {
                Status = data["status"].ToString();

                if (Status == "motion")
                {
                    LastMotionTimestamp = DateTime.Now;
                    MotionDetected?.Invoke(this, EventArgs.Empty);
                }
            }

            if (data["no_motion"] != null)
            {
                NoMotion = int.Parse(data["no_motion"].ToString());

                OnNoMotion?.Invoke(this, new NoMotionEventArgs(NoMotion));
            }
        }