private void _createColor(string label) { if (Color != 0) { return; } IHSApplication hs = _plugin.hs; int hsRef = hs.NewDeviceRef(label + " Color"); DeviceClass device = (DeviceClass)hs.GetDeviceByRef(hsRef); device.set_Address(hs, GetSubDeviceAddress(SubDeviceType.Color)); device.set_Interface(hs, _plugin.Name); device.set_InterfaceInstance(hs, _plugin.InstanceFriendlyName()); device.set_Device_Type_String(hs, "LIFX Device Color"); device.set_DeviceType_Set(hs, new DeviceTypeInfo_m.DeviceTypeInfo { Device_API = DeviceTypeInfo_m.DeviceTypeInfo.eDeviceAPI.Plug_In }); // Create the buttons and slider VSVGPairs.VSPair colorPicker = new VSVGPairs.VSPair(ePairStatusControl.Both); colorPicker.PairType = VSVGPairs.VSVGPairType.SingleValue; colorPicker.Render = Enums.CAPIControlType.Color_Picker; colorPicker.ControlUse = ePairControlUse._ColorControl; hs.DeviceVSP_AddPair(hsRef, colorPicker); device.MISC_Set(hs, Enums.dvMISC.SHOW_VALUES); hs.SetDeviceString(hsRef, "ffffff", false); Color = hsRef; }
/// <summary> /// Initializes a new instance of the <see cref="PluginConfig"/> class. /// </summary> /// <param name="HS">The homeseer application.</param> public PluginConfig(IHSApplication HS) { this.HS = HS; debugLogging = GetValue(DebugLoggingKey, false); string deviceIdsConcatString = GetValue(DeviceIds, string.Empty); var deviceIds = deviceIdsConcatString.Split(DeviceIdsSeparator); foreach (var deviceId in deviceIds) { if (string.IsNullOrWhiteSpace(deviceId)) { continue; } string ipAddressString = GetValue(IPAddressKey, string.Empty, deviceId); if (!IPAddress.TryParse(ipAddressString, out var deviceIP)) { deviceIP = IPAddress.None; } string name = GetValue(NameKey, string.Empty, deviceId); string username = GetValue(UserNameKey, string.Empty, deviceId); string passwordEncrypted = GetValue(PasswordKey, string.Empty, deviceId); string password = HS.DecryptString(passwordEncrypted, EncryptPassword); devices.Add(deviceId, new AirVisualNode(deviceId, name, deviceIP, username, password)); } }
public void TryFindChildren() { if (Root == 0) { return; } IHSApplication hs = _plugin.hs; DeviceClass root = (DeviceClass)hs.GetDeviceByRef(Root); foreach (int childRef in root.get_AssociatedDevices(hs)) { DeviceClass child = (DeviceClass)hs.GetDeviceByRef(childRef); SubDeviceType subType = (SubDeviceType)int.Parse(child.get_Address(hs).Split('-')[1]); switch (subType) { case SubDeviceType.Brightness: Brightness = childRef; break; case SubDeviceType.Color: Color = childRef; break; case SubDeviceType.Temperature: Temperature = childRef; break; } } }
/// <summary> /// Initializes a new instance of the <see cref="PluginConfig"/> class. /// </summary> /// <param name="HS">The homeseer application.</param> public PluginConfig(IHSApplication HS) { this.HS = HS; apiKey = GetValue(APIKeyKey, string.Empty); refreshIntervalMinutes = GetValue(RefreshIntervalKey, 15); debugLogging = GetValue(DebugLoggingKey, false); stationId = GetValue <string>(StationIdKey, string.Empty); if (Enum.TryParse(GetValue(UnitIdKey, Unit.US.ToString()), out Unit readUnit)) { unit = readUnit; } enabledDevices = new Dictionary <string, IDictionary <string, bool> >(); foreach (var deviceDefintion in WUWeatherData.DeviceDefinitions) { var childEnabled = new Dictionary <string, bool>(); foreach (var childDeviceDefinition in deviceDefintion.Children) { childEnabled[childDeviceDefinition.Name] = GetValue(childDeviceDefinition.Name, false, deviceDefintion.Name); } enabledDevices[deviceDefintion.Name] = childEnabled; } }
protected void UpdateFirstNodeAsNumber(IHSApplication HS, DeviceClass device, [AllowNull] XPathNodeIterator value) { double?data = null; if ((value != null) && (value.MoveNext())) { string text = value.Current.ToString().Trim(new char[] { '%', ' ' }); if (double.TryParse(text, NumberStyles.Any, CultureInfo.InvariantCulture, out double doubleValue)) { if (!inValidValues.Contains(doubleValue)) { data = doubleValue; } else { Trace.WriteLine(Invariant($"Device {Name} Address [{device.get_Address(null)}] has invalid Value {doubleValue}")); } } else { Trace.WriteLine(Invariant($"Device {Name} Address [{device.get_Address(null)}] has Non-Double Value:[{text}]")); } } else { Trace.WriteLine(Invariant($"No node value found for {Name} Address [{device.get_Address(null)}]")); } UpdateDeviceData(HS, device, data); }
///<summary> ///This creates a new instance of this page ///</summary> ///<param name="pagename"></param> ///<param name="settings"></param> ///<param name="hs"></param> public WebConfig(string pageName, Settings settings, IHSApplication hs, Plugin plugin, Utils utils) : base(pageName) { _plugin = plugin; _settings = settings; _hs = hs; _utils = utils; }
public ConfigHandler(IHSApplication hs, IAppCallbackAPI callbackApi, IIniSettings iniSettings, ILog log) { _hs = hs; _callbackApi = callbackApi; _iniSettings = iniSettings; _log = log; }
/// <summary> /// 1. Get list of devices or properties (i.e. Locations) - based on combobox "name" /// </summary> /// <param name="name">Selection for defining what to get</param> /// <param name="devices">Full DeviceDictHS, can be "null", then will retrieve inside</param> /// <param name="exclude">List<dev_ids> to exclude</param> /// <returns>List of pairs (Name=Value=item) for dropbox</returns> // TEMP - TODO: change 'name' to Enum public static MyPairList GetDevicesProps(string name, DeviceDictHS devices = null, DeviceIdList exclude = null, string Location = null, string Location2 = null) { IHSApplication _hs = null; //IHSApplication _hs = Hs; if (devices == null) { devices = Devices(); } switch (name) { //case "StateDeviceId": default: return(GetDevices(Location, Location2, devices, min_vspsCount: 1, exclude: exclude)); case "DropListLocation": Func <HSDevice, Int32, string> func1 = (x, i) => x.get_Location(_hs); return(GetDevicesProps(func1, devices, exclude: exclude)); case "DropListLocation2": Func <HSDevice, Int32, string> func2 = (x, i) => x.get_Location2(_hs); return(GetDevicesProps(func2, devices, exclude: exclude)); } //return null; }
public override void SetInitialData(IHSApplication HS, DeviceClass device) { int refId = device.get_Ref(HS); 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.set_DeviceInvalidValue(refId, false); HS.SetDeviceString(refId, "Root", false); }
public DeviceRootDeviceManager(string deviceName, string rootDeviceId, IHSApplication HS) { this.deviceName = deviceName; this.HS = HS; this.rootDeviceId = rootDeviceId; GetCurrentDevices(); }
public DataCurveTriggerB(IHSApplication hs, ILogging logging, IHsCollectionFactory collectionFactory, IHomeSeerHandler homeSeerHandler, IReformatCopiedAction reformatCopiedAction = null, IDataCurveTriggerUi dataCurveUi = null, IDataCurveComputationHandlerB dataCurveComputationHandler = null) { _collectionFactory = collectionFactory; _logging = logging; _homeSeerHandler = homeSeerHandler; _hs = hs; _dataCurveComputationHandler = dataCurveComputationHandler; if (reformatCopiedAction == null) { _reformatCopiedAction = new ReformatCopiedAction(_logging); } if (dataCurveUi == null) { _dataCurveUi = new DataCurveTriggerBUi(_homeSeerHandler, _hs); } if (_dataCurveComputationHandler == null) { _dataCurveComputationHandler = new ComputationTriggerBHandler(_logging); } }
public override void UpdateDeviceData(IHSApplication HS, DeviceClass device, System.Xml.XmlElement value) { var childNavigator = value.CreateNavigator(); var nodeIter = childNavigator.Select(dayDeviceData.PathData.GetPath(Unit.US)); dayDeviceData.UpdateDeviceData(HS, device, nodeIter); }
protected void UpdateByCalculatingAsNumber(IHSApplication HS, DeviceClass device, [AllowNull] XPathNodeIterator value, Func <double, double, double> calculator) { double?data = null; while ((value != null) && (value.MoveNext())) { string text = value.Current.ToString().Trim(new char[] { '%', ' ' }); if (double.TryParse(text, NumberStyles.Any, CultureInfo.InvariantCulture, out double doubleValue)) { if (!inValidValues.Contains(doubleValue)) { if (!data.HasValue) { data = doubleValue; } else { data = calculator(doubleValue, data.Value); } } } } UpdateDeviceData(HS, device, data); }
public PluginConfig(IHSApplication HS) { this.HS = HS; debugLogging = GetValue(DebugLoggingKey, false); forwardSpeech = GetValue(ForwardSpeechKey, true); sapiVoice = GetValue <string>(SapiVoiceKey, null); string webServerIPAddressString = GetValue(WebServerIPAddressKey, string.Empty); IPAddress.TryParse(webServerIPAddressString, out webServerIPAddress); webServerPort = GetValue <ushort>(WebServerPortKey, 8081); string deviceIdsConcatString = GetValue(DeviceIds, string.Empty); var deviceIds = deviceIdsConcatString.Split(DeviceIdsSeparator); foreach (var deviceId in deviceIds) { if (string.IsNullOrWhiteSpace(deviceId)) { continue; } string ipAddressString = GetValue(IPAddressKey, string.Empty, deviceId); if (IPAddress.TryParse(ipAddressString, out var deviceIP)) { string name = GetValue(NameKey, string.Empty, deviceId); var volume = GetValue <short>(VolumeKey, -1, deviceId); devices.Add(deviceId, new ChromecastDevice(deviceId, name, deviceIP, volume == -1 ? null : (ushort?)volume)); } } // Auto create entries in INI File WebServerPort = this.webServerPort; }
/// <summary> /// Initializes a new instance of the <see cref="PluginConfig"/> class. /// </summary> /// <param name="HS">The homeseer application.</param> public PluginConfig(IHSApplication HS, bool offline = false) { this.HS = HS; this.offline = offline; this.PopulateConfig(); }
// private StringBuilder stb; public PageBuilderBase(IHSApplication pHS, IAppCallbackAPI pHSCB, HSPI_EnOcean.HSPI plugInInst) : base("dummy") { hsHost = pHS; hsHostCB = pHSCB; pluginInstance = plugInInst; reset(); }
public MainPlugin(IHSApplication hs, ILogging logging, IIniSettings iniSettings, IAppCallbackAPI callback, HsCollectionFactory collectionFactory) { _hs = hs; _logging = logging; _iniSettings = iniSettings; _callback = callback; _collectionFactory = collectionFactory; }
public override void Update(IHSApplication HS, double value) { if (!lastUpdate.HasValue || lastUpdate.Value != value) { UpdateDeviceData(HS, RefId, value); lastUpdate = value; } }
public MainConfig(ILogging logging, IHSApplication hs, IIniSettings iniSettings, IAppCallbackAPI callback, IMainPlugin mainPlugin) { _hs = hs; _logging = logging; _iniSettings = iniSettings; _callback = callback; _mainPlugin = mainPlugin; }
public GeneralConfig(string pageName, IHSApplication hs, IAppCallbackAPI callback, IIniSettings iniSettings, ILog log) : base(pageName) { _pageName = pageName; _hs = hs; _callback = callback; _iniSettings = iniSettings; _log = log; }
public virtual Task HandleCommand(IHSApplication HS, CameraBase camera, string stringValue, double value, ePairControlUse control, CancellationToken token) { return(Task.CompletedTask); }
/// <summary> /// Updates the device data from string data /// </summary> /// <param name="HS">Homeseer application.</param> /// <param name="device">The device to update.</param> /// <param name="data">string data.</param> protected void UpdateDeviceData(IHSApplication HS, DeviceClass device, [AllowNull] string data) { Trace.WriteLine(Invariant($"Updating {Name} Address [{device.get_Address(null)}] to [{data ?? "<NULL>"}]")); int refId = device.get_Ref(HS); HS.set_DeviceInvalidValue(refId, false); HS.SetDeviceString(refId, data, true); }
public void UpdateName(string label) { IHSApplication hs = _plugin.hs; ((DeviceClass)hs.GetDeviceByRef(Root)).set_Name(hs, label); ((DeviceClass)hs.GetDeviceByRef(Brightness)).set_Name(hs, label + " Brightness"); ((DeviceClass)hs.GetDeviceByRef(Color)).set_Name(hs, label + " Color"); ((DeviceClass)hs.GetDeviceByRef(Temperature)).set_Name(hs, label + " Color Temperature"); }
public EnOceanController(IHSApplication pHsHost, IAppCallbackAPI pHsCB, HSPI pHspiInst, JObject initCfg) { hspiInst = pHspiInst; HS = pHsHost; HSCB = pHsCB; config = initCfg; portName = (string)config["portname"]; UniqueControllerId = (string)config["unique_id"]; }
public ConfigGeneral(string pageName, IHSApplication hs, IIniSettings iniSettings, ILogging log, IMainPlugin mainPlugin) : base(pageName) { _pageName = pageName; _pageNameText = pageName.Replace("_", " "); _hs = hs; _iniSettings = iniSettings; _logging = log; _mainPlugin = mainPlugin; }
/// <summary> /// Initializes a new instance of the <see cref="PluginConfig"/> class. /// </summary> /// <param name="HS">The homeseer application.</param> public PluginConfig(IHSApplication HS) { this.HS = HS; LoadDBSettings(); LoadPersistenceSettings(); LoadImportDeviceSettings(); debugLogging = GetValue(DebugLoggingKey, false); }
public EnOceanDeviceBase(IHSApplication Hs, EnOceanController Ctrl, String deviceId, JObject config) { HS = Hs; DeviceId = deviceId; deviceConfig = config; Controller = Ctrl; deviceType = (EDeviceTypes)(int)config["device_type"]; GetHSDevice(); // Fetch or allocate new hs device }
public MPowerConnectorManager(IHSApplication HS, MPowerDevice device, CancellationToken shutdownToken) { this.HS = HS; this.Device = device; rootDeviceData = new DeviceRootDeviceManager(device.Name, device.Id, this.HS); combinedCancellationSource = CancellationTokenSource.CreateLinkedTokenSource(shutdownToken, instanceCancellationSource.Token); runTask = Task.Factory.StartNew(ManageConnection, Token); processTask = Task.Factory.StartNew(ProcessDeviceUpdates, Token, TaskCreationOptions.LongRunning, TaskScheduler.Current); }
public DeviceRootDeviceManager(ICameraSettings cameraSettings, IHSApplication HS, CancellationToken cancellationToken) { this.HS = HS; this.cancellationToken = cancellationToken; CameraSettings = cameraSettings; GetCurrentDevices(); CreateParentDevice(); }
public static IEnOceanDevice CreateDeviceInstance(IHSApplication HS, EnOceanController Controller, String deviceId, String deviceType, JObject config) { EDeviceTypes DeviceType; if (Enum.TryParse<EDeviceTypes>(deviceType, out DeviceType)) { config["device_type"] = (int)DeviceType; switch (DeviceType) { case EDeviceTypes.PUSHBUTTON_4x: { Console.WriteLine("BUTTON THING"); var newDev = new EnOceanButtonDevice(HS, Controller, deviceId, config); Controller.RegisterDevice(newDev); } break; case EDeviceTypes.DOORCONTACT: { Console.WriteLine("DOOR THING"); var newDev = new EnOceanDoorContactDevice(HS, Controller, deviceId, config); Controller.RegisterDevice(newDev); } break; case EDeviceTypes.TEMPERATURE_SENSOR: { Console.WriteLine("TEMPERATURE THING"); var newDev = new EnOceanTempSensorDevice(HS, Controller, deviceId, config); Controller.RegisterDevice(newDev); } break; } } else { Console.WriteLine("Error getting type: {0}", deviceType); } return null; }
public void run() { string[] cmdArgs = Environment.GetCommandLineArgs(); Console.WriteLine("Manager::run() - arguments are {0}", Environment.CommandLine); String paramServer = "127.0.0.1"; String paramInstance = ""; foreach (string arg in cmdArgs) { Console.WriteLine(" - arg: {0}", arg); if (arg.Contains("=")) { String[] ArgS = arg.Split('='); Console.WriteLine(" -- {0}=>{1}", ArgS[0], ArgS[1]); switch (ArgS[0]) { case "server": paramServer = ArgS[1]; break; case "instance": paramInstance = ArgS[1]; break; default: Console.WriteLine("Unhandled param: {0}", ArgS[0]); break; } } } pluginInst = new HSPI(paramInstance); //Environment.CommandLine. client = ScsServiceClientBuilder.CreateClient<IHSApplication>(new ScsTcpEndPoint(paramServer, 10400), pluginInst); clientCB = ScsServiceClientBuilder.CreateClient<IAppCallbackAPI>(new ScsTcpEndPoint(paramServer, 10400), pluginInst); try { client.Connect(); clientCB.Connect(); hsHost = client.ServiceProxy; double ApiVer = hsHost.APIVersion; Console.WriteLine("Host ApiVersion : {0}", ApiVer); hsHostCB = clientCB.ServiceProxy; ApiVer = hsHostCB.APIVersion; Console.WriteLine("Host CB ApiVersion : {0}", ApiVer); } catch (Exception e) { Console.WriteLine("Cannot start instance because of : {0}", e.Message); return; } Console.WriteLine("Connection to HS succeeded!"); try { pluginInst.hsHost = hsHost; pluginInst.hsHostCB = hsHostCB; hsHost.Connect(pluginInst.Name, ""); Console.WriteLine("Connected, waiting to be initialized..."); do { Thread.Sleep(500); } while (client.CommunicationState == CommunicationStates.Connected && pluginInst.Running); Console.WriteLine("Connection lost, exiting"); pluginInst.Running = false; client.Disconnect(); clientCB.Disconnect(); } catch (Exception e) { Console.WriteLine("Failed to host connect: {0}", e.Message); return; } Console.WriteLine("Exiting!!!"); }
public EnOceanTempSensorDevice(IHSApplication HS, EnOceanController Ctrl, String deviceId, JObject config) : base(HS, Ctrl, deviceId, config) { Console.WriteLine("Init of EnOceanTempSensorDevice : {0}", deviceId); }
public PageBuilder(IHSApplication pHS, IAppCallbackAPI pHSCB, HSPI_EnOcean.HSPI pluginInstance, EnOceanManager pCore) : base(pHS, pHSCB, pluginInstance) { mCore = pCore; HS = pHS; }
public EnOceanManager(IHSApplication pHsHost, IAppCallbackAPI pHsCB, HSPI pHspiInst) { hspiInst = pHspiInst; HS = pHsHost; HSCB = pHsCB; }