{
  "pluginAlias": "LgWebOsTv",
  "pluginType": "platform",
  "singular": true,
  "fixArrays": true,
  "strictValidation": true,
  "headerDisplay": "This plugin works with webOS based TV and 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-lgwebos-tv).",
  "schema": {
    "type": "object",
    "properties": {
      "name": {
        "title": "Platform",
        "type": "string",
        "default": "LG webOS TV"
      },
      "devices": {
        "type": "array",
        "items": {
          "type": "object",
          "title": "Device",
          "properties": {
            "name": {
              "title": "Name",
              "type": "string",
              "placeholder": "LG TV"
            },
            "host": {
              "title": "IP/Hostname",
              "type": "string",
              "placeholder": "192.168.1.8 or tv.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])?))*)$"
            },
            "mac": {
              "title": "Address Mac",
              "type": "string",
              "placeholder": "ab:cd:ef:fe:dc:ba",
              "pattern": "^([A-Fa-f0-9]{2}:){5}[A-Fa-f0-9]{2}$"
            },
            "displayType": {
              "title": "Accessory type",
              "type": "integer",
              "minimum": 0,
              "maximum": 4,
              "default": 1,
              "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 Inputs From Device",
                  "type": "boolean",
                  "default": false,
                  "description": "This function get all available inputs direct from device, manually configured inputs will be skipped."
                },
                "filterSystemApps": {
                  "title": "Hide System Apps",
                  "type": "boolean",
                  "default": false,
                  "description": "If enabled, all System Apps will not be displayed on the list of inputs."
                },
                "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
                      ]
                    }
                  ]
                },
                "data": {
                  "title": "Inputs",
                  "type": "array",
                  "items": {
                    "title": "Input",
                    "type": "object",
                    "properties": {
                      "name": {
                        "title": "Name",
                        "type": "string",
                        "placeholder": "Name",
                        "description": "Here set Your own name."
                      },
                      "reference": {
                        "title": "Reference",
                        "type": "string",
                        "placeholder": "Input/App, Channel reference",
                        "description": "Here set the Input/App, Channel reference."
                      },
                      "mode": {
                        "title": "Mode",
                        "type": "integer",
                        "description": "Here select the function mode.",
                        "anyOf": [
                          {
                            "title": "Input/App",
                            "enum": [
                              0
                            ]
                          },
                          {
                            "title": "Live TV Channel",
                            "enum": [
                              1
                            ]
                          }
                        ]
                      }
                    }
                  },
                  "condition": {
                    "functionBody": "return model.devices[arrayIndices].inputs.getFromDevice == false;"
                  }
                }
              }
            },
            "buttons": {
              "title": "Button",
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "displayType": {
                    "title": "Display Type",
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 2,
                    "description": "Here select display type in HomeKit app.",
                    "anyOf": [
                      {
                        "title": "Disabled",
                        "enum": [
                          0
                        ]
                      },
                      {
                        "title": "Outlet",
                        "enum": [
                          1
                        ]
                      },
                      {
                        "title": "Switch",
                        "enum": [
                          2
                        ]
                      }
                    ]
                  },
                  "name": {
                    "title": "Name",
                    "type": "string",
                    "placeholder": "Name",
                    "description": "Here set Your own name."
                  },
                  "mode": {
                    "title": "Mode",
                    "type": "integer",
                    "description": "Here select the function mode.",
                    "anyOf": [
                      {
                        "title": "Input/App",
                        "enum": [
                          0
                        ]
                      },
                      {
                        "title": "Live TV Channel",
                        "enum": [
                          1
                        ]
                      },
                      {
                        "title": "Remote Control",
                        "enum": [
                          2
                        ]
                      }
                    ],
                    "condition": {
                      "functionBody": "return model.devices[arrayIndices[0]].buttons[arrayIndices[1]].displayType > 0;"
                    }
                  },
                  "reference": {
                    "title": "Reference",
                    "type": "string",
                    "placeholder": "com.webos.app.sheduler",
                    "description": "Here set the Input/App/Channel reference.",
                    "condition": {
                      "functionBody": "return model.devices[arrayIndices[0]].buttons[arrayIndices[1]].displayType > 0 && model.devices[arrayIndices[0]].buttons[arrayIndices[1]].mode < 2;"
                    }
                  },
                  "command": {
                    "title": "RC Command",
                    "type": "string",
                    "description": "Here select the remote control command.",
                    "anyOf": [
                      {
                        "title": "0",
                        "enum": [
                          "0"
                        ]
                      },
                      {
                        "title": "1",
                        "enum": [
                          "1"
                        ]
                      },
                      {
                        "title": "2",
                        "enum": [
                          "2"
                        ]
                      },
                      {
                        "title": "3",
                        "enum": [
                          "3"
                        ]
                      },
                      {
                        "title": "4",
                        "enum": [
                          "4"
                        ]
                      },
                      {
                        "title": "5",
                        "enum": [
                          "5"
                        ]
                      },
                      {
                        "title": "6",
                        "enum": [
                          "6"
                        ]
                      },
                      {
                        "title": "7",
                        "enum": [
                          "7"
                        ]
                      },
                      {
                        "title": "8",
                        "enum": [
                          "8"
                        ]
                      },
                      {
                        "title": "9",
                        "enum": [
                          "9"
                        ]
                      },
                      {
                        "title": "Power",
                        "enum": [
                          "POWER"
                        ]
                      },
                      {
                        "title": "Volume Up",
                        "enum": [
                          "VOLUMEUP"
                        ]
                      },
                      {
                        "title": "Volume Down",
                        "enum": [
                          "VOLUMEDOWN"
                        ]
                      },
                      {
                        "title": "Mute",
                        "enum": [
                          "MUTE"
                        ]
                      },
                      {
                        "title": "Channel Up",
                        "enum": [
                          "CHANNELUP"
                        ]
                      },
                      {
                        "title": "Channel Down",
                        "enum": [
                          "CHANNELDOWN"
                        ]
                      },
                      {
                        "title": "Home",
                        "enum": [
                          "HOME"
                        ]
                      },
                      {
                        "title": "Menu",
                        "enum": [
                          "MENU"
                        ]
                      },
                      {
                        "title": "Q Menu",
                        "enum": [
                          "QMENU"
                        ]
                      },
                      {
                        "title": "Menu Up",
                        "enum": [
                          "UP"
                        ]
                      },
                      {
                        "title": "Menu Down",
                        "enum": [
                          "DOWN"
                        ]
                      },
                      {
                        "title": "Menu Left",
                        "enum": [
                          "LEFT"
                        ]
                      },
                      {
                        "title": "Menu Right",
                        "enum": [
                          "RIGHT"
                        ]
                      },
                      {
                        "title": "Menu OK",
                        "enum": [
                          "ENTER"
                        ]
                      },
                      {
                        "title": "Back",
                        "enum": [
                          "BACK"
                        ]
                      },
                      {
                        "title": "Exit",
                        "enum": [
                          "EXIT"
                        ]
                      },
                      {
                        "title": "Eject",
                        "enum": [
                          "EJECT"
                        ]
                      },
                      {
                        "title": "Info",
                        "enum": [
                          "INFO"
                        ]
                      },
                      {
                        "title": "Play",
                        "enum": [
                          "PLAY"
                        ]
                      },
                      {
                        "title": "Pause",
                        "enum": [
                          "PAUSE"
                        ]
                      },
                      {
                        "title": "Record",
                        "enum": [
                          "RECORD"
                        ]
                      },
                      {
                        "title": "Fast Forward",
                        "enum": [
                          "FASTFORWARD"
                        ]
                      },
                      {
                        "title": "Rewind",
                        "enum": [
                          "REWIND"
                        ]
                      },
                      {
                        "title": "Red",
                        "enum": [
                          "RED"
                        ]
                      },
                      {
                        "title": "Green",
                        "enum": [
                          "GREEN"
                        ]
                      },
                      {
                        "title": "Yellow",
                        "enum": [
                          "YELLOW"
                        ]
                      },
                      {
                        "title": "Blue",
                        "enum": [
                          "BLUE"
                        ]
                      },
                      {
                        "title": "Live Zoom",
                        "enum": [
                          "LIVE_ZOOM"
                        ]
                      },
                      {
                        "title": "Magnifier Zoom",
                        "enum": [
                          "MAGNIFIER_ZOOM"
                        ]
                      },
                      {
                        "title": "3D Mode",
                        "enum": [
                          "3D_MODE"
                        ]
                      },
                      {
                        "title": "List",
                        "enum": [
                          "LIST"
                        ]
                      },
                      {
                        "title": "AD",
                        "enum": [
                          "AD"
                        ]
                      },
                      {
                        "title": "Dash",
                        "enum": [
                          "DASH"
                        ]
                      },
                      {
                        "title": "Favorites",
                        "enum": [
                          "FAVORITES"
                        ]
                      },
                      {
                        "title": "Program",
                        "enum": [
                          "PROGRAM"
                        ]
                      },
                      {
                        "title": "My Apps",
                        "enum": [
                          "MYAPPS"
                        ]
                      },
                      {
                        "title": "Aspect Ratio",
                        "enum": [
                          "ASPECT_RATIO"
                        ]
                      },
                      {
                        "title": "Screen Remot",
                        "enum": [
                          "SCREEN_REMOT"
                        ]
                      },
                      {
                        "title": "Recent",
                        "enum": [
                          "RECENT"
                        ]
                      },
                      {
                        "title": "SAP",
                        "enum": [
                          "SAP"
                        ]
                      },
                      {
                        "title": "CC",
                        "enum": [
                          "CC"
                        ]
                      },
                      {
                        "title": "Click",
                        "enum": [
                          "CLICK"
                        ]
                      },
                      {
                        "title": "Teletext",
                        "enum": [
                          "TELETEXT"
                        ]
                      },
                      {
                        "title": "Text Option",
                        "enum": [
                          "TEXTOPTION"
                        ]
                      },
                      {
                        "title": "BML Data",
                        "enum": [
                          "BML_DATA"
                        ]
                      },
                      {
                        "title": "3 Digital Input",
                        "enum": [
                          "3DIGIT_INPUT"
                        ]
                      }
                    ],
                    "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,
                            1
                          ]
                        }
                      }
                    },
                    "then": {
                      "required": [
                        "reference"
                      ]
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "displayType",
                        "mode"
                      ],
                      "properties": {
                        "displayType": {
                          "enum": [
                            1,
                            2
                          ]
                        },
                        "mode": {
                          "enum": [
                            2
                          ]
                        }
                      }
                    },
                    "then": {
                      "required": [
                        "command"
                      ]
                    }
                  }
                ]
              }
            },
            "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": 11,
                    "description": "Here select the sensor mode.",
                    "anyOf": [
                      {
                        "title": "Input",
                        "enum": [
                          0
                        ]
                      },
                      {
                        "title": "Power",
                        "enum": [
                          1
                        ]
                      },
                      {
                        "title": "Volume",
                        "enum": [
                          2
                        ]
                      },
                      {
                        "title": "Mute",
                        "enum": [
                          3
                        ]
                      },
                      {
                        "title": "Sound Mode",
                        "enum": [
                          4
                        ]
                      },
                      {
                        "title": "Sound Output",
                        "enum": [
                          5
                        ]
                      },
                      {
                        "title": "Picture Mode",
                        "enum": [
                          6
                        ]
                      },
                      {
                        "title": "Screen Off",
                        "enum": [
                          7
                        ]
                      },
                      {
                        "title": "Screen Saver",
                        "enum": [
                          8
                        ]
                      },
                      {
                        "title": "Play State",
                        "enum": [
                          9
                        ]
                      },
                      {
                        "title": "Pixel Refresh",
                        "enum": [
                          10
                        ]
                      },
                      {
                        "title": "Channel",
                        "enum": [
                          11
                        ]
                      }
                    ],
                    "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 reference, sensor fired if switch to this referece.",
                    "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 || model.devices[arrayIndices[0]].sensors[arrayIndices[1]].mode === 4 || model.devices[arrayIndices[0]].sensors[arrayIndices[1]].mode === 5 || model.devices[arrayIndices[0]].sensors[arrayIndices[1]].mode === 6 || model.devices[arrayIndices[0]].sensors[arrayIndices[1]].mode === 11);"
                    }
                  },
                  "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,
                            4,
                            5,
                            6,
                            11
                          ]
                        }
                      }
                    },
                    "then": {
                      "required": [
                        "reference"
                      ]
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "displayType",
                        "mode",
                        "pulse"
                      ],
                      "properties": {
                        "displayType": {
                          "enum": [
                            1,
                            2,
                            3
                          ]
                        },
                        "pulse": {
                          "const": false
                        },
                        "mode": {
                          "enum": [
                            2
                          ]
                        }
                      }
                    },
                    "then": {
                      "required": [
                        "level"
                      ]
                    }
                  }
                ]
              }
            },
            "power": {
              "title": "Power",
              "type": "object",
              "properties": {
                "broadcastAddress": {
                  "title": "Broadcast address",
                  "type": "string",
                  "placeholder": "255.255.255.255",
                  "format": "ipv4",
                  "description": "Her set network broadcast address, only if You use VLANS in Your network configuration and Your router/switch support IP Directed Broadcast."
                },
                "startInput": {
                  "title": "Default Input",
                  "type": "boolean",
                  "description": "This enable possibilty to set default Input/App after Power ON TV."
                },
                "startInputReference": {
                  "title": "Input Reference",
                  "type": "string",
                  "placeholder": "com.webos.app.home",
                  "description": "Here set the default Input/App reference.",
                  "condition": {
                    "functionBody": "return model.devices[arrayIndices].power.startInput === true"
                  }
                }
              }
            },
            "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[arrayIndices[1]].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[arrayIndices[1]].displayType > 0;"
                  }
                }
              }
            },
            "sound": {
              "title": "Sound",
              "type": "object",
              "properties": {
                "modes": {
                  "title": "Sound Mode",
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "displayType": {
                        "title": "Display Type",
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 2,
                        "description": "Here select display type in HomeKit app.",
                        "anyOf": [
                          {
                            "title": "Disabled",
                            "enum": [
                              0
                            ]
                          },
                          {
                            "title": "Outlet",
                            "enum": [
                              1
                            ]
                          },
                          {
                            "title": "Switch",
                            "enum": [
                              2
                            ]
                          }
                        ]
                      },
                      "name": {
                        "title": "Name",
                        "type": "string",
                        "placeholder": "Sound Mode Name",
                        "description": "Here set Your own Sound Mode name."
                      },
                      "reference": {
                        "title": "Mode",
                        "type": "string",
                        "description": "Here choice the Sound Mode.",
                        "anyOf": [
                          {
                            "title": "Ai Sound Plus",
                            "enum": [
                              "aiSoundPlus"
                            ]
                          },
                          {
                            "title": "Standard",
                            "enum": [
                              "standard"
                            ]
                          },
                          {
                            "title": "Movie",
                            "enum": [
                              "movie"
                            ]
                          },
                          {
                            "title": "Clear Voice",
                            "enum": [
                              "clearVoice"
                            ]
                          },
                          {
                            "title": "News",
                            "enum": [
                              "news"
                            ]
                          },
                          {
                            "title": "Sports",
                            "enum": [
                              "sports"
                            ]
                          },
                          {
                            "title": "Music",
                            "enum": [
                              "music"
                            ]
                          },
                          {
                            "title": "Game",
                            "enum": [
                              "game"
                            ]
                          }
                        ],
                        "condition": {
                          "functionBody": "return model.devices[arrayIndices[0]].modes[arrayIndices[1]].displayType > 0;"
                        }
                      },
                      "namePrefix": {
                        "title": "Prefix",
                        "type": "boolean",
                        "description": "Here enable the accessory name as a prefix for sound mode.",
                        "condition": {
                          "functionBody": "return model.devices[arrayIndices[0]].modes[arrayIndices[1]].displayType > 0;"
                        }
                      }
                    },
                    "allOf": [
                      {
                        "if": {
                          "properties": {
                            "displayType": {
                              "enum": [
                                1,
                                2
                              ]
                            }
                          }
                        },
                        "then": {
                          "required": [
                            "reference"
                          ]
                        }
                      }
                    ]
                  }
                },
                "outputs": {
                  "title": "Sound Output",
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "displayType": {
                        "title": "Display Type",
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 2,
                        "description": "Here select display type in HomeKit app.",
                        "anyOf": [
                          {
                            "title": "Disabled",
                            "enum": [
                              0
                            ]
                          },
                          {
                            "title": "Outlet",
                            "enum": [
                              1
                            ]
                          },
                          {
                            "title": "Switch",
                            "enum": [
                              2
                            ]
                          }
                        ]
                      },
                      "name": {
                        "title": "Name",
                        "type": "string",
                        "placeholder": "Sound Output Name",
                        "description": "Here set Your own Sound Output name."
                      },
                      "reference": {
                        "title": "Output",
                        "type": "string",
                        "description": "Here choice the Sound Output.",
                        "anyOf": [
                          {
                            "title": "TV Speaker",
                            "enum": [
                              "tv_speaker"
                            ]
                          },
                          {
                            "title": "External Speaker",
                            "enum": [
                              "external_speaker"
                            ]
                          },
                          {
                            "title": "External Optical",
                            "enum": [
                              "external_optical"
                            ]
                          },
                          {
                            "title": "External ARC",
                            "enum": [
                              "external_arc"
                            ]
                          },
                          {
                            "title": "Line Out",
                            "enum": [
                              "lineout"
                            ]
                          },
                          {
                            "title": "Headphone",
                            "enum": [
                              "headphone"
                            ]
                          },
                          {
                            "title": "TV External Speaker",
                            "enum": [
                              "tv_external_speaker"
                            ]
                          },
                          {
                            "title": "TV Speaker Headphone",
                            "enum": [
                              "tv_speaker_headphone"
                            ]
                          },
                          {
                            "title": "BT Soundbar",
                            "enum": [
                              "bt_soundbar"
                            ]
                          },
                          {
                            "title": "Soundbar",
                            "enum": [
                              "soundbar"
                            ]
                          }
                        ],
                        "condition": {
                          "functionBody": "return model.devices[arrayIndices[0]].outputs[arrayIndices[1]].displayType > 0;"
                        }
                      },
                      "namePrefix": {
                        "title": "Prefix",
                        "type": "boolean",
                        "description": "Here enable the accessory name as a prefix for sound output.",
                        "condition": {
                          "functionBody": "return model.devices[arrayIndices[0]].outputs[arrayIndices[1]].displayType > 0;"
                        }
                      }
                    },
                    "allOf": [
                      {
                        "if": {
                          "properties": {
                            "displayType": {
                              "enum": [
                                1,
                                2
                              ]
                            }
                          }
                        },
                        "then": {
                          "required": [
                            "reference"
                          ]
                        }
                      }
                    ]
                  }
                }
              }
            },
            "picture": {
              "title": "Picture",
              "type": "object",
              "properties": {
                "brightnessControl": {
                  "title": "Brightness",
                  "type": "boolean",
                  "default": false,
                  "description": "This enable possibility adjust the Brightness."
                },
                "backlightControl": {
                  "title": "Backlight",
                  "type": "boolean",
                  "default": false,
                  "description": "This enable possibility adjust the Backlight."
                },
                "contrastControl": {
                  "title": "Contrast",
                  "type": "boolean",
                  "default": false,
                  "description": "This enable possibility adjust the Contrast."
                },
                "colorControl": {
                  "title": "Color",
                  "type": "boolean",
                  "default": false,
                  "description": "This enable possibility adjust the Color."
                },
                "modes": {
                  "title": "Mode",
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "displayType": {
                        "title": "Display Type",
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 2,
                        "description": "Here select display type in HomeKit app.",
                        "anyOf": [
                          {
                            "title": "Disabled",
                            "enum": [
                              0
                            ]
                          },
                          {
                            "title": "Outlet",
                            "enum": [
                              1
                            ]
                          },
                          {
                            "title": "Switch",
                            "enum": [
                              2
                            ]
                          }
                        ]
                      },
                      "name": {
                        "title": "Name",
                        "type": "string",
                        "placeholder": "Picture Mode Name",
                        "description": "Here set Your own Picture Mode name."
                      },
                      "reference": {
                        "title": "Mode",
                        "type": "string",
                        "description": "Here choice the Picture Mode.",
                        "anyOf": [
                          {
                            "title": "Normal",
                            "enum": [
                              "normal"
                            ]
                          },
                          {
                            "title": "Cinema",
                            "enum": [
                              "cinema"
                            ]
                          },
                          {
                            "title": "Eco",
                            "enum": [
                              "eco"
                            ]
                          },
                          {
                            "title": "Game",
                            "enum": [
                              "game"
                            ]
                          },
                          {
                            "title": "Photo",
                            "enum": [
                              "photo"
                            ]
                          },
                          {
                            "title": "Sports",
                            "enum": [
                              "sports"
                            ]
                          },
                          {
                            "title": "Vivid",
                            "enum": [
                              "vivid"
                            ]
                          },
                          {
                            "title": "Technicolor",
                            "enum": [
                              "technicoloro"
                            ]
                          },
                          {
                            "title": "Filmmaker",
                            "enum": [
                              "filmMaker"
                            ]
                          },
                          {
                            "title": "HDR Filmmaker",
                            "enum": [
                              "hdrFilmMaker"
                            ]
                          },
                          {
                            "title": "HDR Cinema",
                            "enum": [
                              "hdrCinema"
                            ]
                          },
                          {
                            "title": "HDR Cinema Bright",
                            "enum": [
                              "hdrCinemaBright"
                            ]
                          },
                          {
                            "title": "HDR Standard",
                            "enum": [
                              "hdrStandard"
                            ]
                          },
                          {
                            "title": "HDR Effect",
                            "enum": [
                              "hdrEffect"
                            ]
                          },
                          {
                            "title": "HDR Game",
                            "enum": [
                              "hdrGame"
                            ]
                          },
                          {
                            "title": "HDR Vivid",
                            "enum": [
                              "hdrVivid"
                            ]
                          },
                          {
                            "title": "HDR Technicolor",
                            "enum": [
                              "hdrTechnicolor"
                            ]
                          },
                          {
                            "title": "HDR External",
                            "enum": [
                              "hdrExternal"
                            ]
                          },
                          {
                            "title": "Dolby HDR Cinema",
                            "enum": [
                              "dolbyHdrCinema"
                            ]
                          },
                          {
                            "title": "Dolby HDR Cinema Bright",
                            "enum": [
                              "dolbyHdrCinemaBright"
                            ]
                          },
                          {
                            "title": "Dolby HDR Cinema Dark",
                            "enum": [
                              "dolbyHdrDarkAmazon"
                            ]
                          },
                          {
                            "title": "Dolby HDR Standard",
                            "enum": [
                              "dolbyHdrStandard"
                            ]
                          },
                          {
                            "title": "Dolby HDR Vivid",
                            "enum": [
                              "dolbyHdrVivid"
                            ]
                          },
                          {
                            "title": "Dolby HDR Game",
                            "enum": [
                              "dolbyHdrGame"
                            ]
                          },
                          {
                            "title": "Expert 1",
                            "enum": [
                              "expert1"
                            ]
                          },
                          {
                            "title": "Expert 2",
                            "enum": [
                              "expert2"
                            ]
                          }
                        ],
                        "condition": {
                          "functionBody": "return model.devices[arrayIndices[0]].modes[arrayIndices[1]].displayType > 0;"
                        }
                      },
                      "namePrefix": {
                        "title": "Prefix",
                        "type": "boolean",
                        "description": "Here enable the accessory name as a prefix for picture mode.",
                        "condition": {
                          "functionBody": "return model.devices[arrayIndices[0]].modes[arrayIndices[1]].displayType > 0;"
                        }
                      }
                    },
                    "allOf": [
                      {
                        "if": {
                          "properties": {
                            "displayType": {
                              "enum": [
                                1,
                                2
                              ]
                            }
                          }
                        },
                        "then": {
                          "required": [
                            "reference"
                          ]
                        }
                      }
                    ]
                  }
                }
              }
            },
            "screen": {
              "title": "Screen",
              "type": "object",
              "properties": {
                "turnOnOff": {
                  "title": "Turn Screen ON/OFF",
                  "type": "boolean",
                  "default": false,
                  "description": "This enable possibility turn screen ON/OFF, webOS >= 4.0.0"
                },
                "saverOnOff": {
                  "title": "Turn Screen Saver ON/OFF",
                  "type": "boolean",
                  "default": false,
                  "description": "This enable possibility turn screen saver ON/OFF, webOS >= 4.0.0"
                }
              }
            },
            "sslWebSocket": {
              "title": "SSL WebSocket",
              "type": "boolean",
              "default": false,
              "description": "This enable SSL WebSocket, support TV with new firmware."
            },
            "disableTvService": {
              "title": "Disable TV Service",
              "type": "boolean",
              "default": false,
              "description": "This disable TV service and prevent display double services if TV already support HomeKit native."
            },
            "infoButtonCommand": {
              "title": "Info Button",
              "type": "string",
              "default": "MENU",
              "description": "Here select the function of info button in RC.",
              "anyOf": [
                {
                  "title": "Home",
                  "enum": [
                    "HOME"
                  ]
                },
                {
                  "title": "Menu",
                  "enum": [
                    "MENU"
                  ]
                },
                {
                  "title": "Q Menu",
                  "enum": [
                    "QMENU"
                  ]
                },
                {
                  "title": "Info",
                  "enum": [
                    "INFO"
                  ]
                },
                {
                  "title": "Red",
                  "enum": [
                    "RED"
                  ]
                },
                {
                  "title": "Green",
                  "enum": [
                    "GREEN"
                  ]
                },
                {
                  "title": "Yellow",
                  "enum": [
                    "YELLOW"
                  ]
                },
                {
                  "title": "Blue",
                  "enum": [
                    "BLUE"
                  ]
                }
              ]
            },
            "heartBeatInterval": {
              "title": "Heart beat interval (sec)",
              "type": "number",
              "minimum": 1,
              "maximum": 30,
              "multipleOf": 1,
              "description": "Heart beat check when TV is off, default is 5 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"
                }
              }
            },
            "restFul": {
              "title": "RESTFul",
              "type": "object",
              "properties": {
                "enable": {
                  "title": "Enable",
                  "type": "boolean",
                  "default": false,
                  "description": "This enable RESTful server."
                },
                "port": {
                  "title": "Port",
                  "type": "integer",
                  "placeholder": 3000,
                  "description": "Here set the listening Port for RESTful server.",
                  "condition": {
                    "functionBody": "return model.devices[arrayIndices].restFul.enable === true;"
                  }
                }
              }
            },
            "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;"
                  }
                },
                "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",
            "mac",
            "displayType"
          ],
          "allOf": [
            {
              "if": {
                "properties": {
                  "displayType": {
                    "enum": [
                      1,
                      2,
                      3,
                      4
                    ]
                  }
                }
              },
              "then": {
                "required": [
                  "name",
                  "host",
                  "mac"
                ]
              }
            }
          ]
        }
      }
    }
  },
  "layout": [
    {
      "key": "devices",
      "type": "tabarray",
      "title": "{{ value.name || 'Device' }}",
      "items": [
        "devices[].name",
        "devices[].host",
        "devices[].mac",
        "devices[].displayType",
        {
          "key": "devices[].inputs",
          "type": "section",
          "title": "Inputs",
          "expandable": true,
          "expanded": false,
          "items": [
            "devices[].inputs.getFromDevice",
            "devices[].inputs.filterSystemApps",
            "devices[].inputs.displayOrder",
            {
              "key": "devices[].inputs.data",
              "type": "tabarray",
              "title": "{{ value.name || 'Input' }}",
              "items": [
                "devices[].inputs.data[].name",
                "devices[].inputs.data[].reference",
                "devices[].inputs.data[].mode"
              ]
            }
          ]
        },
        {
          "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[].namePrefix"
              ]
            }
          ]
        },
        {
          "key": "devices[]",
          "type": "section",
          "title": "Advanced Settings",
          "expandable": true,
          "expanded": false,
          "items": [
            {
              "key": "devices[]",
              "type": "tabarray",
              "title": "{{ value.title }}",
              "items": [
                {
                  "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[].power",
                  "title": "Power",
                  "items": [
                    "devices[].power.broadcastAddress",
                    "devices[].power.startInput",
                    "devices[].power.startInputReference"
                  ]
                },
                {
                  "key": "devices[].volume",
                  "title": "Volume",
                  "items": [
                    "devices[].volume.displayType",
                    "devices[].volume.name",
                    "devices[].volume.namePrefix"
                  ]
                },
                {
                  "key": "devices[].sound",
                  "title": "Sound",
                  "items": [
                    {
                      "key": "devices[].sound",
                      "type": "tabarray",
                      "title": "{{ value.title }}",
                      "items": [
                        {
                          "title": "Mode",
                          "items": [
                            {
                              "key": "devices[].sound.modes",
                              "type": "tabarray",
                              "title": "{{ value.name || 'Mode' }}",
                              "items": [
                                "devices[].sound.modes[].displayType",
                                "devices[].sound.modes[].name",
                                "devices[].sound.modes[].reference",
                                "devices[].sound.modes[].namePrefix"
                              ]
                            }
                          ]
                        },
                        {
                          "title": "Output",
                          "items": [
                            {
                              "key": "devices[].sound.outputs",
                              "type": "tabarray",
                              "title": "{{ value.name || 'Output' }}",
                              "items": [
                                "devices[].sound.outputs[].displayType",
                                "devices[].sound.outputs[].name",
                                "devices[].sound.outputs[].reference",
                                "devices[].sound.outputs[].namePrefix"
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "key": "devices[].picture",
                  "title": "Picture",
                  "items": [
                    "devices[].picture.brightnessControl",
                    "devices[].picture.backlightControl",
                    "devices[].picture.contrastControl",
                    "devices[].picture.colorControl",
                    {
                      "type": "section",
                      "title": "Modes",
                      "expandable": true,
                      "expanded": false,
                      "items": [
                        {
                          "key": "devices[].picture.modes",
                          "type": "tabarray",
                          "title": "{{ value.name || 'Mode' }}",
                          "items": [
                            "devices[].picture.modes[].displayType",
                            "devices[].picture.modes[].name",
                            "devices[].picture.modes[].reference",
                            "devices[].picture.modes[].namePrefix"
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "key": "devices[].screen",
                  "title": "Screen",
                  "items": [
                    "devices[].screen.turnOnOff",
                    "devices[].screen.saverOnOff"
                  ]
                },
                {
                  "key": "devices[]",
                  "title": "Device",
                  "items": [
                    "devices[].sslWebSocket",
                    "devices[].disableTvService",
                    "devices[].infoButtonCommand",
                    "devices[].heartBeatInterval"
                  ]
                },
                {
                  "key": "devices[].log",
                  "title": "Log",
                  "items": [
                    "devices[].log.deviceInfo",
                    "devices[].log.success",
                    "devices[].log.info",
                    "devices[].log.warn",
                    "devices[].log.error",
                    "devices[].log.debug"
                  ]
                },
                {
                  "title": "External Integrations",
                  "items": [
                    {
                      "key": "devices[]",
                      "type": "tabarray",
                      "title": "{{ value.title }}",
                      "items": [
                        {
                          "key": "devices[].restFul",
                          "title": "RESTFul",
                          "items": [
                            "devices[].restFul.enable",
                            "devices[].restFul.port"
                          ]
                        },
                        {
                          "key": "devices[].mqtt",
                          "title": "MQTT",
                          "items": [
                            "devices[].mqtt.enable",
                            "devices[].mqtt.host",
                            "devices[].mqtt.port",
                            "devices[].mqtt.clientId",
                            "devices[].mqtt.prefix",
                            {
                              "key": "devices[].mqtt.auth",
                              "title": "Authorization",
                              "items": [
                                "devices[].mqtt.auth.enable",
                                "devices[].mqtt.auth.user",
                                {
                                  "key": "devices[].mqtt.auth.passwd",
                                  "type": "password"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}