{
	"$schema": "http://json-schema.org/draft-07/schema#",
	"$id": "https://fastybird.com/schemas/simulator-scenario-v1.json",
	"title": "Simulator Device Scenario",
	"description": "Schema for device simulator scenario YAML configuration files",
	"type": "object",
	"required": ["version", "name", "devices"],
	"additionalProperties": false,
	"properties": {
		"version": {
			"type": "string",
			"pattern": "^[0-9]+\\.[0-9]+$",
			"description": "Schema version (e.g., '1.0')"
		},
		"name": {
			"type": "string",
			"minLength": 1,
			"maxLength": 100,
			"description": "Scenario display name"
		},
		"description": {
			"type": "string",
			"maxLength": 500,
			"description": "Optional scenario description"
		},
		"rooms": {
			"type": "array",
			"items": {
				"$ref": "#/definitions/room"
			},
			"description": "Rooms to create (optional)"
		},
		"devices": {
			"type": "array",
			"items": {
				"$ref": "#/definitions/device"
			},
			"minItems": 1,
			"description": "Devices to create"
		},
		"scenes": {
			"type": "array",
			"items": {
				"$ref": "#/definitions/scene"
			},
			"description": "Scenes to create (optional)"
		}
	},
	"definitions": {
		"room": {
			"type": "object",
			"required": ["id", "name"],
			"additionalProperties": false,
			"properties": {
				"id": {
					"type": "string",
					"pattern": "^[a-z][a-z0-9-]*$",
					"minLength": 1,
					"maxLength": 50,
					"description": "Unique room identifier for device references"
				},
				"name": {
					"type": "string",
					"minLength": 1,
					"maxLength": 100,
					"description": "Room display name"
				},
				"type": {
					"type": "string",
					"enum": ["room", "zone"],
					"default": "room",
					"description": "Space type: 'room' for physical rooms, 'zone' for outdoor areas or logical groupings"
				},
				"category": {
					"type": "string",
					"description": "Space category matching the type (e.g., living_room for rooms, outdoor_backyard for zones)"
				}
			}
		},
		"device": {
			"type": "object",
			"required": ["name", "category", "channels"],
			"additionalProperties": false,
			"properties": {
				"id": {
					"type": "string",
					"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$",
					"description": "Optional UUID for idempotent creation"
				},
				"name": {
					"type": "string",
					"minLength": 1,
					"maxLength": 100,
					"description": "Device display name"
				},
				"category": {
					"type": "string",
					"minLength": 1,
					"description": "Device category (e.g., lighting, sensor, thermostat)"
				},
				"room": {
					"type": "string",
					"description": "Reference to room id from rooms array"
				},
				"description": {
					"type": "string",
					"maxLength": 500,
					"description": "Optional device description"
				},
				"auto_simulate": {
					"type": "boolean",
					"default": false,
					"description": "Enable automatic value simulation"
				},
				"simulate_interval": {
					"type": "integer",
					"minimum": 1000,
					"maximum": 3600000,
					"default": 5000,
					"description": "Auto-simulation interval in milliseconds"
				},
				"behavior_mode": {
					"type": "string",
					"enum": ["default", "realistic"],
					"default": "default",
					"description": "Simulation behavior mode: default (timer-based) or realistic (reacts to user commands)"
				},
				"lighting_role": {
					"type": "string",
					"enum": ["main", "task", "ambient", "accent", "night", "other", "hidden"],
					"description": "Lighting domain role for this device"
				},
				"climate_role": {
					"type": "string",
					"enum": ["auto", "heating_only", "cooling_only", "auxiliary", "sensor", "hidden"],
					"description": "Climate domain role for this device"
				},
				"sensor_role": {
					"type": "string",
					"enum": ["environment", "safety", "security", "air_quality", "energy", "other", "hidden"],
					"description": "Sensor domain role for this device"
				},
				"covers_role": {
					"type": "string",
					"enum": ["primary", "blackout", "sheer", "outdoor", "hidden"],
					"description": "Covers domain role for this device"
				},
				"channels": {
					"type": "array",
					"items": {
						"$ref": "#/definitions/channel"
					},
					"minItems": 1,
					"description": "Channels for this device"
				}
			}
		},
		"channel": {
			"type": "object",
			"required": ["category", "properties"],
			"additionalProperties": false,
			"properties": {
				"id": {
					"type": "string",
					"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$",
					"description": "Optional UUID for idempotent creation"
				},
				"category": {
					"type": "string",
					"minLength": 1,
					"description": "Channel category (e.g., light, temperature, thermostat)"
				},
				"name": {
					"type": "string",
					"maxLength": 100,
					"description": "Optional channel display name"
				},
				"properties": {
					"type": "array",
					"items": {
						"$ref": "#/definitions/property"
					},
					"minItems": 1,
					"description": "Properties for this channel"
				}
			}
		},
		"property": {
			"type": "object",
			"required": ["category"],
			"additionalProperties": false,
			"properties": {
				"id": {
					"type": "string",
					"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$",
					"description": "Optional UUID for idempotent creation"
				},
				"category": {
					"type": "string",
					"minLength": 1,
					"description": "Property category (e.g., on, brightness, temperature)"
				},
				"data_type": {
					"type": "string",
					"enum": ["bool", "char", "uchar", "short", "ushort", "int", "uint", "float", "string", "enum"],
					"description": "Optional data type override for multi-datatype properties"
				},
				"value": {
					"oneOf": [
						{ "type": "string" },
						{ "type": "number" },
						{ "type": "boolean" }
					],
					"description": "Initial property value"
				}
			}
		},
		"scene": {
			"type": "object",
			"required": ["name", "actions"],
			"additionalProperties": false,
			"properties": {
				"id": {
					"type": "string",
					"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$",
					"description": "Optional UUID for idempotent creation"
				},
				"name": {
					"type": "string",
					"minLength": 1,
					"maxLength": 100,
					"description": "Scene display name"
				},
				"description": {
					"type": "string",
					"maxLength": 500,
					"description": "Optional scene description"
				},
				"category": {
					"type": "string",
					"description": "Scene category (e.g., movie, night, morning, away)"
				},
				"room": {
					"type": "string",
					"description": "Reference to room id from rooms array"
				},
				"enabled": {
					"type": "boolean",
					"default": true,
					"description": "Whether the scene is enabled"
				},
				"actions": {
					"type": "array",
					"items": {
						"$ref": "#/definitions/scene_action"
					},
					"minItems": 1,
					"description": "Actions to perform when scene is triggered"
				}
			}
		},
		"scene_action": {
			"type": "object",
			"required": ["device_id", "property_id", "value"],
			"additionalProperties": false,
			"properties": {
				"device_id": {
					"type": "string",
					"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$",
					"description": "UUID of the target device"
				},
				"channel_id": {
					"type": "string",
					"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$",
					"description": "Optional UUID of the target channel"
				},
				"property_id": {
					"type": "string",
					"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$",
					"description": "UUID of the target property"
				},
				"value": {
					"oneOf": [
						{ "type": "string" },
						{ "type": "number" },
						{ "type": "boolean" }
					],
					"description": "Value to set on the property"
				}
			}
		}
	}
}
