Beispiel #1
0
        public static void RemoveDevice(string name)
        {
            var tempRemoveObject = new RemoveObject();

            if (Fans[Fans.FindIndex(i => i.Name == name)].DeviceLocation == "Local")
            {
                tempRemoveObject.Payload.Name = name;
                HBCrestron.SendWebSocketData(JsonConvert.SerializeObject(tempRemoveObject)); //Serialize the Data above
            }
            Fans.Remove(Fans[Fans.FindIndex(i => i.Name == name)]);
        }
        public static void UpdatePositionStateFeedback(string name)
        {
            var tempUpdateValueObject = new SetIntValueObject();

            tempUpdateValueObject.Payload.Name           = name;
            tempUpdateValueObject.Payload.Characteristic = "PositionState";
            tempUpdateValueObject.Payload.Value          = Windows[Windows.FindIndex(i => i.Name == name)].PositionState;
            var stringToSend = JsonConvert.SerializeObject(tempUpdateValueObject);

            HBCrestron.SendWebSocketData(stringToSend);
        }
        public static void UpdateObstructionDetectedFeedback(string name)
        {
            var tempUpdateValueObject = new SetBoolValueObject();

            tempUpdateValueObject.Payload.Name           = name;
            tempUpdateValueObject.Payload.Characteristic = "ObstructionDetected";
            tempUpdateValueObject.Payload.Value          = GarageDoors[GarageDoors.FindIndex(i => i.Name == name)].ObstructionDetected;
            var stringToSend = JsonConvert.SerializeObject(tempUpdateValueObject);

            HBCrestron.SendWebSocketData(stringToSend);
        }
Beispiel #4
0
        public static void UpdateCurrentPositionFeedback(string name)
        {
            var tempUpdateValueObject = new SetIntValueObject();

            tempUpdateValueObject.Payload.Name           = name;
            tempUpdateValueObject.Payload.Characteristic = "CurrentPosition";
            tempUpdateValueObject.Payload.Value          = Doors[Doors.FindIndex(i => i.Name == name)].CurrentPosition;
            var stringToSend = JsonConvert.SerializeObject(tempUpdateValueObject);

            HBCrestron.SendWebSocketData(stringToSend);
        }
        public static void UpdateTemperatureDisplayUnitsFeedback(string name)
        {
            var tempUpdateValueObject = new SetIntValueObject();

            tempUpdateValueObject.Payload.Name           = name;
            tempUpdateValueObject.Payload.Characteristic = "TemperatureDisplayUnits";
            tempUpdateValueObject.Payload.Value          = Thermostats[Thermostats.FindIndex(i => i.Name == name)].TemperatureDisplayUnits;
            var stringToSend = JsonConvert.SerializeObject(tempUpdateValueObject);

            HBCrestron.SendWebSocketData(stringToSend);
        }
Beispiel #6
0
        public static void UpdateSecuritySystemAlarmType(string name)
        {
            var tempUpdateValueObject = new SetIntValueObject();

            tempUpdateValueObject.Payload.Name           = name;
            tempUpdateValueObject.Payload.Characteristic = "SecuritySystemAlarmType";
            tempUpdateValueObject.Payload.Value          = SecuritySystems[SecuritySystems.FindIndex(i => i.Name == name)].SecuritySystemAlarmType;
            var stringToSend = JsonConvert.SerializeObject(tempUpdateValueObject);

            HBCrestron.SendWebSocketData(stringToSend);
        }
Beispiel #7
0
        public static void UpdateStatusTamperedFeedback(string name)
        {
            var tempUpdateValueObject = new SetBoolValueObject();

            tempUpdateValueObject.Payload.Name           = name;
            tempUpdateValueObject.Payload.Characteristic = "StatusTampered";
            tempUpdateValueObject.Payload.Value          = SecuritySystems[SecuritySystems.FindIndex(i => i.Name == name)].StatusTampered;
            var stringToSend = JsonConvert.SerializeObject(tempUpdateValueObject);

            HBCrestron.SendWebSocketData(stringToSend);
        }
        public static void UpdateOccupancyDetectedFeedback(string name)
        {
            var tempUpdateValueObject = new SetIntValueObject();

            tempUpdateValueObject.Payload.Name           = name;
            tempUpdateValueObject.Payload.Characteristic = "OccupancyDetected";
            tempUpdateValueObject.Payload.Value          = OccupancySensors[OccupancySensors.FindIndex(i => i.Name == name)].OccupancyDetected;
            var stringToSend = JsonConvert.SerializeObject(tempUpdateValueObject);

            HBCrestron.SendWebSocketData(stringToSend);
        }
