示例#1
0
        public override bool HandleBasicReport(byte[] message)
        {
            bool handled = false;
            //
            //byte cmdLength = message[6];
            byte cmdClass = message[7];
            byte cmdType  = message[8];

            //
            if (cmdClass == (byte)CommandClass.SensorMultilevel && cmdType == (byte)Command.SensorMultilevelReport)
            {
                SensorValue sensorval = SensorValue.Parse(message);
                if (sensorval.Parameter == ZWaveSensorParameter.LUMINANCE)
                {
                    sensorval.Value = BitConverter.ToUInt16(new byte[2] {
                        message[12], message[11]
                    }, 0);
                    nodeHost.RaiseUpdateParameterEvent(nodeHost, 0, sensorval.EventType, sensorval.Value);
                    handled = true;
                }
            }
            //
            // if not handled, fallback to Generic Sensor
            if (!handled)
            {
                handled = base.HandleBasicReport(message);
            }
            //
            return(handled);
        }
示例#2
0
        public virtual bool HandleBasicReport(byte[] message)
        {
            bool handled = false;
            //
            //byte cmdLength = message[6];
            byte cmdClass = message[7];
            byte cmdType  = message[8];

            //
            if (cmdClass == (byte)CommandClass.Basic && (cmdType == (byte)Command.BasicReport || cmdType == (byte)Command.BasicSet))
            {
                nodeHost.RaiseUpdateParameterEvent(nodeHost, 0, ParameterType.LEVEL, (double)message[9]);
                handled = true;
            }
            else if (cmdClass == (byte)CommandClass.SceneActivation && cmdType == (byte)Command.SceneActivationSet)
            {
                nodeHost.RaiseUpdateParameterEvent(nodeHost, 0, ParameterType.GENERIC, (double)message[9]);
                handled = true;
            }
            else if (cmdClass == (byte)CommandClass.SensorBinary && cmdType == (byte)Command.SensorBinaryReport)
            {
                nodeHost.RaiseUpdateParameterEvent(nodeHost, 0, ParameterType.GENERIC, message[9]);
                handled = true;
            }
            else if (cmdClass == (byte)CommandClass.SensorMultilevel && cmdType == (byte)Command.SensorMultilevelReport)
            {
                var sensor = SensorValue.Parse(message);
                if (sensor.Parameter == ZWaveSensorParameter.UNKNOWN)
                {
                    byte key = message[9];
                    nodeHost.RaiseUpdateParameterEvent(nodeHost, 0, ParameterType.GENERIC, sensor.Value);
                    Console.WriteLine("\nUNHANDLED SENSOR PARAMETER TYPE => " + key + "\n");
                }
                else
                {
                    nodeHost.RaiseUpdateParameterEvent(nodeHost, 0, sensor.EventType, sensor.Value);
                    handled = true;
                }
            }
            else if ((cmdClass == (byte)CommandClass.SensorAlarm && cmdType == (byte)Command.SensorAlarmReport) || (cmdClass == (byte)CommandClass.Alarm && cmdType == (byte)Command.AlarmReport))
            {
                var alarm = AlarmValue.Parse(message);
                nodeHost.RaiseUpdateParameterEvent(nodeHost, 0, alarm.EventType, alarm.Value);
                handled = true;
            }
            return(handled);
        }
        public NodeEvent GetEvent(ZWaveNode node, byte[] message)
        {
            NodeEvent nodeEvent = null;
            byte      cmdType   = message[1];

            if (cmdType == (byte)Command.SensorMultilevelReport)
            {
                var sensor = SensorValue.Parse(message);
                if (sensor.Parameter == ZWaveSensorParameter.Unknown)
                {
                    byte key = message[2];
                    nodeEvent = new NodeEvent(node, EventParameter.SensorGeneric, sensor.Value, 0);
                    Utility.logger.Error("Unhandled sensor parameter type: " + key);
                }
                else
                {
                    nodeEvent = new NodeEvent(node, sensor.EventType, sensor.Value, 0);
                }
            }
            return(nodeEvent);
        }
示例#4
0
        public ZWaveEvent GetEvent(ZWaveNode node, byte[] message)
        {
            ZWaveEvent nodeEvent = null;
            byte       cmdType   = message[1];

            if (cmdType == (byte)Command.SensorMultilevelReport)
            {
                var sensor = SensorValue.Parse(message);
                if (sensor.Parameter == ZWaveSensorParameter.Unknown)
                {
                    byte key = message[2];
                    nodeEvent = new ZWaveEvent(node, EventParameter.Generic, sensor.Value, 0);
                    Console.WriteLine("\nUNHANDLED SENSOR PARAMETER TYPE => " + key + "\n");
                }
                else
                {
                    nodeEvent = new ZWaveEvent(node, sensor.EventType, sensor.Value, 0);
                }
            }
            return(nodeEvent);
        }