Ejemplo n.º 1
0
        private static void MQTTProcessor(string strTopic, string strPayload)
        {
            long   lRequestId     = 0;
            double dblTemperature = 0;

            Logging.WriteDebugLog("Service.MQTTProcessor() {0}", strTopic);

            switch (strTopic)
            {
            case "actron/aircon/zone1/set":
                AirConditioner.ChangeZone(lRequestId, 1, strPayload == "ON" ? true : false);
                break;

            case "actron/aircon/zone2/set":
                AirConditioner.ChangeZone(lRequestId, 2, strPayload == "ON" ? true : false);
                break;

            case "actron/aircon/zone3/set":
                AirConditioner.ChangeZone(lRequestId, 3, strPayload == "ON" ? true : false);
                break;

            case "actron/aircon/zone4/set":
                AirConditioner.ChangeZone(lRequestId, 4, strPayload == "ON" ? true : false);
                break;

            case "actron/aircon/zone5/set":
                AirConditioner.ChangeZone(lRequestId, 5, strPayload == "ON" ? true : false);
                break;

            case "actron/aircon/zone6/set":
                AirConditioner.ChangeZone(lRequestId, 6, strPayload == "ON" ? true : false);
                break;

            case "actron/aircon/zone7/set":
                AirConditioner.ChangeZone(lRequestId, 7, strPayload == "ON" ? true : false);
                break;

            case "actron/aircon/zone8/set":
                AirConditioner.ChangeZone(lRequestId, 8, strPayload == "ON" ? true : false);
                break;

            case "actron/aircon/mode/set":
                Logging.WriteDebugLog("ServiceCore.MQTTProcessor() {0}: {1}", strTopic, strPayload);

                switch (strPayload)
                {
                case "off":
                    AirConditioner.ChangeMode(lRequestId, AirConditionerMode.None);

                    break;

                case "auto":
                    AirConditioner.ChangeMode(lRequestId, AirConditionerMode.Automatic);

                    break;

                case "cool":
                    AirConditioner.ChangeMode(lRequestId, AirConditionerMode.Cooling);

                    break;

                case "heat":
                    AirConditioner.ChangeMode(lRequestId, AirConditionerMode.Heating);

                    break;

                case "fan_only":
                    AirConditioner.ChangeMode(lRequestId, AirConditionerMode.FanOnly);

                    break;
                }

                break;

            case "actron/aircon/fan/set":
                Logging.WriteDebugLog("Service.MQTTProcessor() {0}: {1}", strTopic, strPayload);

                switch (strPayload)
                {
                case "low":
                    AirConditioner.ChangeFanSpeed(lRequestId, FanSpeed.Low);

                    break;

                case "medium":
                    AirConditioner.ChangeFanSpeed(lRequestId, FanSpeed.Medium);

                    break;

                case "high":
                    AirConditioner.ChangeFanSpeed(lRequestId, FanSpeed.High);

                    break;
                }

                break;

            case "actron/aircon/temperature/set":
                Logging.WriteDebugLog("Service.MQTTProcessor() {0}: {1}", strTopic, strPayload);

                if (double.TryParse(strPayload, out dblTemperature))
                {
                    AirConditioner.ChangeTemperature(lRequestId, dblTemperature);
                }

                break;
            }
        }