public static void ChangeZone(long lRequestId, int iZone, bool bOn) { AirConditionerCommand command = new AirConditionerCommand(); string[] strZones; Logging.WriteDebugLog("AirConditioner.ChangeZone() [0x{0}] Changing Zone: {1}", lRequestId.ToString("X8"), iZone); lock (_oLockCommand) { command.amOn = _airConditionerCommand.amOn; command.tempTarget = _airConditionerCommand.tempTarget; command.fanSpeed = _airConditionerCommand.fanSpeed; command.mode = _airConditionerCommand.mode; strZones = _airConditionerCommand.enabledZones.Split(new char[] { ',' }); if (strZones.Length != 8 | iZone < 1 | iZone > 8) { command.enabledZones = _airConditionerCommand.enabledZones; } else { strZones[iZone - 1] = bOn ? "1" : "0"; command.enabledZones = string.Format("{0},{1},{2},{3},{4},{5},{6},{7}", strZones[0], strZones[1], strZones[2], strZones[3], strZones[4], strZones[5], strZones[6], strZones[7]); MQTT.SendMessage(string.Format("actron/aircon/zone{0}", iZone), bOn ? "ON" : "OFF"); } } PostCommand(lRequestId, "System", command); }
public static void PostCommand(long lRequestId, string strUser, AirConditionerCommand command) { Logging.WriteDebugLog("AirConditioner.PostCommand() [0x{0}]", lRequestId.ToString("X8")); lock (_oLockCommand) { if (_airConditionerCommand.amOn != command.amOn || _airConditionerCommand.fanSpeed != command.fanSpeed || _airConditionerCommand.mode != command.mode || _airConditionerCommand.tempTarget != command.tempTarget) { Logging.WriteDebugLog("AirConditioner.PostCommand() [0x{0}] Command Update", lRequestId.ToString("X8")); _bPendingCommand = true; Logging.WriteDebugLog("AirConditioner.GetCommand() Command Event Set"); _eventCommand.Set(); _dtLastCommand = DateTime.Now; } if (_airConditionerCommand.enabledZones != command.enabledZones) { Logging.WriteDebugLog("AirConditioner.PostCommand() [0x{0}] Zone Update", lRequestId.ToString("X8")); _bPendingZone = true; Logging.WriteDebugLog("AirConditioner.GetCommand() Command Event Set"); _eventCommand.Set(); _dtLastCommand = DateTime.Now; } _airConditionerCommand = command; } }
public static void ChangeTemperature(long lRequestId, double dblTemperature) { AirConditionerCommand command = new AirConditionerCommand(); Logging.WriteDebugLog("AirConditioner.ChangeTemperature() [0x{0}] Changing Temperature: {1}", lRequestId.ToString("X8"), dblTemperature); lock (_oLockCommand) { command.amOn = _airConditionerCommand.amOn; command.tempTarget = dblTemperature; command.fanSpeed = _airConditionerCommand.fanSpeed; command.mode = _airConditionerCommand.mode; command.enabledZones = _airConditionerCommand.enabledZones; } MQTT.SendMessage("actron/aircon/settemperature", command.tempTarget.ToString()); PostCommand(lRequestId, "System", command); }
public static void ChangeFanSpeed(long lRequestId, FanSpeed speed) { AirConditionerCommand command = new AirConditionerCommand(); Logging.WriteDebugLog("AirConditioner.ChangeFanSpeed() [0x{0}] Changing Fan Speed: {1}", lRequestId.ToString("X8"), Enum.GetName(typeof(FanSpeed), speed)); lock (_oLockCommand) { command.amOn = _airConditionerCommand.amOn; command.tempTarget = _airConditionerCommand.tempTarget; command.fanSpeed = (int)speed; command.mode = _airConditionerCommand.mode; command.enabledZones = _airConditionerCommand.enabledZones; } MQTT.SendMessage("actron/aircon/fanmode", Enum.GetName(typeof(FanSpeed), speed).ToLower()); PostCommand(lRequestId, "System", command); }
public static void ChangeMode(long lRequestId, AirConditionerMode mode) { AirConditionerCommand command = new AirConditionerCommand(); Logging.WriteDebugLog("AirConditioner.ChangeMode() [0x{0}] Changing Mode: {1}", lRequestId.ToString("X8"), Enum.GetName(typeof(AirConditionerMode), mode)); lock (_oLockCommand) { command.amOn = (mode == AirConditionerMode.None ? false : true); command.tempTarget = _airConditionerCommand.tempTarget; command.fanSpeed = _airConditionerCommand.fanSpeed; command.mode = (mode == AirConditionerMode.None ? _airConditionerData.iMode : (int)mode); command.enabledZones = _airConditionerCommand.enabledZones; } MQTT.SendMessage("actron/aircon/mode", (mode != AirConditionerMode.None ? Enum.GetName(typeof(ModeMQTT), mode).ToLower() : "off")); PostCommand(lRequestId, "System", command); }