public override void Initialize() { DefineOrUpdateSetting(new plugin_settings { name = "COMPORT", friendly_name = "Com Port", value = (4).ToString(), value_data_type = (int)Data_Types.COMPORT, description = "The COM port that your USB-UIRT is assigned to." }); // The USB-UIRT device type device_types usbuirtType = new device_types { name = "USBUIRT", friendly_name = "USB-UIRT", show_in_list = true }; usbuirtType.device_type_commands.Add(new device_type_commands { name = "ADD", friendly_name = "Add device", arg_data_type = (int)Data_Types.NONE, description = "Add a new infrared device." }); DefineOrUpdateDeviceType(usbuirtType); // An infrared device type this.infraredType = new device_types { name = "INFRARED", friendly_name = "Infrared", show_in_list = true }; this.infraredType.device_type_commands.Add(new device_type_commands { name = "LEARN", friendly_name = "Learn Command", arg_data_type = (int)Data_Types.NONE, description = "Teaches the device a new command." }); DefineOrUpdateDeviceType(this.infraredType); }
public override void Initialize() { DefineOrUpdateSetting(new plugin_settings { name = "COMPORT", friendly_name = "Com Port", value = (3).ToString(), value_data_type = (int)Data_Types.COMPORT, description = "The COM port that your z-wave controller is assigned to." }); //DefineOrUpdateSetting(new plugin_settings //{ // name = "HID", // friendly_name = "Use HID", // value = false.ToString(), // value_data_type = (int)Data_Types.BOOL, // description = "Use HID rather than COM port. (use this for ControlThink Sticks)" //}); DefineOrUpdateSetting(new plugin_settings { name = "POLLINT", friendly_name = "Polling Interval", value = (360).ToString(), value_data_type = (int)Data_Types.INTEGER, description = "The frequency in which devices are polled for level status on your network. Set high to avoid excessive network traffic. " }); //Controller Type Devices device_types controller_dt = new device_types { name = "CONTROLLER", friendly_name = "OpenZWave Controller", show_in_list = true }; controller_dt.device_type_commands.Add(new device_type_commands { name = "RESET", friendly_name = "Reset Controller", arg_data_type = (int)Data_Types.NONE, description = "Erases all Z-Wave network settings from your controller." }); controller_dt.device_type_commands.Add(new device_type_commands { name = "ADDDEVICE", friendly_name = "Add Device to Network", arg_data_type = (int)Data_Types.NONE, description = "Adds a ZWave Device to your network." }); controller_dt.device_type_commands.Add(new device_type_commands { name = "AddController", friendly_name = "Add Controller to Network", arg_data_type = (int)Data_Types.NONE, description = "Adds a ZWave Controller to your network." }); controller_dt.device_type_commands.Add(new device_type_commands { name = "CreateNewPrimary", friendly_name = "Create New Primary", arg_data_type = (int)Data_Types.NONE, description = "Puts the target controller into receive configuration mode." }); controller_dt.device_type_commands.Add(new device_type_commands { name = "ReceiveConfiguration", friendly_name = "Receive Configuration", arg_data_type = (int)Data_Types.NONE, description = "Receives the network configuration from another controller." }); controller_dt.device_type_commands.Add(new device_type_commands { name = "RemoveController", friendly_name = "Remove Controller", arg_data_type = (int)Data_Types.NONE, description = "Removes a Controller from your network." }); controller_dt.device_type_commands.Add(new device_type_commands { name = "RemoveDevice", friendly_name = "Remove Device", arg_data_type = (int)Data_Types.NONE, description = "Removes a Device from your network." }); controller_dt.device_type_commands.Add(new device_type_commands { name = "TransferPrimaryRole", friendly_name = "Transfer Primary Role", arg_data_type = (int)Data_Types.NONE, description = "Transfers the primary role\nto another controller." }); controller_dt.device_type_commands.Add(new device_type_commands { name = "HasNodeFailed", friendly_name = "Has Node Failed", arg_data_type = (int)Data_Types.NONE, description = "Tests whether a node has failed." }); controller_dt.device_type_commands.Add(new device_type_commands { name = "RemoveFailedNode", friendly_name = "Remove Failed Node", arg_data_type = (int)Data_Types.NONE, description = "Removes the failed node from the controller's list." }); controller_dt.device_type_commands.Add(new device_type_commands { name = "ReplaceFailedNode", friendly_name = "Replace Failed Node", arg_data_type = (int)Data_Types.NONE, description = "Tests the failed node." }); DefineOrUpdateDeviceType(controller_dt); //Switch Type Devices device_types switch_dt = new device_types { name = "SWITCH", friendly_name = "OpenZWave Binary", show_in_list = true }; switch_dt.device_type_commands.Add(new device_type_commands { name = "TURNON", friendly_name = "Turn On", arg_data_type = (int)Data_Types.NONE, description = "Activates a switch." }); switch_dt.device_type_commands.Add(new device_type_commands { name = "TURNOFF", friendly_name = "Turn Off", arg_data_type = (int)Data_Types.NONE, description = "Deactivates a switch." }); switch_dt.device_type_commands.Add(new device_type_commands { name = "MOMENTARY", friendly_name = "Turn On for X milliseconds", arg_data_type = (int)Data_Types.INTEGER, description = "Turns a device on for the specified number of milliseconds and then turns the device back off." }); DefineOrUpdateDeviceType(switch_dt); //Dimmer Type Devices device_types dimmer_dt = new device_types { name = "DIMMER", friendly_name = "OpenZWave Dimmer", show_in_list = true }; dimmer_dt.device_type_commands.Add(new device_type_commands { name = "TURNON", friendly_name = "Turn On", arg_data_type = (int)Data_Types.NONE, description = "Activates a dimmer." }); dimmer_dt.device_type_commands.Add(new device_type_commands { name = "TURNOFF", friendly_name = "Turn Off", arg_data_type = (int)Data_Types.NONE, description = "Deactivates a dimmer." }); device_type_commands dimmer_preset_cmd = new device_type_commands { name = "SETPRESETLEVEL", friendly_name = "Set Level", arg_data_type = (int)Data_Types.LIST, description = "Sets a dimmer to a preset level." }; dimmer_preset_cmd.device_type_command_options.Add(new device_type_command_options { option = "0%" } ); dimmer_preset_cmd.device_type_command_options.Add(new device_type_command_options { option = "20%" } ); dimmer_preset_cmd.device_type_command_options.Add(new device_type_command_options { option = "40%" } ); dimmer_preset_cmd.device_type_command_options.Add(new device_type_command_options { option = "60%" } ); dimmer_preset_cmd.device_type_command_options.Add(new device_type_command_options { option = "80%" } ); dimmer_preset_cmd.device_type_command_options.Add(new device_type_command_options { option = "100%" } ); dimmer_preset_cmd.device_type_command_options.Add(new device_type_command_options { option = "255" } ); dimmer_dt.device_type_commands.Add(dimmer_preset_cmd); DefineOrUpdateDeviceType(dimmer_dt); //Thermostat Type Devices device_types thermo_dt = new device_types { name = "THERMOSTAT", friendly_name = "OpenZWave Thermostat", show_in_list = true }; thermo_dt.device_type_commands.Add(new device_type_commands { name = "SETENERGYMODE", friendly_name = "Set Energy Mode", arg_data_type = (int)Data_Types.NONE, description = "Set thermosat to Energy Mode." }); thermo_dt.device_type_commands.Add(new device_type_commands { name = "SETCONFORTMODE", friendly_name = "Set Confort Mode", arg_data_type = (int)Data_Types.NONE, description = "Set thermosat to Confort Mode. (Run)" }); DefineOrUpdateDeviceType(thermo_dt); //Door Lock Type Devices device_types lock_dt = new device_types { name = "DOORLOCK", friendly_name = "OpenZWave Doorlock", show_in_list = true }; DefineOrUpdateDeviceType(lock_dt); //Sensors device_types sensor_dt = new device_types { name = "SENSOR", friendly_name = "OpenZWave Sensor", show_in_list = true }; DefineOrUpdateDeviceType(sensor_dt); device_propertys.DefineOrUpdateDeviceProperty(new device_propertys { name = "DEFAULONLEVEL", friendly_name = "Level that an object is set to when using the on command.", default_value = "99", value_data_type = (int)Data_Types.BYTE }); device_propertys.DefineOrUpdateDeviceProperty(new device_propertys { name = "ENABLEREPOLLONLEVELCHANGE", friendly_name = "Repoll dimmers 5 seconds after a level change is received?", default_value = true.ToString(), value_data_type = (int)Data_Types.BOOL }); //TODO: Make a new DeviceAPIProperty that is API specific for types of settings that applies OpenZWave Devices ////TEMP //DefineDevice(new device { node_id = 1, device_type_id = GetDeviceType("DIMMER").id, friendly_name = "Test Device 1", last_heard_from = DateTime.Now}); //DefineDevice(new device { node_id = 2, device_type_id = GetDeviceType("DIMMER").id, friendly_name = "Test Device 2", last_heard_from = DateTime.Now }); //int i = 2; //System.Timers.Timer t = new System.Timers.Timer(); //t.Interval = 5000; //t.Elapsed += (sender, e) => //{ // i++; // //zvsEntityControl.zvsContext.devices.FirstOrDefault(d => d.node_id == 1).last_heard_from = DateTime.Now; // //zvsEntityControl.zvsContext.SaveChanges(); // DefineOrUpdateDeviceValue(new device_values // { // device_id = zvsEntityControl.zvsContext.devices.FirstOrDefault(d => d.node_id == 1).id, // value_id = "1!", // label_name = "Basic", // genre = "Genre", // index = "Index", // type = "Type", // commandClassId = "Coomand Class", // value = (i % 2 == 0 ? "99" : "50") // }); // //DefineDevice(new device { node_id = i, device_type_id = GetDeviceType("DIMMER").id, friendly_name = "Test Device " + i, last_heard_from = DateTime.Now }); //}; //t.Enabled = true; }
/// <summary> /// Deprecated Method for adding a new object to the device_types EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddTodevice_types(device_types device_types) { base.AddObject("device_types", device_types); }
public void DefineOrUpdateDeviceType(device_types dt) { using (zvsEntities2 db = new zvsEntities2(zvsEntityControl.GetzvsConnectionString)) { plugin pl = db.plugins.FirstOrDefault(p => p.name == this._name); if (pl != null) { //Does device type exist? device_types existing_dt = pl.device_types.FirstOrDefault(d => d.name == dt.name); if (existing_dt == null) { pl.device_types.Add(dt); } else { existing_dt.friendly_name = dt.friendly_name; existing_dt.show_in_list = dt.show_in_list; foreach (device_type_commands dtc in dt.device_type_commands) { device_type_commands exsisting_dtc = existing_dt.device_type_commands.FirstOrDefault(d => d.name == dtc.name); if (exsisting_dtc == null) { existing_dt.device_type_commands.Add(dtc); } else { exsisting_dtc.friendly_name = dtc.friendly_name; exsisting_dtc.help = dtc.help; exsisting_dtc.custom_data2 = dtc.custom_data2; exsisting_dtc.custom_data1 = dtc.custom_data1; exsisting_dtc.arg_data_type = dtc.arg_data_type; exsisting_dtc.description = dtc.description; foreach (var option in db.device_type_command_options.Where(o => o.device_type_command_id == exsisting_dtc.id).ToArray()) { db.DeleteObject(option); } foreach (device_type_command_options dtco in dtc.device_type_command_options) exsisting_dtc.device_type_command_options.Add(new device_type_command_options { option = dtco.option }); } } } db.SaveChanges(); } } }
/// <summary> /// Create a new device_types object. /// </summary> /// <param name="id">Initial value of the id property.</param> /// <param name="plugin_id">Initial value of the plugin_id property.</param> /// <param name="name">Initial value of the name property.</param> /// <param name="show_in_list">Initial value of the show_in_list property.</param> public static device_types Createdevice_types(global::System.Int64 id, global::System.Int64 plugin_id, global::System.String name, global::System.Boolean show_in_list) { device_types device_types = new device_types(); device_types.id = id; device_types.plugin_id = plugin_id; device_types.name = name; device_types.show_in_list = show_in_list; return device_types; }