{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Charging device state",
  "description": "All encompassing states of a charging device.",
  "subtopic": "/state",
  "type": "object",
  "required": [
    "timestamp",
    "version",
    "serialNumber",
    "connectionState",
    "chargingDeviceState"
  ],
  "properties": {
    "timestamp": {
      "type": "string",
      "format": "date-time",
      "description": "Timestamp in ISO8601 Format (YYYY-MM-DDTHH:mm:ss.sssZ). The timestamp defines the point in time at which the message was sent.",
      "examples": [
        "2015-10-21T16:29:00.000Z"
      ]
    },
    "version": {
      "type": "string",
      "description": "Version of the M2X protocol [Major].[Minor].[Patch] (e.g. 1.3.2)",
      "examples": [
        "1.0.0"
      ]
    },
    "serialNumber": {
      "type": "string",
      "description": "Serial number of the charging device."
    },
    "manufacturer": {
      "type": "string",
      "description": "Manufacturer of the charging device."
    },
    "connectionState": {
      "type": "string",
      "enum": [
        "ONLINE",
        "OFFLINE",
        "CONNECTION_BROKEN"
      ],
      "description": "ONLINE: connection between charging device and broker is active. OFFLINE: connection between charging device and broker has gone offline in a coordinated way. CONNECTION_BROKEN: The connection between charging device and broker has unexpectedly ended."
    },
    "chargingDeviceState": {
      "type": "object",
      "description": "The charging device state contains the current status of the charging device, including its requests.",
      "required": [
        "chargingDeviceId",
        "currentCharging",
        "requestStates"
      ],
      "properties": {
        "chargingDeviceId": {
          "type": "string",
          "description": "Unique identifier of the individual charging device."
        },
        "currentCharging": {
          "description": "Current charging process.",
          "type": "object",
          "required": [
            "chargingSessionId"
          ],
          "properties": {
            "chargingSessionId": {
              "type": "string",
              "description": "Current charging process."
            },
            "descriptor": {
              "type": "string",
              "description": "Description of the charging process."
            }
          }
        },
        "requestStates": {
          "type": "array",
          "description": "Array of upcoming and current requests.",
          "items": {
            "type": "object",
            "required": [
              "requestId",
              "requestStatus"
            ],
            "properties": {
              "requestId": {
                "type": "string",
                "description": "Id of a request to be referred to in this state."
              },
              "chargingProcess": {
                "description": "Charging process.",
                "type": "object",
                "required": [
                  "charging"
                ],
                "properties": {
                  "charging": {
                    "type": "string",
                    "description": "Current charging process.",
                    "examples": [
                      "CHARGING",
                      "DONE",
                      "IDLE"
                    ]
                  },
                  "temperature": {
                    "type": "number",
                    "description": "Current temperature of the charging device.",
                    "unit": "°C"
                  },
                  "chargingRate": {
                    "type": "number",
                    "description": "Current charging rate of the charging device.",
                    "unit": "kW"
                  },
                  "derating": {
                    "type": "boolean",
                    "description": "Indicates if the charging device is in derating mode."
                  },
                  "descriptor": {
                    "type": "string",
                    "description": "Description of the charging process."
                  }
                }
              },
              "requestType": {
                "type": "string",
                "description": "requestType of the request. Optional: Only for informational or visualization purposes."
              },
              "requestStatus": {
                "type": "string",
                "description": "Status of the request.",
                "enum": [
                  "PENDING",
                  "RUNNING",
                  "PAUSED",
                  "FINISHED",
                  "FAILED"
                ]
              },
              "resultDescription": {
                "type": "string",
                "description": "Description of the result. Errors will be transmitted in errors."
              }
            }
          }
        },
        "operatingHours": {
          "type": "number",
          "description": "Total operating hours of the charging device.",
          "unit": "h"
        },
        "errors": {
          "type": "array",
          "description": "Array of error-objects. All active errors of the charging device should be in the list. An empty array indicates that the charging device has no active errors.",
          "items": {
            "type": "object",
            "required": [
              "errorType",
              "errorLevel"
            ],
            "properties": {
              "errorType": {
                "type": "string",
                "description": "Type of error."
              },
              "requestId": {
                "type": "string",
                "description": "Id of the request that is caused by or related to the error."
              },
              "errorDescription": {
                "type": "string",
                "description": "Verbose description of error."
              },
              "errorLevel": {
                "type": "string",
                "description": "Description of the error level, which is warning or fatal. WARNING: charging device is ready to start (e.g., maintenance cycle expiration warning). FATAL: charging device is not in running condition, user intervention required.",
                "enum": [
                  "WARNING",
                  "FATAL"
                ]
              }
            }
          }
        }
      }
    }
  }
}
