{
    "pluginAlias": "SamsungTizen",
    "pluginType": "platform",
    "singular": true,
    "headerDisplay": "Please [read the documentation](https://tavicu.github.io/homebridge-samsung-tizen/) of the plugin for more informations and step by step instructions on how to configure it.",

    "schema": {
        "type": "object",
        "properties": {
            "name": {"type": "string"},
            "delay": {"type": "integer"},
            "method": {"type": "string"},
            "timeout": {"type": "integer"},
            "wait_time": {"type": "integer"},
            "api_key": {"type": "string"},

            "refresh": {
                "type": "object",
                "properties": {
                    "main": {"type": ["integer", "boolean"]},
                    "switch": {"type": ["integer", "boolean"]}
                }
            },

            "inputs": {
                "type": "array",
                "items": {
                    "type": "object",
                    "properties": {
                        "type": {"type": "string"},
                        "name": {"type": "string"},
                        "value": {"type": "string"}
                    }
                }
            },

            "switches": {
                "type": "array",
                "items": {
                    "type": "object",
                    "properties": {
                        "name": {"type": "string"},
                        "power": {"type": "boolean"},
                        "app": {"type": "string"},
                        "input": {"type": "string"},
                        "sleep": {"type": "integer"},
                        "mute": {"type": "boolean"},
                        "volume": {"type": "integer"},
                        "channel": {"type": "integer"},
                        "picture_mode": {"type": "string"},
                        "command": {
                            "type": "array",
                            "items": {
                                "type": "string"
                            }
                        }
                    }
                }
            },

            "keys": {
                "type": "object",
                "properties": {
                    "ARROW_UP": {"type": "string"},
                    "ARROW_DOWN": {"type": "string"},
                    "ARROW_LEFT": {"type": "string"},
                    "ARROW_RIGHT": {"type": "string"},
                    "SELECT": {"type": "string"},
                    "BACK": {"type": "string"},
                    "PLAY_PAUSE": {"type": "string"},
                    "INFORMATION": {"type": "string"}
                }
            },

            "devices": {
                "type": "array",
                "items": {
                    "type": "object",
                    "properties": {
                        "wol": {"type": "object"},
                        "timeout": {"type": "integer"},
                        "wait_time": {"type": "integer"},
                        "api_key": {"type": "string"},
                        "device_id": {"type": "string"},

                        "name": {
                            "type": "string",
                            "required": true
                        },
                        "ip": {
                            "type": "string",
                            "format": "ipv4",
                            "required": true
                        },
                        "mac": {
                            "type": "string",
                            "required": true,
                            "pattern": "^([A-Fa-f0-9]{2}:){5}[A-Fa-f0-9]{2}$"
                        },
                        "uuid": {
                            "type": "string"
                        },
                        "delay": {
                            "type": "integer"
                        },
                        "method": {
                            "type": "string",
                            "enum": ["wss", "frame", "ws"]
                        },
                        "options": {
                            "type": "array",
                            "items": {
                                "type": "string",
                                "enum": ["Switch.DeviceName.Disable", "Frame.RealPowerMode", "Frame.ArtSwitch.Disable", "Frame.PowerSwitch.Disable"]
                            }
                        },
                        "refresh": {
                            "type": "object",
                            "properties": {
                                "main": {"type": ["integer", "boolean"]},
                                "switch": {"type": ["integer", "boolean"]}
                            }
                        },
                        "inputs": {
                            "type": "array",
                            "items": {
                                "type": "object",
                                "properties": {
                                    "type": {
                                        "type": "string",
                                        "default": "app",
                                        "enum": ["app", "input", "command", "art"]
                                    },
                                    "name": {
                                        "type": "string"
                                    },
                                    "value": {
                                        "type": "string"
                                    }
                                },
                                "required": ["name", "type", "value"]
                            }
                        },
                        "switches": {
                            "type": "array",
                            "items": {
                                "type": "object",
                                "properties": {
                                    "name": {
                                        "type": "string",
                                        "required": true
                                    },
                                    "power": {
                                        "type": "boolean"
                                    },
                                    "app": {
                                        "type": "string"
                                    },
                                    "input": {
                                        "type": "string",
                                        "enum": ["digitalTv", "HDMI1", "HDMI2", "HDMI3", "HDMI4", "HDMI5", "HDMI6", "USB", "AM", "FM", "USB-C", "Display Port"]
                                    },
                                    "sleep": {
                                        "type": "integer"
                                    },
                                    "mute": {
                                        "type": "boolean"
                                    },
                                    "volume": {
                                        "type": "integer"
                                    },
                                    "channel": {
                                        "type": "integer"
                                    },
                                    "picture_mode": {
                                        "type": "string",
                                        "enum": ["Standard", "Dynamic", "Natural", "Movie"]
                                    },
                                    "command": {
                                        "type": "array",
                                        "items": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        },
                        "keys": {
                            "type": "object",
                            "properties": {
                                "ARROW_UP": {
                                    "type": "string"
                                },
                                "ARROW_DOWN": {
                                    "type": "string"
                                },
                                "ARROW_LEFT": {
                                    "type": "string"
                                },
                                "ARROW_RIGHT": {
                                    "type": "string"
                                },
                                "SELECT": {
                                    "type": "string"
                                },
                                "BACK": {
                                    "type": "string"
                                },
                                "PLAY_PAUSE": {
                                    "type": "string"
                                },
                                "INFORMATION": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                }
            }
        }
    },

    "layout": [
        {
            "type": "fieldset",
            "title": "Devices",
            "items": [
                {
                    "title": "Device",
                    "key": "devices",
                    "type": "array",
                    "notitle": true,
                    "items": [
                        {
                            "type": "div",
                            "items": [
                                {
                                    "key": "devices[].name",
                                    "title": "Device Name",
                                    "default": "Bedroom TV"
                                },
                                {
                                  "type": "help",
                                  "helpvalue": "<p class='help-block'>Make sure that your device have a static IP address. You can set it from your router admin interface!</p>"
                                },
                                {
                                    "type": "flex",
                                    "flex-flow": "row wrap",
                                    "items": [
                                        {
                                            "key": "devices[].ip",
                                            "title": "IP Address",
                                            "placeholder": "10.20.30.40"
                                        },
                                        {
                                            "key": "devices[].mac",
                                            "title": "MAC Address",
                                            "placeholder": "A0:B1:C2:D3:E4:F5"
                                        }
                                    ]
                                },
                                {
                                    "type": "fieldset",
                                    "title": "SmartThings API",
                                    "items": [
                                        {
                                          "type": "help",
                                          "helpvalue": "<p class='help-block'>SmartThings API is <strong>optional</strong>. You will need to set these parameters only if you want to use inputs! Please <a href='https://tavicu.github.io/homebridge-samsung-tizen/configuration/smartthings-api.html' target='_blank'>follow this tutorial</a>.</p>"
                                        },
                                        {
                                            "key": "devices[].api_key",
                                            "title": "API Key"
                                        },
                                        {
                                            "key": "devices[].device_id",
                                            "title": "Device ID"
                                        }
                                    ]
                                },
                                {
                                    "type": "fieldset",
                                    "title": "Inputs",
                                    "expandable": true,
                                    "expanded": false,
                                    "items": [
                                        {
                                            "type": "help",
                                            "helpvalue": "<p class='help-block'>By default no inputs are set. Use this section to set your own inputs. You can find more informations on our <a href='https://tavicu.github.io/homebridge-samsung-tizen/features/inputs.html' target='_blank'>documentation</a>.</p>"
                                        },
                                        {
                                            "type": "array",
                                            "notitle": true,
                                            "items": [
                                                {
                                                    "title": "Input",
                                                    "type": "div",
                                                    "notitle": true,
                                                    "display": "flex",
                                                    "flex-direction": "row",
                                                    "items": [
                                                        {
                                                            "key": "devices[].inputs[].type",
                                                            "title": "Type",
                                                            "titleMap": {
                                                                "app": "Application",
                                                                "input": "Input",
                                                                "command": "Command",
                                                                "art": "Art Mode"
                                                            }
                                                        },
                                                        {
                                                            "key": "devices[].inputs[].name",
                                                            "title": "Input Name",
                                                            "placeholder": "Netflix"
                                                        },
                                                        {
                                                            "key": "devices[].inputs[].value",
                                                            "title": "Input Value",
                                                            "placeholder": "11101200001",
                                                            "condition": {
                                                                "functionBody": "return !['art', 'input'].includes(model.devices[arrayIndices[0]].inputs[arrayIndices[1]].type);"
                                                            }
                                                        },
                                                        {
                                                            "key": "devices[].inputs[].value",
                                                            "title": "Input Source",
                                                            "condition": {
                                                                "functionBody": "return model.devices[arrayIndices[0]].inputs[arrayIndices[1]].type == 'input';"
                                                            },
                                                            "enum": ["digitalTv", "HDMI1", "HDMI2", "HDMI3", "HDMI4", "HDMI5", "HDMI6", "USB", "AM", "FM", "USB-C", "Display Port"],
                                                            "titleMap": {
                                                                "digitalTv": "Live TV",
                                                                "HDMI1": "HDMI 1",
                                                                "HDMI2": "HDMI 2",
                                                                "HDMI3": "HDMI 3",
                                                                "HDMI4": "HDMI 4",
                                                                "HDMI5": "HDMI 5",
                                                                "HDMI6": "HDMI 6",
                                                                "USB": "USB",
                                                                "AM": "AM",
                                                                "FM": "FM",
                                                                "USB-C": "USB-C",
                                                                "Display Port": "Display Port"
                                                            }
                                                        }
                                                    ]
                                                }
                                            ]
                                        }
                                    ]
                                },
                                {
                                    "type": "fieldset",
                                    "title": "Switches",
                                    "expandable": true,
                                    "expanded": false,
                                    "items": [
                                        {
                                            "type": "help",
                                            "helpvalue": "<p class='help-block'>This section give you the option to create custom switches (separated accessories) that make specific actions. You can find more informations on our <a href='https://tavicu.github.io/homebridge-samsung-tizen/features/switches.html' target='_blank'>documentation</a>.</p>"
                                        },
                                        {
                                            "type": "array",
                                            "notitle": true,
                                            "items": [
                                                {
                                                    "title": "Switch",
                                                    "type": "div",
                                                    "notitle": true,
                                                    "items": [
                                                        {
                                                            "key": "devices[].switches[].name",
                                                            "title": "Switch Name",
                                                            "description": "Name for the switch. The device name will be appended."
                                                        },
                                                        {
                                                            "key": "devices[].switches[].power",
                                                            "title": "Power on the TV before running any action"
                                                        },
                                                        {
                                                            "key": "devices[].switches[].mute",
                                                            "title": "Send mute command to TV"
                                                        },
                                                        {
                                                            "key": "devices[].switches[].app",
                                                            "title": "Application ID",
                                                            "description": "Set this if you want to open an application."
                                                        },
                                                        {
                                                            "key": "devices[].switches[].input",
                                                            "title": "Input Source",
                                                            "description": "Set this if you want to change TV source. <strong>For this you will have to set SmartThings settings</strong>.",
                                                            "titleMap": {
                                                                "digitalTv": "Live TV",
                                                                "USB": "USB",
                                                                "HDMI1": "HDMI 1",
                                                                "HDMI2": "HDMI 2",
                                                                "HDMI3": "HDMI 3",
                                                                "HDMI4": "HDMI 4",
                                                                "HDMI5": "HDMI 5",
                                                                "HDMI6": "HDMI 6",
                                                                "USB-C": "USB-C",
                                                                "Display Port": "Display Port"
                                                            }
                                                        },
                                                        {
                                                            "key": "devices[].switches[].volume",
                                                            "title": "Audio volume",
                                                            "description": "Change audio volume"
                                                        },
                                                        {
                                                            "key": "devices[].switches[].picture_mode",
                                                            "title": "Picture mode",
                                                            "description": "Change picture mode"
                                                        },
                                                        {
                                                            "key": "devices[].switches[].sleep",
                                                            "title": "Sleep timer",
                                                            "description": "This option will turn off the TV after the set time has elapsed. Value is in <b>minutes</b>."
                                                        },
                                                        {
                                                            "key": "devices[].switches[].channel",
                                                            "title": "Channel Number",
                                                            "description": "Switch the TV to a channel number. This will not work if you are not on Live TV when you trigger the switch!"
                                                        },
                                                        {
                                                            "key": "devices[].switches[].command",
                                                            "notitle": true,
                                                            "items": [
                                                                {
                                                                    "type": "string",
                                                                    "title": "Command",
                                                                    "description": "Send commands to TV. Multiple commands can be added together."
                                                                }
                                                            ]
                                                        }
                                                    ]
                                                }
                                            ]
                                        }
                                    ]
                                },

                                {
                                    "type": "fieldset",
                                    "title": "SmartThings",
                                    "expandable": true,
                                    "expanded": false,
                                    "items": [
                                        {
                                            "type": "flex",
                                            "flex-flow": "row wrap",
                                            "items": [
                                                {
                                                    "key": "devices[].api_key",
                                                    "title": "API Key"
                                                },
                                                {
                                                    "key": "devices[].device_id",
                                                    "title": "Device ID"
                                                }
                                            ]
                                        }
                                    ]
                                },
                                {
                                    "type": "fieldset",
                                    "title": "Advanced Configuration",
                                    "expandable": true,
                                    "expanded": false,
                                    "items": [
                                        {
                                            "type": "help",
                                            "helpvalue": "<p class='help-block'>Here you can add advanced options like <b>Inputs</b> and <b>Switches</b>. Make sure you read our <a href='https://tavicu.github.io/homebridge-samsung-tizen/configuration/' target='_blank'>documentation</a> where we explain in details every section.</p>"
                                        },
                                        {
                                            "key": "devices[].method",
                                            "title": "Type",
                                            "titleMap": {
                                                "ws": "Legacy",
                                                "wss": "Default",
                                                "frame": "Frame"
                                            },
                                            "description": "The plugin detects the type of TV <b>automaticaly</b>. Leave this option set to <b>None</b> unless you are having problems and the plugin don't detect your TV type correctly."
                                        },
                                        {
                                            "key": "devices[].uuid",
                                            "title": "UUID",
                                            "placeholder": "A1",
                                            "description": "If you have problems adding the TV to Home app, set this field to a unique value. You can find more informations regarding this in the documentation."
                                        },
                                        {
                                            "key": "devices[].delay",
                                            "title": "Command Delay Interval",
                                            "placeholder": "400",
                                            "description": "This is the delay between each command when you send multiple commands. By lowering the value you risk the commands not being executed. Value is in <b>miliseconds</b>."
                                        },
                                        {
                                            "key": "devices[].options",
                                            "title": "Options",
                                            "titleMap": {
                                                "Switch.DeviceName.Disable": "Disable prepending device name on custom switches",
                                                "Frame.RealPowerMode": "Display and control Real Power with Main Acccessory (for Frame TVs)",
                                                "Frame.ArtSwitch.Disable": "Disable Art Switch (for Frame TVs)",
                                                "Frame.PowerSwitch.Disable": "Disable Power Switch (for Frame TVs)"
                                            }
                                        },
                                        {
                                            "type": "section",
                                            "title": "Key Mapping",
                                            "expandable": true,
                                            "expanded": false,
                                            "display": "flex",
                                            "flex-flow": "row wrap",
                                            "items": [
                                                {
                                                    "type": "help",
                                                    "helpvalue": "<p class='help-block'>You don't have to edit this section unless you want to change the default commands for <b>Remote Control</b> buttons. You can find more informations on our <a href='https://tavicu.github.io/homebridge-samsung-tizen/features/keys.html' target='_blank'>documentation</a>.</p>",
                                                    "flex": "1 1 100%"
                                                },
                                                {
                                                    "key": "devices[].keys.ARROW_UP",
                                                    "title": "ARROW_UP",
                                                    "placeholder": "KEY_UP",
                                                    "flex": "1 1 25%"
                                                },
                                                {
                                                    "key": "devices[].keys.ARROW_DOWN",
                                                    "title": "ARROW_DOWN",
                                                    "placeholder": "KEY_DOWN",
                                                    "flex": "1 1 25%"
                                                },
                                                {
                                                    "key": "devices[].keys.ARROW_LEFT",
                                                    "title": "ARROW_LEFT",
                                                    "placeholder": "KEY_LEFT",
                                                    "flex": "1 1 25%"
                                                },
                                                {
                                                    "key": "devices[].keys.ARROW_RIGHT",
                                                    "title": "ARROW_RIGHT",
                                                    "placeholder": "KEY_RIGHT",
                                                    "flex": "1 1 25%"
                                                },
                                                {
                                                    "key": "devices[].keys.SELECT",
                                                    "title": "SELECT",
                                                    "placeholder": "KEY_ENTER",
                                                    "flex": "1 1 25%"
                                                },
                                                {
                                                    "key": "devices[].keys.BACK",
                                                    "title": "BACK",
                                                    "placeholder": "KEY_RETURN",
                                                    "flex": "1 1 25%"
                                                },
                                                {
                                                    "key": "devices[].keys.PLAY_PAUSE",
                                                    "title": "PLAY_PAUSE",
                                                    "placeholder": "KEY_PLAY_BACK",
                                                    "flex": "1 1 25%"
                                                },
                                                {
                                                    "key": "devices[].keys.INFORMATION",
                                                    "title": "INFORMATION",
                                                    "placeholder": "KEY_INFO",
                                                    "flex": "1 1 25%"
                                                }
                                            ]
                                        }
                                    ]
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ]
}
