{    
  "code_name": "known_template",
  "template_type": "database-entry",
  "unique_prefix": "KNWN",
  "plugin_type": "system",
  "enabled": true,
  "data_source": "template", 
  "show_ui": false, 
  "localized": ["display_name", "description", "icon"],
  "display_name": [{
      "language_code": "en_us",
      "string": "Known Devices"
    }],
  "description": [{
    "language_code": "en_us",
    "string": "The template used for known devices."
  }],
  "icon": [
    {
      "language_code": "en_us",
      "string": "<i class=\"fa fa-check\"></i>"
    }
  ],
  "params" : [
    {
        "name"  : "target_macs",
        "type"  : "setting",
        "value" : "KNWN_target_macs"
    }, 
    {
        "name"  : "dev_AlertDeviceDown",
        "type"  : "setting",
        "value" : "KNWN_dev_AlertDeviceDown"    
    }, 
    {
        "name"  : "dev_AlertEvents",
        "type"  : "setting",
        "value" : "KNWN_dev_AlertEvents"
    },    
    {
        "name"  : "trigger_ids",
        "type"  : "array",
        "value" : "trigger.Object_PrimaryID"
    },
    {
        "name"  : "trigger_objects",
        "type"  : "array",
        "value" : "trigger"
    }
  ], 
  "settings":[
        {
          "function": "FLOW",
          "type": "json",          
          "default_value": [{
              "name":"apply_template",  
              "trigger": [
                  {
                      "object_event": "new",
                      "object_filter": "",                      
                      "object": "Devices"                      
                  }
              ],
              "steps": [
                  {
                      "step_type":"wait",
                      "params": [
                          {
                              "days": 3,
                              "hours": 0,
                              "minutes": 0,
                              "seconds": 0
                          }
                      ]
                  },
                  {
                      "step_type":"condition",
                      "params": [
                          {
                              "left": {
                                  "value": "triggers[0].object['dev_NewDevice']",
                                  "use_quotes": true,
                                  "js_template": "'{value}'.toString()"
                              },
                              "operator": {
                                  "value" : "==",
                                  "data_type": "boolean"
                              },
                              "right": {
                                  "value": true,
                                  "use_quotes": false,
                                  "js_template": "'{value}'.toString()"
                              }
                          }
                      ]
                  },
                  {
                      "step_type":"action",
                      "params": [
                          {
                              "type": "plugin",            
                              "params": 
                              {
                                  "unique_prefix": "KNWN",
                                  "overrides":[
                                      {
                                          "object_path": "settings.0",
                                          "key":"function", 
                                          "value":"target_macs", 
                                          "target_property":"default_value", 
                                          "desired_value":  "triggers.keys"                              
                                      }
                                  ]
                              }
          
                          }
                      ]
                  }
              ]
          }],
          "options": [],
          "localized": ["name", "description"],
          "name": [
            {
              "language_code": "en_us",
              "string": "Plugin flow"
            }
          ],
          "description": [
            {
              "language_code": "en_us",
              "string": "This flow makes sure the template is applied to devices that are older than 3 days."
            }
          ]
        },
        {
          "function": "target_macs",
          "type": "list.readonly",          
          "maxLength": 50,
          "default_value": [],
          "options": [],
          "localized": ["name", "description"],
          "name": [
            {
              "language_code": "en_us",
              "string": "Target devices"
            }
          ],
          "description": [
            {
              "language_code": "en_us",
              "string": "The MAC address of the devices to update. Uneditable. This parameter is dynamically updated via a Flow."
            }
          ]
        },
        {
          "function": "CMD",
          "type": "text",
          "default_value":"UPDATE Devices SET dev_AlertDeviceDown = {KNWN_dev_AlertDeviceDown}, dev_AlertEvents = {KNWN_dev_AlertEvents} WHERE dev_MAC in ({target_macs})",
          "options": [],
          "localized": ["name", "description"],
          "name" : [{
              "language_code":"en_us",
              "string" : "UPDATE SQL"
          }],
          "description": [{
              "language_code":"en_us",
              "string" : "This SQL query is used to update target devices."
          }]
        },
        {
          "function": "dev_Name",
          "type": "readonly",
          "maxLength": 50,
          "default_value": "(unknown)",
          "options": [],
          "localized": ["name", "description"],
          "name": [
            {
              "language_code": "en_us",
              "string": "Device Name"
            }
          ],
          "description": [
            {
              "language_code": "en_us",
              "string": "The name of the device. Uneditable as internal functionality is dependent on specific new device names."
            }
          ]
        },
        {
          "function": "dev_Owner",
          "type": "string",
          "maxLength": 30,
          "default_value": "House",
          "override_value": {                 
            "override": false
          },
          "options": [],
          "localized": ["name", "description"],
          "name": [
            {
              "language_code": "en_us",
              "string": "Device Owner"
            }
          ],
          "description": [
            {
              "language_code": "en_us",
              "string": "The owner of the device."
            }
          ]
        },
        {
          "function": "dev_DeviceType",
          "type": "string",
          "maxLength": 30,
          "default_value": "",
          "options": [],
          "localized": ["name", "description"],
          "name": [
            {
              "language_code": "en_us",
              "string": "Device Type"
            }
          ],
          "description": [
            {
              "language_code": "en_us",
              "string": "The type of the device."
            }
          ]
        },
         {
          "function": "dev_Vendor",
          "type": "readonly",
          "maxLength": 250,
          "default_value": "",
          "options": [],
          "localized": ["name", "description"],
          "name": [
            {
              "language_code": "en_us",
              "string": "Device Vendor"
            }
          ],
          "description": [
            {
              "language_code": "en_us",
              "string": "The vendor of the device. Uneditable - Autodetected."
            }
          ]
        },
        {
          "function": "dev_Favorite",
          "type": "integer.checkbox",
          "default_value": 0,
          "override_value": {            
            "override": false
          },
          "options": [],
          "localized": ["name", "description"],
          "name": [
            {
              "language_code": "en_us",
              "string": "Favorite Device"
            }
          ],
          "description": [
            {
              "language_code": "en_us",
              "string": "Indicates whether the device is marked as a favorite."
            }
          ]
        },
        {
          "function": "dev_Group",
          "type": "string",
          "maxLength": 10,
          "default_value": "",
          "override_value": {            
            "override": false
          },
          "options": [],
          "localized": ["name", "description"],
          "name": [
            {
              "language_code": "en_us",
              "string": "Device Group"
            }
          ],
          "description": [
            {
              "language_code": "en_us",
              "string": "The group to which the device belongs."
            }
          ]
        },
         {
          "function": "dev_Comments",
          "type": "string",
          "default_value": "",
          "options": [],
          "localized": ["name", "description"],
          "name": [
            {
              "language_code": "en_us",
              "string": "Device Comments"
            }
          ],
          "description": [
            {
              "language_code": "en_us",
              "string": "Additional comments or notes about the device."
            }
          ]
        },
        {
          "function": "dev_FirstConnection",
          "type": "readonly",
          "format": "date-time",
          "default_value": "",
          "options": [],
          "localized": ["name", "description"],
          "name": [
            {
              "language_code": "en_us",
              "string": "First Connection"
            }
          ],
          "description": [
            {
              "language_code": "en_us",
              "string": "The date and time of the first connection with the device. Uneditable - Autodetected."
            }
          ]
        },
        {
          "function": "dev_LastConnection",
          "type": "readonly",
          "format": "date-time",
          "default_value": "",
          "options": [],
          "localized": ["name", "description"],
          "name": [
            {
              "language_code": "en_us",
              "string": "Last Connection"
            }
          ],
          "description": [
            {
              "language_code": "en_us",
              "string": "The date and time of the last connection with the device. Uneditable - Autodetected."
            }
          ]
        },
        {
          "function": "dev_LastIP",
          "type": "readonly",
          "maxLength": 50,
          "default_value": "",
          "options": [],
          "localized": ["name", "description"],
          "name": [
            {
              "language_code": "en_us",
              "string": "Last IP"
            }
          ],
          "description": [
            {
              "language_code": "en_us",
              "string": "The last known IP address of the device. Uneditable - Autodetected."
            }
          ]
        },
        {
          "function": "dev_StaticIP",
          "type": "integer.checkbox",
          "default_value": 1,
          "override_value": {            
            "override": true
          },
          "options": [],
          "localized": ["name", "description"],
          "name": [
            {
              "language_code": "en_us",
              "string": "Static IP"
            }
          ],
          "description": [
            {
              "language_code": "en_us",
              "string": "Indicates whether the device has a static IP address."
            }
          ]
        },
        {
          "function": "dev_ScanCycle",
          "type": "integer.checkbox",
          "default_value": 1,
          "override_value": {            
            "override": true
          },
          "options": [],
          "localized": ["name", "description"],
          "name": [
            {
              "language_code": "en_us",
              "string": "Scan Cycle"
            }
          ],
          "description": [
            {
              "language_code": "en_us",
              "string": "The default value of the <code>Scan device</code> dropdown. Enable if newly discovered devices should be scanned."
            }
          ]
        },
        {
          "function": "dev_LogEvents",
          "type": "integer.checkbox",
          "default_value": 0,          
          "override_value": {              
            "override": false
          },
          "options": [],
          "localized": ["name", "description"],
          "name": [
            {
              "language_code": "en_us",
              "string": "Log Events"
            }
          ],
          "description": [
            {
              "language_code": "en_us",
              "string": "Indicates whether events related to the device shouldbe logged."
          }]
        },
        {
          "function": "dev_AlertEvents",
          "type": "integer.checkbox",
          "default_value": 0,
          "override_value": {            
            "override": true
          },
          "options": [],
          "localized": ["name", "description"],
          "name": [
            {
              "language_code": "en_us",
              "string": "Alert Events"
            }
          ],
          "description": [
            {
              "language_code": "en_us",
              "string": "Indicates whether events related to the device should trigger alerts. The default value of the <code>Alert All Events</code> checkbox."
            }
          ]
        },
        {
          "function": "dev_AlertDeviceDown",
          "type": "integer.checkbox",
          "default_value": 0,
          "options": [],
          "localized": ["name", "description"],
          "name": [
            {
              "language_code": "en_us",
              "string": "Alert Device Down"
            }
          ],
          "description": [
            {
              "language_code": "en_us",
              "string": "Indicates whether an alert should be triggered when the device goes down. The default value of the <code>Alert Down</code> checkbox."
            }
          ]
        },
        {
          "function": "dev_SkipRepeated",
          "type": "integer",
          "default_value": 0,
          "options": [],
          "localized": ["name", "description"],
          "name": [
            {
              "language_code": "en_us",
              "string": "Skip Repeated"
            }
          ],
          "description": [
            {
              "language_code": "en_us",
              "string": "The default value of the <code>Skip repeated notifications for</code> dropdown. Enter number of <b>hours</b> for which repeated notifications should be ignored for. If you enter <code>0</code> then you get notified on all events."
            }
          ]
        },
        {
          "function": "dev_LastNotification",
          "type": "readonly",
          "format": "date-time",
          "default_value": "",
          "options": [],
          "localized": ["name", "description"],
          "name": [
            {
              "language_code": "en_us",
              "string": "Last Notification"
            }
          ],
          "description": [
            {
              "language_code": "en_us",
              "string": "The date and time of the last notification sent for the device. Uneditable - Autodetected."
            }
          ]
        },
       {
          "function": "dev_PresentLastScan",
          "type": "integer.checkbox",
          "default_value": 1,
          "options": [],
          "localized": ["name", "description"],
          "name": [
            {
              "language_code": "en_us",
              "string": "Present Last Scan"
            }
          ],
          "description": [
            {
              "language_code": "en_us",
              "string": "Indicates whether the device should be marked as present after detected in a scan."
            }
          ]
        },
        {
          "function": "dev_NewDevice",
          "type": "integer.checkbox",
          "default_value": true,
          "options": [],
          "localized": ["name", "description"],
          "name": [
            {
              "language_code": "en_us",
              "string": "New Device"
            }
          ],
          "description": [
            {
              "language_code": "en_us",
              "string": "Indicates whether the device is considered a new device. The default value of the <code>New Device</code> checkbox."
            }
          ]
        },
         {
          "function": "dev_Location",
          "type": "string",
          "maxLength": 250,
          "default_value": "",
          "options": [],
          "localized": ["name", "description"],
          "name": [
            {
              "language_code": "en_us",
              "string": "Device Location"
            }
          ],
          "description": [
            {
              "language_code": "en_us",
              "string": "The location of the device."
            }
          ]
        },
        {
          "function": "dev_Archived",
          "type": "integer.checkbox",
          "default_value": 0,
          "options": [],
          "localized": ["name", "description"],
          "name": [
            {
              "language_code": "en_us",
              "string": "Archived"
            }
          ],
          "description": [
            {
              "language_code": "en_us",
              "string": "Indicates whether the device is archived. The default value of the <code>Archived</code> checkbox."
            }
          ]
        },
        {
          "function": "dev_Network_Node_MAC_ADDR",
          "type": "string",
          "default_value": "",
          "options": [],
          "localized": ["name", "description"],
          "name": [
            {
              "language_code": "en_us",
              "string": "Network Node MAC Address"
            }
          ],
          "description": [
            {
              "language_code": "en_us",
              "string": "The MAC address of the network node."
            }
          ]
        },
         {
          "function": "dev_Network_Node_port",
          "type": "readonly",
          "default_value": 0,
          "options": [],
          "localized": ["name", "description"],
         "name": [
            {
              "language_code": "en_us",
              "string": "Network Node Port"
            }
          ],
          "description": [
            {
              "language_code": "en_us",
              "string": "The port number of the network node. Uneditable."
            }
          ]
        },
         {
          "function": "dev_Icon",
          "type": "string",
          "default_value": "",
          "options": [],
          "localized": ["name", "description"],
          "name": [
            {
              "language_code": "en_us",
              "string": "Device Icon"
            }
          ],
          "description": [
            {
              "language_code": "en_us",
              "string": "The icon associated with the device. Check the <a href=\"https://github.com/jokob-sk/NetAlertX/blob/main/docs/ICONS.md\" target=\"_blank\">documentation on icons</a> for more details."
            }
          ]
        }
  ],
    "required": [
      "dev_MAC",
      "dev_Name",
      "dev_Owner",
      "dev_FirstConnection",
      "dev_LastConnection",
      "dev_LastIP",
      "dev_StaticIP",
      "dev_ScanCycle",
      "dev_LogEvents",
      "dev_AlertEvents",
      "dev_AlertDeviceDown",
      "dev_SkipRepeated",
      "dev_LastNotification",
      "dev_PresentLastScan",
      "dev_NewDevice",
      "dev_Location",
      "dev_Archived",
      "dev_Network_Node_MAC_ADDR",
      "dev_Network_Node_port",
      "dev_Icon"
    ],
    "additionalProperties": false
  }
    

  