Beispiel #9
0
        public static void UpdateOnFeedback(string name)
        {
            var tempUpdateValueObject = new SetBoolValueObject();

            tempUpdateValueObject.Payload.Name           = name;
            tempUpdateValueObject.Payload.Characteristic = "On";
            tempUpdateValueObject.Payload.Value          = Fans[Fans.FindIndex(i => i.Name == name)].On;
            var stringToSend = JsonConvert.SerializeObject(tempUpdateValueObject);

            HBCrestron.SendWebSocketData(stringToSend);
        }
        public static void UpdateStatusLowBatteryFeedback(string name)
        {
            var tempUpdateValueObject = new SetBoolValueObject();

            tempUpdateValueObject.Payload.Name           = name;
            tempUpdateValueObject.Payload.Characteristic = "StatusLowBattery";
            tempUpdateValueObject.Payload.Value          = OccupancySensors[OccupancySensors.FindIndex(i => i.Name == name)].StatusLowBattery;
            var stringToSend = JsonConvert.SerializeObject(tempUpdateValueObject);

            HBCrestron.SendWebSocketData(stringToSend);
        }
        public static void UpdateCoolingThresholdTemperatureFeedback(string name)
        {
            var tempUpdateValueObject = new SetIntValueObject();

            tempUpdateValueObject.Payload.Name           = name;
            tempUpdateValueObject.Payload.Characteristic = "CoolingThresholdTemperature";
            tempUpdateValueObject.Payload.Value          = (int)Thermostats[Thermostats.FindIndex(i => i.Name == name)].CoolingThresholdTemperature;
            var stringToSend = JsonConvert.SerializeObject(tempUpdateValueObject);

            HBCrestron.SendWebSocketData(stringToSend);
        }
        public static void UpdateCurrentRelativeHumidityFeedback(string name)
        {
            var tempUpdateValueObject = new SetIntValueObject();

            tempUpdateValueObject.Payload.Name           = name;
            tempUpdateValueObject.Payload.Characteristic = "CurrentRelativeHumidity";
            tempUpdateValueObject.Payload.Value          = Thermostats[Thermostats.FindIndex(i => i.Name == name)].CurrentRelativeHumidity;
            var stringToSend = JsonConvert.SerializeObject(tempUpdateValueObject);

            HBCrestron.SendWebSocketData(stringToSend);
        }
        public static void UpdateTargetDoorStateFeedback(string name)
        {
            var tempUpdateValueObject = new SetIntValueObject();

            tempUpdateValueObject.Payload.Name           = name;
            tempUpdateValueObject.Payload.Characteristic = "TargetDoorState";
            tempUpdateValueObject.Payload.Value          = GarageDoors[GarageDoors.FindIndex(i => i.Name == name)].TargetDoorState;
            var stringToSend = JsonConvert.SerializeObject(tempUpdateValueObject);

            HBCrestron.SendWebSocketData(stringToSend);
        }
 public static void UpdateColorTemperatureFeedback(string name)
 {
     if (Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].SupportsColorTemperature == 1)
     {
         var tempUpdateValueObject = new SetIntValueObject();
         tempUpdateValueObject.Payload.Name           = name;
         tempUpdateValueObject.Payload.Characteristic = "ColorTemperature";
         tempUpdateValueObject.Payload.Value          = Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].ColorTemperature;
         var stringToSend = JsonConvert.SerializeObject(tempUpdateValueObject);
         HBCrestron.SendWebSocketData(stringToSend);
     }
 }
