{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schema.nfh.global/MeterServiceProfile/v1.1",
  "title": "MeterServiceProfile",
  "description": "Tariff, regulatory load, and connection profile for a single meter connection point. v1.1: power/demand fields use QuantitativeValue {value, unit} with short unit aliases (W, kW, MW) mapped to QUDT IRIs. Links to a METER resource via meterId. CIM: UsagePoint (IEC 61968-9). Formerly called ConsumptionProfile in ElectricityCredential — that alias is preserved for backward compatibility. Optional admin field serviceStatus carries the connection lifecycle state (CIM UsagePoint.status).",
  "$defs": {
    "QVPower": {
      "$anchor": "QVPower",
      "type": "object",
      "description": "Active power quantity. unit must be one of: W (watt), kW (kilowatt), MW (megawatt).",
      "required": ["value", "unit"],
      "additionalProperties": false,
      "properties": {
        "value": { "type": "number" },
        "unit":  { "type": "string", "enum": ["W", "kW", "MW"] }
      }
    },
    "MeterServiceProfile": {
      "$anchor": "MeterServiceProfile",
      "type": "object",
      "description": "Tariff and regulatory load profile for one meter connection. meterId matches the id of a METER entry in energyResources[].",
      "required": ["meterId", "sanctionedLoad", "tariffCategoryCode"],
      "properties": {
        "meterId":              { "type": "string", "minLength": 1, "description": "Matches the id of a METER entry in customerProfile.energyResources[]." },
        "sanctionedLoad":       { "$ref": "#/$defs/QVPower", "description": "Sanctioned/approved import load. unit: W | kW | MW. CIM: UsagePoint.ratedCurrent × voltage." },
        "sanctionedExportLoad": { "$ref": "#/$defs/QVPower", "description": "Sanctioned/approved grid export limit. unit: W | kW | MW." },
        "billingCycleDay":      { "type": "integer", "minimum": 1, "maximum": 31, "description": "Day of month the billing cycle resets." },
        "contractMaxDemand":    { "$ref": "#/$defs/QVPower", "description": "Maximum demand contracted with the utility. unit: W | kW | MW." },
        "tariffCategoryCode":   { "type": "string", "minLength": 1, "description": "Billing/tariff category code assigned by the utility." },
        "premisesType":         { "type": "string", "enum": ["Residential", "Commercial", "Industrial", "Agricultural"] },
        "connectionType":       { "type": "string", "enum": ["Single-phase", "Three-phase"], "description": "Electrical connection type. CIM: UsagePoint.phaseCode." },
        "paymentMode":          { "type": "string", "enum": ["POSTPAID", "PREPAID"], "description": "Billing/payment modality. Administrative — placed on the profile not the meter. CIM: ESPI AmiBillingReadyKind." },
        "serviceStatus":        { "type": "string", "enum": ["active", "suspended", "closed"], "description": "Lifecycle state of the service connection (UsagePoint), not the meter device. 'active' = energised/billable; 'suspended' = temporarily disconnected with contract on record; 'closed' = permanently terminated. CIM: cim:UsagePoint.status (IEC 61968-9)." }
      }
    }
  }
}
