{
  "pluginAlias": "HomebridgeDummy",
  "pluginType": "platform",
  "singular": true,
  "customUi": true,
  "customUiPath": "./dist/homebridge-ui",
  "schema": {
    "type": "object",
    "definitions": {
      "units": {
        "type": "string",
        "title": "Đơn vị",
        "enum": [ "MILLISECONDS", "SECONDS", "MINUTES", "HOURS"],
        "enumNames": ["Mili giây", "Giây", "Phút", "Giờ"]
      },
      "sensor": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "title": "Gắn cảm biến",
            "enum": ["CarbonDioxideSensor", "CarbonMonoxideSensor", "ContactSensor", "LeakSensor", "MotionSensor", "OccupancySensor", "SmokeSensor"],
            "enumNames": ["Carbon Dioxide", "Carbon Monoxide", "Cảm biến tiếp xúc", "Cảm biến rò rỉ", "Cảm biến chuyển động", "Cảm biến hiện diện", "Cảm biến khói"]
          },
          "behavior": {
            "type": "string",
            "title": "Hành vi cảm biến",
            "enum": ["MIRROR", "TIMER"],
            "enumNames": ["Phản chiếu phụ kiện", "Kích hoạt theo hẹn giờ"]
          }
        }
      },
      "notification": {
        "type": "object",
        "properties": {
          "api": {
            "type": "string",
            "title": "API",
            "enum": ["PINGIE_NOTIFY"],
            "enumNames": ["Notify! (notify.pingie.com)"]
          },
          "token": {
            "type": "string",
            "title": "Token"
          },
          "id": {
            "type": "string",
            "title": "ID thiết bị hoặc nhóm"
          },
          "title": {
            "type": "string",
            "title": "Tiêu đề (Tùy chọn)"
          },
          "text": {
            "type": "string",
            "title": "Nội dung"
          },
          "groupType": {
            "type": "string"
          },
          "iconURL": {
            "type": "string"
          }
        },
        "allOf": [
          {
            "if": {
              "properties": {
                "api": {
                  "enum": ["PINGIE_NOTIFY"]
                }
              },
              "required": ["api"]
            },
            "then": {
              "required": ["token", "id", "text"]
            }
          },
          {
            "if": {
              "properties": {
                "token": {
                }
              },
              "required": ["token"]
            },
            "then": {
              "required": ["api", "id", "text"]
            }
          },
          {
            "if": {
              "properties": {
                "id": {
                }
              },
              "required": ["id"]
            },
            "then": {
              "required": ["token"]
            }
          },
          {
            "if": {
              "properties": {
                "title": {
                }
              },
              "required": ["title"]
            },
            "then": {
              "required": ["text"]
            }
          }
        ]
      },
      "schedule": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "title": "Loại",
            "enum": [ "TIMEOUT", "INTERVAL", "CRON", "SUNRISE", "SUNSET", "DAWN", "DUSK", "GOLDEN_HOUR", "NIGHT"],
            "enumNames": ["Sau khoảng trễ", "Khoảng lặp lại", "Cron", "Mặt trời mọc", "Mặt trời lặn", "Bình minh", "Hoàng hôn", "Giờ vàng", "Ban đêm"]
          },
          "time": {
            "type": "integer",
            "title": "Thời gian",
            "minimum": 1
          },
          "units": { "$ref": "#/definitions/units" },
          "random": {
            "type": "boolean",
            "title": "Ngẫu nhiên",
            "description": "Thời gian sẽ được ngẫu nhiên với giá trị trên làm mức tối đa"
          },
          "cron": {
            "type": "string",
            "title": "Cài đặt sẵn",
            "enum": [ "@secondly", "@minutely", "@hourly", "@daily", "@weekly", "@weekdays", "@weekends", "@monthly", "@yearly", "CRON_CUSTOM"],
            "enumNames": ["Mỗi giây", "Mỗi phút", "Mỗi giờ", "Hàng ngày", "Hàng tuần", "Ngày trong tuần", "Cuối tuần", "Hàng tháng", "Hàng năm", "Tùy chỉnh"]
          },
          "cronCustom": {
            "type": "string",
            "title": "Cron tùy chỉnh",
            "placeholder": "* * * * * *",
            "pattern": "(^((\\*\\/)?([0-5]?[0-9])((,|-|\\/)([0-5]?[0-9]))*|\\*)\\s((\\*\\/)?((2[0-3]|1[0-9]|[0-9]|00))((,|-|\\/)(2[0-3]|1[0-9]|[0-9]|00))*|\\*)\\s((\\*\\/)?([1-9]|[12][0-9]|3[01])((,|-|\\/)([1-9]|[12][0-9]|3[01]))*|\\*)\\s((\\*\\/)?([1-9]|1[0-2])((,|-|\\/)([1-9]|1[0-2]))*|\\*|(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec))\\s((\\*\\/)?[0-6]((,|-|\\/)[0-6])*|\\*|00|(sun|mon|tue|wed|thu|fri|sat))$)"
          },
          "offset": {
            "type": "number",
            "title": "Độ lệch",
            "enum": [-45, -30, -20, -15, -10, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 10, 15, 20, 30, 45],
            "enumNames": ["-45 Phút", "-30 Phút", "-20 Phút", "-15 Phút", "-10 Phút", "-5 Phút", "-4 Phút", "-3 Phút", "-2 Phút", "-1 Phút", "+1 Phút", "+2 Phút", "+3 Phút", "+4 Phút", "+5 Phút", "+10 Phút", "+15 Phút", "+20 Phút", "+30 Phút", "+45 Phút"]
          },
          "latitude": {
            "type": "number",
            "title": "Vĩ độ"
          },
          "longitude": {
            "type": "number",
            "title": "Kinh độ"
          }
        },
        "allOf": [
          {
            "if": {
              "properties": {
                "type": {
                  "enum": ["TIMEOUT", "INTERVAL"]
                }
              }
            },
            "then": {
              "required": ["time", "units"]
            }
          },
          {
            "if": {
              "properties": {
                "type": {
                  "const": "CRON"
                }
              }
            },
            "then": {
              "required": ["cron"]
            }
          },
          {
            "if": {
              "required": ["cron"],
              "properties": {
                "cron": {
                  "const": "CRON_CUSTOM"
                }
              }
            },
            "then": {
              "required": ["cronCustom"]
            }
          },
          {
            "if": {
              "properties": {
                "type": {
                  "enum": ["SUNRISE", "SUNSET", "DAWN", "DUSK", "GOLDEN_HOUR", "NIGHT"]
                }
              }
            },
            "then": {
              "required": ["latitude", "longitude"]
            }
          }
        ]
      },
      "limiter": {
        "type": "object",
        "properties": {
          "limit": {
            "type": "number",
            "title": "Giới hạn"
          },
          "units": {
            "type": "string",
            "title": "Đơn vị",
            "enum": [ "SECONDS", "MINUTES", "HOURS"],
            "enumNames": ["Giây", "Phút", "Giờ"],
            "required": true
          },
          "period": {
            "type": "string",
            "title": "Trong mỗi",
            "enum": [ "HOUR", "DAY", "WEEK", "MONTH"],
            "enumNames": ["Giờ", "Ban ngày", "Tuần", "Tháng"],
            "required": true
          },
          "resetOnRestart": {
            "type": "boolean"
          }
        },
        "allOf": [
          {
            "if": {
              "properties": {
                "limit": {
                }
              },
              "required": ["limit"]
            },
            "then": {
              "required": ["units", "period"]
            }
          },
          {
            "if": {
              "properties": {
                "units" : {
                }
              },
              "required": [ "units" ]
            },
            "then": {
              "required": [ "limit"]
            }
          },
          {
            "if": {
              "properties": {
                "period" : {
                }
              },
              "required": [ "period" ]
            },
            "then": {
              "required": [ "limit"]
            }
          }
        ]
      },
      "operand": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "title": "Loại",
            "enum": [ "ACCESSORY", "LOG", "PING" ],
            "enumNames": [ "Phụ kiện", "Theo dõi log", "Kiểm tra kết nối" ],
            "required": true
          },
          "accessoryId": {
            "type": "string",
            "title": "Phụ kiện"
          },
          "accessoryState": {
            "type": "string",
            "title": "Trạng thái",
            "enum": [ "on", "off", "open", "closed", "locked", "unlocked" ],
            "enumNames": [ "Bật", "Tắt", "Mở", "Đóng", "Đã khóa", "Đã mở khóa" ]
          },
          "pattern": {
            "type": "string",
            "title": "Chuỗi tìm kiếm hoặc RegEx"
          },
          "pingHost": {
            "type": "string",
            "title": "Máy chủ"
          },
          "pingAvailability": {
            "type": "string",
            "title": "Trạng thái",
            "enum": [ "AVAILABLE",  "NOT_AVAILABLE"],
            "enumNames": [ "Khả dụng", "Không khả dụng" ]
          },
          "pingInterval": {
            "type": "integer",
            "title": "Khoảng thời gian",
            "minimum": 1
          },
          "pingUnits": {
            "$ref": "#/definitions/units"
          }
        },
        "allOf": [
          {
            "if": {
              "properties": {
                "type": {
                  "const": "ACCESSORY"
                }
              },
              "required": ["type"]
            },
            "then": {
              "required": ["accessoryId", "accessoryState"]
            }
          },
          {
            "if": {
              "properties": {
                "type": {
                    "const": "LOG"
                }
              },
              "required": ["type"]
            },
            "then": {
              "required": ["pattern"]
            }
          },
          {
            "if": {
              "properties": {
                "type": {
                    "const": "PING"
                }
              },
              "required": ["type"]
            },
            "then": {
                "required": ["pingHost", "pingAvailability", "pingInterval", "pingUnits"]
            }
          }
        ]
      },
      "conditions": {
        "type": "object",
        "properties": {
          "operator": {
            "type": "string",
            "title": "Kích hoạt khi…",
            "enum": [ "and", "or"],
            "enumNames": ["TẤT CẢ điều kiện đều được đáp ứng", "BẤT KỲ điều kiện nào được đáp ứng"]
          },
          "operands": {
            "type": "array",
            "minItems":1,
            "items": { "$ref": "#/definitions/operand" }
          }
        },
        "allOf": [
          {
            "if": {
              "properties": {
                "operator": {
                }
              },
              "required": ["operator"]
            },
            "then": {
              "required": ["operands"]
            }
          }
        ]
      },
      "simulation": {
        "type": "object",
        "properties": {
          "enabled": {
            "type": "boolean"
          },
          "time": {
            "type": "integer",
            "minimum": 1
          },
          "units": { "$ref": "#/definitions/units" }
        }
      },
      "fadeOut": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "title": "Loại",
            "enum": [ "INCREMENTAL", "FIXED"],
            "enumNames": ["Tăng dần", "Cố định"]
          },
          "time": {
            "title": "Thời gian",
            "type": "integer",
            "minimum": 1
          },
          "units": { "$ref": "#/definitions/units" }
        },
        "allOf": [
          {
            "if": {
              "properties": {
                "type": {
                }
              },
              "required": ["type"]
            },
            "then": {
              "required": ["time", "units"]
            }
          },
          {
            "if": {
                "properties": {
                  "time": {
                  }
                },
                "required": ["time"]
            },
            "then": {
                "required": ["type"]
            }
          },
          {
            "if": {
                "properties": {
                  "units": {
                  }
                },
                "required": ["units"]
            },
            "then": {
                "required": ["type"]
            }
          }
        ]
      }
    },
    "properties": {
      "name": {
        "type": "string",
        "default": "Homebridge Dummy"
      },
      "accessories": {
        "type": "array",
        "items": {
          "type": "object",
          "required": ["name", "type"],
          "properties": {
            "id": {
              "type": "string"
            },
            "name": {
              "type": "string",
              "title": "Tên"
            },
            "type": {
              "type": "string",
              "title": "Loại",
              "enum": ["Door", "GarageDoorOpener", "HumidifierDehumidifier", "HumiditySensor", "Lightbulb", "LockMechanism", "Outlet", "StatelessProgrammableSwitch", "Switch", "TemperatureSensor", "Thermostat", "Valve", "Window", "WindowCovering"],
              "enumNames": ["Cửa", "Cửa gara", "Máy tạo ẩm/Hút ẩm", "Cảm biến độ ẩm", "Bóng đèn", "Khóa", "Ổ cắm", "Công tắc không trạng thái", "Công tắc", "Cảm biến nhiệt độ", "Bộ điều nhiệt", "Van", "Cửa sổ", "Rèm cửa"]
            },
            "groupName": {
              "type": "string",
              "title": "Tên nhóm"
            },
            "sensor": { "$ref": "#/definitions/sensor" },
            "notification": { "$ref": "#/definitions/notification" },
            "schedule": { "$ref": "#/definitions/schedule" },
            "fadeOut": { "$ref": "#/definitions/fadeOut" },
            "autoReset": { "$ref": "#/definitions/schedule" },
            "limiter": { "$ref": "#/definitions/limiter" },
            "conditions": { "$ref": "#/definitions/conditions" },
            "simulation": { "$ref": "#/definitions/simulation" },
            "temperatureUnits": {
              "type": "string",
              "title": "Đơn vị nhiệt độ",
              "enum": ["C", "F"],
              "enumNames": ["°C", "°F"]
            },
            "isDimmer": {
              "type": "boolean",
              "title": "Bật điều chỉnh độ sáng"
            },
            "defaultState": {
              "type": "string",
              "title": "Trạng thái mặc định",
              "enum": ["on", "off"],
              "enumNames": ["Bật", "Tắt"]
            },
            "defaultLockState": {
              "type": "string",
              "title": "Trạng thái mặc định",
              "enum": ["locked", "unlocked"],
              "enumNames": ["Đã khóa", "Đã mở khóa"]
            },
            "defaultPosition": {
              "type": "string",
              "title": "Vị trí mặc định",
              "enum": ["open", "closed"],
              "enumNames": ["Mở", "Đóng"]
            },
            "defaultThermostatState": {
              "type": "string",
              "title": "Trạng thái mặc định",
              "enum": ["auto", "heat", "cool", "off"],
              "enumNames": ["Tự động", "Sưởi", "Làm mát", "Tắt"]
            },
            "defaultTemperature": {
              "type": "number",
              "title": "Nhiệt độ mặc định"
            },
            "minimumTemperature": {
              "type": "number",
              "title": "Nhiệt độ tối thiểu"
            },
            "maximumTemperature": {
              "type": "number",
              "title": "Nhiệt độ tối đa"
            },
            "validStates": {
              "type": "array",
              "uniqueItems": true,
              "items": {
                "type": "string",
                "enum": ["off", "heat", "cool", "auto"]
              }
            },
            "humidifierType": {
              "type": "string",
              "title": "Loại",
              "enum": ["humidifier", "dehumidifier"],
              "enumNames": ["Máy tạo ẩm", "Máy hút ẩm"]
            },
            "valveType": {
              "type": "string",
              "title": "Loại van",
              "enum": ["generic", "faucet", "irrigation", "shower"],
              "enumNames": ["Chung", "Vòi nước", "Tưới tiêu", "Vòi sen"]
            },
            "commandOn": {
              "type": "string",
              "title": "Lệnh bật"
            },
            "commandOff": {
              "type": "string",
              "title": "Lệnh tắt"
            },
            "commandLock": {
              "type": "string",
              "title": "Lệnh khóa"
            },
            "commandUnlock": {
              "type": "string",
              "title": "Lệnh mở khóa"
            },
            "commandOpen": {
              "type": "string",
              "title": "Lệnh mở"
            },
            "commandClose": {
              "type": "string",
              "title": "Lệnh đóng"
            },
            "commandHumidity": {
              "type": "string",
              "title": "Lệnh khi độ ẩm thay đổi"
            },
            "commandTemperature": {
              "type": "string",
              "title": "Lệnh khi nhiệt độ thay đổi"
            },
            "commandSync": {
              "type": "string",
              "title": "Sync Command"
            },
            "syncSchedule": { "$ref": "#/definitions/schedule" },
            "resetOnRestart": {
              "type": "boolean",
              "title": "Đặt lại khi khởi động lại"
            },
            "enableWebhook": {
              "type": "boolean",
              "title": "Bật Webhook"
            },
            "disableLogging": {
              "type": "boolean",
              "title": "Tắt ghi log"
            },
            "enableHistory": {
              "type": "boolean",
              "title": "Bật lịch sử"
            }
          },
          "allOf": [
            {
              "if": {
                "properties": {
                  "commandSync": {
                  }
                },
                "required": ["commandSync"]
              },
              "then": {
                "required": ["syncSchedule"]
              }
            }
          ]
        }
      },
      "verbose": {
        "type": "boolean"
      },
      "webhookConfig": {
        "type": "object",
        "properties": {
          "port": {
            "type": "number"
          },
          "keyPath": {
            "type": "string"
          },
          "certPath": {
            "type": "string"
          },
          "passphrase": {
            "type": "string"
          }
        }
      }
    }
  },
    "layout": [
    {
      "type": "array",
      "key": "accessories",
      "notitle": true,
      "items": [
        {
          "type": "fieldset",
          "expandable": true,
          "title": "Phụ kiện",
          "items": [
            {
              "type": "div",
              "displayFlex": true,
              "flex-direction": "row",
              "notitle": true,
              "items": [
                {
                  "key": "accessories[].name",
                  "flex": "0 0 33%"
                },
                {
                  "key": "accessories[].type",
                  "flex": "0 0 33%"
                },
                {
                  "key": "accessories[].groupName",
                  "flex": "0 0 33%"
                }
              ]
            },
            {
              "type": "fieldset",
              "notitle": true,
              "condition": {
                "functionBody": "return model.accessories?.[arguments[1]]?.type;"
              },
              "items": [
                {
                  "type": "div",
                  "displayFlex": true,
                  "flex-direction": "row",
                  "notitle": true,
                  "condition": {
                    "functionBody": "return ['Lightbulb','Outlet','Switch'].includes(model.accessories?.[arguments[1]]?.type);"
                  },
                  "items": [
                    {
                      "key": "accessories[].defaultState",
                      "flex": "0 0 33%"
                    },
                    {
                      "key": "accessories[].sensor.type",
                      "flex": "0 0 33%"
                    },
                    {
                      "key": "accessories[].sensor.behavior",
                      "flex": "0 0 33%",
                      "condition": {
                        "functionBody": "return model.accessories?.[arguments[1]]?.sensor.type !== undefined;"
                      }
                    }
                  ]
                },
                {
                  "type": "div",
                  "displayFlex": true,
                  "flex-direction": "row",
                  "notitle": true,
                  "condition": {
                    "functionBody": "return ['LockMechanism'].includes(model.accessories?.[arguments[1]]?.type);"
                  },
                  "items": [
                    {
                      "key": "accessories[].defaultLockState",
                      "flex": "0 0 33%"
                    },
                    {
                      "key": "accessories[].sensor.type",
                      "flex": "0 0 33%"
                    },
                    {
                      "key": "accessories[].sensor.behavior",
                      "flex": "0 0 33%",
                      "condition": {
                        "functionBody": "return model.accessories?.[arguments[1]]?.sensor.type !== undefined;"
                      }
                    }
                  ]
                },
                {
                  "type": "div",
                  "displayFlex": true,
                  "flex-direction": "row",
                  "notitle": true,
                  "condition": {
                    "functionBody": "return ['Door', 'GarageDoorOpener', 'Window', 'WindowCovering'].includes(model.accessories?.[arguments[1]]?.type);"
                  },
                  "items": [
                    {
                      "key": "accessories[].defaultPosition",
                      "flex": "0 0 33%"
                    },
                    {
                      "key": "accessories[].sensor.type",
                      "flex": "0 0 33%"
                    },
                    {
                      "key": "accessories[].sensor.behavior",
                      "flex": "0 0 33%",
                      "condition": {
                        "functionBody": "return model.accessories?.[arguments[1]]?.sensor.type !== undefined;"
                      }
                    }
                  ]
                },
                {
                  "type": "div",
                  "displayFlex": true,
                  "flex-direction": "row",
                  "notitle": true,
                  "items": [
                    {
                      "key": "accessories[].temperatureUnits",
                      "flex": "0 0 33%",
                      "condition": {
                        "functionBody": "return ['TemperatureSensor','Thermostat'].includes(model.accessories?.[arguments[1]]?.type);"
                      }
                    },
                    {
                      "key": "accessories[].defaultThermostatState",
                      "flex": "0 0 33%",
                      "condition": {
                        "functionBody": "return ['Thermostat'].includes(model.accessories?.[arguments[1]]?.type);"
                      }
                    }
                  ]
                },
                {
                  "type": "div",
                  "displayFlex": true,
                  "flex-direction": "row",
                  "notitle": true,
                  "condition": {
                    "functionBody": "return ['Thermostat'].includes(model.accessories?.[arguments[1]]?.type);"
                  },
                  "items": [
                    {
                      "key": "accessories[].defaultTemperature",
                      "flex": "0 0 33%"
                    },
                    {
                      "key": "accessories[].minimumTemperature",
                      "flex": "0 0 33%"
                    },
                    {
                      "key": "accessories[].maximumTemperature",
                      "flex": "0 0 33%"
                    }
                  ]
                },
                {
                  "type": "div",
                  "displayFlex": true,
                  "flex-direction": "row",
                  "notitle": true,
                  "condition": {
                    "functionBody": "return ['HumidifierDehumidifier'].includes(model.accessories?.[arguments[1]]?.type);"
                  },
                  "items": [
                    {
                      "key": "accessories[].defaultState",
                      "flex": "0 0 33%"
                    },
                    {
                      "key": "accessories[].humidifierType",
                      "flex": "0 0 33%"
                    }
                  ]
                },
                {
                  "type": "div",
                  "displayFlex": true,
                  "flex-direction": "row",
                  "notitle": true,
                  "condition": {
                    "functionBody": "return ['Valve'].includes(model.accessories?.[arguments[1]]?.type);"
                  },
                  "items": [
                    {
                      "key": "accessories[].defaultState",
                      "flex": "0 0 33%"
                    },
                    {
                      "key": "accessories[].valveType",
                      "flex": "0 0 33%"
                    }
                  ]
                },
                {
                  "type": "div",
                  "displayFlex": true,
                  "flex-direction": "row",
                  "notitle": true,
                  "items": [
                    {
                      "key": "accessories[].enableWebhook",
                      "flex": "0 0 auto"
                    },
                    {
                      "flex": "0 0 5%"
                    },
                    {
                      "key": "accessories[].enableHistory",
                      "flex": "0 0 auto",
                      "condition": {
                        "functionBody": "return ['Door', 'GarageDoorOpener', 'HumidifierDehumidifier', 'HumiditySensor', 'Outlet', 'Lightbulb', 'Switch', 'TemperatureSensor', 'Thermostat', 'Window', 'WindowCovering'].includes(model.accessories?.[arguments[1]]?.type);"
                      }
                    },
                    {
                      "flex": "0 0 5%"
                    },
                    {
                      "key": "accessories[].simulation.enabled",
                      "title": "Mô phỏng mở/đóng",
                      "flex": "0 0 auto",
                      "condition": {
                        "functionBody": "return ['Door', 'GarageDoorOpener', 'Window', 'WindowCovering'].includes(model.accessories?.[arguments[1]]?.type);"
                      }
                    },
                    {
                      "key": "accessories[].isDimmer",
                      "flex": "0 0 auto",
                      "condition": {
                        "functionBody": "return model.accessories?.[arguments[1]]?.type === 'Lightbulb';"
                      }
                    }
                  ]
                },
                {
                  "type": "div",
                  "displayFlex": true,
                  "flex-direction": "row",
                  "notitle": true,
                  "items": [
                    {
                      "key": "accessories[].disableLogging",
                      "flex": "0 0 auto"
                    },
                    {
                      "flex": "0 0 5%"
                    },
                    {
                      "key": "accessories[].resetOnRestart",
                      "flex": "0 0 auto",
                      "condition": {
                        "functionBody": "return model.accessories?.[arguments[1]]?.type !== 'StatelessProgrammableSwitch';"
                      }
                    }
                  ]
                }
              ]
            },
            {
              "type": "fieldset",
              "title": "Lịch",
              "description": "Đặt phụ kiện sang giá trị ngược lại (không mặc định)",
              "condition": {
                "functionBody": "const type = model.accessories?.[arguments[1]]?.type; return type && !['HumiditySensor','TemperatureSensor','Thermostat'].includes(type);"
              },
              "items": [
                {
                  "type": "div",
                  "displayFlex": true,
                  "flex-direction": "row",
                  "notitle": true,
                  "items": [
                    {
                      "key": "accessories[].schedule.type",
                      "flex": "0 0 auto"
                    },
                    {
                      "key": "accessories[].schedule.time",
                      "flex": "0 0 auto",
                      "condition": {
                          "functionBody": "return ['TIMEOUT', 'INTERVAL'].includes(model.accessories?.[arguments[1]]?.schedule?.type);"
                      }
                    },
                    {
                      "key": "accessories[].schedule.units",
                      "flex": "0 0 auto",
                      "condition": {
                          "functionBody": "return ['TIMEOUT', 'INTERVAL'].includes(model.accessories?.[arguments[1]]?.schedule?.type);"
                      }
                    },
                    {
                      "key": "accessories[].schedule.cron",
                      "flex": "0 0 auto",
                      "condition": {
                          "functionBody": "return model.accessories?.[arguments[1]]?.schedule?.type === 'CRON';"
                      }
                    },
                    {
                      "key": "accessories[].schedule.cronCustom",
                      "flex": "1 0 auto",
                      "condition": {
                          "functionBody": "return model.accessories?.[arguments[1]]?.schedule?.cron === 'CRON_CUSTOM';"
                      }
                    },
                    {
                      "key": "accessories[].schedule.offset",
                      "flex": "0 1 auto",
                      "condition": {
                          "functionBody": "return ['SUNRISE', 'SUNSET', 'DAWN', 'DUSK', 'GOLDEN_HOUR', 'NIGHT'].includes(model.accessories?.[arguments[1]]?.schedule?.type);"
                      }
                    },
                    {
                      "key": "accessories[].schedule.latitude",
                      "flex": "0 1 auto",
                      "condition": {
                          "functionBody": "return ['SUNRISE', 'SUNSET', 'DAWN', 'DUSK', 'GOLDEN_HOUR', 'NIGHT'].includes(model.accessories?.[arguments[1]]?.schedule?.type);"
                      }
                    },
                    {
                      "key": "accessories[].schedule.longitude",
                      "flex": "0 1 auto",
                      "condition": {
                          "functionBody": "return ['SUNRISE', 'SUNSET', 'DAWN', 'DUSK', 'GOLDEN_HOUR', 'NIGHT'].includes(model.accessories?.[arguments[1]]?.schedule?.type);"
                      }
                    }
                  ]
                },
                {
                  "key": "accessories[].schedule.random",
                  "condition": {
                      "functionBody": "const schedule = model.accessories?.[arguments[1]]?.schedule; return ['TIMEOUT', 'INTERVAL'].includes(schedule?.type) && schedule?.time;"
                  }
                }
              ]
            },
            {
              "type": "fieldset",
              "title": "Giảm dần",
              "description": "Giảm độ sáng trong một khoảng thời gian cố định hoặc giảm dần 1% theo từng khoảng thời gian",
              "condition": {
                "functionBody": "const accessory = model.accessories?.[arguments[1]]; return accessory?.isDimmer === true && !accessory?.autoReset;"
              },
              "items": [
                {
                  "type": "div",
                  "displayFlex": true,
                  "flex-direction": "row",
                  "notitle": true,
                  "items": [
                    {
                      "key": "accessories[].fadeOut.type",
                      "flex": "0 0 auto"
                    },
                    {
                      "key": "accessories[].fadeOut.time",
                      "flex": "0 0 auto",
                      "condition": {
                          "functionBody": "return model.accessories?.[arguments[1]]?.fadeOut?.type;"
                      }
                    },
                    {
                      "key": "accessories[].fadeOut.units",
                      "flex": "0 0 auto",
                      "condition": {
                          "functionBody": "return model.accessories?.[arguments[1]]?.fadeOut?.type;"
                      }
                    }
                  ]
                }
              ]
            },
            {
              "type": "fieldset",
              "title": "Tự đặt lại",
              "description": "Đưa phụ kiện trở về giá trị mặc định",
              "condition": {
                "functionBody": "const accessory = model.accessories?.[arguments[1]]; const type = accessory?.type; return !accessory?.fadeOut && type && !['HumiditySensor','StatelessProgrammableSwitch','TemperatureSensor','Thermostat'].includes(type);"
              },
              "items": [
                {
                  "type": "div",
                  "displayFlex": true,
                  "flex-direction": "row",
                  "notitle": true,
                  "items": [
                    {
                      "key": "accessories[].autoReset.type",
                      "flex": "0 0 auto"
                    },
                    {
                      "key": "accessories[].autoReset.time",
                      "flex": "0 0 auto",
                      "condition": {
                          "functionBody": "return ['TIMEOUT', 'INTERVAL'].includes(model.accessories?.[arguments[1]]?.autoReset?.type);"
                      }
                    },
                    {
                      "key": "accessories[].autoReset.units",
                      "flex": "0 0 auto",
                      "condition": {
                          "functionBody": "return ['TIMEOUT', 'INTERVAL'].includes(model.accessories?.[arguments[1]]?.autoReset?.type);"
                      }
                    },
                    {
                      "key": "accessories[].autoReset.cron",
                      "flex": "0 0 auto",
                      "condition": {
                          "functionBody": "return model.accessories?.[arguments[1]]?.autoReset?.type === 'CRON';"
                      }
                    },
                    {
                      "key": "accessories[].autoReset.cronCustom",
                      "flex": "1 0 auto",
                      "condition": {
                          "functionBody": "return model.accessories?.[arguments[1]]?.autoReset?.cron === 'CRON_CUSTOM';"
                      }
                    },
                    {
                      "key": "accessories[].autoReset.offset",
                      "flex": "0 1 auto",
                      "condition": {
                          "functionBody": "return ['SUNRISE', 'SUNSET', 'DAWN', 'DUSK', 'GOLDEN_HOUR', 'NIGHT'].includes(model.accessories?.[arguments[1]]?.autoReset?.type);"
                      }
                    },
                    {
                      "key": "accessories[].autoReset.latitude",
                      "flex": "0 1 auto",
                      "condition": {
                          "functionBody": "return ['SUNRISE', 'SUNSET', 'DAWN', 'DUSK', 'GOLDEN_HOUR', 'NIGHT'].includes(model.accessories?.[arguments[1]]?.autoReset?.type);"
                      }
                    },
                    {
                      "key": "accessories[].autoReset.longitude",
                      "flex": "0 1 auto",
                      "condition": {
                          "functionBody": "return ['SUNRISE', 'SUNSET', 'DAWN', 'DUSK', 'GOLDEN_HOUR', 'NIGHT'].includes(model.accessories?.[arguments[1]]?.autoReset?.type);"
                      }
                    }
                  ]
                },
                {
                  "key": "accessories[].autoReset.random",
                  "condition": {
                      "functionBody": "const autoReset = model.accessories?.[arguments[1]]?.autoReset; return ['TIMEOUT', 'INTERVAL'].includes(autoReset?.type) && autoReset?.time;"
                  }
                }
              ]
            },
            {
              "type": "fieldset",
              "title": "Thông báo",
              "description": "Nhận thông báo khi phụ kiện được đặt sang giá trị ngược lại (không mặc định). Xem wiki để biết thêm chi tiết.",
              "condition": {
                "functionBody": "const type = model.accessories?.[arguments[1]]?.type; return type && !['HumiditySensor','TemperatureSensor','Thermostat'].includes(type);"
              },
              "items": [
                {
                  "type": "fieldset",
                  "items": [
                    {
                      "type": "div",
                      "displayFlex": true,
                      "flex-direction": "row",
                      "notitle": true,
                      "items": [
                        {
                          "key": "accessories[].notification.api",
                          "flex": "0 0 auto"
                        },
                        {
                          "key": "accessories[].notification.token",
                          "flex": "0 0 auto",
                          "condition": {
                            "functionBody": "return model.accessories?.[arguments[1]]?.notification?.api;"
                          }
                        },
                        {
                          "key": "accessories[].notification.id",
                          "flex": "0 0 auto",
                          "condition": {
                            "functionBody": "return model.accessories?.[arguments[1]]?.notification?.api;"
                          }
                        }
                      ]
                    },
                    {
                      "type": "div",
                      "displayFlex": true,
                      "flex-direction": "row",
                      "notitle": true,
                      "condition": {
                        "functionBody": "return model.accessories?.[arguments[1]]?.notification?.token || model.accessories?.[arguments[1]]?.notification?.id;"
                      },
                      "items": [
                        {
                          "key": "accessories[].notification.title",
                          "flex": "0 0 30%"
                        },
                        {
                          "key": "accessories[].notification.text",
                          "flex": "0 0 70%"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "type": "fieldset",
              "title": "Giới hạn thời gian",
              "description": "Giới hạn tổng thời gian phụ kiện có thể ở trạng thái không mặc định trong mỗi chu kỳ được chỉ định",
              "condition": {
                "functionBody": "const type = model.accessories?.[arguments[1]]?.type; return type && !['HumiditySensor','StatelessProgrammableSwitch','TemperatureSensor','Thermostat'].includes(type);"
              },
              "items": [
                {
                  "type": "div",
                  "displayFlex": true,
                  "flex-direction": "row",
                  "items": [
                    {
                      "key": "accessories[].limiter.limit",
                      "flex": "0 0 33%"
                    },
                    {
                      "key": "accessories[].limiter.units",
                      "flex": "0 0 33%",
                      "condition": {
                        "functionBody": "return model.accessories?.[arguments[1]]?.limiter?.limit;"
                      }
                    },
                    {
                      "key": "accessories[].limiter.period",
                      "flex": "0 0 33%",
                      "condition": {
                        "functionBody": "return model.accessories?.[arguments[1]]?.limiter?.limit;"
                      }
                    }
                  ]
                }
              ]
            },
            {
              "type": "fieldset",
              "title": "Điều kiện kích hoạt",
              "description": "Đặt phụ kiện về giá trị ngược lại (không phải mặc định) khi các điều kiện được chỉ định được đáp ứng",
              "condition": {
                "functionBody": "const type = model.accessories?.[arguments[1]]?.type; return type && !['HumiditySensor','TemperatureSensor','Thermostat'].includes(type);"
              },
              "items": [
                {
                  "type": "div",
                  "displayFlex": true,
                  "flex-direction": "row",
                  "items": [
                    {
                      "key": "accessories[].conditions.operator",
                      "flex": "0 0 auto"
                    }
                  ]
                }
              ]
            },
            {
              "type": "array",
              "title": "Điều kiện",
              "notitle": true,
              "condition": {
                "functionBody": "return model.accessories?.[arguments[1]]?.conditions?.operator;"
              },
              "key": "accessories[].conditions.operands",
              "items": [
                {
                  "type": "div",
                  "displayFlex": true,
                  "flex-direction": "row",
                  "items": [
                    {
                      "key": "accessories[].conditions.operands[].type",
                      "flex": "0 0 auto"
                    },
                    {
                      "key": "accessories[].conditions.operands[].accessoryId",
                      "flex": "0 0 auto",
                      "condition": {
                        "functionBody": "return model.accessories?.[arguments[1][0]]?.conditions?.operands?.[arguments[1][1]]?.type === 'ACCESSORY';"
                      }
                    },
                    {
                      "key": "accessories[].conditions.operands[].accessoryState",
                      "flex": "0 0 auto",
                      "condition": {
                        "functionBody": "return model.accessories?.[arguments[1][0]]?.conditions?.operands?.[arguments[1][1]]?.accessoryId;"
                      }
                    },
                    {
                      "key": "accessories[].conditions.operands[].pattern",
                      "flex": "1 0 auto",
                      "condition": {
                        "functionBody": "return model.accessories?.[arguments[1][0]]?.conditions?.operands?.[arguments[1][1]]?.type === 'LOG';"
                      }
                    },
                    {
                      "key": "accessories[].conditions.operands[].pingHost",
                      "flex": "0 0 28%",
                      "condition": {
                        "functionBody": "return model.accessories?.[arguments[1][0]]?.conditions?.operands?.[arguments[1][1]]?.type === 'PING';"
                      }
                    },
                    {
                      "key": "accessories[].conditions.operands[].pingAvailability",
                      "flex": "0 0 22%",
                      "condition": {
                        "functionBody": "return model.accessories?.[arguments[1][0]]?.conditions?.operands?.[arguments[1][1]]?.type === 'PING';"
                      }
                    },
                    {
                      "key": "accessories[].conditions.operands[].pingInterval",
                      "flex": "0 0 10%",
                      "condition": {
                        "functionBody": "return model.accessories?.[arguments[1][0]]?.conditions?.operands?.[arguments[1][1]]?.type === 'PING';"
                      }
                    },
                    {
                      "key": "accessories[].conditions.operands[].pingUnits",
                      "flex": "0 0 20%",
                      "condition": {
                        "functionBody": "return model.accessories?.[arguments[1][0]]?.conditions?.operands?.[arguments[1][1]]?.type === 'PING';"
                      }
                    }
                  ]
                }
              ]
            },
            {
              "type": "fieldset",
              "title": "Lệnh",
              "description": "Thực thi các lệnh tùy ý (ví dụ: curl) khi trạng thái phụ kiện thay đổi",
              "condition": {
                "functionBody": "return model.accessories?.[arguments[1]]?.type;"
              },
              "items": [
                {
                  "key": "accessories[].commandOn",
                  "condition": {
                    "functionBody": "return ['HumidifierDehumidifier','Lightbulb','Outlet','StatelessProgrammableSwitch','Switch','Thermostat','Valve'].includes(model.accessories?.[arguments[1]]?.type);"
                  }
                },
                {
                  "key": "accessories[].commandOff",
                  "condition": {
                    "functionBody": "return ['HumidifierDehumidifier','Lightbulb','Outlet','Switch','Thermostat','Valve'].includes(model.accessories?.[arguments[1]]?.type);"
                  }
                },
                {
                  "key": "accessories[].commandLock",
                  "condition": {
                    "functionBody": "return ['LockMechanism'].includes(model.accessories?.[arguments[1]]?.type);"
                  }
                },
                {
                  "key": "accessories[].commandUnlock",
                  "condition": {
                    "functionBody": "return ['LockMechanism'].includes(model.accessories?.[arguments[1]]?.type);"
                  }
                },
                {
                  "key": "accessories[].commandOpen",
                  "condition": {
                    "functionBody": "return ['Door', 'GarageDoorOpener', 'Window', 'WindowCovering'].includes(model.accessories?.[arguments[1]]?.type);"
                  }
                },
                {
                  "key": "accessories[].commandClose",
                  "condition": {
                    "functionBody": "return ['Door', 'GarageDoorOpener', 'Window', 'WindowCovering'].includes(model.accessories?.[arguments[1]]?.type);"
                  }
                },
                {
                  "key": "accessories[].commandHumidity",
                  "condition": {
                    "functionBody": "return ['HumiditySensor'].includes(model.accessories?.[arguments[1]]?.type);"
                  }
                },
                {
                  "key": "accessories[].commandTemperature",
                  "condition": {
                    "functionBody": "return ['TemperatureSensor','Thermostat'].includes(model.accessories?.[arguments[1]]?.type);"
                  }
                },
                {
                  "key": "accessories[].commandSync",
                  "condition": {
                    "functionBody": "return !['StatelessProgrammableSwitch'].includes(model.accessories?.[arguments[1]]?.type);"
                  }
                },
                {
                  "type": "div",
                  "displayFlex": true,
                  "flex-direction": "row",
                  "notitle": true,
                  "condition": {
                    "functionBody": "return model.accessories?.[arguments[1]]?.commandSync !== undefined"
                  },
                  "items": [
                    {
                      "key": "accessories[].syncSchedule.type",
                      "title": "Sync Schedule",
                      "flex": "0 0 auto"
                    },
                    {
                      "key": "accessories[].syncSchedule.time",
                      "flex": "0 0 auto",
                      "condition": {
                          "functionBody": "return ['TIMEOUT', 'INTERVAL'].includes(model.accessories?.[arguments[1]]?.syncSchedule?.type);"
                      }
                    },
                    {
                      "key": "accessories[].syncSchedule.units",
                      "flex": "0 0 auto",
                      "condition": {
                          "functionBody": "return ['TIMEOUT', 'INTERVAL'].includes(model.accessories?.[arguments[1]]?.syncSchedule?.type);"
                      }
                    },
                    {
                      "key": "accessories[].syncSchedule.cron",
                      "flex": "0 0 auto",
                      "condition": {
                          "functionBody": "return model.accessories?.[arguments[1]]?.syncSchedule?.type === 'CRON';"
                      }
                    },
                    {
                      "key": "accessories[].syncSchedule.cronCustom",
                      "flex": "1 0 auto",
                      "condition": {
                          "functionBody": "return model.accessories?.[arguments[1]]?.syncSchedule?.cron === 'CRON_CUSTOM';"
                      }
                    },
                    {
                      "key": "accessories[].syncSchedule.offset",
                      "flex": "0 1 auto",
                      "condition": {
                          "functionBody": "return ['SUNRISE', 'SUNSET', 'DAWN', 'DUSK', 'GOLDEN_HOUR', 'NIGHT'].includes(model.accessories?.[arguments[1]]?.syncSchedule?.type);"
                      }
                    },
                    {
                      "key": "accessories[].syncSchedule.latitude",
                      "flex": "0 1 auto",
                      "condition": {
                          "functionBody": "return ['SUNRISE', 'SUNSET', 'DAWN', 'DUSK', 'GOLDEN_HOUR', 'NIGHT'].includes(model.accessories?.[arguments[1]]?.syncSchedule?.type);"
                      }
                    },
                    {
                      "key": "accessories[].syncSchedule.longitude",
                      "flex": "0 1 auto",
                      "condition": {
                          "functionBody": "return ['SUNRISE', 'SUNSET', 'DAWN', 'DUSK', 'GOLDEN_HOUR', 'NIGHT'].includes(model.accessories?.[arguments[1]]?.syncSchedule?.type);"
                      }
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}