/**
 * @license
 * Copyright 2022-2024 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { MatterDefinition } from "../MatterDefinition.js";
import {
  ClusterElement as Cluster,
  AttributeElement as Attribute,
  FieldElement as Field,
  EventElement as Event,
  DatatypeElement as Datatype
} from "../../elements/index.js";
const ElectricalPowerMeasurement = Cluster({
  name: "ElectricalPowerMeasurement",
  id: 144,
  asOf: "1.3",
  classification: "application",
  pics: "EPM",
  details: "This cluster provides a mechanism for querying data about electrical power as measured by the server.",
  xref: { document: "cluster", section: "2.13" },
  children: [
    Attribute({ name: "ClusterRevision", id: 65533, type: "ClusterRevision", default: 1 }),
    Attribute({
      name: "FeatureMap",
      id: 65532,
      type: "FeatureMap",
      xref: { document: "cluster", section: "2.13.4" },
      children: [
        Field({
          name: "DIRC",
          conformance: "O.a+",
          constraint: "0",
          description: "DirectCurrent",
          details: "This feature indicates the cluster can measure a direct current.",
          xref: { document: "cluster", section: "2.13.4.1" }
        }),
        Field({
          name: "ALTC",
          conformance: "O.a+",
          constraint: "1",
          description: "AlternatingCurrent",
          details: "This feature indicates the cluster can measure an alternating current.",
          xref: { document: "cluster", section: "2.13.4.2" }
        }),
        Field({
          name: "POLY",
          conformance: "[ALTC]",
          constraint: "2",
          description: "PolyphasePower",
          details: "This feature indicates the cluster represents the collective measurements for a Polyphase power supply.",
          xref: { document: "cluster", section: "2.13.4.3" }
        }),
        Field({
          name: "HARM",
          conformance: "[ALTC]",
          constraint: "3",
          description: "Harmonics",
          details: "This feature indicates the cluster can measure the harmonics of an alternating current.",
          xref: { document: "cluster", section: "2.13.4.4" }
        }),
        Field({
          name: "PWRQ",
          conformance: "[ALTC]",
          constraint: "4",
          description: "PowerQuality",
          details: "This feature indicates the cluster can measure the harmonic phases of an alternating current.",
          xref: { document: "cluster", section: "2.13.4.5" }
        })
      ]
    }),
    Attribute({
      name: "PowerMode",
      id: 0,
      type: "PowerModeEnum",
      access: "R V",
      conformance: "M",
      details: "This shall indicate the current mode of the server. For some servers, such as an EV, this may change depending on the mode of charging or discharging.",
      xref: { document: "cluster", section: "2.13.6.1" }
    }),
    Attribute({
      name: "NumberOfMeasurementTypes",
      id: 1,
      type: "uint8",
      access: "R V",
      conformance: "M",
      constraint: "min 1",
      quality: "F",
      details: "This shall indicate the maximum number of measurement types the server is capable of reporting.",
      xref: { document: "cluster", section: "2.13.6.2" }
    }),
    Attribute({
      name: "Accuracy",
      id: 2,
      type: "list",
      access: "R V",
      conformance: "M",
      constraint: "1 to numberOfMeasurementTypes",
      quality: "F",
      details: "This shall indicate a list of accuracy specifications for the measurement types supported by the server. There shall be an entry for ActivePower, as well as any other measurement types implemented by this server.",
      xref: { document: "cluster", section: "2.13.6.3" },
      children: [Field({ name: "entry", type: "MeasurementAccuracyStruct" })]
    }),
    Attribute({
      name: "Ranges",
      id: 3,
      type: "list",
      access: "R V",
      conformance: "O",
      constraint: "0 to numberOfMeasurementTypes",
      default: [],
      quality: "Q",
      details: "This shall indicate a list of measured ranges for different measurement types. Each measurement type shall have at most one entry in this list, representing the range of measurements in the most recent measurement period.\nThe reporting interval of this attribute shall be manufacturer dependent. The server may choose to omit publication of deltas considered not meaningful.\nThe server shall NOT mark this attribute ready for report if the last time this was done was more recently than 1 second ago.\nThe server may delay marking this attribute ready for report for longer periods if needed, however the server shall NOT delay marking this attribute as ready for report for longer than 60 seconds.",
      xref: { document: "cluster", section: "2.13.6.4" },
      children: [Field({ name: "entry", type: "MeasurementRangeStruct" })]
    }),
    Attribute({
      name: "Voltage",
      id: 4,
      type: "voltage-mV",
      access: "R V",
      conformance: "O",
      default: null,
      quality: "X Q",
      details: "This shall indicate the most recent Voltage reading in millivolts (mV).\nThe reporting interval of this attribute shall be manufacturer dependent. The server may choose to omit publication of deltas considered not meaningful.\nThe server shall NOT mark this attribute ready for report if the last time this was done was more recently than 1 second ago.\nThe server may delay marking this attribute ready for report for longer periods if needed, however the server shall NOT delay marking this attribute as ready for report for longer than 60 seconds.\nIf the voltage cannot be measured, a value of null shall be returned.",
      xref: { document: "cluster", section: "2.13.6.5" }
    }),
    Attribute({
      name: "ActiveCurrent",
      id: 5,
      type: "amperage-mA",
      access: "R V",
      conformance: "O",
      default: null,
      quality: "X Q",
      details: "This shall indicate the most recent ActiveCurrent reading in milliamps (mA).\nA positive value represents current flowing into the server, while a negative value represents current flowing out of the server.\nThe reporting interval of this attribute shall be manufacturer dependent. The server may choose to omit publication of deltas considered not meaningful.\nThe server shall NOT mark this attribute ready for report if the last time this was done was more recently than 1 second ago.\nThe server may delay marking this attribute ready for report for longer periods if needed, however the server shall NOT delay marking this attribute as ready for report for longer than 60 seconds.\nIf the current cannot be measured, a value of null shall be returned.",
      xref: { document: "cluster", section: "2.13.6.6" }
    }),
    Attribute({
      name: "ReactiveCurrent",
      id: 6,
      type: "amperage-mA",
      access: "R V",
      conformance: "[ALTC]",
      default: null,
      quality: "X Q",
      details: "This shall indicate the most recent ReactiveCurrent reading in milliamps (mA).\nA positive value represents current flowing into the server, while a negative value represents current flowing out of the server.\nThe reporting interval of this attribute shall be manufacturer dependent. The server may choose to omit publication of deltas considered not meaningful.\nThe server shall NOT mark this attribute ready for report if the last time this was done was more recently than 1 second ago.\nThe server may delay marking this attribute ready for report for longer periods if needed, however the server shall NOT delay marking this attribute as ready for report for longer than 60 seconds.\nIf the current cannot be measured, a value of null shall be returned.",
      xref: { document: "cluster", section: "2.13.6.7" }
    }),
    Attribute({
      name: "ApparentCurrent",
      id: 7,
      type: "amperage-mA",
      access: "R V",
      conformance: "[ALTC]",
      constraint: "min 0",
      default: null,
      quality: "X Q",
      details: "This shall indicate the most recent ApparentCurrent (square root sum of the squares of active and reactive currents) reading in milliamps (mA).\nThe reporting interval of this attribute shall be manufacturer dependent. The server may choose to omit publication of deltas considered not meaningful.\nThe server shall NOT mark this attribute ready for report if the last time this was done was more recently than 1 second ago.\nThe server may delay marking this attribute ready for report for longer periods if needed, however the server shall NOT delay marking this attribute as ready for report for longer than 60 seconds.\nIf the active or reactive currents cannot be measured, a value of null shall be returned.",
      xref: { document: "cluster", section: "2.13.6.8" }
    }),
    Attribute({
      name: "ActivePower",
      id: 8,
      type: "power-mW",
      access: "R V",
      conformance: "M",
      default: null,
      quality: "X Q",
      details: "This shall indicate the most recent ActivePower reading in milliwatts (mW). If the power cannot be measured, a value of null shall be returned.\nA positive value represents power imported, while a negative value represents power exported.\nThe reporting interval of this attribute shall be manufacturer dependent. The server may choose to omit publication of deltas considered not meaningful.\nThe server shall NOT mark this attribute ready for report if the last time this was done was more recently than 1 second ago.\nThe server may delay marking this attribute ready for report for longer periods if needed, however the server shall NOT delay marking this attribute as ready for report for longer than 60 seconds.\nIf the Polyphase Power feature is set, this value represents the combined active power imported or exported.",
      xref: { document: "cluster", section: "2.13.6.9" }
    }),
    Attribute({
      name: "ReactivePower",
      id: 9,
      type: "power-mW",
      access: "R V",
      conformance: "[ALTC]",
      default: null,
      quality: "X Q",
      details: "This shall indicate the most recent ReactivePower reading in millivolt-amps reactive (mVAR). A positive value represents power imported, while a negative value represents power exported.\nThe reporting interval of this attribute shall be manufacturer dependent. The server may choose to omit publication of deltas considered not meaningful.\nThe server shall NOT mark this attribute ready for report if the last time this was done was more recently than 1 second ago.\nThe server may delay marking this attribute ready for report for longer periods if needed, however the server shall NOT delay marking this attribute as ready for report for longer than 60 seconds.\nIf the reactive power cannot be measured, a value of null shall be returned.\nIf the Polyphase Power feature is supported, this value represents the combined reactive power imported or exported.",
      xref: { document: "cluster", section: "2.13.6.10" }
    }),
    Attribute({
      name: "ApparentPower",
      id: 10,
      type: "power-mW",
      access: "R V",
      conformance: "[ALTC]",
      default: null,
      quality: "X Q",
      details: "This shall indicate the most recent ApparentPower reading in millivolt-amps (mVA).\nA positive value represents power imported, while a negative value represents power exported.\nThe reporting interval of this attribute shall be manufacturer dependent. The server may choose to omit publication of deltas considered not meaningful.\nThe server shall NOT mark this attribute ready for report if the last time this was done was more recently than 1 second ago.\nThe server may delay marking this attribute ready for report for longer periods if needed, however the server shall NOT delay marking this attribute as ready for report for longer than 60 seconds.\nIf the apparent power cannot be measured, a value of null shall be returned.",
      xref: { document: "cluster", section: "2.13.6.11" }
    }),
    Attribute({
      name: "RmsVoltage",
      id: 11,
      type: "voltage-mV",
      access: "R V",
      conformance: "[ALTC]",
      default: null,
      quality: "X Q",
      details: "This shall indicate the most recent RMSVoltage reading in millivolts (mV).\nThe reporting interval of this attribute shall be manufacturer dependent. The server may choose to omit publication of deltas considered not meaningful.\nThe server shall NOT mark this attribute ready for report if the last time this was done was more recently than 1 second ago.\nThe server may delay marking this attribute ready for report for longer periods if needed, however the server shall NOT delay marking this attribute as ready for report for longer than 60 seconds.\nIf the RMS voltage cannot be measured, a value of null shall be returned.",
      xref: { document: "cluster", section: "2.13.6.12" }
    }),
    Attribute({
      name: "RmsCurrent",
      id: 12,
      type: "amperage-mA",
      access: "R V",
      conformance: "[ALTC]",
      default: null,
      quality: "X Q",
      details: "This shall indicate the most recent RMSCurrent reading in milliamps (mA).\nA positive value represents current flowing into the server, while a negative value represents current flowing out of the server.\nThe reporting interval of this attribute shall be manufacturer dependent. The server may choose to omit publication of deltas considered not meaningful.\nThe server shall NOT mark this attribute ready for report if the last time this was done was more recently than 1 second ago.\nThe server may delay marking this attribute ready for report for longer periods if needed, however the server shall NOT delay marking this attribute as ready for report for longer than 60 seconds.\nIf the RMS current cannot be measured, a value of null shall be returned.",
      xref: { document: "cluster", section: "2.13.6.13" }
    }),
    Attribute({
      name: "RmsPower",
      id: 13,
      type: "power-mW",
      access: "R V",
      conformance: "[ALTC]",
      default: null,
      quality: "X Q",
      details: "This shall indicate the most recent RMSPower reading in milliwatts (mW).\nA positive value represents power imported, while a negative value represents power exported.\nThe reporting interval of this attribute shall be manufacturer dependent. The server may choose to omit publication of deltas considered not meaningful.\nThe server shall NOT mark this attribute ready for report if the last time this was done was more recently than 1 second ago.\nThe server may delay marking this attribute ready for report for longer periods if needed, however the server shall NOT delay marking this attribute as ready for report for longer than 60 seconds.\nIf the RMS power cannot be measured, a value of null shall be returned.",
      xref: { document: "cluster", section: "2.13.6.14" }
    }),
    Attribute({
      name: "Frequency",
      id: 14,
      type: "int64",
      access: "R V",
      conformance: "[ALTC]",
      constraint: "0 to 1000000",
      default: null,
      quality: "X Q",
      details: "This shall indicate the most recent Frequency reading in millihertz (mHz).\nThe reporting interval of this attribute shall be manufacturer dependent. The server may choose to omit publication of deltas considered not meaningful.\nThe server shall NOT mark this attribute ready for report if the last time this was done was more recently than 1 second ago.\nThe server may delay marking this attribute ready for report for longer periods if needed, however the server shall NOT delay marking this attribute as ready for report for longer than 60 seconds.\nIf the frequency cannot be measured, a value of null shall be returned.",
      xref: { document: "cluster", section: "2.13.6.15" }
    }),
    Attribute({
      name: "HarmonicCurrents",
      id: 15,
      type: "list",
      access: "R V",
      conformance: "HARM",
      constraint: "desc",
      default: null,
      quality: "X Q",
      details: "This shall indicate a list of HarmonicMeasurementStruct values, with each HarmonicMeasurementStruct representing the harmonic current reading for the harmonic order specified by Order.\nThe reporting interval of this attribute shall be manufacturer dependent. The server may choose to omit publication of deltas considered not meaningful.\nThe server shall NOT mark this attribute ready for report if the last time this was done was more recently than 1 second ago.\nThe server may delay marking this attribute ready for report for longer periods if needed, however the server shall NOT delay marking this attribute as ready for report for longer than 60 seconds.",
      xref: { document: "cluster", section: "2.13.6.16" },
      children: [Field({ name: "entry", type: "HarmonicMeasurementStruct" })]
    }),
    Attribute({
      name: "HarmonicPhases",
      id: 16,
      type: "list",
      access: "R V",
      conformance: "PWRQ",
      constraint: "desc",
      default: null,
      quality: "X Q",
      details: "This shall indicate a list of HarmonicMeasurementStruct values, with each HarmonicMeasurementStruct representing the most recent phase of the harmonic current reading for the harmonic\norder specified by Order.\nThe reporting interval of this attribute shall be manufacturer dependent. The server may choose to omit publication of deltas considered not meaningful.\nThe server shall NOT mark this attribute ready for report if the last time this was done was more recently than 1 second ago.\nThe server may delay marking this attribute ready for report for longer periods if needed, however the server shall NOT delay marking this attribute as ready for report for longer than 60 seconds.",
      xref: { document: "cluster", section: "2.13.6.17" },
      children: [Field({ name: "entry", type: "HarmonicMeasurementStruct" })]
    }),
    Attribute({
      name: "PowerFactor",
      id: 17,
      type: "int64",
      access: "R V",
      conformance: "[ALTC]",
      constraint: "-10000 to 10000",
      default: null,
      quality: "X Q",
      details: "This shall indicate the Power Factor ratio in +/- 1/100ths of a percent.\nThe reporting interval of this attribute shall be manufacturer dependent. The server may choose to omit publication of deltas considered not meaningful.\nThe server shall NOT mark this attribute ready for report if the last time this was done was more recently than 1 second ago.\nThe server may delay marking this attribute ready for report for longer periods if needed, however the server shall NOT delay marking this attribute as ready for report for longer than 60 seconds.",
      xref: { document: "cluster", section: "2.13.6.18" }
    }),
    Attribute({
      name: "NeutralCurrent",
      id: 18,
      type: "amperage-mA",
      access: "R V",
      conformance: "[POLY]",
      default: null,
      quality: "X Q",
      details: "This shall indicate the most recent NeutralCurrent reading in milliamps (mA). Typically this is a derived value, taking the magnitude of the vector sum of phase currents.\nIf the neutral current cannot be measured or derived, a value of null shall be returned.\nA positive value represents an imbalance between the phase currents when power is imported. A negative value represents an imbalance between the phase currents when power is exported.\nThe reporting interval of this attribute shall be manufacturer dependent. The server may choose to omit publication of deltas considered not meaningful.\nThe server shall NOT mark this attribute ready for report if the last time this was done was more recently than 1 second ago.\nThe server may delay marking this attribute ready for report for longer periods if needed, however the server shall NOT delay marking this attribute as ready for report for longer than 60 seconds.",
      xref: { document: "cluster", section: "2.13.6.19" }
    }),
    Event({
      name: "MeasurementPeriodRanges",
      id: 0,
      access: "R V",
      conformance: "Ranges",
      priority: "info",
      details: "If supported, this event shall be generated at the end of a measurement period. The start and end times for measurement periods shall be determined by the server, and may represent overlapping periods.",
      xref: { document: "cluster", section: "2.13.7.1" },
      children: [Field({
        name: "Ranges",
        id: 0,
        type: "list",
        access: "R V",
        conformance: "M",
        default: [],
        details: "This shall indicate the value of the Ranges attribute at the time of event generation.",
        xref: { document: "cluster", section: "2.13.7.1.1" },
        children: [Field({ name: "entry", type: "MeasurementRangeStruct" })]
      })]
    }),
    Datatype({
      name: "PowerModeEnum",
      type: "enum8",
      xref: { document: "cluster", section: "2.13.5.1" },
      children: [
        Field({ name: "Unknown", id: 0, conformance: "M" }),
        Field({ name: "Dc", id: 1, conformance: "M", description: "Direct current" }),
        Field({
          name: "Ac",
          id: 2,
          conformance: "M",
          description: "Alternating current, either single-phase or polyphase"
        })
      ]
    }),
    Datatype({
      name: "MeasurementRangeStruct",
      type: "struct",
      details: "This struct shall indicate the maximum and minimum values of a given measurement type during a measurement period, along with the observation times of these values.\nA server which does not have the ability to determine the time in UTC, or has not yet done so, shall use the system time fields to specify the measurement period and observation times.\nA server which has determined the time in UTC shall use the timestamp fields to specify the measurement period and observation times. Such a server may also include the systime fields to indicate how many seconds had passed since boot for a given timestamp; this allows for client-side resolution of UTC time for previous reports that only included systime.",
      xref: { document: "cluster", section: "2.13.5.2" },
      children: [
        Field({
          name: "MeasurementType",
          id: 0,
          type: "MeasurementTypeEnum",
          conformance: "M",
          details: "This field shall be the type of measurement for the range provided.",
          xref: { document: "cluster", section: "2.13.5.2.1" }
        }),
        Field({
          name: "Min",
          id: 1,
          type: "int64",
          conformance: "M",
          details: "This field shall be the smallest measured value for the associated measurement over either the period between StartTimestamp and EndTimestamp, or the period between StartSystime and EndSystime, or both.",
          xref: { document: "cluster", section: "2.13.5.2.2" }
        }),
        Field({
          name: "Max",
          id: 2,
          type: "int64",
          conformance: "M",
          details: "This field shall be the largest measured value for the associated measurement over the period between either StartTimestamp and EndTimestamp or the period between StartSystime and EndSystime, or both.",
          xref: { document: "cluster", section: "2.13.5.2.3" }
        }),
        Field({
          name: "StartTimestamp",
          id: 3,
          type: "epoch-s",
          conformance: "EndTimestamp",
          details: "This field shall be the timestamp in UTC of the beginning of the measurement period.\nIf the server had not yet determined the time in UTC at or before the beginning of the measurement period, or does not have the capability of determining the time in UTC, this field shall be omitted.",
          xref: { document: "cluster", section: "2.13.5.2.4" }
        }),
        Field({
          name: "EndTimestamp",
          id: 4,
          type: "epoch-s",
          conformance: "desc",
          constraint: "min startTimestamp1",
          details: "This field shall be the timestamp in UTC of the end of the measurement period.\nIf the server had not yet determined the time in UTC at or before the beginning of the measurement period, or does not have the capability of determining the time in UTC, this field shall be omitted.",
          xref: { document: "cluster", section: "2.13.5.2.5" }
        }),
        Field({
          name: "MinTimestamp",
          id: 5,
          type: "epoch-s",
          conformance: "EndTimestamp",
          details: "This field shall be the most recent timestamp in UTC that the value in the Min field was measured.\nThis field shall be greater than or equal to the value of the StartTimestamp field. This field shall be less than or equal to the value of the EndTimestamp field.",
          xref: { document: "cluster", section: "2.13.5.2.6" }
        }),
        Field({
          name: "MaxTimestamp",
          id: 6,
          type: "epoch-s",
          conformance: "EndTimestamp",
          constraint: "min minTimestamp1",
          details: "This field shall be the most recent timestamp in UTC of the value in the Max field. This field shall be greater than or equal to the value of the StartTimestamp field. This field shall be less than or equal to the value of the EndTimestamp field.",
          xref: { document: "cluster", section: "2.13.5.2.7" }
        }),
        Field({
          name: "StartSystime",
          id: 7,
          type: "systime-ms",
          conformance: "EndSystime",
          details: "This field shall be the time since boot of the beginning of the measurement period.\nIf the server had determined the time in UTC at or before the start of the measurement period, this field may be omitted along with the EndSystime, MinSystime, and MaxSystime fields.",
          xref: { document: "cluster", section: "2.13.5.2.8" }
        }),
        Field({
          name: "EndSystime",
          id: 8,
          type: "systime-ms",
          conformance: "desc",
          constraint: "min startSystime1",
          details: "This field shall be the time since boot of the end of the measurement period.\nIf the server had determined the time in UTC at the end of the measurement period, this field may be omitted along with the StartSystime field, MinSystime, and MaxSystime fields.",
          xref: { document: "cluster", section: "2.13.5.2.9" }
        }),
        Field({
          name: "MinSystime",
          id: 9,
          type: "systime-ms",
          conformance: "EndSystime",
          details: "This field shall be the measurement time since boot of the value in the Min field was measured. This field shall be greater than or equal to the value of the StartSystime field.\nThis field shall be less than or equal to the value of the EndSystime field.",
          xref: { document: "cluster", section: "2.13.5.2.10" }
        }),
        Field({
          name: "MaxSystime",
          id: 10,
          type: "systime-ms",
          conformance: "EndSystime",
          constraint: "min minSystime1",
          details: "This field shall be the measurement time since boot of the value in the Max field. This field shall be greater than or equal to the value of the StartSystime field.\nThis field shall be less than or equal to the value of the EndSystime field.",
          xref: { document: "cluster", section: "2.13.5.2.11" }
        })
      ]
    }),
    Datatype({
      name: "HarmonicMeasurementStruct",
      type: "struct",
      xref: { document: "cluster", section: "2.13.5.3" },
      children: [
        Field({
          name: "Order",
          id: 0,
          type: "uint8",
          conformance: "M",
          constraint: "min 1",
          default: 1,
          details: "This field shall be the order of the harmonic being measured. Typically this is an odd number, but servers may choose to report even harmonics.",
          xref: { document: "cluster", section: "2.13.5.3.1" }
        }),
        Field({
          name: "Measurement",
          id: 1,
          type: "int64",
          conformance: "M",
          default: null,
          quality: "X",
          details: "This field shall be the measured value for the given harmonic order.\nFor the Harmonic Currents attribute, this value is the most recently measured harmonic current reading in milliamps (mA). A positive value indicates that the measured harmonic current is positive, and a negative value indicates that the measured harmonic current is negative.\nFor the Harmonic Phases attribute, this value is the most recent phase of the given harmonic order\nin millidegrees (mDeg). A positive value indicates that the measured phase is leading, and a negative value indicates that the measured phase is lagging.\nIf this measurement is not currently available, a value of null shall be returned.",
          xref: { document: "cluster", section: "2.13.5.3.2" }
        })
      ]
    })
  ]
});
MatterDefinition.children.push(ElectricalPowerMeasurement);
export {
  ElectricalPowerMeasurement
};
//# sourceMappingURL=ElectricalPowerMeasurement.js.map