Beispiel #15
0
 public static void UpdateRotationDirectionFeedback(string name)
 {
     if (Fans[Fans.FindIndex(i => i.Name == name)].SupportsRotationDirection == 1)
     {
         var tempUpdateValueObject = new SetIntValueObject();
         tempUpdateValueObject.Payload.Name           = name;
         tempUpdateValueObject.Payload.Characteristic = "RotationDirection";
         tempUpdateValueObject.Payload.Value          = Fans[Fans.FindIndex(i => i.Name == name)].RotationDirection;
         var stringToSend = JsonConvert.SerializeObject(tempUpdateValueObject);
         HBCrestron.SendWebSocketData(stringToSend);
     }
 }
 public static void AddDevice(string name, string deviceLocation)
 {
     Outlets.Add(new Outlet {
         Name = name, DeviceLocation = deviceLocation
     });
     if (deviceLocation == "Local")
     {
         var tempAddOutletPayload = new AddOutletPayload();
         tempAddOutletPayload.Name = name;
         var tempAddObject = new AddObject(tempAddOutletPayload);
         HBCrestron.SendWebSocketData(JsonConvert.SerializeObject(tempAddObject)); //Serialize the Data above
     }
 }
 public static void AddDevice(string name, ushort supportsHoldPosition, ushort supportsObstructionDetected, string deviceLocation)
 {
     GarageDoors.Add(new GarageDoor {
         Name = name, DeviceLocation = deviceLocation
     });
     if (deviceLocation == "Local")
     {
         var tempAddGarageDoorObject = new AddGarageDoorPayload();
         tempAddGarageDoorObject.Name = name;
         tempAddGarageDoorObject.SupportsHoldPosition        = supportsHoldPosition;
         tempAddGarageDoorObject.SupportsObstructionDetected = supportsObstructionDetected;
         var tempAddObject = new AddObject(tempAddGarageDoorObject);
         HBCrestron.SendWebSocketData(JsonConvert.SerializeObject(tempAddObject)); //Serialize the Data above
     }
 }
Beispiel #18
0
 public static void AddDevice(string name, ushort supportsStatusFault, ushort supportsStatusTampered, string deviceLocation)
 {
     SecuritySystems.Add(new SecuritySystem {
         Name = name, SupportsStatusFault = supportsStatusFault, SupportsStatusTampered = supportsStatusTampered, DeviceLocation = deviceLocation
     });
     if (deviceLocation == "Local")
     {
         var tempAddSecuritySystemPayload = new AddSecuritySystemPayload();
         tempAddSecuritySystemPayload.Name = name;
         tempAddSecuritySystemPayload.SupportsStatusFault    = supportsStatusFault;
         tempAddSecuritySystemPayload.SupportsStatusTampered = supportsStatusFault;
         var tempAddObject = new AddObject(tempAddSecuritySystemPayload);
         HBCrestron.SendWebSocketData(JsonConvert.SerializeObject(tempAddObject)); //Serialize the Data above
     }
 }
Beispiel #19
0
        public static void SetOn(string name, ushort value)
        {
            ControlBoolValueObject tempControlBoolValueObject = new ControlBoolValueObject();

            tempControlBoolValueObject.Characteristics[0]     = new ControlBoolValuePayload();
            tempControlBoolValueObject.Characteristics[0].AID = Fans[Fans.FindIndex(i => i.Name == name)].RemoteDeviceAID;
            tempControlBoolValueObject.Characteristics[0].IID = Fans[Fans.FindIndex(i => i.Name == name)].RemoteDeviceOnIID;
            if (value == 1)
            {
                tempControlBoolValueObject.Characteristics[0].Value = true;
            }
            var stringToSend = JsonConvert.SerializeObject(tempControlBoolValueObject);

            HBCrestron.hbHttpClient_SendRequest("characteristics", "", stringToSend);
        }
