Esempio n. 1
0
        public NodeEvent GetEvent(ZWaveNode node, byte[] message)
        {
            ZWaveValue zvalue   = ZWaveValue.ExtractValueFromBytes(message, 4);
            var        setPoint = GetSetPointData(node);

            setPoint.Precision = zvalue.Precision;
            setPoint.Scale     = zvalue.Scale;
            setPoint.Size      = zvalue.Size;
            setPoint.Value     = zvalue.Value;
            // convert from Fahrenheit to Celsius if needed
            var ptype = new {
                Type  = (Value)message[2],
                Value = (zvalue.Scale == (int)ZWaveTemperatureScaleType.Fahrenheit ? SensorValue.FahrenheitToCelsius(zvalue.Value) : zvalue.Value)
            };

            return(new NodeEvent(node, EventParameter.ThermostatSetPoint, ptype, 0));
        }
Esempio n. 2
0
        // all Thermostat command classes use
        //    0x01 for the "set" command (same as Command.BasicSet)
        //    0x02 for the "get" command (same as Command.BasicGet)
        //    0x03 value for the "report" command (that is the same as Command.BasicReport)

        public static ZWaveEvent GetEvent(ZWaveNode node, byte[] message)
        {
            ZWaveEvent nodeEvent = null;
            byte       cmdClass  = message[7];
            byte       cmdType   = message[8];

            if (cmdType == (byte)Command.BasicReport)
            {
                switch (cmdClass)
                {
                case (byte)CommandClass.ThermostatMode:
                    nodeEvent = new ZWaveEvent(node, EventParameter.ThermostatMode, (Thermostat.Mode)message[9], 0);
                    break;

                case (byte)CommandClass.ThermostatOperatingState:
                    nodeEvent = new ZWaveEvent(node, EventParameter.ThermostatOperatingState, message[9], 0);
                    break;

                case (byte)CommandClass.ThermostatFanMode:
                    nodeEvent = new ZWaveEvent(node, EventParameter.ThermostatFanMode, message[9], 0);
                    break;

                case (byte)CommandClass.ThermostatFanState:
                    nodeEvent = new ZWaveEvent(node, EventParameter.ThermostatFanState, message[9], 0);
                    break;

                case (byte)CommandClass.ThermostatHeating:
                    nodeEvent = new ZWaveEvent(node, EventParameter.ThermostatHeating, message[9], 0);
                    break;

                case (byte)CommandClass.ThermostatSetBack:
                    nodeEvent = new ZWaveEvent(node, EventParameter.ThermostatSetBack, message[9], 0);
                    break;

                case (byte)CommandClass.ThermostatSetPoint:
                    ZWaveValue zvalue   = ZWaveValue.ExtractValueFromBytes(message, 11);
                    var        setPoint = GetSetPointData(node);
                    setPoint.Precision = zvalue.Precision;
                    setPoint.Scale     = zvalue.Scale;
                    setPoint.Size      = zvalue.Size;
                    setPoint.Value     = zvalue.Value;
                    dynamic ptype = new ExpandoObject();
                    ptype.Type = (SetPointType)message[9];
                    // convert from Fahrenheit to Celsius if needed
                    ptype.Value = (zvalue.Scale == (int)ZWaveTemperatureScaleType.Fahrenheit ? SensorValue.FahrenheitToCelsius(zvalue.Value) : zvalue.Value);
                    nodeEvent   = new ZWaveEvent(node, EventParameter.ThermostatSetPoint, ptype, 0);
                    break;
                }
            }
            return(nodeEvent);
        }