{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "oneOf": [
        {
            "title": "Device Connected",
            "description": "Schema for marking a device as connected",
            "type": "object",
            "properties": {
                "status": {
                    "type": "string",
                    "enum": [
                        "connected"
                    ]
                },
                "connectedAt": {
                    "oneOf": [
                        {
                            "type": "string"
                        },
                        {
                            "type": "number"
                        },
                        {
                            "type": "object",
                            "properties": {
                                "$date": {
                                    "type": "string"
                                }
                            },
                            "additionalProperties": false,
                            "required": [
                                "$date"
                            ]
                        }
                    ]
                }
            },
            "required": [
                "status"
            ],
            "additionalProperties": false
        },
        {
            "title": "Device Disconnected",
            "description": "Schema for marking a device as disconnected",
            "type": "object",
            "properties": {
                "status": {
                    "type": "string",
                    "enum": [
                        "disconnected"
                    ]
                },
                "connectedAt": {
                    "oneOf": [
                        {
                            "type": "string"
                        },
                        {
                            "type": "number"
                        },
                        {
                            "type": "object",
                            "properties": {
                                "$date": {
                                    "type": "string"
                                }
                            },
                            "additionalProperties": false,
                            "required": [
                                "$date"
                            ]
                        }
                    ]
                },
                "disconnectedAt": {
                    "oneOf": [
                        {
                            "type": "string"
                        },
                        {
                            "type": "number"
                        },
                        {
                            "type": "object",
                            "properties": {
                                "$date": {
                                    "type": "string"
                                }
                            },
                            "additionalProperties": false,
                            "required": [
                                "$date"
                            ]
                        }
                    ]
                },
                "disconnectReason": {
                    "type": "string",
                    "maxLength": 1024
                },
                "messagesFromClient": {
                    "type": "number"
                },
                "messagesToClient": {
                    "type": "number"
                }
            },
            "required": [
                "status"
            ],
            "additionalProperties": false
        }
    ]
}