/**
 * @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,
  DatatypeElement as Datatype
} from "../../elements/index.js";
const EnergyPreference = Cluster({
  name: "EnergyPreference",
  id: 155,
  classification: "application",
  pics: "EPREF",
  details: "This cluster provides an interface to specify preferences for how devices should consume energy.\nNOTE Support for Energy Preference cluster is provisional.",
  xref: { document: "cluster", section: "9.5" },
  children: [
    Attribute({ name: "ClusterRevision", id: 65533, type: "ClusterRevision", default: 1 }),
    Attribute({
      name: "FeatureMap",
      id: 65532,
      type: "FeatureMap",
      xref: { document: "cluster", section: "9.5.4" },
      children: [
        Field({
          name: "BALA",
          conformance: "O.a+",
          constraint: "0",
          description: "EnergyBalance",
          details: "This feature allows a user to select from a list of energy balances with associated descriptions of which strategies a device will use to target the specified balance.",
          xref: { document: "cluster", section: "9.5.4.1" }
        }),
        Field({
          name: "LPMS",
          conformance: "O.a+",
          constraint: "1",
          description: "LowPowerModeSensitivity",
          details: "This feature allows the user to select a condition or set of conditions which will cause the device to switch to a mode using less power. For example, a device might provide a scale of durations that must elapse without user interaction before it goes to sleep.",
          xref: { document: "cluster", section: "9.5.4.2" }
        })
      ]
    }),
    Attribute({
      name: "EnergyBalances",
      id: 0,
      type: "list",
      access: "R V",
      conformance: "BALA",
      constraint: "2 to 10",
      quality: "F",
      details: "Indicates a list of BalanceStructs, each representing a step along a linear scale\nof relative priorities. A Step field with a value of zero shall indicate that the device SHOULD entirely favor the priority specified by the first element in EnergyPriorities; whereas a Step field with a value of 100 shall indicate that the device SHOULD entirely favor the priority specified by the second element in EnergyPriorities. The midpoint value of 50 shall indicate an even split between the two priorities.\nThis shall contain at least two BalanceStructs.\nEach BalanceStruct shall have a Step field larger than the Step field on the previous BalanceStruct in the list.\nThe first BalanceStruct shall have a Step value of zero, and the last BalanceStruct shall have a Step value of 100.",
      xref: { document: "cluster", section: "9.5.6.1" },
      children: [Field({ name: "entry", type: "BalanceStruct" })]
    }),
    Attribute({
      name: "CurrentEnergyBalance",
      id: 1,
      type: "uint8",
      access: "RW VO",
      conformance: "BALA",
      quality: "N",
      details: "Indicates the current preference of the user for balancing different priorities during device use. The value of this attribute is the index, 0-based, into the EnergyBalances attribute for the currently selected balance.\nIf an attempt is made to set this attribute to an index outside the maximum index for EnergyBalances, a response with the status code CONSTRAINT_ERROR shall be returned.\nIf the value of EnergyBalances changes after an update, the device shall migrate the value of the CurrentEnergyBalance attribute to the index which the manufacturer specifies most closely matches the previous value, while preserving extreme preferences as follows:\n  1. If the previous value of CurrentEnergyBalance was zero, indicating a total preference for the      priority specified by the first element in EnergyPriorities, the new value of      CurrentEnergyBalance shall also be zero.\n  2. If the previous value of CurrentEnergyBalance was the index of the last BalanceStruct in the      previous value of EnergyBalances, indicating a total preference for the priority specified by      the last element in EnergyPriorities, the new value of CurrentEnergyBalance shall be the index      of the last element in the updated value of EnergyBalances.",
      xref: { document: "cluster", section: "9.5.6.2" }
    }),
    Attribute({
      name: "EnergyPriorities",
      id: 2,
      type: "list",
      access: "R V",
      conformance: "BALA",
      constraint: "2",
      quality: "F",
      details: "Indicates two extremes for interpreting the values in the EnergyBalances attribute. These two priorities shall be in opposition to each other; e.g. Comfort vs. Efficiency or Speed vs. WaterConsumption.\nIf the value of EnergyPriorities changes after an update to represent a new balance between priorities, the value of the CurrentEnergyBalance attribute shall be set to its default.",
      xref: { document: "cluster", section: "9.5.6.3" },
      children: [Field({ name: "entry", type: "EnergyPriorityEnum" })]
    }),
    Attribute({
      name: "LowPowerModeSensitivities",
      id: 3,
      type: "list",
      access: "R V",
      conformance: "LPMS",
      constraint: "2 to 10",
      quality: "F",
      details: "Indicates a list of BalanceStructs, each representing a condition or set of conditions for the device to enter a low power mode.\nThis shall contain at least two BalanceStructs.\nEach BalanceStruct shall have a Step field larger than the Step field on the previous BalanceStruct in the list.",
      xref: { document: "cluster", section: "9.5.6.4" },
      children: [Field({ name: "entry", type: "BalanceStruct" })]
    }),
    Attribute({
      name: "CurrentLowPowerModeSensitivity",
      id: 4,
      type: "uint8",
      access: "RW VO",
      conformance: "LPMS",
      quality: "N",
      details: "Indicates the current preference of the user for determining when the device should enter a low power mode. The value of this attribute is the index, 0-based, into the LowPowerModeSensitivities attribute for the currently selected preference.\nIf an attempt is made to set this attribute to an index outside the maximum index for LowPowerModeSensitivities, a response with the status code CONSTRAINT_ERROR shall be returned.\nIf the value of LowPowerModeSensitivities changes after an update, the device shall migrate the value of the LowPowerModeSensitivity attribute to the index which the manufacturer specifies most closely matches the previous value.",
      xref: { document: "cluster", section: "9.5.6.5" }
    }),
    Datatype({
      name: "EnergyPriorityEnum",
      type: "enum8",
      xref: { document: "cluster", section: "9.5.5.1" },
      children: [
        Field({
          name: "Comfort",
          id: 0,
          conformance: "M",
          details: "This value shall emphasize user comfort; e.g. local temperature for a thermostat.",
          xref: { document: "cluster", section: "9.5.5.1.1" }
        }),
        Field({
          name: "Speed",
          id: 1,
          conformance: "M",
          details: "This value shall emphasize how quickly a device accomplishes its targeted use; e.g. how quickly a robot vacuum completes a cleaning cycle.",
          xref: { document: "cluster", section: "9.5.5.1.2" }
        }),
        Field({
          name: "Efficiency",
          id: 2,
          conformance: "M",
          details: "This value shall emphasize how much energy a device uses; e.g. electricity usage for a Pump.",
          xref: { document: "cluster", section: "9.5.5.1.3" }
        }),
        Field({ name: "WaterConsumption", id: 3, conformance: "M" })
      ]
    }),
    Datatype({
      name: "BalanceStruct",
      type: "struct",
      details: "This represents a step along a scale of preferences.",
      xref: { document: "cluster", section: "9.5.5.2" },
      children: [
        Field({
          name: "Step",
          id: 0,
          type: "percent",
          conformance: "M",
          quality: "F",
          details: "This field shall indicate the relative value of this step.",
          xref: { document: "cluster", section: "9.5.5.2.1" }
        }),
        Field({
          name: "Label",
          id: 1,
          type: "string",
          conformance: "O",
          constraint: "max 64",
          quality: "F",
          details: "This field shall indicate an optional string explaining which actions a device might take at the given step value.",
          xref: { document: "cluster", section: "9.5.5.2.2" }
        })
      ]
    })
  ]
});
MatterDefinition.children.push(EnergyPreference);
export {
  EnergyPreference
};
//# sourceMappingURL=EnergyPreference.js.map
