public void Create(string name, bool force) { string addr = "AK_" + name; deviceHS = controller.GetHSDeviceByAddress(addr, out bool created, create: true, name: name); RefId = deviceHS.get_Ref(null); if (created) { DeviceTypeInfo_m.DeviceTypeInfo DT = new DeviceTypeInfo_m.DeviceTypeInfo(); DT.Device_API = DeviceTypeInfo_m.DeviceTypeInfo.eDeviceAPI.Security; DT.Device_Type = (int)DeviceTypeInfo_m.DeviceTypeInfo.eDeviceAPI.Plug_In; deviceHS.set_DeviceType_Set(hs, DT); deviceHS.set_InterfaceInstance(hs, ""); deviceHS.set_Status_Support(hs, false);//Set to True if the devices can be polled, false if not deviceHS.MISC_Set(hs, Enums.dvMISC.SHOW_VALUES); deviceHS.MISC_Set(hs, Enums.dvMISC.NO_LOG); Interface = controller.plugin.Name; Type = "Virtual"; Address = addr; //Location = "EnOcean"; //Location2 = "EnOcean"; //LastChange = DateTime.Now; } controller.UsedDevices[RefId] = this; }
///<summary> ///List of all devices in HomeSeer. Used to enable Linq queries on devices. ///</summary> ///<returns>Generic.List() of all devices</returns> ///<remarks>By Moskus</remarks> public static DeviceDictHS Devices() { DeviceDictHS ret = new DeviceDictHS(); Scheduler.Classes.clsDeviceEnumeration deviceEnumeration = (clsDeviceEnumeration)Hs.GetDeviceEnumerator(); while (!deviceEnumeration.Finished) { HSDevice device = deviceEnumeration.GetNext(); ret[device.get_Ref(null)] = device; } return(ret); }
public bool Create(string name, bool force, string type = "Virtual", eDeviceAPI Device_API = eDeviceAPI.Plug_In, int Device_Type = (int)eDeviceAPI.Plug_In, int Device_SubType = 0, string Device_SubType_Description = "" ) { string addr = ADDR_PREFIX + name; deviceHS = controller.GetHSDeviceByAddress(addr, out bool created, create: true, name: name); RefId = deviceHS.get_Ref(null); if (created) { DeviceTypeInfo_m.DeviceTypeInfo DT = new DeviceTypeInfo_m.DeviceTypeInfo() { Device_API = Device_API, Device_Type = Device_Type, Device_SubType = Device_SubType, Device_SubType_Description = Device_SubType_Description }; deviceHS.set_DeviceType_Set(hs, DT); deviceHS.set_InterfaceInstance(hs, ""); deviceHS.set_Status_Support(hs, false);//Set to True if the devices can be polled, false if not deviceHS.MISC_Set(hs, Enums.dvMISC.SHOW_VALUES | Enums.dvMISC.NO_LOG); deviceHS.MISC_Clear(hs, Enums.dvMISC.AUTO_VOICE_COMMAND); Interface = controller.plugin.Name; Type = type; Address = addr; //Location = "EnOcean"; //Location2 = "EnOcean"; //LastChange = DateTime.Now; } controller.UsedDevices[RefId] = this; return(created); }
/// <summary> /// Constructor /// Pass either devID or deviceHS /// </summary> /// <param name="controller">Controller</param> /// <param name="devID">HSDevice</param> /// <param name="deviceHS">HSDevice</param> public DeviceBase(ControllerBase controller, int devID = 0) { FullUpdate = false; this.controller = controller; this.RefId = devID; //if (deviceHS==null) { deviceHS = controller.GetHSDeviceByRef(devID); if (deviceHS == null) { // Deleted device. This also sets "Attension" field LogErr("Device doesn't exist in the system"); return; } } this.deviceHS = deviceHS; this.RefId = deviceHS.get_Ref(null); }