private void UpdateDimmerForStatus(DimmerDevice dimmerDevice, double value) { WD200NormalModeColor newColor = Math.Abs(value) < 0.1 ? offColor : onColor; HSPI_ZWave.HSPI.ConfigResult result = SetDeviceNormalModeColor(dimmerDevice.HomeID, dimmerDevice.NodeID, newColor); Program.WriteLog(LogType.Info, string.Format( "Setting normal mode color for device {0} (node ID {1}) to {2}; result: {3}", dimmerDevice.SwitchMultiLevelDeviceRef, dimmerDevice.NodeID, newColor, result )); }
public override void Setup() { testDevice = new DimmerDevice(); testDimmerDevice = (DimmerDevice)testDevice; }
public override string InitIO(string port) { Program.WriteLog(LogType.Verbose, "InitIO"); dimmersByRef = new Dictionary <int, DimmerDevice>(); haveDoneInitialUpdate = false; Dictionary <byte, DimmerDevice> dict = new Dictionary <byte, DimmerDevice>(); clsDeviceEnumeration enumerator = (clsDeviceEnumeration)hs.GetDeviceEnumerator(); do { DeviceClass device = enumerator.GetNext(); if (device != null) { if (device.get_Interface(hs) != "Z-Wave") { continue; } // It's a Z-Wave device PlugExtraData.clsPlugExtraData extraData = device.get_PlugExtraData_Get(hs); string[] addressParts = device.get_Address(hs).Split('-'); byte nodeId = byte.Parse(addressParts[1]); if (dict.ContainsKey(nodeId)) { continue; } if (DeviceIsDimmer(extraData)) { DimmerDevice dimmerDevice = new DimmerDevice { HomeID = addressParts[0], NodeID = nodeId, SwitchMultiLevelDeviceRef = device.get_Ref(hs) }; dict[nodeId] = dimmerDevice; dimmersByRef[dimmerDevice.SwitchMultiLevelDeviceRef] = dimmerDevice; } } } while (!enumerator.Finished); callbacks.RegisterEventCB(HomeSeerAPI.Enums.HSEvent.VALUE_SET, Name, InstanceFriendlyName()); callbacks.RegisterEventCB(HomeSeerAPI.Enums.HSEvent.VALUE_CHANGE, Name, InstanceFriendlyName()); hs.RegisterPage("IdleLightColorsSettings", Name, InstanceFriendlyName()); WebPageDesc configLink = new WebPageDesc { plugInName = Name, link = "IdleLightColorsSettings", linktext = "Settings", order = 1, page_title = "HS-WD200+ Idle Light Colors Settings", plugInInstance = InstanceFriendlyName() }; callbacks.RegisterConfigLink(configLink); callbacks.RegisterLink(configLink); offColor = (WD200NormalModeColor)int.Parse(hs.GetINISetting("Colors", "idle_color", ((int)WD200NormalModeColor.Blue).ToString(), IniFilename)); onColor = (WD200NormalModeColor)int.Parse(hs.GetINISetting("Colors", "active_color", ((int)WD200NormalModeColor.White).ToString(), IniFilename)); Program.WriteLog(LogType.Info, string.Format( "Init complete. Active color: {0}. Idle color: {1}. Found {2} dimmers with node IDs: {3}", onColor, offColor, dimmersByRef.Keys.Count, string.Join(", ", dimmersByRef.Values.Select(dimmerDevice => dimmerDevice.NodeID)) )); return(""); }