Beispiel #20
0
 public static void AddDevice(string name, ushort supportsRotationSpeed, ushort supportsRotationDirection, string deviceLocation)
 {
     Fans.Add(new Fan {
         Name = name, SupportsRotationSpeed = supportsRotationSpeed, SupportsRotationDirection = supportsRotationDirection, DeviceLocation = deviceLocation
     });
     if (deviceLocation == "Local")
     {
         var tempAddFanPayload = new AddFanPayload();
         tempAddFanPayload.Name = name;
         tempAddFanPayload.SupportsRotationSpeed     = supportsRotationSpeed;
         tempAddFanPayload.SupportsRotationDirection = supportsRotationDirection;
         var tempAddObject = new AddObject(tempAddFanPayload);
         HBCrestron.SendWebSocketData(JsonConvert.SerializeObject(tempAddObject)); //Serialize the Data above
     }
 }
 public static void SetColorTemperature(string name, ushort value)
 {
     if (Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].SupportsColorTemperature == 1 &&
         Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].ColorTemperature != value)
     {
         ControlIntValueObject tempControlIntValueObject = new ControlIntValueObject();
         tempControlIntValueObject.Characteristics[0]     = new ControlIntValuePayload();
         tempControlIntValueObject.Characteristics[0].AID =
             Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].RemoteDeviceAID;
         tempControlIntValueObject.Characteristics[0].IID =
             Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].RemoteDeviceColorTemperatureIID;
         tempControlIntValueObject.Characteristics[0].Value = value;
         var stringToSend = JsonConvert.SerializeObject(tempControlIntValueObject);
         HBCrestron.hbHttpClient_SendRequest("characteristics", "", stringToSend);
     }
 }
 public static void SetRGB(string name, ushort red, ushort green, ushort blue)
 {
     if (Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].SupportsRGB == 1)
     {
         RGB tempRgb = new RGB((byte)red, (byte)green, (byte)blue);
         HSV tempHsv = HBLightbulbConversion.RGBtoHSV(tempRgb);
         if (Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].Hue != (ushort)tempHsv.H)
         {
             Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].Hue = (ushort)tempHsv.H;
             ControlIntValueObject tempControlIntValueObject = new ControlIntValueObject();
             tempControlIntValueObject.Characteristics[0]     = new ControlIntValuePayload();
             tempControlIntValueObject.Characteristics[0].AID =
                 Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].RemoteDeviceAID;
             tempControlIntValueObject.Characteristics[0].IID =
                 Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].RemoteDeviceHueIID;
             tempControlIntValueObject.Characteristics[0].Value = Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].Hue;
             var stringToSend = JsonConvert.SerializeObject(tempControlIntValueObject);
             HBCrestron.hbHttpClient_SendRequest("characteristics", "", stringToSend);
         }
         if (Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].Saturation != (ushort)tempHsv.S)
         {
             Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].Saturation = (ushort)tempHsv.S;
             ControlIntValueObject tempControlIntValueObject = new ControlIntValueObject();
             tempControlIntValueObject.Characteristics[0]     = new ControlIntValuePayload();
             tempControlIntValueObject.Characteristics[0].AID =
                 Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].RemoteDeviceAID;
             tempControlIntValueObject.Characteristics[0].IID =
                 Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].RemoteDeviceSaturationIID;
             tempControlIntValueObject.Characteristics[0].Value = Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].Saturation;
             var stringToSend = JsonConvert.SerializeObject(tempControlIntValueObject);
             HBCrestron.hbHttpClient_SendRequest("characteristics", "", stringToSend);
         }
         if (Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].Hue != (ushort)tempHsv.V)
         {
             Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].Hue = (ushort)tempHsv.V;
             ControlIntValueObject tempControlIntValueObject = new ControlIntValueObject();
             tempControlIntValueObject.Characteristics[0]     = new ControlIntValuePayload();
             tempControlIntValueObject.Characteristics[0].AID =
                 Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].RemoteDeviceAID;
             tempControlIntValueObject.Characteristics[0].IID =
                 Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].RemoteDeviceBrightnessIID;
             tempControlIntValueObject.Characteristics[0].Value = Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].Brightness;
             var stringToSend = JsonConvert.SerializeObject(tempControlIntValueObject);
             HBCrestron.hbHttpClient_SendRequest("characteristics", "", stringToSend);
         }
     }
 }
 public static void AddDevice(string name, ushort supportsCurrentRelativeHumidity, ushort supportsTargetRelativeHumidity, ushort supportsCoolingThresholdTemperature, ushort supportsHeatingThresholdTemperature, string deviceLocation)
 {
     Thermostats.Add(new Thermostat {
         Name = name, SupportsCurrentRelativeHumidity = supportsCurrentRelativeHumidity, SupportsTargetRelativeHumidity = supportsTargetRelativeHumidity, SupportsCoolingThresholdTemperature = supportsCoolingThresholdTemperature, SupportsHeatingThresholdTemperature = supportsHeatingThresholdTemperature, DeviceLocation = deviceLocation
     });
     if (deviceLocation == "Local")
     {
         var tempAddThermostatPayload = new AddThermostatPayload();
         tempAddThermostatPayload.Name = name;
         tempAddThermostatPayload.SupportsCurrentRelativeHumidity     = supportsCurrentRelativeHumidity;
         tempAddThermostatPayload.SupportsTargetRelativeHumidity      = supportsTargetRelativeHumidity;
         tempAddThermostatPayload.SupportsCoolingThresholdTemperature = supportsCoolingThresholdTemperature;
         tempAddThermostatPayload.SupportsHeatingThresholdTemperature = supportsHeatingThresholdTemperature;
         var tempAddObject = new AddObject(tempAddThermostatPayload);
         HBCrestron.SendWebSocketData(JsonConvert.SerializeObject(tempAddObject)); //Serialize the Data above
     }
 }
 public static void AddDevice(string name, ushort supportsStatusActive, ushort supportsStatusFault, ushort supportsStatusTampered, ushort supportsStatusLowBattery, string deviceLocation)
 {
     OccupancySensors.Add(new OccupancySensor {
         Name = name, SupportsStatusActive = supportsStatusActive, SupportsStatusFault = supportsStatusFault, SupportsStatusTampered = supportsStatusTampered, SupportsStatusLowBattery = supportsStatusLowBattery, DeviceLocation = deviceLocation
     });
     if (deviceLocation == "Local")
     {
         var tempAddOccupancySensorPayload = new AddOccupancySensorPayload();
         tempAddOccupancySensorPayload.Name = name;
         tempAddOccupancySensorPayload.SupportsStatusActive     = supportsStatusActive;
         tempAddOccupancySensorPayload.SupportsStatusFault      = supportsStatusFault;
         tempAddOccupancySensorPayload.SupportsStatusTampered   = supportsStatusFault;
         tempAddOccupancySensorPayload.SupportsStatusLowBattery = supportsStatusLowBattery;
         var tempAddObject = new AddObject(tempAddOccupancySensorPayload);
         HBCrestron.SendWebSocketData(JsonConvert.SerializeObject(tempAddObject)); //Serialize the Data above
     }
 }
        public static void AddDevice(string name, ushort supportsBrightness, ushort supportsHue, ushort supportsSaturation, ushort supportsColorTemperature, ushort supportsRGB, string deviceLocation)
        {
            Lightbulbs.Add(new Lightbulb {
                Name = name, SupportsBrightness = supportsBrightness, SupportsHue = supportsHue, SupportsSaturation = supportsSaturation, SupportsColorTemperature = supportsColorTemperature, SupportsRGB = supportsRGB, DeviceLocation = deviceLocation
            });

            if (deviceLocation == "Local")
            {
                var tempAddLightbulbPayload = new AddLightbulbPayload();
                tempAddLightbulbPayload.Name = name;
                tempAddLightbulbPayload.SupportsBrightness       = supportsBrightness;
                tempAddLightbulbPayload.SupportsHue              = supportsHue;
                tempAddLightbulbPayload.SupportsSaturation       = supportsSaturation;
                tempAddLightbulbPayload.SupportsColorTemperature = supportsColorTemperature;
                var tempAddObject = new AddObject(tempAddLightbulbPayload);
                HBCrestron.SendWebSocketData(JsonConvert.SerializeObject(tempAddObject));
            }
        }
 public static void SetBrightness(string name, ushort value)
 {
     if (Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].SupportsBrightness == 1)
     {
         var newvalue = Math.Round(value / 655.35);
         // ReSharper disable once CompareOfFloatsByEqualityOperator This works, but could probably be written better
         if (newvalue != Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].Brightness)
         {
             var tempControlIntValueObject = new ControlIntValueObject();
             tempControlIntValueObject.Characteristics[0]     = new ControlIntValuePayload();
             tempControlIntValueObject.Characteristics[0].AID =
                 Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].RemoteDeviceAID;
             tempControlIntValueObject.Characteristics[0].IID =
                 Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].RemoteDeviceBrightnessIID;
             tempControlIntValueObject.Characteristics[0].Value = (ushort)newvalue;
             var stringToSend = JsonConvert.SerializeObject(tempControlIntValueObject);
             HBCrestron.hbHttpClient_SendRequest("characteristics", "", stringToSend);
         }
     }
 }