示例#1
0
        public override void SetInitialData(IHSApplication HS, DeviceClass device)
        {
            int refId = device.get_Ref(HS);

            HS.SetDeviceValueByRef(refId, 0D, false);
            HS.set_DeviceInvalidValue(refId, true);
        }
        private void UpdateConnectedDevices(double value, string text)
        {
            UpdateDevicesIfNecessary();
            var devicesToUpdate = _melcloudDevices.Where(x => x.IsOfPedType(Constants.Connection, _hs)).ToList();

            foreach (var deviceClass in devicesToUpdate)
            {
                var deviceRef = deviceClass.get_Ref(_hs);
                _hs.SetDeviceValueByRef(deviceRef, value, true);
                _hs.SetDeviceString(deviceRef, text, false);
            }
        }
        public override void UpdateDeviceData(IHSApplication HS, DeviceClass device,
                                              [AllowNull] System.Xml.XPath.XPathNodeIterator value)
        {
            int  refId    = device.get_Ref(HS);
            bool valueSet = false;

            if ((value != null) && (value.MoveNext()))
            {
                var data = value == null ? null : value.Current.ToString();

                if (!string.IsNullOrWhiteSpace(data))
                {
                    HS.SetDeviceValueByRef(refId, FromString(data).ToDouble(CultureInfo.InvariantCulture), true);
                    valueSet = true;
                }
            }

            if (!valueSet)
            {
                HS.SetDeviceValueByRef(refId, defaultValue.ToDouble(CultureInfo.InvariantCulture), true);
            }
        }
示例#4
0
        /// <summary>
        /// Updates the device data from number data
        /// </summary>
        /// <param name="HS">Homeseer application.</param>
        /// <param name="device">The device to update.</param>
        /// <param name="data">Number data.</param>
        protected void UpdateDeviceData(IHSApplication HS, DeviceClass device, double?data)
        {
            int refId = device.get_Ref(HS);

            if (data.HasValue)
            {
                Trace.WriteLine(Invariant($"Updating {Name} Address [{device.get_Address(null)}] to [{data.Value}]"));
                HS.set_DeviceInvalidValue(refId, false);
                HS.SetDeviceValueByRef(refId, data.Value, true);
            }
            else
            {
                // do not update double value on no value.
                Trace.WriteLine(Invariant($"Updating {Name} Address [{device.get_Address(null)}] to Invalid Value"));
                HS.set_DeviceInvalidValue(refId, true);
            }
        }
示例#5
0
        private void _createTemperature(string label)
        {
            if (Temperature != 0)
            {
                return;
            }

            IHSApplication hs = _plugin.hs;

            int         hsRef  = hs.NewDeviceRef(label + " Color Temperature");
            DeviceClass device = (DeviceClass)hs.GetDeviceByRef(hsRef);

            device.set_Address(hs, GetSubDeviceAddress(SubDeviceType.Temperature));
            device.set_Interface(hs, _plugin.Name);
            device.set_InterfaceInstance(hs, _plugin.InstanceFriendlyName());
            device.set_Device_Type_String(hs, "LIFX Device Color Temperature");
            device.set_DeviceType_Set(hs, new DeviceTypeInfo_m.DeviceTypeInfo {
                Device_API = DeviceTypeInfo_m.DeviceTypeInfo.eDeviceAPI.Plug_In
            });

            VSVGPairs.VSPair temp = new VSVGPairs.VSPair(ePairStatusControl.Both);
            temp.PairType          = VSVGPairs.VSVGPairType.Range;
            temp.Render            = Enums.CAPIControlType.ValuesRangeSlider;
            temp.RangeStart        = 2500;
            temp.RangeEnd          = 9000;
            temp.RangeStatusSuffix = " K";

            hs.DeviceVSP_AddPair(hsRef, temp);

            device.MISC_Set(hs, Enums.dvMISC.SHOW_VALUES);

            _plugin.IgnoreNextDeviceControl(hsRef);
            hs.SetDeviceValueByRef(hsRef, 3200, false);

            Temperature = hsRef;
        }
