{
  "pluginAlias": "OpenWebIfTv",
  "pluginType": "platform",
  "singular": true,
  "fixArrays": true,
  "strictValidation": true,
  "headerDisplay": "This plugin works with Sat Receivers basis on the OpenWebIf interface. 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-openwebif-tv).",
  "schema": {
    "type": "object",
    "properties": {
      "name": {
        "title": "Platform",
        "type": "string",
        "default": "OpenWebIf TV"
      },
      "devices": {
        "type": "array",
        "items": {
          "title": "Device",
          "type": "object",
          "properties": {
            "name": {
              "title": "Name",
              "type": "string",
              "placeholder": "Sat Receiver"
            },
            "host": {
              "title": "IP/Hostname",
              "type": "string",
              "placeholder": "192.168.1.10 or receiver.local",
              "pattern": "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}|([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)(\\.([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?))*)$"
            },
            "port": {
              "title": "Port",
              "type": "integer",
              "placeholder": 80
            },
            "auth": {
              "title": "Authorization",
              "type": "object",
              "properties": {
                "enable": {
                  "title": "Enable",
                  "type": "boolean",
                  "default": false
                },
                "user": {
                  "title": "User",
                  "type": "string",
                  "placeholder": "User",
                  "condition": {
                    "functionBody": "return model.devices[arrayIndices].auth.enable === true;"
                  }
                },
                "passwd": {
                  "title": "Password",
                  "type": "string",
                  "placeholder": "Password",
                  "format": "password",
                  "condition": {
                    "functionBody": "return model.devices[arrayIndices].auth.enable === true;"
                  }
                }
              },
              "allOf": [
                {
                  "if": {
                    "required": [
                      "enable"
                    ],
                    "properties": {
                      "enable": {
                        "const": true
                      }
                    }
                  },
                  "then": {
                    "required": [
                      "user",
                      "passwd"
                    ]
                  }
                }
              ]
            },
            "displayType": {
              "title": "Accessory type",
              "type": "integer",
              "minimum": 0,
              "maximum": 4,
              "default": 2,
              "description": "Accessory type for Home app",
              "anyOf": [
                {
                  "title": "Disabled",
                  "enum": [
                    0
                  ]
                },
                {
                  "title": "Television",
                  "enum": [
                    1
                  ]
                },
                {
                  "title": "TV Set Top Box",
                  "enum": [
                    2
                  ]
                },
                {
                  "title": "TV Streaming Stick",
                  "enum": [
                    3
                  ]
                },
                {
                  "title": "Audio Receiver",
                  "enum": [
                    4
                  ]
                }
              ]
            },
            "inputs": {
              "title": "Inputs",
              "type": "object",
              "properties": {
                "getFromDevice": {
                  "title": "Load From Device",
                  "type": "boolean",
                  "default": false,
                  "description": "This function get all available inputs direct from device, manually configured inputs will be skipped."
                },
                "displayOrder": {
                  "title": "Display Order",
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 4,
                  "description": "Here select display order of the inputs list.",
                  "anyOf": [
                    {
                      "title": "Disabled",
                      "enum": [
                        0
                      ]
                    },
                    {
                      "title": "Ascending by Name",
                      "enum": [
                        1
                      ]
                    },
                    {
                      "title": "Descending by Name",
                      "enum": [
                        2
                      ]
                    },
                    {
                      "title": "Ascending by Reference",
                      "enum": [
                        3
                      ]
                    },
                    {
                      "title": "Descending by Reference",
                      "enum": [
                        4
                      ]
                    }
                  ]
                },
                "bouquets": {
                  "title": "Bouquets",
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "title": "Name",
                        "type": "string",
                        "placeholder": "Bouquet name",
                        "description": "Here set bouquet name which should be loaded from device, only first 85 channels will be used."
                      },
                      "displayType": {
                        "title": "Display Type",
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 2,
                        "description": "Here select extra tile for all channels of this bouquet to be exposed in HomeKit app.",
                        "anyOf": [
                          {
                            "title": "Disabled",
                            "enum": [
                              0
                            ]
                          },
                          {
                            "title": "Outlet",
                            "enum": [
                              1
                            ]
                          },
                          {
                            "title": "Switch",
                            "enum": [
                              2
                            ]
                          }
                        ]
                      },
                      "namePrefix": {
                        "title": "Prefix",
                        "type": "boolean",
                        "description": "Here enable the accessory name as a prefix for extra tile name.",
                        "condition": {
                          "functionBody": "return model.devices[arrayIndices[0]].inputs.bouquets[arrayIndices[1]].displayType > 0;"
                        }
                      }
                    }
                  }
                },
                "channels": {
                  "title": "Channels",
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "title": "Name",
                        "type": "string",
                        "placeholder": "Channel name",
                        "description": "Here set Your own name."
                      },
                      "reference": {
                        "title": "Reference",
                        "type": "string",
                        "placeholder": "Channel reference",
                        "description": "Here set the reference."
                      },
                      "displayType": {
                        "title": "Extra Tile",
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 2,
                        "description": "Here select extra tile to be exposed in HomeKit app.",
                        "anyOf": [
                          {
                            "title": "Disabled",
                            "enum": [
                              0
                            ]
                          },
                          {
                            "title": "Outlet",
                            "enum": [
                              1
                            ]
                          },
                          {
                            "title": "Switch",
                            "enum": [
                              2
                            ]
                          }
                        ]
                      },
                      "namePrefix": {
                        "title": "Prefix",
                        "type": "boolean",
                        "description": "Here enable the accessory name as a prefix for extra tile name.",
                        "condition": {
                          "functionBody": "return model.devices[arrayIndices[0]].inputs.channels[arrayIndices[1]].displayType > 0;"
                        }
                      }
                    }
                  }
                }
              }
            },
            "buttons": {
              "title": "Button",
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "displayType": {
                    "title": "Display Type",
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 2,
                    "anyOf": [
                      {
                        "title": "Disabled",
                        "enum": [
                          0
                        ]
                      },
                      {
                        "title": "Outlet",
                        "enum": [
                          1
                        ]
                      },
                      {
                        "title": "Switch",
                        "enum": [
                          2
                        ]
                      }
                    ],
                    "description": "Here select display type in HomeKit app"
                  },
                  "name": {
                    "title": "Name",
                    "type": "string",
                    "placeholder": "Button name",
                    "description": "Here set Your own name."
                  },
                  "mode": {
                    "title": "Mode",
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 2,
                    "description": "Here select the function mode.",
                    "anyOf": [
                      {
                        "title": "Live TV Channel",
                        "enum": [
                          0
                        ]
                      },
                      {
                        "title": "Remote Control",
                        "enum": [
                          1
                        ]
                      },
                      {
                        "title": "Power Control",
                        "enum": [
                          2
                        ]
                      }
                    ],
                    "condition": {
                      "functionBody": "return model.devices[arrayIndices[0]].buttons[arrayIndices[1]].displayType > 0;"
                    }
                  },
                  "reference": {
                    "title": "Reference",
                    "type": "string",
                    "placeholder": "Button reference",
                    "description": "Here set the reference.",
                    "condition": {
                      "functionBody": "return model.devices[arrayIndices[0]].buttons[arrayIndices[1]].displayType > 0 && model.devices[arrayIndices[0]].buttons[arrayIndices[1]].mode === 0;"
                    }
                  },
                  "command": {
                    "title": "RC Command",
                    "type": "string",
                    "description": "Here select the remote control command.",
                    "anyOf": [
                      {
                        "title": "0",
                        "enum": [
                          "11"
                        ]
                      },
                      {
                        "title": "1",
                        "enum": [
                          "2"
                        ]
                      },
                      {
                        "title": "2",
                        "enum": [
                          "3"
                        ]
                      },
                      {
                        "title": "3",
                        "enum": [
                          "4"
                        ]
                      },
                      {
                        "title": "4",
                        "enum": [
                          "5"
                        ]
                      },
                      {
                        "title": "5",
                        "enum": [
                          "6"
                        ]
                      },
                      {
                        "title": "6",
                        "enum": [
                          "7"
                        ]
                      },
                      {
                        "title": "7",
                        "enum": [
                          "8"
                        ]
                      },
                      {
                        "title": "8",
                        "enum": [
                          "9"
                        ]
                      },
                      {
                        "title": "9",
                        "enum": [
                          "10"
                        ]
                      },
                      {
                        "title": "<",
                        "enum": [
                          "412"
                        ]
                      },
                      {
                        "title": ">",
                        "enum": [
                          "407"
                        ]
                      },
                      {
                        "title": "Power",
                        "enum": [
                          "116"
                        ]
                      },
                      {
                        "title": "Volume Up",
                        "enum": [
                          "115"
                        ]
                      },
                      {
                        "title": "Volume Down",
                        "enum": [
                          "114"
                        ]
                      },
                      {
                        "title": "Mute",
                        "enum": [
                          "113"
                        ]
                      },
                      {
                        "title": "Bouquet Up",
                        "enum": [
                          "402"
                        ]
                      },
                      {
                        "title": "Bouquet Down",
                        "enum": [
                          "403"
                        ]
                      },
                      {
                        "title": "Epg",
                        "enum": [
                          "358"
                        ]
                      },
                      {
                        "title": "Menu",
                        "enum": [
                          "139"
                        ]
                      },
                      {
                        "title": "Menu Up",
                        "enum": [
                          "103"
                        ]
                      },
                      {
                        "title": "Menu Down",
                        "enum": [
                          "108"
                        ]
                      },
                      {
                        "title": "Menu Left",
                        "enum": [
                          "105"
                        ]
                      },
                      {
                        "title": "Menu Right",
                        "enum": [
                          "106"
                        ]
                      },
                      {
                        "title": "Menu OK",
                        "enum": [
                          "352"
                        ]
                      },
                      {
                        "title": "Back",
                        "enum": [
                          "174"
                        ]
                      },
                      {
                        "title": "Exit",
                        "enum": [
                          "174"
                        ]
                      },
                      {
                        "title": "Play",
                        "enum": [
                          "207"
                        ]
                      },
                      {
                        "title": "Pause",
                        "enum": [
                          "119"
                        ]
                      },
                      {
                        "title": "Stop",
                        "enum": [
                          "128"
                        ]
                      },
                      {
                        "title": "Record",
                        "enum": [
                          "167"
                        ]
                      },
                      {
                        "title": "Forward",
                        "enum": [
                          "208"
                        ]
                      },
                      {
                        "title": "Rewind",
                        "enum": [
                          "168"
                        ]
                      },
                      {
                        "title": "Next",
                        "enum": [
                          "407"
                        ]
                      },
                      {
                        "title": "Previous",
                        "enum": [
                          "412"
                        ]
                      },
                      {
                        "title": "Red",
                        "enum": [
                          "398"
                        ]
                      },
                      {
                        "title": "Green",
                        "enum": [
                          "399"
                        ]
                      },
                      {
                        "title": "Yellow",
                        "enum": [
                          "400"
                        ]
                      },
                      {
                        "title": "Blue",
                        "enum": [
                          "401"
                        ]
                      },
                      {
                        "title": "TV",
                        "enum": [
                          "377"
                        ]
                      },
                      {
                        "title": "Radio",
                        "enum": [
                          "385"
                        ]
                      },
                      {
                        "title": "Video",
                        "enum": [
                          "393"
                        ]
                      },
                      {
                        "title": "Audio",
                        "enum": [
                          "392"
                        ]
                      },
                      {
                        "title": "Help",
                        "enum": [
                          "138"
                        ]
                      },
                      {
                        "title": "Subtitle",
                        "enum": [
                          "370"
                        ]
                      },
                      {
                        "title": "Text",
                        "enum": [
                          "388"
                        ]
                      }
                    ],
                    "condition": {
                      "functionBody": "return model.devices[arrayIndices[0]].buttons[arrayIndices[1]].displayType > 0 && model.devices[arrayIndices[0]].buttons[arrayIndices[1]].mode === 1;"
                    }
                  },
                  "powerCommand": {
                    "title": "Power Command",
                    "type": "string",
                    "description": "Here select the power control command.",
                    "anyOf": [
                      {
                        "title": "Toogle Standby",
                        "enum": [
                          "0"
                        ]
                      },
                      {
                        "title": "Deep Standby",
                        "enum": [
                          "1"
                        ]
                      },
                      {
                        "title": "Reboot",
                        "enum": [
                          "2"
                        ]
                      },
                      {
                        "title": "Restart Enigma",
                        "enum": [
                          "3"
                        ]
                      },
                      {
                        "title": "Wake Up",
                        "enum": [
                          "4"
                        ]
                      },
                      {
                        "title": "Standby",
                        "enum": [
                          "5"
                        ]
                      }
                    ],
                    "condition": {
                      "functionBody": "return model.devices[arrayIndices[0]].buttons[arrayIndices[1]].displayType > 0 && model.devices[arrayIndices[0]].buttons[arrayIndices[1]].mode === 2;"
                    }
                  },
                  "namePrefix": {
                    "title": "Prefix",
                    "type": "boolean",
                    "description": "Here enable the accessory name as a prefix for button name.",
                    "condition": {
                      "functionBody": "return model.devices[arrayIndices[0]].buttons[arrayIndices[1]].displayType > 0;"
                    }
                  }
                },
                "allOf": [
                  {
                    "if": {
                      "required": [
                        "displayType"
                      ],
                      "properties": {
                        "displayType": {
                          "enum": [
                            1,
                            2
                          ]
                        }
                      }
                    },
                    "then": {
                      "required": [
                        "mode"
                      ]
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "displayType",
                        "mode"
                      ],
                      "properties": {
                        "displayType": {
                          "enum": [
                            1,
                            2
                          ]
                        },
                        "mode": {
                          "enum": [
                            0
                          ]
                        }
                      }
                    },
                    "then": {
                      "required": [
                        "reference"
                      ]
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "displayType",
                        "mode"
                      ],
                      "properties": {
                        "displayType": {
                          "enum": [
                            1,
                            2
                          ]
                        },
                        "mode": {
                          "enum": [
                            1
                          ]
                        }
                      }
                    },
                    "then": {
                      "required": [
                        "command"
                      ]
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "displayType",
                        "mode"
                      ],
                      "properties": {
                        "displayType": {
                          "enum": [
                            1,
                            2
                          ]
                        },
                        "mode": {
                          "enum": [
                            2
                          ]
                        }
                      }
                    },
                    "then": {
                      "required": [
                        "powerCommand"
                      ]
                    }
                  }
                ]
              }
            },
            "sensors": {
              "type": "array",
              "items": {
                "title": "Sensors",
                "type": "object",
                "properties": {
                  "displayType": {
                    "title": "Display Type",
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 3,
                    "anyOf": [
                      {
                        "title": "Disabled",
                        "enum": [
                          0
                        ]
                      },
                      {
                        "title": "Motion Sensor",
                        "enum": [
                          1
                        ]
                      },
                      {
                        "title": "Occupancy Sensor",
                        "enum": [
                          2
                        ]
                      },
                      {
                        "title": "Contact Sensor",
                        "enum": [
                          3
                        ]
                      }
                    ],
                    "description": "Here select sensor type to be exposed in HomeKit app."
                  },
                  "name": {
                    "title": "Name",
                    "type": "string",
                    "placeholder": "Name",
                    "description": "Here set Your own name."
                  },
                  "mode": {
                    "title": "Mode",
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 6,
                    "anyOf": [
                      {
                        "title": "Channel",
                        "enum": [
                          0
                        ]
                      },
                      {
                        "title": "Power",
                        "enum": [
                          1
                        ]
                      },
                      {
                        "title": "Volume",
                        "enum": [
                          2
                        ]
                      },
                      {
                        "title": "Mute",
                        "enum": [
                          3
                        ]
                      },
                      {
                        "title": "Recording",
                        "enum": [
                          4
                        ]
                      },
                      {
                        "title": "Streaming",
                        "enum": [
                          5
                        ]
                      },
                      {
                        "title": "Play State",
                        "enum": [
                          6
                        ]
                      }
                    ],
                    "description": "Here select the sensor mode.",
                    "condition": {
                      "functionBody": "return model.devices[arrayIndices[0]].sensors[arrayIndices[1]].displayType > 0;"
                    }
                  },
                  "namePrefix": {
                    "title": "Prefix",
                    "type": "boolean",
                    "description": "Here enable the accessory name as a prefix for sensor name.",
                    "condition": {
                      "functionBody": "return model.devices[arrayIndices[0]].sensors[arrayIndices[1]].displayType > 0;"
                    }
                  },
                  "pulse": {
                    "title": "Pulse",
                    "type": "boolean",
                    "description": "Here enable sensor pulse, sensor send pulse and fired on every value change of selected mode.",
                    "condition": {
                      "functionBody": "return model.devices[arrayIndices[0]].sensors[arrayIndices[1]].displayType > 0;"
                    }
                  },
                  "reference": {
                    "title": "Reference",
                    "type": "string",
                    "placeholder": "Reference",
                    "description": "Here set the channel reference, sensor fired if switch to this reference.",
                    "condition": {
                      "functionBody": "return model.devices[arrayIndices[0]].sensors[arrayIndices[1]].displayType > 0 && model.devices[arrayIndices[0]].sensors[arrayIndices[1]].pulse === false && model.devices[arrayIndices[0]].sensors[arrayIndices[1]].mode === 0;"
                    }
                  },
                  "level": {
                    "title": "Level",
                    "type": "number",
                    "minimum": 0,
                    "maximum": 100,
                    "multipleOf": 1,
                    "description": "Here set the level between 0-100% at which the sensor fired.",
                    "condition": {
                      "functionBody": "return model.devices[arrayIndices[0]].sensors[arrayIndices[1]].displayType > 0 && model.devices[arrayIndices[0]].sensors[arrayIndices[1]].pulse === false && model.devices[arrayIndices[0]].sensors[arrayIndices[1]].mode === 2;"
                    }
                  }
                },
                "allOf": [
                  {
                    "if": {
                      "required": [
                        "displayType"
                      ],
                      "properties": {
                        "displayType": {
                          "enum": [
                            1,
                            2,
                            3
                          ]
                        }
                      }
                    },
                    "then": {
                      "required": [
                        "mode"
                      ]
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "displayType",
                        "mode",
                        "pulse"
                      ],
                      "properties": {
                        "displayType": {
                          "enum": [
                            1,
                            2,
                            3
                          ]
                        },
                        "pulse": {
                          "const": false
                        },
                        "mode": {
                          "enum": [
                            0
                          ]
                        }
                      }
                    },
                    "then": {
                      "required": [
                        "reference"
                      ]
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "displayType",
                        "mode",
                        "pulse"
                      ],
                      "properties": {
                        "displayType": {
                          "enum": [
                            1,
                            2,
                            3
                          ]
                        },
                        "pulse": {
                          "const": false
                        },
                        "mode": {
                          "enum": [
                            2
                          ]
                        }
                      }
                    },
                    "then": {
                      "required": [
                        "level"
                      ]
                    }
                  }
                ]
              }
            },
            "volume": {
              "title": "Volume",
              "type": "object",
              "properties": {
                "displayType": {
                  "title": "Display Type",
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 5,
                  "description": "Here select what a extra volume/mute control type You want to use.",
                  "anyOf": [
                    {
                      "title": "Disabled",
                      "enum": [
                        0
                      ]
                    },
                    {
                      "title": "Lightbulb",
                      "enum": [
                        1
                      ]
                    },
                    {
                      "title": "Fan",
                      "enum": [
                        2
                      ]
                    },
                    {
                      "title": "TV Speaker (HW buttons)",
                      "enum": [
                        3
                      ]
                    },
                    {
                      "title": "TV Speaker / Lightbulb",
                      "enum": [
                        4
                      ]
                    },
                    {
                      "title": "TV Speaker / Fan",
                      "enum": [
                        5
                      ]
                    }
                  ]
                },
                "name": {
                  "title": "Name",
                  "type": "string",
                  "placeholder": "Volume Control Name",
                  "description": "Here set Your own volume control name or leave empty.",
                  "condition": {
                    "functionBody": "return model.devices[arrayIndices[0]].volume.displayType > 0;"
                  }
                },
                "namePrefix": {
                  "title": "Prefix",
                  "type": "boolean",
                  "description": "Here enable the accessory name as a prefix for volume control name.",
                  "condition": {
                    "functionBody": "return model.devices[arrayIndices[0]].volume.displayType > 0;"
                  }
                }
              }
            },
            "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"
                }
              }
            },
            "infoButtonCommand": {
              "title": "Info Button",
              "type": "string",
              "default": "139",
              "description": "Here select the function of info button in RC.",
              "anyOf": [
                {
                  "title": "Epg",
                  "enum": [
                    "358"
                  ]
                },
                {
                  "title": "Menu",
                  "enum": [
                    "139"
                  ]
                },
                {
                  "title": "Red",
                  "enum": [
                    "398"
                  ]
                },
                {
                  "title": "Green",
                  "enum": [
                    "399"
                  ]
                },
                {
                  "title": "Yellow",
                  "enum": [
                    "400"
                  ]
                },
                {
                  "title": "Blue",
                  "enum": [
                    "401"
                  ]
                },
                {
                  "title": "TV",
                  "enum": [
                    "377"
                  ]
                },
                {
                  "title": "Radio",
                  "enum": [
                    "385"
                  ]
                },
                {
                  "title": "Video",
                  "enum": [
                    "393"
                  ]
                },
                {
                  "title": "Audio",
                  "enum": [
                    "392"
                  ]
                },
                {
                  "title": "Help",
                  "enum": [
                    "138"
                  ]
                },
                {
                  "title": "Subtitle",
                  "enum": [
                    "370"
                  ]
                },
                {
                  "title": "Text",
                  "enum": [
                    "388"
                  ]
                },
                {
                  "title": "Record",
                  "enum": [
                    "167"
                  ]
                }
              ]
            },
            "refreshInterval": {
              "title": "Refresh interval (sec)",
              "type": "number",
              "minimum": 0.5,
              "maximum": 30,
              "multipleOf": 0.5,
              "default": 5,
              "description": "Here set the background data refresh interval."
            },
            "mqtt": {
              "title": "MQTT",
              "type": "object",
              "properties": {
                "enable": {
                  "title": "Enable",
                  "type": "boolean",
                  "default": false,
                  "description": "This enable MQTT client."
                },
                "host": {
                  "title": "IP/Hostname",
                  "type": "string",
                  "placeholder": "192.168.1.20 or mqtt.local",
                  "pattern": "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}|([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)(\\.([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?))*)$",
                  "description": "Here set the IP/Hostname of MQTT Broker.",
                  "condition": {
                    "functionBody": "return model.devices[arrayIndices].mqtt.enable === true;"
                  }
                },
                "port": {
                  "title": "Port",
                  "type": "integer",
                  "placeholder": 1883,
                  "description": "Here set the port of MQTT Broker.",
                  "condition": {
                    "functionBody": "return model.devices[arrayIndices].mqtt.enable === true;"
                  }
                },
                "clientId": {
                  "title": "Client ID",
                  "type": "string",
                  "placeholder": "client id",
                  "description": "Here optional set the Client ID of MQTT Broker.",
                  "condition": {
                    "functionBody": "return model.devices[arrayIndices].mqtt.enable === true"
                  }
                },
                "prefix": {
                  "title": "Prefix",
                  "type": "string",
                  "placeholder": "home",
                  "description": "Here set the prefix.",
                  "condition": {
                    "functionBody": "return model.devices[arrayIndices].mqtt.enable === true;"
                  }
                },
                "protocolVersion": {
                  "title": "Protocol Version",
                  "type": "integer",
                  "default": 5,
                  "oneOf": [
                    {
                      "title": "5.0",
                      "enum": [5]
                    },
                    {
                      "title": "3.1.1",
                      "enum": [4]
                    }
                  ],
                  "description": "MQTT protocol version used to connect to the broker. Some brokers (e.g. the ioBroker MQTT adapter) only support 3.1.1 and will silently reject 5.0 connections.",
                  "condition": {
                    "functionBody": "return model.devices[arrayIndices].mqtt.enable === true;"
                  }
                },
                "haDiscovery": {
                  "title": "HA Discovery",
                  "type": "boolean",
                  "default": false,
                  "description": "Publish a Home Assistant MQTT discovery message so the device appears as one media player (class receiver). Requires the MQTT Universal Media Player integration in Home Assistant: https://github.com/grzegorz914/homeassistant-mqtt-media-player",
                  "condition": {
                    "functionBody": "return model.devices[arrayIndices].mqtt.enable === true;"
                  }
                },
                "auth": {
                  "title": "Authorization",
                  "type": "object",
                  "properties": {
                    "enable": {
                      "title": "Enable",
                      "type": "boolean",
                      "description": "This enable authorization for MQTT Broker."
                    },
                    "user": {
                      "title": "User",
                      "type": "string",
                      "placeholder": "user",
                      "description": "Here set the user of MQTT Broker.",
                      "condition": {
                        "functionBody": "return model.devices[arrayIndices].mqtt.auth.enable === true;"
                      }
                    },
                    "passwd": {
                      "title": "Password",
                      "type": "string",
                      "placeholder": "password",
                      "description": "Here set the password of MQTT Broker.",
                      "format": "password",
                      "condition": {
                        "functionBody": "return model.devices[arrayIndices].mqtt.auth.enable === true;"
                      }
                    }
                  },
                  "condition": {
                    "functionBody": "return model.devices[arrayIndices].mqtt.enable === true;"
                  },
                  "allOf": [
                    {
                      "if": {
                        "required": [
                          "enable"
                        ],
                        "properties": {
                          "enable": {
                            "const": true
                          }
                        }
                      },
                      "then": {
                        "required": [
                          "user",
                          "passwd"
                        ]
                      }
                    }
                  ]
                }
              },
              "allOf": [
                {
                  "if": {
                    "required": [
                      "enable"
                    ],
                    "properties": {
                      "enable": {
                        "const": true
                      }
                    }
                  },
                  "then": {
                    "required": [
                      "host"
                    ]
                  }
                }
              ]
            }
          },
          "required": [
            "name",
            "host",
            "port",
            "displayType"
          ],
          "allOf": [
            {
              "if": {
                "properties": {
                  "displayType": {
                    "enum": [
                      1,
                      2,
                      3,
                      4
                    ]
                  }
                }
              },
              "then": {
                "required": [
                  "name",
                  "host"
                ]
              }
            }
          ]
        }
      }
    }
  },
  "layout": [
    {
      "key": "devices",
      "type": "tabarray",
      "title": "{{ value.name || 'device' }}",
      "items": [
        "devices[].name",
        "devices[].host",
        "devices[].port",
        "devices[].displayType",
        {
          "key": "devices[].imputs",
          "type": "section",
          "title": "Inputs",
          "expandable": true,
          "expanded": false,
          "items": [
            "devices[].inputs.getFromDevice",
            "devices[].inputs.displayOrder",
            {
              "type": "section",
              "title": "Bouquets",
              "items": [
                {
                  "key": "devices[].inputs.bouquets",
                  "type": "tabarray",
                  "title": "{{ value.name || 'Bouquet' }}",
                  "items": [
                    "devices[].inputs.bouquets[].name",
                    "devices[].inputs.bouquets[].displayType",
                    "devices[].inputs.bouquets[].namePrefix"
                  ]
                }
              ],
              "condition": {
                "functionBody": "return model.devices[arrayIndices[0]].inputs.getFromDevice === true;"
              }
            },
            {
              "type": "section",
              "title": "Channels",
              "items": [
                {
                  "key": "devices[].inputs.channels",
                  "type": "tabarray",
                  "title": "{{ value.name || 'Channel' }}",
                  "items": [
                    "devices[].inputs.channels[].name",
                    "devices[].inputs.channels[].reference",
                    "devices[].inputs.channels[].displayType",
                    "devices[].inputs.channels[].namePrefix"
                  ]
                }
              ],
              "condition": {
                "functionBody": "return model.devices[arrayIndices[0]].inputs.getFromDevice === false;"
              }
            }
          ]
        },
        {
          "key": "devices[]",
          "type": "section",
          "title": "Buttons",
          "expandable": true,
          "expanded": false,
          "items": [
            {
              "key": "devices[].buttons",
              "type": "tabarray",
              "title": "{{ value.name || 'Button' }}",
              "items": [
                "devices[].buttons[].displayType",
                "devices[].buttons[].name",
                "devices[].buttons[].mode",
                "devices[].buttons[].reference",
                "devices[].buttons[].command",
                "devices[].buttons[].powerCommand",
                "devices[].buttons[].namePrefix"
              ]
            }
          ]
        },
        {
          "key": "devices[]",
          "type": "section",
          "title": "Advanced Settings",
          "expandable": true,
          "expanded": false,
          "items": [
            {
              "key": "devices[]",
              "type": "tabarray",
              "title": "{{ value.title }}",
              "items": [
                {
                  "key": "devices[].volume",
                  "title": "Volume",
                  "items": [
                    "devices[].volume.displayType",
                    "devices[].volume.name",
                    "devices[].volume.namePrefix"
                  ]
                },
                {
                  "key": "devices[]",
                  "title": "Sensors",
                  "items": [
                    {
                      "key": "devices[].sensors",
                      "type": "tabarray",
                      "title": "{{ value.name || 'Sensor' }}",
                      "items": [
                        "devices[].sensors[].displayType",
                        "devices[].sensors[].mode",
                        "devices[].sensors[].name",
                        "devices[].sensors[].namePrefix",
                        "devices[].sensors[].pulse",
                        "devices[].sensors[].reference",
                        "devices[].sensors[].level"
                      ]
                    }
                  ]
                },
                {
                  "key": "devices[].auth",
                  "title": "Authorization",
                  "items": [
                    "devices[].auth.enable",
                    "devices[].auth.user",
                    {
                      "key": "devices[].auth.passwd",
                      "type": "password"
                    }
                  ]
                },
                {
                  "key": "devices[]",
                  "title": "Device",
                  "items": [
                    "devices[].infoButtonCommand",
                    "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"
                  ]
                },
                {
                  "key": "devices[]",
                  "title": "External Integrations",
                  "items": [
                    {
                      "key": "devices[]",
                      "type": "tabarray",
                      "title": "{{ value.title }}",
                      "items": [
                        {
                          "key": "devices[].mqtt",
                          "title": "MQTT",
                          "items": [
                            "devices[].mqtt.enable",
                            "devices[].mqtt.host",
                            "devices[].mqtt.port",
                            "devices[].mqtt.clientId",
                            "devices[].mqtt.prefix",
                            "devices[].mqtt.protocolVersion",
                            "devices[].mqtt.haDiscovery",
                            {
                              "key": "devices[].mqtt.auth",
                              "title": "Authorization",
                              "items": [
                                "devices[].mqtt.auth.enable",
                                "devices[].mqtt.auth.user",
                                {
                                  "key": "devices[].mqtt.auth.passwd",
                                  "type": "password"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}