{
  "pluginAlias": "Meraki",
  "pluginType": "platform",
  "singular": true,
  "fixArrays": true,
  "strictValidation": true,
  "headerDisplay": "This plugin works with Meraki Devices based on Dashboard API. Devices are exposed to HomeKit as separate accessories and each needs to be manually paired.",
  "footerDisplay": "For documentation please see [GitHub repository](https://github.com/grzegorz914/homebridge-meraki-control).",
  "schema": {
    "type": "object",
    "properties": {
      "name": {
        "title": "Platform",
        "type": "string",
        "default": "Meraki Control"
      },
      "devices": {
        "type": "array",
        "items": {
          "type": "object",
          "title": "Network",
          "properties": {
            "name": {
              "title": "Network",
              "type": "string",
              "placeholder": "Network Name",
              "description": "Here set the Name to be displayed in Homebridge/HomeKit for this Accessory."
            },
            "host": {
              "title": "API Path",
              "type": "string",
              "placeholder": "https://n123.meraki.com",
              "format": "uri",
              "description": "Here set the Meraki Api Path."
            },
            "disableAccessory": {
              "title": "Disable Accessory",
              "type": "boolean",
              "default": false,
              "description": "Here You can disable this accessory."
            },
            "apiKey": {
              "title": "API Key",
              "type": "string",
              "placeholder": "01032453453421923",
              "description": "Here set the Meraki Api Key.",
              "format": "password"
            },
            "organizationId": {
              "title": "Organization Id",
              "type": "string",
              "placeholder": "123456789",
              "description": "Here set the Organization Id."
            },
            "networkId": {
              "title": "Network Id",
              "type": "string",
              "placeholder": "L_0123456789",
              "description": "Here set the Network Id."
            },
            "dashboardClientsControl": {
              "title": "Dashboard Clients Control",
              "type": "boolean",
              "default": false,
              "description": "This option enable control of dashboard clients."
            },
            "enablePrefixForClientName": {
              "title": "Prefix For Client Name",
              "type": "boolean",
              "description": "This option enable prefix (C.) for client name displayed in HomeKit app.",
              "condition": {
                "functionBody": "return model.devices[arrayIndices].dashboardClientsControl === true;"
              }
            },
            "enableSonsorClients": {
              "title": "Clients Sensors",
              "type": "boolean",
              "description": "This option expose Contact Sensor in HomeKit app for all exposed Clients.",
              "condition": {
                "functionBody": "return model.devices[arrayIndices].dashboardClientsControl === true;"
              }
            },
            "dashboardClientsPolicy": {
              "title": "Clients",
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "mode": {
                    "title": "Enable",
                    "type": "boolean",
                    "description": "Here Enable/Disable this Client control."
                  },
                  "name": {
                    "title": "Name",
                    "type": "string",
                    "placeholder": "Name",
                    "description": "Here set the Name to be displayed in Homebridge/HomeKit for this Client."
                  },
                  "mac": {
                    "title": "Mac",
                    "type": "string",
                    "placeholder": "Mac Address",
                    "description": "Here set the Mac Address of the Client to be exposed in Homebridge/HomeKit.",
                    "condition": {
                      "functionBody": "return model.devices[arrayIndices[0]].dashboardClientsPolicy[arrayIndices[1]].mode === true;"
                    }
                  },
                  "type": {
                    "title": "Policy",
                    "type": "string",
                    "description": "Here choice the Policy type to be appiled for this Client.",
                    "anyOf": [
                      {
                        "title": "Normal",
                        "enum": [
                          "Normal"
                        ]
                      },
                      {
                        "title": "Whitelisted",
                        "enum": [
                          "Whitelisted"
                        ]
                      },
                      {
                        "title": "Group Policy",
                        "enum": [
                          "Group policy"
                        ]
                      }
                    ],
                    "condition": {
                      "functionBody": "return model.devices[arrayIndices[0]].dashboardClientsPolicy[arrayIndices[1]].mode === true;"
                    }
                  }
                },
                "allOf": [
                  {
                    "if": {
                      "required": [
                        "mode"
                      ],
                      "properties": {
                        "mode": {
                          "const": true
                        }
                      }
                    },
                    "then": {
                      "required": [
                        "mac",
                        "type"
                      ]
                    }
                  }
                ]
              }
            },
            "accessPointsControl": {
              "title": "Access Points Control",
              "type": "boolean",
              "default": false,
              "description": "This option enable control of Access Points."
            },
            "hideUnconfiguredSsids": {
              "title": "Hide Unconfigured SSIDs",
              "type": "boolean",
              "description": "This option hide all unconfigured SSIDs, the name of this SSID must start with Unconfigured.",
              "condition": {
                "functionBody": "return model.devices[arrayIndices].accessPointsControl === true;"
              }
            },
            "enablePrefixForSsidsName": {
              "title": "Prefix For SSIDs Name",
              "type": "boolean",
              "description": "This option enable prefix (W.) for SSIDs name displayed in HomeKit app.",
              "condition": {
                "functionBody": "return model.devices[arrayIndices].accessPointsControl === true;"
              }
            },
            "enableSonsorSsids": {
              "title": "SSIDs Sensors",
              "type": "boolean",
              "description": "This option expose Contact Sensor in HomeKit app for all exposed SSIDs.",
              "condition": {
                "functionBody": "return model.devices[arrayIndices].accessPointsControl === true;"
              }
            },
            "hideSsids": {
              "title": "SSIDs",
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "mode": {
                    "title": "Enable",
                    "type": "boolean",
                    "description": "Here Enable/Disable this SSID control."
                  },
                  "name": {
                    "title": "Name",
                    "type": "string",
                    "placeholder": "SSID Name",
                    "description": "Here set the SSID Name to be not exposed in Homebridge/HomeKit."
                  }
                },
                "allOf": [
                  {
                    "if": {
                      "required": [
                        "mode"
                      ],
                      "properties": {
                        "mode": {
                          "const": true
                        }
                      }
                    },
                    "then": {
                      "required": [
                        "name"
                      ]
                    }
                  }
                ]
              }
            },
            "switches": {
              "title": "Switches",
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "mode": {
                    "title": "Enable",
                    "type": "boolean",
                    "default": false,
                    "description": "Here Enable/Disable this Switch control."
                  },
                  "name": {
                    "title": "Name",
                    "type": "string",
                    "placeholder": "Switch Name",
                    "description": "Here set the Switch Name."
                  },
                  "serialNumber": {
                    "title": "Serial Number",
                    "type": "string",
                    "placeholder": "Serial Number",
                    "description": "Here set the Serial Number of the Switch to be exposed in Homebridge/HomeKit.",
                    "condition": {
                      "functionBody": "return model.devices[arrayIndices[0]].switches[arrayIndices[1]].mode === true;"
                    }
                  },
                  "hideUplinkPorts": {
                    "title": "Hide Uplink Ports",
                    "type": "boolean",
                    "description": "This option hide all uplink ports, the name of this Port must start with Uplink.",
                    "condition": {
                      "functionBody": "return model.devices[arrayIndices[0]].switches[arrayIndices[1]].mode === true;"
                    }
                  },
                  "enablePrefixForPortName": {
                    "title": "Prefix For Port Name",
                    "type": "boolean",
                    "description": "This option enable prefix (Port Number) for port name displayed in HomeKit app.",
                    "condition": {
                      "functionBody": "return model.devices[arrayIndices[0]].switches[arrayIndices[1]].mode === true;"
                    }
                  },
                  "enablePoePortsControl": {
                    "title": "POE Ports Control",
                    "type": "boolean",
                    "description": "This option enable POE control for controled ports.",
                    "condition": {
                      "functionBody": "return model.devices[arrayIndices[0]].switches[arrayIndices[1]].mode === true;"
                    }
                  },
                  "enableSensorPorts": {
                    "title": "Ports Sensors",
                    "type": "boolean",
                    "description": "This option expose Contact Sensor in HomeKit app for all exposed ports.",
                    "condition": {
                      "functionBody": "return model.devices[arrayIndices[0]].switches[arrayIndices[1]].mode === true;"
                    }
                  },
                  "hidePorts": {
                    "title": "Ports",
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "mode": {
                          "title": "Enable",
                          "type": "boolean",
                          "description": "Here Enable/Disable this Port control."
                        },
                        "name": {
                          "title": "Name",
                          "type": "string",
                          "placeholder": "Port Name",
                          "description": "Here set the Port Name to be not exposed in Homebridge/HomeKit."
                        }
                      },
                      "allOf": [
                        {
                          "if": {
                            "required": [
                              "mode"
                            ],
                            "properties": {
                              "mode": {
                                "const": true
                              }
                            }
                          },
                          "then": {
                            "required": [
                              "name"
                            ]
                          }
                        }
                      ]
                    }
                  }
                },
                "allOf": [
                  {
                    "if": {
                      "required": [
                        "mode"
                      ],
                      "properties": {
                        "mode": {
                          "const": true
                        }
                      }
                    },
                    "then": {
                      "required": [
                        "serialNumber"
                      ]
                    }
                  }
                ]
              }
            },
            "refreshInterval": {
              "title": "Refresh Interval (sec)",
              "type": "integer",
              "minimum": 0,
              "maximum": 60,
              "default": 5,
              "description": "Here set the data refresh time in (sec)."
            },
            "log": {
              "title": "Log",
              "type": "object",
              "properties": {
                "deviceInfo": {
                  "title": "Device Info",
                  "type": "boolean",
                  "default": true,
                  "description": "This enable log level device info, will display overall device info by every plugin restart"
                },
                "success": {
                  "title": "Success",
                  "type": "boolean",
                  "default": true,
                  "description": "This enable log level success"
                },
                "info": {
                  "title": "Info",
                  "type": "boolean",
                  "default": false,
                  "description": "This enable log level info"
                },
                "warn": {
                  "title": "Warn",
                  "type": "boolean",
                  "default": true,
                  "description": "This enable log level warn"
                },
                "error": {
                  "title": "Error",
                  "type": "boolean",
                  "default": true,
                  "description": "This enable log level error"
                },
                "debug": {
                  "title": "Debug",
                  "type": "boolean",
                  "default": false,
                  "description": "This enable log level debug"
                }
              }
            }
          },
          "required": [
            "name",
            "host",
            "disableAccessory",
            "apiKey",
            "organizationId",
            "networkId"
          ]
        }
      }
    }
  },
  "layout": [
    {
      "key": "devices",
      "type": "tabarray",
      "title": "{{ value.name || 'network' }}",
      "items": [
        "devices[].name",
        "devices[].host",
        "devices[].disableAccessory",
        {
          "key": "devices[]",
          "type": "section",
          "title": "Advanced Settings",
          "expandable": true,
          "expanded": false,
          "items": [
            {
              "key": "devices[]",
              "type": "tabarray",
              "title": "{{ value.title }}",
              "items": [
                {
                  "key": "devices[]",
                  "title": "Dashboard Clients",
                  "items": [
                    "devices[].dashboardClientsControl",
                    "devices[].enablePrefixForClientName",
                    "devices[].enableSonsorClients",
                    {
                      "key": "devices[]",
                      "type": "section",
                      "title": "Clients policy",
                      "expandable": true,
                      "expanded": false,
                      "items": [
                        {
                          "key": "devices[].dashboardClientsPolicy",
                          "type": "tabarray",
                          "title": "{{ value.name || 'Client' }}",
                          "items": [
                            "devices[].dashboardClientsPolicy[].mode",
                            "devices[].dashboardClientsPolicy[].name",
                            "devices[].dashboardClientsPolicy[].mac",
                            "devices[].dashboardClientsPolicy[].type"
                          ]
                        }
                      ],
                      "condition": {
                        "functionBody": "return model.devices[arrayIndices].dashboardClientsControl === true;"
                      }
                    }
                  ]
                },
                {
                  "key": "devices[]",
                  "title": "Access Points",
                  "items": [
                    "devices[].accessPointsControl",
                    "devices[].hideUnconfiguredSsids",
                    "devices[].enablePrefixForSsidsName",
                    "devices[].enableSonsorSsids",
                    {
                      "key": "devices[]",
                      "type": "section",
                      "title": "Hidden SSIDs",
                      "expandable": true,
                      "expanded": false,
                      "items": [
                        {
                          "key": "devices[].hideSsids",
                          "type": "tabarray",
                          "title": "{{ value.name || 'SSID' }}",
                          "items": [
                            "devices[].hideSsids[].mode",
                            "devices[].hideSsids[].name"
                          ]
                        }
                      ],
                      "condition": {
                        "functionBody": "return model.devices[arrayIndices].accessPointsControl === true;"
                      }
                    }
                  ]
                },
                {
                  "key": "devices[]",
                  "title": "Switches",
                  "items": [
                    {
                      "key": "devices[].switches",
                      "type": "tabarray",
                      "title": "{{ value.name || 'Switch' }}",
                      "items": [
                        "devices[].switches[].mode",
                        "devices[].switches[].name",
                        "devices[].switches[].serialNumber",
                        "devices[].switches[].hideUplinkPorts",
                        "devices[].switches[].enablePrefixForPortName",
                        "devices[].switches[].enablePoePortsControl",
                        "devices[].switches[].enableSensorPorts",
                        {
                          "key": "devices[].switches[]",
                          "type": "section",
                          "title": "Hidden Ports",
                          "expandable": true,
                          "expanded": false,
                          "items": [
                            {
                              "key": "devices[].switches[].hidePorts",
                              "type": "tabarray",
                              "title": "{{ value.name || 'Port' }}",
                              "items": [
                                "devices[].switches[].hidePorts[].mode",
                                "devices[].switches[].hidePorts[].name"
                              ]
                            }
                          ],
                          "condition": {
                            "functionBody": "return model.devices[arrayIndices[0]].switches[arrayIndices[1]].mode === true;"
                          }
                        }
                      ]
                    }
                  ]
                },
                {
                  "key": "devices[]",
                  "title": "Authorization",
                  "items": [
                    {
                      "key": "devices[].apiKey",
                      "type": "password"
                    },
                    "devices[].organizationId",
                    "devices[].networkId"
                  ]
                },
                {
                  "key": "devices[]",
                  "title": "Devices",
                  "items": [
                    "devices[].refreshInterval"
                  ]
                },
                {
                  "key": "devices[].log",
                  "title": "Log",
                  "items": [
                    "devices[].log.deviceInfo",
                    "devices[].log.success",
                    "devices[].log.info",
                    "devices[].log.warn",
                    "devices[].log.error",
                    "devices[].log.debug"
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}