public static void ProcessWebsocketResponse(JObject o) { string topic = (string)o["topic"]; string name = (string)o["payload"]["name"]; if (topic == "get") { string characteristic = (string)o["payload"]["characteristic"]; switch (characteristic) { case "TargetHeatingCoolingState": UpdateTargetHeatingCoolingStateFeedback(name); break; case "CurrentHeatingCoolingState": UpdateCurrentHeatingCoolingStateFeedback(name); break; case "TargetTemperature": UpdateTargetTemperatureFeedback(name); break; case "CurrentTemperature": UpdateCurrentTemperatureFeedback(name); break; case "TemperatureDisplayUnits": UpdateTemperatureDisplayUnitsFeedback(name); break; case "TargetRelativeHumidity": UpdateTargetRelativeHumidityFeedback(name); break; case "CurrentRelativeHumidity": UpdateCurrentRelativeHumidityFeedback(name); break; case "HeatingThresholdTemperature": UpdateHeatingThresholdTemperatureFeedback(name); break; case "CoolingThresholdTemperature": UpdateCoolingThresholdTemperatureFeedback(name); break; } } else if (topic == "set") { string characteristic = (string)o["payload"]["characteristic"]; switch (characteristic) { case "TargetHeatingCoolingState": ushort targetHeatingCoolingStateValue = (ushort)o["payload"]["value"]; ThermostatEvent(new HBCrestronEventArgs(name, characteristic, targetHeatingCoolingStateValue)); break; case "TargetTemperature": ushort targetTemperatureValue = (ushort)o["payload"]["value"]; ThermostatEvent(new HBCrestronEventArgs(name, characteristic, (ushort)HBThermostatExtension.CtoF(targetTemperatureValue))); break; case "TargetRelativeHumidity": ushort targetRelativeHumidityValue = (ushort)o["payload"]["value"]; ThermostatEvent(new HBCrestronEventArgs(name, characteristic, targetRelativeHumidityValue)); break; case "CoolingThresholdTemperature": ushort coolingThresholdTemperatureValue = (ushort)o["payload"]["value"]; ThermostatEvent(new HBCrestronEventArgs(name, characteristic, (ushort)HBThermostatExtension.CtoF(coolingThresholdTemperatureValue))); break; case "HeatingThresholdTemperature": ushort heatingThresholdTemperatureValue = (ushort)o["payload"]["value"]; ThermostatEvent(new HBCrestronEventArgs(name, characteristic, (ushort)HBThermostatExtension.CtoF(heatingThresholdTemperatureValue))); break; } } }
public static void SetCoolingThresholdTemperatureFeedback(string name, ushort value) { if (Thermostats[Thermostats.FindIndex(i => i.Name == name)].CoolingThresholdTemperature != HBThermostatExtension.FtoC(value)) { Thermostats[Thermostats.FindIndex(i => i.Name == name)].CoolingThresholdTemperature = HBThermostatExtension.FtoC(value); UpdateCoolingThresholdTemperatureFeedback(name); } }