示例#6
0
        private void _createBrightness(string label)
        {
            if (Brightness != 0)
            {
                return;
            }

            IHSApplication hs = _plugin.hs;

            int         hsRef  = hs.NewDeviceRef(label + " Brightness");
            DeviceClass device = (DeviceClass)hs.GetDeviceByRef(hsRef);

            device.set_Address(hs, GetSubDeviceAddress(SubDeviceType.Brightness));
            device.set_Interface(hs, _plugin.Name);
            device.set_InterfaceInstance(hs, _plugin.InstanceFriendlyName());
            device.set_Device_Type_String(hs, "LIFX Device Brightness");
            device.set_DeviceType_Set(hs, new DeviceTypeInfo_m.DeviceTypeInfo {
                Device_API = DeviceTypeInfo_m.DeviceTypeInfo.eDeviceAPI.Plug_In
            });

            // Create the buttons and slider
            VSVGPairs.VSPair offBtn = new VSVGPairs.VSPair(ePairStatusControl.Both);
            offBtn.PairType        = VSVGPairs.VSVGPairType.SingleValue;
            offBtn.Render          = Enums.CAPIControlType.Button;
            offBtn.Status          = "Off";
            offBtn.ControlUse      = ePairControlUse._Off;
            offBtn.Value           = 0;
            offBtn.Render_Location = new Enums.CAPIControlLocation {
                Column = 1,
                Row    = 1,
            };

            VSVGPairs.VSPair onBtn = new VSVGPairs.VSPair(ePairStatusControl.Both);
            onBtn.PairType        = VSVGPairs.VSVGPairType.SingleValue;
            onBtn.Render          = Enums.CAPIControlType.Button;
            onBtn.Status          = "On";
            onBtn.ControlUse      = ePairControlUse._On;
            onBtn.Value           = 99;
            onBtn.Render_Location = new Enums.CAPIControlLocation {
                Column = 2,
                Row    = 1,
            };

            VSVGPairs.VSPair lastBtn = new VSVGPairs.VSPair(ePairStatusControl.Control);
            lastBtn.PairType        = VSVGPairs.VSVGPairType.SingleValue;
            lastBtn.Render          = Enums.CAPIControlType.Button;
            lastBtn.Status          = "Last";
            lastBtn.ControlUse      = ePairControlUse._On_Alternate;
            lastBtn.Value           = 255;
            lastBtn.Render_Location = new Enums.CAPIControlLocation {
                Column = 4,
                Row    = 1,
            };

            VSVGPairs.VSPair dim = new VSVGPairs.VSPair(ePairStatusControl.Both);
            dim.PairType          = VSVGPairs.VSVGPairType.Range;
            dim.Render            = Enums.CAPIControlType.ValuesRangeSlider;
            dim.RangeStart        = 1;
            dim.RangeEnd          = 98;
            dim.RangeStatusPrefix = "Dim ";
            dim.RangeStatusSuffix = "%";
            dim.ControlUse        = ePairControlUse._Dim;
            dim.Render_Location   = new Enums.CAPIControlLocation {
                Column     = 1,
                Row        = 2,
                ColumnSpan = 3,
            };

            hs.DeviceVSP_AddPair(hsRef, offBtn);
            hs.DeviceVSP_AddPair(hsRef, onBtn);
            hs.DeviceVSP_AddPair(hsRef, lastBtn);
            hs.DeviceVSP_AddPair(hsRef, dim);

            device.MISC_Set(hs, Enums.dvMISC.SHOW_VALUES);
            device.MISC_Set(hs, Enums.dvMISC.IS_LIGHT);

            _plugin.IgnoreNextDeviceControl(hsRef);
            hs.SetDeviceValueByRef(hsRef, 0, false);

            Brightness = hsRef;
        }
 /// <summary>
 /// Updates the device data from number data
 /// </summary>
 /// <param name="HS">Homeseer application.</param>
 /// <param name="refId">The reference identifier.</param>
 /// <param name="data">Number data.</param>
 protected static void UpdateDeviceData(IHSApplication HS, int refId, double data, DateTime updateTime)
 {
     HS.set_DeviceInvalidValue(refId, false);
     HS.SetDeviceValueByRef(refId, data, true);
     HS.SetDeviceLastChange(refId, updateTime);
 }
示例#8
0
 public override void SetInitialData(IHSApplication HS, int refId)
 {
     HS.SetDeviceValueByRef(refId, 0D, false);
     HS.set_DeviceInvalidValue(refId, true);
 }
        public override void SetInitialData(IHSApplication HS, DeviceClass device)
        {
            int refId = device.get_Ref(HS);

            HS.SetDeviceValueByRef(refId, defaultValue.ToDouble(CultureInfo.InvariantCulture), false);
        }
示例#10
0
 protected void UpdateDeviceData(IHSApplication HS, double data)
 {
     HS.set_DeviceInvalidValue(RefId, false);
     HS.SetDeviceString(RefId, string.Empty, false);
     HS.SetDeviceValueByRef(RefId, data, true);
 }
示例#11
0
 public virtual void SetOnDeviceCreateData(IHSApplication HS, ICameraSettings cameraSettings, int refId)
 {
     HS.SetDeviceValueByRef(refId, 0D, false);
     HS.set_DeviceInvalidValue(refId, true);
 }