{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/hypervolt/json-schema/hypervolt-user-json-schema.json",
  "title": "UserJson",
  "x-generated": "2026-11-17",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/hypervolt-openapi.json#/components/schemas/UserJson",
  "type": "object",
  "required": [
    "id"
  ],
  "properties": {
    "id": {
      "description": "KeycloaK ID",
      "type": "string"
    },
    "realm": {
      "description": "Keycloak Realm",
      "type": "string"
    },
    "chargers": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/ChargerJson"
      }
    },
    "placements": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/PlacementJson"
      }
    },
    "email": {
      "type": "string"
    },
    "picture": {
      "type": "string"
    },
    "view_mode": {
      "description": "The `view_mode` in the returned JSON can be one of ReadOnlyView, FullView. ReadOnlyView means the user can only perform read actions (e.g. they are a Octopus Operator using Watson), and thus should not be presented with action buttons.  FullView means the user can perform all actions, (e.g. they are a hypervolt Admin using Watson) and so should be presented with all the buttons.",
      "type": "string"
    },
    "name": {
      "type": "string"
    },
    "creation_date": {
      "type": "string",
      "format": "date-time"
    }
  },
  "$defs": {
    "AC": {
      "title": "AC",
      "type": "object"
    },
    "BatteryJson": {
      "title": "BatteryJson",
      "description": "A home-battery",
      "type": "object",
      "properties": {
        "make": {
          "type": "string"
        },
        "model": {
          "type": "string"
        },
        "unit_count": {
          "type": "integer",
          "format": "int32"
        },
        "unit_capacity_in_wh": {
          "type": "integer",
          "format": "int32"
        },
        "power_coupling": {
          "$ref": "#/$defs/PowerCoupling"
        }
      }
    },
    "Both": {
      "title": "Both",
      "type": "object"
    },
    "ChargerJson": {
      "title": "ChargerJson",
      "type": "object",
      "required": [
        "id",
        "adopted_at"
      ],
      "properties": {
        "id": {
          "description": "Device ID",
          "type": "string"
        },
        "model": {
          "description": "Charger model ('Home 2.0', 'Home 3.0', 'Home 3 Pro')",
          "type": "string"
        },
        "adopted_at": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "Ct2Setup": {
      "title": "Ct2Setup",
      "type": "string",
      "enum": [
        "battery",
        "hybrid",
        "none",
        "solar"
      ]
    },
    "CurrencyJson": {
      "title": "CurrencyJson",
      "type": "object",
      "required": [
        "code",
        "name",
        "symbol"
      ],
      "properties": {
        "code": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "symbol": {
          "type": "string"
        }
      }
    },
    "DC": {
      "title": "DC",
      "type": "object"
    },
    "EnergySupplier": {
      "title": "EnergySupplier",
      "description": "The Energy supplier for this location.",
      "oneOf": [
        {
          "$ref": "#/$defs/Known"
        },
        {
          "$ref": "#/$defs/Other"
        }
      ]
    },
    "GB": {
      "title": "GB",
      "type": "object",
      "required": [
        "street",
        "postalCode"
      ],
      "properties": {
        "street": {
          "type": "string"
        },
        "town": {
          "type": "string"
        },
        "postalCode": {
          "type": "string"
        }
      }
    },
    "KeycloakUserId": {
      "title": "KeycloakUserId",
      "type": "object",
      "required": [
        "id"
      ],
      "properties": {
        "id": {
          "type": "string"
        }
      }
    },
    "Known": {
      "title": "Known",
      "description": "A known energy supplier",
      "type": "object",
      "required": [
        "supplier"
      ],
      "properties": {
        "supplier": {
          "description": "A known energy supplier. Can be one of BritishGas Edf Eon Octopus Ovo ScottishPower",
          "type": "string"
        }
      }
    },
    "Other": {
      "title": "Other",
      "description": "The an unknown energy supplier",
      "type": "object",
      "required": [
        "supplier"
      ],
      "properties": {
        "supplier": {
          "type": "string"
        }
      }
    },
    "PlacementJson": {
      "title": "PlacementJson",
      "type": "object",
      "required": [
        "id",
        "version",
        "owner",
        "tz",
        "currency",
        "created_at"
      ],
      "properties": {
        "id": {
          "description": "Placement ID",
          "type": "string",
          "format": "uuid"
        },
        "version": {
          "type": "integer",
          "format": "int32"
        },
        "owner": {
          "$ref": "#/$defs/KeycloakUserId"
        },
        "name": {
          "type": "string"
        },
        "charger_id": {
          "description": "Device ID",
          "type": "string"
        },
        "tz": {
          "description": "A IANA time-zone",
          "type": "string"
        },
        "currency": {
          "$ref": "#/$defs/CurrencyJson"
        },
        "country": {
          "description": "Two-letter ISO3166-1 country code",
          "type": "string"
        },
        "active_energy_provider": {
          "description": "An energy provider ID",
          "type": "string"
        },
        "created_at": {
          "type": "string",
          "format": "date-time"
        },
        "updated_at": {
          "type": "string",
          "format": "date-time"
        },
        "archived": {
          "type": "boolean"
        },
        "has_solar": {
          "type": "boolean"
        },
        "home_batteries": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/BatteryJson"
          }
        },
        "ct2": {
          "$ref": "#/$defs/Ct2Setup"
        },
        "ct1": {
          "type": "boolean"
        },
        "ct1_inverted": {
          "type": "boolean"
        },
        "meter_ref": {
          "description": "A reference to a specific boundary meter, prefixed by the scheme.",
          "type": "string"
        },
        "address": {
          "$ref": "#/$defs/PostalAddress"
        },
        "energy_supplier": {
          "$ref": "#/$defs/EnergySupplier"
        },
        "view_mode": {
          "description": "The `view_mode` in the returned JSON can be one of ReadOnlyView, FullView. ReadOnlyView means the user can only perform read actions (e.g. they are a Octopus Operator using Watson), and thus should not be presented with action buttons.  FullView means the user can perform all actions, (e.g. they are a hypervolt Admin using Watson) and so should be presented with all the buttons.",
          "type": "string"
        },
        "boost_only_smart_charging": {
          "type": "boolean"
        }
      }
    },
    "PostalAddress": {
      "title": "PostalAddress",
      "oneOf": [
        {
          "$ref": "#/$defs/GB"
        }
      ]
    },
    "PowerCoupling": {
      "title": "PowerCoupling",
      "oneOf": [
        {
          "$ref": "#/$defs/AC"
        },
        {
          "$ref": "#/$defs/Both"
        },
        {
          "$ref": "#/$defs/DC"
        }
      ]
    }
  }
}