{
  "settings": {
    "type": "object",
    "title": "Device Settings",
    "properties": {}
  },
  "definitions": {
    "schema": {},
    "init": {
      "type": "object",
      "required": [
        "level",
        "reference"
      ],
      "description": "Set a level that is started if a player is referenced in a device message. If message contains json with reference key, the level is started with the matching or a new player as first variable agument.",
      "properties": {
        "level": {
          "type": "string",
          "enum": []
        },
        "reference": {
          "type": "string"
        }
      }
    },
    "devices_response": {
      "type": "string",
      "description": "On match, respond to the incoming message."
    }
  },
  "action_variables": {
    "onDeviceMessage": {
      "match": {},
      "message": {
        "type": [
          "string",
          "number",
          "integer",
          "object",
          "array"
        ]
      }
    }
  },
  "actions": {
    "send": {
      "type": "object",
      "title": "Send Message",
      "description": "Send a Message to your device.",
      "documentation": "https://docs.adaptorex.org/basics/actions/devices/send.html",
      "required": [
        "to"
      ],
      "default": {
        "message": ""
      },
      "additionalProperties": false,
      "properties": {
        "to": {
          "$ref": "#/definitions/devices_items"
        },
        "message": {
          "type": [
            "string",
            "number",
            "boolean",
            "object",
            "array"
          ]
        },
        "is_float": {
          "type": "boolean",
          "format": "checkbox",
          "description": "specify if number message should be send as floating point value."
        },
        "path": {
          "type": [
            "string"
          ]
        },
        "method": {
          "type": "string",
          "description": "Method requests to your HTTP device will be send with.",
          "enum": [
            "GET",
            "POST"
          ]
        },
        "header": {
          "type": "string"
        }
      }
    },
    "onDeviceMessage": {
      "type": "object",
      "title": "On Device Message",
      "mode": "listen",
      "documentation": "https://docs.adaptorex.org/basics/actions/devices/onDeviceMessage.html",
      "resolveAdaptorVariables": false,
      "required": [
        "device"
      ],
      "default": {
        "if": []
      },
      "additionalProperties": false,
      "properties": {
        "device": {
          "$ref": "#/definitions/devices_items"
        },
        "if": {
          "type": "array",
          "title": "if",
          "items": {
            "title": "condition",
            "oneOf": [
              {
                "title": "Equals",
                "description": "If message equals the or any of the following values",
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "equals"
                ],
                "properties": {
                  "field": {
                    "$ref": "#/definitions/field"
                  },
                  "equals": {
                    "$ref": "#/definitions/equals"
                  },
                  "case_sensitive": {
                    "type": "boolean",
                    "format": "checkbox",
                    "title": "case sensitive"
                  },
                  "next": {
                    "$ref": "#/definitions/next"
                  }
                }
              },
              {
                "title": "Contains",
                "description": "If message contains the or any of the following values",
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "contains"
                ],
                "properties": {
                  "field": {
                    "$ref": "#/definitions/field"
                  },
                  "contains": {
                    "$ref": "#/definitions/contains"
                  },
                  "case_sensitive": {
                    "type": "boolean",
                    "format": "checkbox",
                    "title": "case sensitive"
                  },
                  "next": {
                    "$ref": "#/definitions/next"
                  }
                }
              },
              {
                "title": "Less Than",
                "description": "If message is value that is less than",
                "type": "object",
                "default": {
                  "lessThan": ""
                },
                "additionalProperties": false,
                "properties": {
                  "field": {
                    "$ref": "#/definitions/field"
                  },
                  "lessThan": {
                    "$ref": "#/definitions/lessThan"
                  },
                  "next": {
                    "$ref": "#/definitions/next"
                  }
                }
              },
              {
                "title": "Greater Than",
                "description": "If message is value that is greater than",
                "type": "object",
                "default": {
                  "greaterThan": ""
                },
                "additionalProperties": false,
                "properties": {
                  "field": {
                    "$ref": "#/definitions/field"
                  },
                  "greaterThan": {
                    "$ref": "#/definitions/greaterThan"
                  },
                  "next": {
                    "$ref": "#/definitions/next"
                  }
                }
              },
              {
                "title": "Regular Expression",
                "description": "If regular expression returns anything when used on incoming message",
                "type": "object",
                "default": {
                  "regex": ""
                },
                "additionalProperties": false,
                "properties": {
                  "field": {
                    "$ref": "#/definitions/field"
                  },
                  "regex": {
                    "$ref": "#/definitions/regex"
                  },
                  "next": {
                    "$ref": "#/definitions/next"
                  }
                }
              },
              {
                "title": "Javascript function",
                "description": "If javascript function returns true. Use value as function argument.",
                "type": "object",
                "default": {
                  "javascript": ""
                },
                "additionalProperties": false,
                "properties": {
                  "field": {
                    "$ref": "#/definitions/field"
                  },
                  "javascript": {
                    "$ref": "#/definitions/javascript"
                  },
                  "next": {
                    "$ref": "#/definitions/next"
                  }
                }
              },
              {
                "title": "Database Query",
                "description": "If database find query returns a valid document. You can use event 'payload' action var in query: [[action.payload]]",
                "type": "object",
                "default": {
                  "find": ""
                },
                "additionalProperties": false,
                "properties": {
                  "find": {
                    "$ref": "#/definitions/find"
                  },
                  "next": {
                    "$ref": "#/definitions/next"
                  }
                }
              }
            ]
          }
        },
        "else": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "next": {
              "$ref": "#/definitions/next"
            }
          }
        },
        "keep_listening": {
          "$ref": "#/definitions/keep_listening"
        }
      }
    }
  },
  "data_variables": {
    "http": {
      "incoming": {
        "type": [
          "string",
          "number",
          "integer",
          "boolean",
          "object",
          "array"
        ]
      }
    },
    "tcp": {
      "incoming": {
        "type": [
          "string",
          "number",
          "integer",
          "boolean",
          "object",
          "array"
        ]
      }
    },
    "udp": {
      "incoming": {
        "type": [
          "string",
          "number",
          "integer",
          "boolean",
          "object",
          "array"
        ]
      }
    },
    "osc": {
      "incoming": {
        "type": [
          "string",
          "number",
          "integer",
          "boolean",
          "object",
          "array"
        ]
      }
    },
    "serial": {
      "incoming": {
        "type": [
          "string",
          "number",
          "integer",
          "boolean",
          "object",
          "array"
        ]
      }
    }
  },
  "collections": {
    "http": {
      "type": "object",
      "title": "HTTP Device",
      "required": [
        "settings",
        "name"
      ],
      "events": {
        "incomingMessage": {}
      },
      "properties": {
        "name": {
          "type": "string",
          "pattern": "^[0-9A-Za-z_-]*$",
          "propertyOrder": 1
        },
        "settings": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "to_device": {
              "type": "object",
              "required": [
                "url"
              ],
              "additionalProperties": false,
              "properties": {
                "url": {
                  "type": "string",
                  "pattern": "https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}(\\.[a-zA-Z0-9()])?\\b([-a-zA-Z0-9()!@:%_\\+.~#?&\\/\\/=]*)",
                  "description": "Set url adaptor will send requests to. E.g. http://yourdomain.com:8080/mydevice"
                },
                "method": {
                  "type": "string",
                  "description": "Method requests to your device will be send with.",
                  "enum": [
                    "GET",
                    "POST"
                  ]
                }
              }
            },
            "from_device": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "method": {
                  "type": "string",
                  "description": "Method the device sends requests to adaptor.",
                  "enum": [
                    "GET",
                    "POST"
                  ]
                },
                "webhook": {
                  "title": "Webhook URLs",
                  "$ref": "#/definitions/webhooks"
                }
              }
            }
          }
        }
      }
    },
    "tcp": {
      "type": "object",
      "title": "TCP Device",
      "events": {
        "incomingMessage": {}
      },
      "required": [
        "settings",
        "name"
      ],
      "properties": {
        "name": {
          "type": "string",
          "pattern": "^[0-9A-Za-z_-]*$",
          "propertyOrder": 1
        },
        "settings": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "port": {
              "type": "integer",
              "title": "Device Port",
              "default": 0,
              "description": "TCP port the device is listening to."
            },
            "ip": {
              "type": "string",
              "title": "Device IP",
              "description": "Set the ip address of your device so adaptor:ex can send messages to it."
            },
            "adaptor_port": {
              "type": "integer",
              "title": "Adaptor Port",
              "description": "Set a port on which adaptor listens for messages from the TCP device."
            }
          }
        }
      }
    },
    "udp": {
      "type": "object",
      "title": "UDP Device",
      "events": {
        "incomingMessage": {}
      },
      "required": [
        "settings",
        "name"
      ],
      "properties": {
        "name": {
          "type": "string",
          "pattern": "^[0-9A-Za-z_-]*$",
          "propertyOrder": 1
        },
        "settings": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "port": {
              "type": "integer",
              "title": "Device Port",
              "default": 0,
              "description": "UDP port the device is listening to."
            },
            "ip": {
              "type": "string",
              "title": "Device IP",
              "description": "Set the ip address of your device so adaptor can send messages to it.",
              "default": "0.0.0.0"
            },
            "adaptor_port": {
              "type": "integer",
              "title": "Adaptor Port",
              "description": "Set a port on which adaptor listens for messages from the UDP device."
            }
          }
        }
      }
    },
    "osc": {
      "type": "object",
      "title": "OSC Device",
      "events": {
        "incomingMessage": {}
      },
      "required": [
        "settings",
        "name"
      ],
      "properties": {
        "name": {
          "type": "string",
          "pattern": "^[0-9A-Za-z_-]*$",
          "propertyOrder": 1
        },
        "settings": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "port": {
              "type": "integer",
              "title": "Device Port",
              "default": 0,
              "description": "OSC port the device is listening to."
            },
            "ip": {
              "type": "string",
              "title": "Device IP",
              "description": "Set the ip address of your device so adaptor can send messages to it.",
              "default": "0.0.0.0"
            },
            "path": {
              "type": "string",
              "title": "Prepend Path",
              "description": "Set an OSC formatted address that is prepended to every message sent to the OSC device"
            },
            "adaptor_port": {
              "type": "integer",
              "title": "Adaptor Port",
              "description": "Set a port on which adaptor listens for messages from the OSC device."
            }
          }
        }
      }
    },
    "serial": {
      "type": "object",
      "title": "Serial Device",
      "events": {
        "incomingMessage": {}
      },
      "required": [
        "settings",
        "name"
      ],
      "properties": {
        "name": {
          "type": "string",
          "pattern": "^[0-9A-Za-z_-]*$",
          "propertyOrder": 1
        },
        "settings": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "port",
            "baud"
          ],
          "properties": {
            "port": {
              "type": "string",
              "title": "Serial Port",
              "description": "Serial port of connected device (e.g. '/dev/ttyACM0' or 'COM0')",
              "enum": [
                "No port available"
              ]
            },
            "baud": {
              "type": "number",
              "title": "Baud Rate",
              "default": 115200,
              "enum": [
                300,
                1200,
                2400,
                4800,
                9600,
                19200,
                38400,
                57600,
                74880,
                115200,
                230400,
                250000,
                500000,
                1000000,
                2000000
              ]
            }
          }
        }
      }
    }
  }
}