{
    "pluginAlias": "Homebridge Automower Platform",
    "pluginType": "platform",
    "singular": false,
    "schema": {
      "type": "object",
      "properties": {
        "name": {
          "title": "Name",
          "type": "string",
          "default": "Homebridge Automower Platform",
          "minLength": 1,
          "required": true          
        },
        "device_type": {
          "title": "Device Type",
          "type": "string",
          "description": "This is the type of mower device associated with your Husqvarna account.",
          "required": true,
          "default": "automower",
          "enum": [
            "automower",
            "gardena"
          ],
          "x-schema-form": {
            "type": "select",
            "titleMap": [
              {
                "value": "automower",
                "name": "Automower"
              },
              {
                "value": "gardena",
                "name": "Gardena Smart"
              }
            ]
          }
        },
        "sensor_mode": {
          "title": "Sensors",
          "type": "string",
          "description": "This determines which sensors (if any) will be made available within HomeKit for the devices.",
          "required": true,
          "default": "all",
          "enum": [
            "all",
            "motion_only",
            "contact_only",
            "none"
          ],
          "x-schema-form": {
            "type": "select",
            "titleMap": [
              {
                "value": "all",
                "name": "All sensors"
              },
              {
                "value": "motion_only",
                "name": "Motion sensors only"
              },
              {
                "value": "contact_only",
                "name": "Contact sensors only"
              },
              {
                "value": "none",
                "name": "None (Disabled)"
              }
            ]
          }
        },
        "logger_type": {
          "title": "Logging",
          "type": "string",
          "description": "This determines how your plugin logs statements. The default logger doesn't do debugging.",
          "required": true,
          "default": "default",
          "enum": [
            "default",
            "imitation",
            "force_debug"
          ],
          "x-schema-form": {
            "type": "select",
            "titleMap": [
              {
                "value": "default",
                "name": "Default - Homebridge stock logger"
              },
              {
                "value": "imitation",
                "name": "Imitation - Looks like the default logger but includes debugging support"
              },
              {
                "value": "force_debug",
                "name": "Force debug statements"
              }
            ]
          }
        },
        "username": {
          "title": "Email Address",
          "type": "string",
          "required": false,
          "x-schema-form": {
            "type": "email"
          },
          "condition": {
            "functionBody": "return model.authentication_mode === 'password' "
          }
        },
        "password": {
          "title": "Password",
          "type": "string",
          "required": false,
          "x-schema-form": {
            "type": "password"
          },
          "condition": {
            "functionBody": "return model.authentication_mode === 'password' "
          }
        },
        "lang": {
          "title": "Language",
          "type": "string",
          "required": true,
          "default": "en",
          "enum": [
            "en",
            "de"
          ],
          "x-schema-form": {
            "type": "select",
            "titleMap": [
              {
                "value": "en",
                "name": "English (en)"
              },
              {
                "value": "de",
                "name": "Deutsch (de)"
              }
            ]
          }
        },
        "appKey": {
          "title": "Application Key",
          "description": "This is the application key of the application registered on the Husqvarna Developer portal.",
          "type": "string",
          "default": "78e47163-dd2a-48bf-9af9-3cec8cadae00",
          "minLength": 1,
          "required": true
        },
        "authentication_mode": {
          "title": "Authentication Mode",
          "type": "string",
          "required": true,
          "default": "password",
          "enum": [
            "password",
            "client_credentials"
          ],
          "x-schema-form": {
            "type": "select",
            "titleMap": [
              {
                "value": "password",
                "name": "Password (No longer supported)"
              },
              {
                "value": "client_credentials",
                "name": "Client Credentials"
              }
            ]
          }          
        },
        "client_credentials_requires_account": {
          "type": "label",
          "title": "In order to use the Client Credentials authentication mode, you will need to register an account at the <a href=\"https://developer.husqvarnagroup.cloud/\">Husqvarna developer portal</a>. Please see the documentation <a href=\"https://jeff-winn.github.io/homebridge-automower-platform/getting-started/step-1b-configuring-client-credentials-authentication\">HERE</a> for more details.",
          "condition": {
            "functionBody": "return model.authentication_mode === 'client_credentials' "
          }
        },
        "authentication_mode_no_longer_supported": {
          "type": "label",
          "title": "<b>ATTENTION!</b> Your current authentication mode is no longer supported by the Husqvarna platform, please choose a different value from the options available.",
          "labelHtmlClass": "text-warning",
          "condition": {
            "functionBody": "return model.authentication_mode === 'password' "
          }
        },        
        "application_secret": {
          "title": "Application Secret",
          "description": "This is the application secret of the application registered on the Husqvarna Developer portal.",
          "type": "string",
          "minLength": 1,
          "required": false,
          "x-schema-form": {
            "type": "password"
          },
          "condition": {
            "functionBody": "return model.authentication_mode === 'client_credentials' "
          }
        }
      }
    },
    "layout": [
      {
        "type": "flex",
        "flex-flow": "column-count: 2",
        "items": [
          "name",
          "lang"
        ]
      },
      "device_type",      
      {
        "type": "fieldset",
        "title": "Behaviors",
        "description": "Allows you to change how the plugin behaves. These settings are all optional.",
        "expandable": true,
        "items": [
          "sensor_mode",
          "logger_type"
        ]
      },
      {
        "type": "fieldset",
        "title": "Account Settings",
        "description": "Changing any settings here could cause the plugin to fail while logging into the Husqvarna platform, so please proceed with caution.",
        "expandable": true,
        "items": [
          "authentication_mode_no_longer_supported",
          "authentication_mode",          
          "client_credentials_requires_account",
          "appKey",
          "username",
          "password",
          "application_secret"
        ]
      }
    ]
  }
