/// <summary>
 /// Deprecated Method for adding a new object to the device_type_commands EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTodevice_type_commands(device_type_commands device_type_commands)
 {
     base.AddObject("device_type_commands", device_type_commands);
 }
        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>
 /// Create a new device_type_commands object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 /// <param name="device_type_id">Initial value of the device_type_id property.</param>
 /// <param name="description">Initial value of the description property.</param>
 /// <param name="friendly_name">Initial value of the friendly_name property.</param>
 /// <param name="arg_data_type">Initial value of the arg_data_type property.</param>
 public static device_type_commands Createdevice_type_commands(global::System.Int64 id, global::System.Int64 device_type_id, global::System.String description, global::System.String friendly_name, global::System.Int64 arg_data_type)
 {
     device_type_commands device_type_commands = new device_type_commands();
     device_type_commands.id = id;
     device_type_commands.device_type_id = device_type_id;
     device_type_commands.description = description;
     device_type_commands.friendly_name = friendly_name;
     device_type_commands.arg_data_type = arg_data_type;
     return device_type_commands;
 }