diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml
index d14d188a2fb6e4..6ed2ea89cf9dd2 100644
--- a/.github/workflows/tests.yaml
+++ b/.github/workflows/tests.yaml
@@ -206,6 +206,7 @@ jobs:
src/app/zap-templates/zcl/data-model/chip/sample-mei-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/electrical-energy-measurement-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/electrical-power-measurement-cluster.xml \
+ src/app/zap-templates/zcl/data-model/chip/energy-calendar-cluster.xml \
"
- name: Build Apps
run: |
diff --git a/docs/zap_clusters.md b/docs/zap_clusters.md
index 41679143b5c428..523ef5735f36d2 100644
--- a/docs/zap_clusters.md
+++ b/docs/zap_clusters.md
@@ -82,6 +82,7 @@ Generally regenerate using one of:
| 151 | 0x97 | Messages |
| 152 | 0x98 | DeviceEnergyManagement |
| 153 | 0x99 | EnergyEvse |
+| 154 | 0x9A | EnergyCalendar |
| 155 | 0x9B | EnergyPreference |
| 156 | 0x9C | PowerTopology |
| 157 | 0x9D | EnergyEvseMode |
diff --git a/scripts/rules.matterlint b/scripts/rules.matterlint
index e7bd644249a13e..47b4712a7ff90d 100644
--- a/scripts/rules.matterlint
+++ b/scripts/rules.matterlint
@@ -117,6 +117,7 @@ load "../src/app/zap-templates/zcl/data-model/chip/resource-monitoring-cluster.x
load "../src/app/zap-templates/zcl/data-model/chip/sample-mei-cluster.xml";
load "../src/app/zap-templates/zcl/data-model/chip/electrical-energy-measurement-cluster.xml";
load "../src/app/zap-templates/zcl/data-model/chip/electrical-power-measurement-cluster.xml";
+load "../src/app/zap-templates/zcl/data-model/chip/energy-calendar-cluster.xml";
all endpoints {
// These attributes follow a different code path and do not have to be
diff --git a/src/app/zap-templates/zcl/data-model/chip/energy-calendar-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/energy-calendar-cluster.xml
new file mode 100644
index 00000000000000..d9e0d53d99d22b
--- /dev/null
+++ b/src/app/zap-templates/zcl/data-model/chip/energy-calendar-cluster.xml
@@ -0,0 +1,116 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Energy Management
+ Energy Calendar
+ 0x009A
+ ENERGY_CALENDAR_CLUSTER
+ The Energy Calendar Cluster provides a mechanism for communicating schedules associated with various forms of energy consumption
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+ CalendarID
+ Name
+ ProviderID
+ EventID
+ StartDate
+ CalendarPeriods
+ SpecialDays
+ CurrentDay
+ NextDay
+ CurrentTransition
+ CurrentPeakPeriod
+ NextPeakPeriod
+
+
diff --git a/src/app/zap-templates/zcl/zcl-with-test-extensions.json b/src/app/zap-templates/zcl/zcl-with-test-extensions.json
index bc1a29c4b4aa3b..c34e11d60742ce 100644
--- a/src/app/zap-templates/zcl/zcl-with-test-extensions.json
+++ b/src/app/zap-templates/zcl/zcl-with-test-extensions.json
@@ -47,6 +47,7 @@
"microwave-oven-control-cluster.xml",
"door-lock-cluster.xml",
"ecosystem-information-cluster.xml",
+ "energy-calendar-cluster.xml",
"energy-preference-cluster.xml",
"electrical-energy-measurement-cluster.xml",
"electrical-power-measurement-cluster.xml",
@@ -659,6 +660,16 @@
"NeutralCurrent",
"FeatureMap"
],
+ "Energy Calendar": [
+ "CalendarPeriods",
+ "SpecialDays",
+ "CurrentDay",
+ "NextDay",
+ "CurrentTransition",
+ "CurrentPeakPeriod",
+ "NextPeakPeriod",
+ "FeatureMap"
+ ],
"Power Topology": ["FeatureMap"],
"Valve Configuration and Control": ["RemainingDuration"],
"Boolean State Configuration": ["CurrentSensitivityLevel"],
diff --git a/src/app/zap-templates/zcl/zcl.json b/src/app/zap-templates/zcl/zcl.json
index db4526e39cbbde..bed533e61b0cc7 100644
--- a/src/app/zap-templates/zcl/zcl.json
+++ b/src/app/zap-templates/zcl/zcl.json
@@ -43,6 +43,7 @@
"ecosystem-information-cluster.xml",
"electrical-energy-measurement-cluster.xml",
"electrical-power-measurement-cluster.xml",
+ "energy-calendar-cluster.xml",
"energy-evse-cluster.xml",
"energy-evse-mode-cluster.xml",
"energy-preference-cluster.xml",
@@ -653,6 +654,16 @@
"NeutralCurrent",
"FeatureMap"
],
+ "Energy Calendar": [
+ "CalendarPeriods",
+ "SpecialDays",
+ "CurrentDay",
+ "NextDay",
+ "CurrentTransition",
+ "CurrentPeakPeriod",
+ "NextPeakPeriod",
+ "FeatureMap"
+ ],
"Power Topology": ["FeatureMap"],
"Valve Configuration and Control": ["RemainingDuration"],
"Boolean State Configuration": ["CurrentSensitivityLevel"],
diff --git a/src/app/zap_cluster_list.json b/src/app/zap_cluster_list.json
index a047340147ece5..0beffd37128c37 100644
--- a/src/app/zap_cluster_list.json
+++ b/src/app/zap_cluster_list.json
@@ -33,6 +33,7 @@
"DIAGNOSTIC_LOGS_CLUSTER": [],
"DISHWASHER_ALARM_CLUSTER": [],
"DISHWASHER_MODE_CLUSTER": [],
+ "ENERGY_CALENDAR_CLUSTER": [],
"MICROWAVE_OVEN_MODE_CLUSTER": [],
"DOOR_LOCK_CLUSTER": [],
"ECOSYSTEM_INFORMATION_CLUSTER": [],
@@ -178,6 +179,7 @@
"DIAGNOSTIC_LOGS_CLUSTER": ["diagnostic-logs-server"],
"DISHWASHER_ALARM_CLUSTER": ["dishwasher-alarm-server"],
"DISHWASHER_MODE_CLUSTER": ["mode-base-server"],
+ "ENERGY_CALENDAR_CLUSTER": ["energy-calendar-server"],
"MICROWAVE_OVEN_MODE_CLUSTER": ["mode-base-server"],
"DOOR_LOCK_CLUSTER": ["door-lock-server"],
"ECOSYSTEM_INFORMATION_CLUSTER": ["ecosystem-information-server"],
diff --git a/src/controller/data_model/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter
index 1ba56719ab4549..288c2d6af457fd 100644
--- a/src/controller/data_model/controller-clusters.matter
+++ b/src/controller/data_model/controller-clusters.matter
@@ -5437,6 +5437,91 @@ cluster EnergyEvse = 153 {
timed command ClearTargets(): DefaultSuccess = 7;
}
+/** The Energy Calendar Cluster provides a mechanism for communicating schedules associated with various forms of energy consumption */
+cluster EnergyCalendar = 154 {
+ revision 3;
+
+ enum PeakPeriodSeverityEnum : enum8 {
+ kUnused = 0;
+ kLow = 1;
+ kMedium = 2;
+ kHigh = 3;
+ }
+
+ bitmap AuxiliaryLoadBitmap : bitmap8 {
+ kAuxiliarySwitch1 = 0x1;
+ kAuxiliarySwitch2 = 0x2;
+ kAuxiliarySwitch3 = 0x4;
+ kAuxiliarySwitch4 = 0x8;
+ kAuxiliarySwitch5 = 0x10;
+ kAuxiliarySwitch6 = 0x20;
+ kAuxiliarySwitch7 = 0x40;
+ kAuxiliarySwitch8 = 0x80;
+ }
+
+ bitmap Feature : bitmap32 {
+ kPricingTier = 0x1;
+ kFriendlyCredit = 0x2;
+ kAuxiliaryLoad = 0x4;
+ kPeakPeriod = 0x8;
+ }
+
+ bitmap TransitionDayOfWeekBitmap : bitmap8 {
+ kSunday = 0x1;
+ kMonday = 0x2;
+ kTuesday = 0x4;
+ kWednesday = 0x8;
+ kThursday = 0x10;
+ kFriday = 0x20;
+ kSaturday = 0x40;
+ }
+
+ struct TransitionStruct {
+ int16u transitionTime = 0;
+ optional int32u priceTier = 1;
+ optional boolean friendlyCredit = 2;
+ optional AuxiliaryLoadBitmap auxiliaryLoad = 3;
+ }
+
+ struct DayStruct {
+ optional epoch_s date = 0;
+ optional TransitionDayOfWeekBitmap daysOfWeek = 1;
+ TransitionStruct transitions[] = 2;
+ optional int32u calendarID = 3;
+ }
+
+ struct CalendarPeriodStruct {
+ nullable epoch_s startDate = 0;
+ DayStruct days[] = 1;
+ }
+
+ struct PeakPeriodStruct {
+ PeakPeriodSeverityEnum severity = 0;
+ int16u peakPeriod = 1;
+ nullable epoch_s startTime = 2;
+ nullable epoch_s endTime = 3;
+ }
+
+ readonly attribute nullable int32u calendarID = 0;
+ readonly attribute nullable char_string<12> name = 1;
+ readonly attribute nullable int32u providerID = 2;
+ readonly attribute nullable int32u eventID = 3;
+ readonly attribute nullable epoch_s startDate = 4;
+ readonly attribute nullable CalendarPeriodStruct calendarPeriods[] = 5;
+ readonly attribute nullable DayStruct specialDays[] = 6;
+ readonly attribute nullable DayStruct currentDay = 7;
+ readonly attribute nullable DayStruct nextDay = 8;
+ readonly attribute nullable TransitionStruct currentTransition = 9;
+ readonly attribute optional nullable PeakPeriodStruct currentPeakPeriod = 10;
+ readonly attribute optional nullable PeakPeriodStruct nextPeakPeriod = 11;
+ readonly attribute command_id generatedCommandList[] = 65528;
+ readonly attribute command_id acceptedCommandList[] = 65529;
+ readonly attribute event_id eventList[] = 65530;
+ readonly attribute attrib_id attributeList[] = 65531;
+ readonly attribute bitmap32 featureMap = 65532;
+ readonly attribute int16u clusterRevision = 65533;
+}
+
/** This cluster provides an interface to specify preferences for how devices should consume energy. */
provisional cluster EnergyPreference = 155 {
revision 1;
diff --git a/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java b/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java
index 2ce04c328ded6f..be757382e3e212 100644
--- a/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java
+++ b/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java
@@ -32659,6 +32659,571 @@ public void onSuccess(byte[] tlv) {
}
}
+ public static class EnergyCalendarCluster extends BaseChipCluster {
+ public static final long CLUSTER_ID = 154L;
+
+ private static final long CALENDAR_ID_ATTRIBUTE_ID = 0L;
+ private static final long NAME_ATTRIBUTE_ID = 1L;
+ private static final long PROVIDER_ID_ATTRIBUTE_ID = 2L;
+ private static final long EVENT_ID_ATTRIBUTE_ID = 3L;
+ private static final long START_DATE_ATTRIBUTE_ID = 4L;
+ private static final long CALENDAR_PERIODS_ATTRIBUTE_ID = 5L;
+ private static final long SPECIAL_DAYS_ATTRIBUTE_ID = 6L;
+ private static final long CURRENT_DAY_ATTRIBUTE_ID = 7L;
+ private static final long NEXT_DAY_ATTRIBUTE_ID = 8L;
+ private static final long CURRENT_TRANSITION_ATTRIBUTE_ID = 9L;
+ private static final long CURRENT_PEAK_PERIOD_ATTRIBUTE_ID = 10L;
+ private static final long NEXT_PEAK_PERIOD_ATTRIBUTE_ID = 11L;
+ private static final long GENERATED_COMMAND_LIST_ATTRIBUTE_ID = 65528L;
+ private static final long ACCEPTED_COMMAND_LIST_ATTRIBUTE_ID = 65529L;
+ private static final long EVENT_LIST_ATTRIBUTE_ID = 65530L;
+ private static final long ATTRIBUTE_LIST_ATTRIBUTE_ID = 65531L;
+ private static final long FEATURE_MAP_ATTRIBUTE_ID = 65532L;
+ private static final long CLUSTER_REVISION_ATTRIBUTE_ID = 65533L;
+
+ public EnergyCalendarCluster(long devicePtr, int endpointId) {
+ super(devicePtr, endpointId, CLUSTER_ID);
+ }
+
+ @Override
+ @Deprecated
+ public long initWithDevice(long devicePtr, int endpointId) {
+ return 0L;
+ }
+
+ public interface CalendarIDAttributeCallback extends BaseAttributeCallback {
+ void onSuccess(@Nullable Long value);
+ }
+
+ public interface NameAttributeCallback extends BaseAttributeCallback {
+ void onSuccess(@Nullable String value);
+ }
+
+ public interface ProviderIDAttributeCallback extends BaseAttributeCallback {
+ void onSuccess(@Nullable Long value);
+ }
+
+ public interface EventIDAttributeCallback extends BaseAttributeCallback {
+ void onSuccess(@Nullable Long value);
+ }
+
+ public interface StartDateAttributeCallback extends BaseAttributeCallback {
+ void onSuccess(@Nullable Long value);
+ }
+
+ public interface CalendarPeriodsAttributeCallback extends BaseAttributeCallback {
+ void onSuccess(@Nullable List value);
+ }
+
+ public interface SpecialDaysAttributeCallback extends BaseAttributeCallback {
+ void onSuccess(@Nullable List value);
+ }
+
+ public interface CurrentDayAttributeCallback extends BaseAttributeCallback {
+ void onSuccess(@Nullable ChipStructs.EnergyCalendarClusterDayStruct value);
+ }
+
+ public interface NextDayAttributeCallback extends BaseAttributeCallback {
+ void onSuccess(@Nullable ChipStructs.EnergyCalendarClusterDayStruct value);
+ }
+
+ public interface CurrentTransitionAttributeCallback extends BaseAttributeCallback {
+ void onSuccess(@Nullable ChipStructs.EnergyCalendarClusterTransitionStruct value);
+ }
+
+ public interface CurrentPeakPeriodAttributeCallback extends BaseAttributeCallback {
+ void onSuccess(@Nullable ChipStructs.EnergyCalendarClusterPeakPeriodStruct value);
+ }
+
+ public interface NextPeakPeriodAttributeCallback extends BaseAttributeCallback {
+ void onSuccess(@Nullable ChipStructs.EnergyCalendarClusterPeakPeriodStruct value);
+ }
+
+ public interface GeneratedCommandListAttributeCallback extends BaseAttributeCallback {
+ void onSuccess(List value);
+ }
+
+ public interface AcceptedCommandListAttributeCallback extends BaseAttributeCallback {
+ void onSuccess(List value);
+ }
+
+ public interface EventListAttributeCallback extends BaseAttributeCallback {
+ void onSuccess(List value);
+ }
+
+ public interface AttributeListAttributeCallback extends BaseAttributeCallback {
+ void onSuccess(List value);
+ }
+
+ public void readCalendarIDAttribute(
+ CalendarIDAttributeCallback callback) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CALENDAR_ID_ATTRIBUTE_ID);
+
+ readAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, CALENDAR_ID_ATTRIBUTE_ID, true);
+ }
+
+ public void subscribeCalendarIDAttribute(
+ CalendarIDAttributeCallback callback, int minInterval, int maxInterval) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CALENDAR_ID_ATTRIBUTE_ID);
+
+ subscribeAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, CALENDAR_ID_ATTRIBUTE_ID, minInterval, maxInterval);
+ }
+
+ public void readNameAttribute(
+ NameAttributeCallback callback) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, NAME_ATTRIBUTE_ID);
+
+ readAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ @Nullable String value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, NAME_ATTRIBUTE_ID, true);
+ }
+
+ public void subscribeNameAttribute(
+ NameAttributeCallback callback, int minInterval, int maxInterval) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, NAME_ATTRIBUTE_ID);
+
+ subscribeAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ @Nullable String value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, NAME_ATTRIBUTE_ID, minInterval, maxInterval);
+ }
+
+ public void readProviderIDAttribute(
+ ProviderIDAttributeCallback callback) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, PROVIDER_ID_ATTRIBUTE_ID);
+
+ readAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, PROVIDER_ID_ATTRIBUTE_ID, true);
+ }
+
+ public void subscribeProviderIDAttribute(
+ ProviderIDAttributeCallback callback, int minInterval, int maxInterval) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, PROVIDER_ID_ATTRIBUTE_ID);
+
+ subscribeAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, PROVIDER_ID_ATTRIBUTE_ID, minInterval, maxInterval);
+ }
+
+ public void readEventIDAttribute(
+ EventIDAttributeCallback callback) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, EVENT_ID_ATTRIBUTE_ID);
+
+ readAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, EVENT_ID_ATTRIBUTE_ID, true);
+ }
+
+ public void subscribeEventIDAttribute(
+ EventIDAttributeCallback callback, int minInterval, int maxInterval) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, EVENT_ID_ATTRIBUTE_ID);
+
+ subscribeAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, EVENT_ID_ATTRIBUTE_ID, minInterval, maxInterval);
+ }
+
+ public void readStartDateAttribute(
+ StartDateAttributeCallback callback) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, START_DATE_ATTRIBUTE_ID);
+
+ readAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, START_DATE_ATTRIBUTE_ID, true);
+ }
+
+ public void subscribeStartDateAttribute(
+ StartDateAttributeCallback callback, int minInterval, int maxInterval) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, START_DATE_ATTRIBUTE_ID);
+
+ subscribeAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, START_DATE_ATTRIBUTE_ID, minInterval, maxInterval);
+ }
+
+ public void readCalendarPeriodsAttribute(
+ CalendarPeriodsAttributeCallback callback) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CALENDAR_PERIODS_ATTRIBUTE_ID);
+
+ readAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ @Nullable List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, CALENDAR_PERIODS_ATTRIBUTE_ID, true);
+ }
+
+ public void subscribeCalendarPeriodsAttribute(
+ CalendarPeriodsAttributeCallback callback, int minInterval, int maxInterval) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CALENDAR_PERIODS_ATTRIBUTE_ID);
+
+ subscribeAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ @Nullable List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, CALENDAR_PERIODS_ATTRIBUTE_ID, minInterval, maxInterval);
+ }
+
+ public void readSpecialDaysAttribute(
+ SpecialDaysAttributeCallback callback) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, SPECIAL_DAYS_ATTRIBUTE_ID);
+
+ readAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ @Nullable List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, SPECIAL_DAYS_ATTRIBUTE_ID, true);
+ }
+
+ public void subscribeSpecialDaysAttribute(
+ SpecialDaysAttributeCallback callback, int minInterval, int maxInterval) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, SPECIAL_DAYS_ATTRIBUTE_ID);
+
+ subscribeAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ @Nullable List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, SPECIAL_DAYS_ATTRIBUTE_ID, minInterval, maxInterval);
+ }
+
+ public void readCurrentDayAttribute(
+ CurrentDayAttributeCallback callback) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CURRENT_DAY_ATTRIBUTE_ID);
+
+ readAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ @Nullable ChipStructs.EnergyCalendarClusterDayStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, CURRENT_DAY_ATTRIBUTE_ID, true);
+ }
+
+ public void subscribeCurrentDayAttribute(
+ CurrentDayAttributeCallback callback, int minInterval, int maxInterval) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CURRENT_DAY_ATTRIBUTE_ID);
+
+ subscribeAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ @Nullable ChipStructs.EnergyCalendarClusterDayStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, CURRENT_DAY_ATTRIBUTE_ID, minInterval, maxInterval);
+ }
+
+ public void readNextDayAttribute(
+ NextDayAttributeCallback callback) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, NEXT_DAY_ATTRIBUTE_ID);
+
+ readAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ @Nullable ChipStructs.EnergyCalendarClusterDayStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, NEXT_DAY_ATTRIBUTE_ID, true);
+ }
+
+ public void subscribeNextDayAttribute(
+ NextDayAttributeCallback callback, int minInterval, int maxInterval) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, NEXT_DAY_ATTRIBUTE_ID);
+
+ subscribeAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ @Nullable ChipStructs.EnergyCalendarClusterDayStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, NEXT_DAY_ATTRIBUTE_ID, minInterval, maxInterval);
+ }
+
+ public void readCurrentTransitionAttribute(
+ CurrentTransitionAttributeCallback callback) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CURRENT_TRANSITION_ATTRIBUTE_ID);
+
+ readAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ @Nullable ChipStructs.EnergyCalendarClusterTransitionStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, CURRENT_TRANSITION_ATTRIBUTE_ID, true);
+ }
+
+ public void subscribeCurrentTransitionAttribute(
+ CurrentTransitionAttributeCallback callback, int minInterval, int maxInterval) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CURRENT_TRANSITION_ATTRIBUTE_ID);
+
+ subscribeAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ @Nullable ChipStructs.EnergyCalendarClusterTransitionStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, CURRENT_TRANSITION_ATTRIBUTE_ID, minInterval, maxInterval);
+ }
+
+ public void readCurrentPeakPeriodAttribute(
+ CurrentPeakPeriodAttributeCallback callback) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CURRENT_PEAK_PERIOD_ATTRIBUTE_ID);
+
+ readAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ @Nullable ChipStructs.EnergyCalendarClusterPeakPeriodStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, CURRENT_PEAK_PERIOD_ATTRIBUTE_ID, true);
+ }
+
+ public void subscribeCurrentPeakPeriodAttribute(
+ CurrentPeakPeriodAttributeCallback callback, int minInterval, int maxInterval) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CURRENT_PEAK_PERIOD_ATTRIBUTE_ID);
+
+ subscribeAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ @Nullable ChipStructs.EnergyCalendarClusterPeakPeriodStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, CURRENT_PEAK_PERIOD_ATTRIBUTE_ID, minInterval, maxInterval);
+ }
+
+ public void readNextPeakPeriodAttribute(
+ NextPeakPeriodAttributeCallback callback) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, NEXT_PEAK_PERIOD_ATTRIBUTE_ID);
+
+ readAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ @Nullable ChipStructs.EnergyCalendarClusterPeakPeriodStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, NEXT_PEAK_PERIOD_ATTRIBUTE_ID, true);
+ }
+
+ public void subscribeNextPeakPeriodAttribute(
+ NextPeakPeriodAttributeCallback callback, int minInterval, int maxInterval) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, NEXT_PEAK_PERIOD_ATTRIBUTE_ID);
+
+ subscribeAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ @Nullable ChipStructs.EnergyCalendarClusterPeakPeriodStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, NEXT_PEAK_PERIOD_ATTRIBUTE_ID, minInterval, maxInterval);
+ }
+
+ public void readGeneratedCommandListAttribute(
+ GeneratedCommandListAttributeCallback callback) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, GENERATED_COMMAND_LIST_ATTRIBUTE_ID);
+
+ readAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, GENERATED_COMMAND_LIST_ATTRIBUTE_ID, true);
+ }
+
+ public void subscribeGeneratedCommandListAttribute(
+ GeneratedCommandListAttributeCallback callback, int minInterval, int maxInterval) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, GENERATED_COMMAND_LIST_ATTRIBUTE_ID);
+
+ subscribeAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, GENERATED_COMMAND_LIST_ATTRIBUTE_ID, minInterval, maxInterval);
+ }
+
+ public void readAcceptedCommandListAttribute(
+ AcceptedCommandListAttributeCallback callback) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ACCEPTED_COMMAND_LIST_ATTRIBUTE_ID);
+
+ readAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, ACCEPTED_COMMAND_LIST_ATTRIBUTE_ID, true);
+ }
+
+ public void subscribeAcceptedCommandListAttribute(
+ AcceptedCommandListAttributeCallback callback, int minInterval, int maxInterval) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ACCEPTED_COMMAND_LIST_ATTRIBUTE_ID);
+
+ subscribeAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, ACCEPTED_COMMAND_LIST_ATTRIBUTE_ID, minInterval, maxInterval);
+ }
+
+ public void readEventListAttribute(
+ EventListAttributeCallback callback) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, EVENT_LIST_ATTRIBUTE_ID);
+
+ readAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, EVENT_LIST_ATTRIBUTE_ID, true);
+ }
+
+ public void subscribeEventListAttribute(
+ EventListAttributeCallback callback, int minInterval, int maxInterval) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, EVENT_LIST_ATTRIBUTE_ID);
+
+ subscribeAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, EVENT_LIST_ATTRIBUTE_ID, minInterval, maxInterval);
+ }
+
+ public void readAttributeListAttribute(
+ AttributeListAttributeCallback callback) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ATTRIBUTE_LIST_ATTRIBUTE_ID);
+
+ readAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, ATTRIBUTE_LIST_ATTRIBUTE_ID, true);
+ }
+
+ public void subscribeAttributeListAttribute(
+ AttributeListAttributeCallback callback, int minInterval, int maxInterval) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, ATTRIBUTE_LIST_ATTRIBUTE_ID);
+
+ subscribeAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, ATTRIBUTE_LIST_ATTRIBUTE_ID, minInterval, maxInterval);
+ }
+
+ public void readFeatureMapAttribute(
+ LongAttributeCallback callback) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, FEATURE_MAP_ATTRIBUTE_ID);
+
+ readAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, FEATURE_MAP_ATTRIBUTE_ID, true);
+ }
+
+ public void subscribeFeatureMapAttribute(
+ LongAttributeCallback callback, int minInterval, int maxInterval) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, FEATURE_MAP_ATTRIBUTE_ID);
+
+ subscribeAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, FEATURE_MAP_ATTRIBUTE_ID, minInterval, maxInterval);
+ }
+
+ public void readClusterRevisionAttribute(
+ IntegerAttributeCallback callback) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CLUSTER_REVISION_ATTRIBUTE_ID);
+
+ readAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ Integer value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, CLUSTER_REVISION_ATTRIBUTE_ID, true);
+ }
+
+ public void subscribeClusterRevisionAttribute(
+ IntegerAttributeCallback callback, int minInterval, int maxInterval) {
+ ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, CLUSTER_REVISION_ATTRIBUTE_ID);
+
+ subscribeAttribute(new ReportCallbackImpl(callback, path) {
+ @Override
+ public void onSuccess(byte[] tlv) {
+ Integer value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
+ callback.onSuccess(value);
+ }
+ }, CLUSTER_REVISION_ATTRIBUTE_ID, minInterval, maxInterval);
+ }
+ }
+
public static class EnergyPreferenceCluster extends BaseChipCluster {
public static final long CLUSTER_ID = 155L;
diff --git a/src/controller/java/generated/java/chip/devicecontroller/ChipStructs.java b/src/controller/java/generated/java/chip/devicecontroller/ChipStructs.java
index 7ee8a88f80f64b..2b0fbeaa76fe5c 100644
--- a/src/controller/java/generated/java/chip/devicecontroller/ChipStructs.java
+++ b/src/controller/java/generated/java/chip/devicecontroller/ChipStructs.java
@@ -8759,6 +8759,340 @@ public String toString() {
return output.toString();
}
}
+public static class EnergyCalendarClusterTransitionStruct {
+ public Integer transitionTime;
+ public Optional priceTier;
+ public Optional friendlyCredit;
+ public Optional auxiliaryLoad;
+ private static final long TRANSITION_TIME_ID = 0L;
+ private static final long PRICE_TIER_ID = 1L;
+ private static final long FRIENDLY_CREDIT_ID = 2L;
+ private static final long AUXILIARY_LOAD_ID = 3L;
+
+ public EnergyCalendarClusterTransitionStruct(
+ Integer transitionTime,
+ Optional priceTier,
+ Optional friendlyCredit,
+ Optional auxiliaryLoad
+ ) {
+ this.transitionTime = transitionTime;
+ this.priceTier = priceTier;
+ this.friendlyCredit = friendlyCredit;
+ this.auxiliaryLoad = auxiliaryLoad;
+ }
+
+ public StructType encodeTlv() {
+ ArrayList values = new ArrayList<>();
+ values.add(new StructElement(TRANSITION_TIME_ID, new UIntType(transitionTime)));
+ values.add(new StructElement(PRICE_TIER_ID, priceTier.map((nonOptionalpriceTier) -> new UIntType(nonOptionalpriceTier)).orElse(new EmptyType())));
+ values.add(new StructElement(FRIENDLY_CREDIT_ID, friendlyCredit.map((nonOptionalfriendlyCredit) -> new BooleanType(nonOptionalfriendlyCredit)).orElse(new EmptyType())));
+ values.add(new StructElement(AUXILIARY_LOAD_ID, auxiliaryLoad.map((nonOptionalauxiliaryLoad) -> new UIntType(nonOptionalauxiliaryLoad)).orElse(new EmptyType())));
+
+ return new StructType(values);
+ }
+
+ public static EnergyCalendarClusterTransitionStruct decodeTlv(BaseTLVType tlvValue) {
+ if (tlvValue == null || tlvValue.type() != TLVType.Struct) {
+ return null;
+ }
+ Integer transitionTime = null;
+ Optional priceTier = Optional.empty();
+ Optional friendlyCredit = Optional.empty();
+ Optional auxiliaryLoad = Optional.empty();
+ for (StructElement element: ((StructType)tlvValue).value()) {
+ if (element.contextTagNum() == TRANSITION_TIME_ID) {
+ if (element.value(BaseTLVType.class).type() == TLVType.UInt) {
+ UIntType castingValue = element.value(UIntType.class);
+ transitionTime = castingValue.value(Integer.class);
+ }
+ } else if (element.contextTagNum() == PRICE_TIER_ID) {
+ if (element.value(BaseTLVType.class).type() == TLVType.UInt) {
+ UIntType castingValue = element.value(UIntType.class);
+ priceTier = Optional.of(castingValue.value(Long.class));
+ }
+ } else if (element.contextTagNum() == FRIENDLY_CREDIT_ID) {
+ if (element.value(BaseTLVType.class).type() == TLVType.Boolean) {
+ BooleanType castingValue = element.value(BooleanType.class);
+ friendlyCredit = Optional.of(castingValue.value(Boolean.class));
+ }
+ } else if (element.contextTagNum() == AUXILIARY_LOAD_ID) {
+ if (element.value(BaseTLVType.class).type() == TLVType.UInt) {
+ UIntType castingValue = element.value(UIntType.class);
+ auxiliaryLoad = Optional.of(castingValue.value(Integer.class));
+ }
+ }
+ }
+ return new EnergyCalendarClusterTransitionStruct(
+ transitionTime,
+ priceTier,
+ friendlyCredit,
+ auxiliaryLoad
+ );
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder output = new StringBuilder();
+ output.append("EnergyCalendarClusterTransitionStruct {\n");
+ output.append("\ttransitionTime: ");
+ output.append(transitionTime);
+ output.append("\n");
+ output.append("\tpriceTier: ");
+ output.append(priceTier);
+ output.append("\n");
+ output.append("\tfriendlyCredit: ");
+ output.append(friendlyCredit);
+ output.append("\n");
+ output.append("\tauxiliaryLoad: ");
+ output.append(auxiliaryLoad);
+ output.append("\n");
+ output.append("}\n");
+ return output.toString();
+ }
+}
+public static class EnergyCalendarClusterDayStruct {
+ public Optional date;
+ public Optional daysOfWeek;
+ public ArrayList transitions;
+ public Optional calendarID;
+ private static final long DATE_ID = 0L;
+ private static final long DAYS_OF_WEEK_ID = 1L;
+ private static final long TRANSITIONS_ID = 2L;
+ private static final long CALENDAR_ID_ID = 3L;
+
+ public EnergyCalendarClusterDayStruct(
+ Optional date,
+ Optional daysOfWeek,
+ ArrayList transitions,
+ Optional calendarID
+ ) {
+ this.date = date;
+ this.daysOfWeek = daysOfWeek;
+ this.transitions = transitions;
+ this.calendarID = calendarID;
+ }
+
+ public StructType encodeTlv() {
+ ArrayList values = new ArrayList<>();
+ values.add(new StructElement(DATE_ID, date.map((nonOptionaldate) -> new UIntType(nonOptionaldate)).orElse(new EmptyType())));
+ values.add(new StructElement(DAYS_OF_WEEK_ID, daysOfWeek.map((nonOptionaldaysOfWeek) -> new UIntType(nonOptionaldaysOfWeek)).orElse(new EmptyType())));
+ values.add(new StructElement(TRANSITIONS_ID, ArrayType.generateArrayType(transitions, (elementtransitions) -> elementtransitions.encodeTlv())));
+ values.add(new StructElement(CALENDAR_ID_ID, calendarID.map((nonOptionalcalendarID) -> new UIntType(nonOptionalcalendarID)).orElse(new EmptyType())));
+
+ return new StructType(values);
+ }
+
+ public static EnergyCalendarClusterDayStruct decodeTlv(BaseTLVType tlvValue) {
+ if (tlvValue == null || tlvValue.type() != TLVType.Struct) {
+ return null;
+ }
+ Optional date = Optional.empty();
+ Optional daysOfWeek = Optional.empty();
+ ArrayList transitions = null;
+ Optional calendarID = Optional.empty();
+ for (StructElement element: ((StructType)tlvValue).value()) {
+ if (element.contextTagNum() == DATE_ID) {
+ if (element.value(BaseTLVType.class).type() == TLVType.UInt) {
+ UIntType castingValue = element.value(UIntType.class);
+ date = Optional.of(castingValue.value(Long.class));
+ }
+ } else if (element.contextTagNum() == DAYS_OF_WEEK_ID) {
+ if (element.value(BaseTLVType.class).type() == TLVType.UInt) {
+ UIntType castingValue = element.value(UIntType.class);
+ daysOfWeek = Optional.of(castingValue.value(Integer.class));
+ }
+ } else if (element.contextTagNum() == TRANSITIONS_ID) {
+ if (element.value(BaseTLVType.class).type() == TLVType.Array) {
+ ArrayType castingValue = element.value(ArrayType.class);
+ transitions = castingValue.map((elementcastingValue) -> ChipStructs.EnergyCalendarClusterTransitionStruct.decodeTlv(elementcastingValue));
+ }
+ } else if (element.contextTagNum() == CALENDAR_ID_ID) {
+ if (element.value(BaseTLVType.class).type() == TLVType.UInt) {
+ UIntType castingValue = element.value(UIntType.class);
+ calendarID = Optional.of(castingValue.value(Long.class));
+ }
+ }
+ }
+ return new EnergyCalendarClusterDayStruct(
+ date,
+ daysOfWeek,
+ transitions,
+ calendarID
+ );
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder output = new StringBuilder();
+ output.append("EnergyCalendarClusterDayStruct {\n");
+ output.append("\tdate: ");
+ output.append(date);
+ output.append("\n");
+ output.append("\tdaysOfWeek: ");
+ output.append(daysOfWeek);
+ output.append("\n");
+ output.append("\ttransitions: ");
+ output.append(transitions);
+ output.append("\n");
+ output.append("\tcalendarID: ");
+ output.append(calendarID);
+ output.append("\n");
+ output.append("}\n");
+ return output.toString();
+ }
+}
+public static class EnergyCalendarClusterCalendarPeriodStruct {
+ public @Nullable Long startDate;
+ public ArrayList days;
+ private static final long START_DATE_ID = 0L;
+ private static final long DAYS_ID = 1L;
+
+ public EnergyCalendarClusterCalendarPeriodStruct(
+ @Nullable Long startDate,
+ ArrayList days
+ ) {
+ this.startDate = startDate;
+ this.days = days;
+ }
+
+ public StructType encodeTlv() {
+ ArrayList values = new ArrayList<>();
+ values.add(new StructElement(START_DATE_ID, startDate != null ? new UIntType(startDate) : new NullType()));
+ values.add(new StructElement(DAYS_ID, ArrayType.generateArrayType(days, (elementdays) -> elementdays.encodeTlv())));
+
+ return new StructType(values);
+ }
+
+ public static EnergyCalendarClusterCalendarPeriodStruct decodeTlv(BaseTLVType tlvValue) {
+ if (tlvValue == null || tlvValue.type() != TLVType.Struct) {
+ return null;
+ }
+ @Nullable Long startDate = null;
+ ArrayList days = null;
+ for (StructElement element: ((StructType)tlvValue).value()) {
+ if (element.contextTagNum() == START_DATE_ID) {
+ if (element.value(BaseTLVType.class).type() == TLVType.UInt) {
+ UIntType castingValue = element.value(UIntType.class);
+ startDate = castingValue.value(Long.class);
+ }
+ } else if (element.contextTagNum() == DAYS_ID) {
+ if (element.value(BaseTLVType.class).type() == TLVType.Array) {
+ ArrayType castingValue = element.value(ArrayType.class);
+ days = castingValue.map((elementcastingValue) -> ChipStructs.EnergyCalendarClusterDayStruct.decodeTlv(elementcastingValue));
+ }
+ }
+ }
+ return new EnergyCalendarClusterCalendarPeriodStruct(
+ startDate,
+ days
+ );
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder output = new StringBuilder();
+ output.append("EnergyCalendarClusterCalendarPeriodStruct {\n");
+ output.append("\tstartDate: ");
+ output.append(startDate);
+ output.append("\n");
+ output.append("\tdays: ");
+ output.append(days);
+ output.append("\n");
+ output.append("}\n");
+ return output.toString();
+ }
+}
+public static class EnergyCalendarClusterPeakPeriodStruct {
+ public Integer severity;
+ public Integer peakPeriod;
+ public @Nullable Long startTime;
+ public @Nullable Long endTime;
+ private static final long SEVERITY_ID = 0L;
+ private static final long PEAK_PERIOD_ID = 1L;
+ private static final long START_TIME_ID = 2L;
+ private static final long END_TIME_ID = 3L;
+
+ public EnergyCalendarClusterPeakPeriodStruct(
+ Integer severity,
+ Integer peakPeriod,
+ @Nullable Long startTime,
+ @Nullable Long endTime
+ ) {
+ this.severity = severity;
+ this.peakPeriod = peakPeriod;
+ this.startTime = startTime;
+ this.endTime = endTime;
+ }
+
+ public StructType encodeTlv() {
+ ArrayList values = new ArrayList<>();
+ values.add(new StructElement(SEVERITY_ID, new UIntType(severity)));
+ values.add(new StructElement(PEAK_PERIOD_ID, new UIntType(peakPeriod)));
+ values.add(new StructElement(START_TIME_ID, startTime != null ? new UIntType(startTime) : new NullType()));
+ values.add(new StructElement(END_TIME_ID, endTime != null ? new UIntType(endTime) : new NullType()));
+
+ return new StructType(values);
+ }
+
+ public static EnergyCalendarClusterPeakPeriodStruct decodeTlv(BaseTLVType tlvValue) {
+ if (tlvValue == null || tlvValue.type() != TLVType.Struct) {
+ return null;
+ }
+ Integer severity = null;
+ Integer peakPeriod = null;
+ @Nullable Long startTime = null;
+ @Nullable Long endTime = null;
+ for (StructElement element: ((StructType)tlvValue).value()) {
+ if (element.contextTagNum() == SEVERITY_ID) {
+ if (element.value(BaseTLVType.class).type() == TLVType.UInt) {
+ UIntType castingValue = element.value(UIntType.class);
+ severity = castingValue.value(Integer.class);
+ }
+ } else if (element.contextTagNum() == PEAK_PERIOD_ID) {
+ if (element.value(BaseTLVType.class).type() == TLVType.UInt) {
+ UIntType castingValue = element.value(UIntType.class);
+ peakPeriod = castingValue.value(Integer.class);
+ }
+ } else if (element.contextTagNum() == START_TIME_ID) {
+ if (element.value(BaseTLVType.class).type() == TLVType.UInt) {
+ UIntType castingValue = element.value(UIntType.class);
+ startTime = castingValue.value(Long.class);
+ }
+ } else if (element.contextTagNum() == END_TIME_ID) {
+ if (element.value(BaseTLVType.class).type() == TLVType.UInt) {
+ UIntType castingValue = element.value(UIntType.class);
+ endTime = castingValue.value(Long.class);
+ }
+ }
+ }
+ return new EnergyCalendarClusterPeakPeriodStruct(
+ severity,
+ peakPeriod,
+ startTime,
+ endTime
+ );
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder output = new StringBuilder();
+ output.append("EnergyCalendarClusterPeakPeriodStruct {\n");
+ output.append("\tseverity: ");
+ output.append(severity);
+ output.append("\n");
+ output.append("\tpeakPeriod: ");
+ output.append(peakPeriod);
+ output.append("\n");
+ output.append("\tstartTime: ");
+ output.append(startTime);
+ output.append("\n");
+ output.append("\tendTime: ");
+ output.append(endTime);
+ output.append("\n");
+ output.append("}\n");
+ return output.toString();
+ }
+}
public static class EnergyPreferenceClusterBalanceStruct {
public Integer step;
public Optional label;
diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java
index 8bf4e6d615c358..e8d6fc3262642a 100644
--- a/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java
+++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java
@@ -238,6 +238,9 @@ public static BaseCluster getCluster(long clusterId) {
if (clusterId == EnergyEvse.ID) {
return new EnergyEvse();
}
+ if (clusterId == EnergyCalendar.ID) {
+ return new EnergyCalendar();
+ }
if (clusterId == EnergyPreference.ID) {
return new EnergyPreference();
}
@@ -9995,6 +9998,118 @@ public long getCommandID(String name) throws IllegalArgumentException {
return Command.valueOf(name).getID();
}
}
+ public static class EnergyCalendar implements BaseCluster {
+ public static final long ID = 154L;
+ public long getID() {
+ return ID;
+ }
+
+ public enum Attribute {
+ CalendarID(0L),
+ Name(1L),
+ ProviderID(2L),
+ EventID(3L),
+ StartDate(4L),
+ CalendarPeriods(5L),
+ SpecialDays(6L),
+ CurrentDay(7L),
+ NextDay(8L),
+ CurrentTransition(9L),
+ CurrentPeakPeriod(10L),
+ NextPeakPeriod(11L),
+ GeneratedCommandList(65528L),
+ AcceptedCommandList(65529L),
+ EventList(65530L),
+ AttributeList(65531L),
+ FeatureMap(65532L),
+ ClusterRevision(65533L),;
+ private final long id;
+ Attribute(long id) {
+ this.id = id;
+ }
+
+ public long getID() {
+ return id;
+ }
+
+ public static Attribute value(long id) throws NoSuchFieldError {
+ for (Attribute attribute : Attribute.values()) {
+ if (attribute.getID() == id) {
+ return attribute;
+ }
+ }
+ throw new NoSuchFieldError();
+ }
+ }
+
+ public enum Event {;
+ private final long id;
+ Event(long id) {
+ this.id = id;
+ }
+
+ public long getID() {
+ return id;
+ }
+
+ public static Event value(long id) throws NoSuchFieldError {
+ for (Event event : Event.values()) {
+ if (event.getID() == id) {
+ return event;
+ }
+ }
+ throw new NoSuchFieldError();
+ }
+ }
+
+ public enum Command {;
+ private final long id;
+ Command(long id) {
+ this.id = id;
+ }
+
+ public long getID() {
+ return id;
+ }
+
+ public static Command value(long id) throws NoSuchFieldError {
+ for (Command command : Command.values()) {
+ if (command.getID() == id) {
+ return command;
+ }
+ }
+ throw new NoSuchFieldError();
+ }
+ }@Override
+ public String getAttributeName(long id) throws NoSuchFieldError {
+ return Attribute.value(id).toString();
+ }
+
+ @Override
+ public String getEventName(long id) throws NoSuchFieldError {
+ return Event.value(id).toString();
+ }
+
+ @Override
+ public String getCommandName(long id) throws NoSuchFieldError {
+ return Command.value(id).toString();
+ }
+
+ @Override
+ public long getAttributeID(String name) throws IllegalArgumentException {
+ return Attribute.valueOf(name).getID();
+ }
+
+ @Override
+ public long getEventID(String name) throws IllegalArgumentException {
+ return Event.valueOf(name).getID();
+ }
+
+ @Override
+ public long getCommandID(String name) throws IllegalArgumentException {
+ return Command.valueOf(name).getID();
+ }
+ }
public static class EnergyPreference implements BaseCluster {
public static final long ID = 155L;
public long getID() {
diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java
index 40427e62794337..8e2e2efcad8095 100644
--- a/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java
+++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java
@@ -11424,6 +11424,342 @@ public void onError(Exception ex) {
}
}
+ public static class DelegatedEnergyCalendarClusterCalendarIDAttributeCallback implements ChipClusters.EnergyCalendarCluster.CalendarIDAttributeCallback, DelegatedClusterCallback {
+ private ClusterCommandCallback callback;
+ @Override
+ public void setCallbackDelegate(ClusterCommandCallback callback) {
+ this.callback = callback;
+ }
+
+ @Override
+ public void onSuccess(@Nullable Long value) {
+ Map responseValues = new LinkedHashMap<>();
+ CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Long");
+ responseValues.put(commandResponseInfo, value);
+ callback.onSuccess(responseValues);
+ }
+
+ @Override
+ public void onError(Exception ex) {
+ callback.onFailure(ex);
+ }
+ }
+
+ public static class DelegatedEnergyCalendarClusterNameAttributeCallback implements ChipClusters.EnergyCalendarCluster.NameAttributeCallback, DelegatedClusterCallback {
+ private ClusterCommandCallback callback;
+ @Override
+ public void setCallbackDelegate(ClusterCommandCallback callback) {
+ this.callback = callback;
+ }
+
+ @Override
+ public void onSuccess(@Nullable String value) {
+ Map responseValues = new LinkedHashMap<>();
+ CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "String");
+ responseValues.put(commandResponseInfo, value);
+ callback.onSuccess(responseValues);
+ }
+
+ @Override
+ public void onError(Exception ex) {
+ callback.onFailure(ex);
+ }
+ }
+
+ public static class DelegatedEnergyCalendarClusterProviderIDAttributeCallback implements ChipClusters.EnergyCalendarCluster.ProviderIDAttributeCallback, DelegatedClusterCallback {
+ private ClusterCommandCallback callback;
+ @Override
+ public void setCallbackDelegate(ClusterCommandCallback callback) {
+ this.callback = callback;
+ }
+
+ @Override
+ public void onSuccess(@Nullable Long value) {
+ Map responseValues = new LinkedHashMap<>();
+ CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Long");
+ responseValues.put(commandResponseInfo, value);
+ callback.onSuccess(responseValues);
+ }
+
+ @Override
+ public void onError(Exception ex) {
+ callback.onFailure(ex);
+ }
+ }
+
+ public static class DelegatedEnergyCalendarClusterEventIDAttributeCallback implements ChipClusters.EnergyCalendarCluster.EventIDAttributeCallback, DelegatedClusterCallback {
+ private ClusterCommandCallback callback;
+ @Override
+ public void setCallbackDelegate(ClusterCommandCallback callback) {
+ this.callback = callback;
+ }
+
+ @Override
+ public void onSuccess(@Nullable Long value) {
+ Map responseValues = new LinkedHashMap<>();
+ CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Long");
+ responseValues.put(commandResponseInfo, value);
+ callback.onSuccess(responseValues);
+ }
+
+ @Override
+ public void onError(Exception ex) {
+ callback.onFailure(ex);
+ }
+ }
+
+ public static class DelegatedEnergyCalendarClusterStartDateAttributeCallback implements ChipClusters.EnergyCalendarCluster.StartDateAttributeCallback, DelegatedClusterCallback {
+ private ClusterCommandCallback callback;
+ @Override
+ public void setCallbackDelegate(ClusterCommandCallback callback) {
+ this.callback = callback;
+ }
+
+ @Override
+ public void onSuccess(@Nullable Long value) {
+ Map responseValues = new LinkedHashMap<>();
+ CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Long");
+ responseValues.put(commandResponseInfo, value);
+ callback.onSuccess(responseValues);
+ }
+
+ @Override
+ public void onError(Exception ex) {
+ callback.onFailure(ex);
+ }
+ }
+
+ public static class DelegatedEnergyCalendarClusterCalendarPeriodsAttributeCallback implements ChipClusters.EnergyCalendarCluster.CalendarPeriodsAttributeCallback, DelegatedClusterCallback {
+ private ClusterCommandCallback callback;
+ @Override
+ public void setCallbackDelegate(ClusterCommandCallback callback) {
+ this.callback = callback;
+ }
+
+ @Override
+ public void onSuccess(@Nullable List valueList) {
+ Map responseValues = new LinkedHashMap<>();
+ CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List");
+ responseValues.put(commandResponseInfo, valueList);
+ callback.onSuccess(responseValues);
+ }
+
+ @Override
+ public void onError(Exception ex) {
+ callback.onFailure(ex);
+ }
+ }
+
+ public static class DelegatedEnergyCalendarClusterSpecialDaysAttributeCallback implements ChipClusters.EnergyCalendarCluster.SpecialDaysAttributeCallback, DelegatedClusterCallback {
+ private ClusterCommandCallback callback;
+ @Override
+ public void setCallbackDelegate(ClusterCommandCallback callback) {
+ this.callback = callback;
+ }
+
+ @Override
+ public void onSuccess(@Nullable List valueList) {
+ Map responseValues = new LinkedHashMap<>();
+ CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List");
+ responseValues.put(commandResponseInfo, valueList);
+ callback.onSuccess(responseValues);
+ }
+
+ @Override
+ public void onError(Exception ex) {
+ callback.onFailure(ex);
+ }
+ }
+
+ public static class DelegatedEnergyCalendarClusterCurrentDayAttributeCallback implements ChipClusters.EnergyCalendarCluster.CurrentDayAttributeCallback, DelegatedClusterCallback {
+ private ClusterCommandCallback callback;
+ @Override
+ public void setCallbackDelegate(ClusterCommandCallback callback) {
+ this.callback = callback;
+ }
+
+ @Override
+ public void onSuccess(@Nullable ChipStructs.EnergyCalendarClusterDayStruct value) {
+ Map responseValues = new LinkedHashMap<>();
+ CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "ChipStructs.EnergyCalendarClusterDayStruct");
+ responseValues.put(commandResponseInfo, value);
+ callback.onSuccess(responseValues);
+ }
+
+ @Override
+ public void onError(Exception ex) {
+ callback.onFailure(ex);
+ }
+ }
+
+ public static class DelegatedEnergyCalendarClusterNextDayAttributeCallback implements ChipClusters.EnergyCalendarCluster.NextDayAttributeCallback, DelegatedClusterCallback {
+ private ClusterCommandCallback callback;
+ @Override
+ public void setCallbackDelegate(ClusterCommandCallback callback) {
+ this.callback = callback;
+ }
+
+ @Override
+ public void onSuccess(@Nullable ChipStructs.EnergyCalendarClusterDayStruct value) {
+ Map responseValues = new LinkedHashMap<>();
+ CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "ChipStructs.EnergyCalendarClusterDayStruct");
+ responseValues.put(commandResponseInfo, value);
+ callback.onSuccess(responseValues);
+ }
+
+ @Override
+ public void onError(Exception ex) {
+ callback.onFailure(ex);
+ }
+ }
+
+ public static class DelegatedEnergyCalendarClusterCurrentTransitionAttributeCallback implements ChipClusters.EnergyCalendarCluster.CurrentTransitionAttributeCallback, DelegatedClusterCallback {
+ private ClusterCommandCallback callback;
+ @Override
+ public void setCallbackDelegate(ClusterCommandCallback callback) {
+ this.callback = callback;
+ }
+
+ @Override
+ public void onSuccess(@Nullable ChipStructs.EnergyCalendarClusterTransitionStruct value) {
+ Map responseValues = new LinkedHashMap<>();
+ CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "ChipStructs.EnergyCalendarClusterTransitionStruct");
+ responseValues.put(commandResponseInfo, value);
+ callback.onSuccess(responseValues);
+ }
+
+ @Override
+ public void onError(Exception ex) {
+ callback.onFailure(ex);
+ }
+ }
+
+ public static class DelegatedEnergyCalendarClusterCurrentPeakPeriodAttributeCallback implements ChipClusters.EnergyCalendarCluster.CurrentPeakPeriodAttributeCallback, DelegatedClusterCallback {
+ private ClusterCommandCallback callback;
+ @Override
+ public void setCallbackDelegate(ClusterCommandCallback callback) {
+ this.callback = callback;
+ }
+
+ @Override
+ public void onSuccess(@Nullable ChipStructs.EnergyCalendarClusterPeakPeriodStruct value) {
+ Map responseValues = new LinkedHashMap<>();
+ CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "ChipStructs.EnergyCalendarClusterPeakPeriodStruct");
+ responseValues.put(commandResponseInfo, value);
+ callback.onSuccess(responseValues);
+ }
+
+ @Override
+ public void onError(Exception ex) {
+ callback.onFailure(ex);
+ }
+ }
+
+ public static class DelegatedEnergyCalendarClusterNextPeakPeriodAttributeCallback implements ChipClusters.EnergyCalendarCluster.NextPeakPeriodAttributeCallback, DelegatedClusterCallback {
+ private ClusterCommandCallback callback;
+ @Override
+ public void setCallbackDelegate(ClusterCommandCallback callback) {
+ this.callback = callback;
+ }
+
+ @Override
+ public void onSuccess(@Nullable ChipStructs.EnergyCalendarClusterPeakPeriodStruct value) {
+ Map responseValues = new LinkedHashMap<>();
+ CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "ChipStructs.EnergyCalendarClusterPeakPeriodStruct");
+ responseValues.put(commandResponseInfo, value);
+ callback.onSuccess(responseValues);
+ }
+
+ @Override
+ public void onError(Exception ex) {
+ callback.onFailure(ex);
+ }
+ }
+
+ public static class DelegatedEnergyCalendarClusterGeneratedCommandListAttributeCallback implements ChipClusters.EnergyCalendarCluster.GeneratedCommandListAttributeCallback, DelegatedClusterCallback {
+ private ClusterCommandCallback callback;
+ @Override
+ public void setCallbackDelegate(ClusterCommandCallback callback) {
+ this.callback = callback;
+ }
+
+ @Override
+ public void onSuccess(List valueList) {
+ Map responseValues = new LinkedHashMap<>();
+ CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List");
+ responseValues.put(commandResponseInfo, valueList);
+ callback.onSuccess(responseValues);
+ }
+
+ @Override
+ public void onError(Exception ex) {
+ callback.onFailure(ex);
+ }
+ }
+
+ public static class DelegatedEnergyCalendarClusterAcceptedCommandListAttributeCallback implements ChipClusters.EnergyCalendarCluster.AcceptedCommandListAttributeCallback, DelegatedClusterCallback {
+ private ClusterCommandCallback callback;
+ @Override
+ public void setCallbackDelegate(ClusterCommandCallback callback) {
+ this.callback = callback;
+ }
+
+ @Override
+ public void onSuccess(List valueList) {
+ Map responseValues = new LinkedHashMap<>();
+ CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List");
+ responseValues.put(commandResponseInfo, valueList);
+ callback.onSuccess(responseValues);
+ }
+
+ @Override
+ public void onError(Exception ex) {
+ callback.onFailure(ex);
+ }
+ }
+
+ public static class DelegatedEnergyCalendarClusterEventListAttributeCallback implements ChipClusters.EnergyCalendarCluster.EventListAttributeCallback, DelegatedClusterCallback {
+ private ClusterCommandCallback callback;
+ @Override
+ public void setCallbackDelegate(ClusterCommandCallback callback) {
+ this.callback = callback;
+ }
+
+ @Override
+ public void onSuccess(List valueList) {
+ Map responseValues = new LinkedHashMap<>();
+ CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List");
+ responseValues.put(commandResponseInfo, valueList);
+ callback.onSuccess(responseValues);
+ }
+
+ @Override
+ public void onError(Exception ex) {
+ callback.onFailure(ex);
+ }
+ }
+
+ public static class DelegatedEnergyCalendarClusterAttributeListAttributeCallback implements ChipClusters.EnergyCalendarCluster.AttributeListAttributeCallback, DelegatedClusterCallback {
+ private ClusterCommandCallback callback;
+ @Override
+ public void setCallbackDelegate(ClusterCommandCallback callback) {
+ this.callback = callback;
+ }
+
+ @Override
+ public void onSuccess(List valueList) {
+ Map responseValues = new LinkedHashMap<>();
+ CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List");
+ responseValues.put(commandResponseInfo, valueList);
+ callback.onSuccess(responseValues);
+ }
+
+ @Override
+ public void onError(Exception ex) {
+ callback.onFailure(ex);
+ }
+ }
+
public static class DelegatedEnergyPreferenceClusterEnergyBalancesAttributeCallback implements ChipClusters.EnergyPreferenceCluster.EnergyBalancesAttributeCallback, DelegatedClusterCallback {
private ClusterCommandCallback callback;
@Override
@@ -22140,6 +22476,10 @@ public Map initializeClusterMap() {
(ptr, endpointId) -> new ChipClusters.EnergyEvseCluster(ptr, endpointId), new HashMap<>());
clusterMap.put("energyEvse", energyEvseClusterInfo);
+ ClusterInfo energyCalendarClusterInfo = new ClusterInfo(
+ (ptr, endpointId) -> new ChipClusters.EnergyCalendarCluster(ptr, endpointId), new HashMap<>());
+ clusterMap.put("energyCalendar", energyCalendarClusterInfo);
+
ClusterInfo energyPreferenceClusterInfo = new ClusterInfo(
(ptr, endpointId) -> new ChipClusters.EnergyPreferenceCluster(ptr, endpointId), new HashMap<>());
clusterMap.put("energyPreference", energyPreferenceClusterInfo);
@@ -22422,6 +22762,7 @@ public void combineCommand(Map destination, Map> getCommandMap() {
commandMap.put("energyEvse", energyEvseClusterInteractionInfoMap);
+ Map energyCalendarClusterInteractionInfoMap = new LinkedHashMap<>();
+
+ commandMap.put("energyCalendar", energyCalendarClusterInteractionInfoMap);
+
Map energyPreferenceClusterInteractionInfoMap = new LinkedHashMap<>();
commandMap.put("energyPreference", energyPreferenceClusterInteractionInfoMap);
diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java
index 7de9e8cdc25d2f..1558ff6fb1de90 100644
--- a/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java
+++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java
@@ -9985,6 +9985,153 @@ private static Map readEnergyEvseInteractionInfo() {
return result;
}
+ private static Map readEnergyCalendarInteractionInfo() {
+ Map result = new LinkedHashMap<>();Map readEnergyCalendarCalendarIDCommandParams = new LinkedHashMap();
+ InteractionInfo readEnergyCalendarCalendarIDAttributeInteractionInfo = new InteractionInfo(
+ (cluster, callback, commandArguments) -> {
+ ((ChipClusters.EnergyCalendarCluster) cluster).readCalendarIDAttribute(
+ (ChipClusters.EnergyCalendarCluster.CalendarIDAttributeCallback) callback
+ );
+ },
+ () -> new ClusterInfoMapping.DelegatedEnergyCalendarClusterCalendarIDAttributeCallback(),
+ readEnergyCalendarCalendarIDCommandParams
+ );
+ result.put("readCalendarIDAttribute", readEnergyCalendarCalendarIDAttributeInteractionInfo);
+ Map readEnergyCalendarNameCommandParams = new LinkedHashMap();
+ InteractionInfo readEnergyCalendarNameAttributeInteractionInfo = new InteractionInfo(
+ (cluster, callback, commandArguments) -> {
+ ((ChipClusters.EnergyCalendarCluster) cluster).readNameAttribute(
+ (ChipClusters.EnergyCalendarCluster.NameAttributeCallback) callback
+ );
+ },
+ () -> new ClusterInfoMapping.DelegatedEnergyCalendarClusterNameAttributeCallback(),
+ readEnergyCalendarNameCommandParams
+ );
+ result.put("readNameAttribute", readEnergyCalendarNameAttributeInteractionInfo);
+ Map readEnergyCalendarProviderIDCommandParams = new LinkedHashMap();
+ InteractionInfo readEnergyCalendarProviderIDAttributeInteractionInfo = new InteractionInfo(
+ (cluster, callback, commandArguments) -> {
+ ((ChipClusters.EnergyCalendarCluster) cluster).readProviderIDAttribute(
+ (ChipClusters.EnergyCalendarCluster.ProviderIDAttributeCallback) callback
+ );
+ },
+ () -> new ClusterInfoMapping.DelegatedEnergyCalendarClusterProviderIDAttributeCallback(),
+ readEnergyCalendarProviderIDCommandParams
+ );
+ result.put("readProviderIDAttribute", readEnergyCalendarProviderIDAttributeInteractionInfo);
+ Map readEnergyCalendarEventIDCommandParams = new LinkedHashMap();
+ InteractionInfo readEnergyCalendarEventIDAttributeInteractionInfo = new InteractionInfo(
+ (cluster, callback, commandArguments) -> {
+ ((ChipClusters.EnergyCalendarCluster) cluster).readEventIDAttribute(
+ (ChipClusters.EnergyCalendarCluster.EventIDAttributeCallback) callback
+ );
+ },
+ () -> new ClusterInfoMapping.DelegatedEnergyCalendarClusterEventIDAttributeCallback(),
+ readEnergyCalendarEventIDCommandParams
+ );
+ result.put("readEventIDAttribute", readEnergyCalendarEventIDAttributeInteractionInfo);
+ Map readEnergyCalendarStartDateCommandParams = new LinkedHashMap();
+ InteractionInfo readEnergyCalendarStartDateAttributeInteractionInfo = new InteractionInfo(
+ (cluster, callback, commandArguments) -> {
+ ((ChipClusters.EnergyCalendarCluster) cluster).readStartDateAttribute(
+ (ChipClusters.EnergyCalendarCluster.StartDateAttributeCallback) callback
+ );
+ },
+ () -> new ClusterInfoMapping.DelegatedEnergyCalendarClusterStartDateAttributeCallback(),
+ readEnergyCalendarStartDateCommandParams
+ );
+ result.put("readStartDateAttribute", readEnergyCalendarStartDateAttributeInteractionInfo);
+ Map readEnergyCalendarCalendarPeriodsCommandParams = new LinkedHashMap();
+ InteractionInfo readEnergyCalendarCalendarPeriodsAttributeInteractionInfo = new InteractionInfo(
+ (cluster, callback, commandArguments) -> {
+ ((ChipClusters.EnergyCalendarCluster) cluster).readCalendarPeriodsAttribute(
+ (ChipClusters.EnergyCalendarCluster.CalendarPeriodsAttributeCallback) callback
+ );
+ },
+ () -> new ClusterInfoMapping.DelegatedEnergyCalendarClusterCalendarPeriodsAttributeCallback(),
+ readEnergyCalendarCalendarPeriodsCommandParams
+ );
+ result.put("readCalendarPeriodsAttribute", readEnergyCalendarCalendarPeriodsAttributeInteractionInfo);
+ Map readEnergyCalendarSpecialDaysCommandParams = new LinkedHashMap();
+ InteractionInfo readEnergyCalendarSpecialDaysAttributeInteractionInfo = new InteractionInfo(
+ (cluster, callback, commandArguments) -> {
+ ((ChipClusters.EnergyCalendarCluster) cluster).readSpecialDaysAttribute(
+ (ChipClusters.EnergyCalendarCluster.SpecialDaysAttributeCallback) callback
+ );
+ },
+ () -> new ClusterInfoMapping.DelegatedEnergyCalendarClusterSpecialDaysAttributeCallback(),
+ readEnergyCalendarSpecialDaysCommandParams
+ );
+ result.put("readSpecialDaysAttribute", readEnergyCalendarSpecialDaysAttributeInteractionInfo);
+ Map readEnergyCalendarGeneratedCommandListCommandParams = new LinkedHashMap();
+ InteractionInfo readEnergyCalendarGeneratedCommandListAttributeInteractionInfo = new InteractionInfo(
+ (cluster, callback, commandArguments) -> {
+ ((ChipClusters.EnergyCalendarCluster) cluster).readGeneratedCommandListAttribute(
+ (ChipClusters.EnergyCalendarCluster.GeneratedCommandListAttributeCallback) callback
+ );
+ },
+ () -> new ClusterInfoMapping.DelegatedEnergyCalendarClusterGeneratedCommandListAttributeCallback(),
+ readEnergyCalendarGeneratedCommandListCommandParams
+ );
+ result.put("readGeneratedCommandListAttribute", readEnergyCalendarGeneratedCommandListAttributeInteractionInfo);
+ Map readEnergyCalendarAcceptedCommandListCommandParams = new LinkedHashMap();
+ InteractionInfo readEnergyCalendarAcceptedCommandListAttributeInteractionInfo = new InteractionInfo(
+ (cluster, callback, commandArguments) -> {
+ ((ChipClusters.EnergyCalendarCluster) cluster).readAcceptedCommandListAttribute(
+ (ChipClusters.EnergyCalendarCluster.AcceptedCommandListAttributeCallback) callback
+ );
+ },
+ () -> new ClusterInfoMapping.DelegatedEnergyCalendarClusterAcceptedCommandListAttributeCallback(),
+ readEnergyCalendarAcceptedCommandListCommandParams
+ );
+ result.put("readAcceptedCommandListAttribute", readEnergyCalendarAcceptedCommandListAttributeInteractionInfo);
+ Map readEnergyCalendarEventListCommandParams = new LinkedHashMap();
+ InteractionInfo readEnergyCalendarEventListAttributeInteractionInfo = new InteractionInfo(
+ (cluster, callback, commandArguments) -> {
+ ((ChipClusters.EnergyCalendarCluster) cluster).readEventListAttribute(
+ (ChipClusters.EnergyCalendarCluster.EventListAttributeCallback) callback
+ );
+ },
+ () -> new ClusterInfoMapping.DelegatedEnergyCalendarClusterEventListAttributeCallback(),
+ readEnergyCalendarEventListCommandParams
+ );
+ result.put("readEventListAttribute", readEnergyCalendarEventListAttributeInteractionInfo);
+ Map readEnergyCalendarAttributeListCommandParams = new LinkedHashMap();
+ InteractionInfo readEnergyCalendarAttributeListAttributeInteractionInfo = new InteractionInfo(
+ (cluster, callback, commandArguments) -> {
+ ((ChipClusters.EnergyCalendarCluster) cluster).readAttributeListAttribute(
+ (ChipClusters.EnergyCalendarCluster.AttributeListAttributeCallback) callback
+ );
+ },
+ () -> new ClusterInfoMapping.DelegatedEnergyCalendarClusterAttributeListAttributeCallback(),
+ readEnergyCalendarAttributeListCommandParams
+ );
+ result.put("readAttributeListAttribute", readEnergyCalendarAttributeListAttributeInteractionInfo);
+ Map readEnergyCalendarFeatureMapCommandParams = new LinkedHashMap();
+ InteractionInfo readEnergyCalendarFeatureMapAttributeInteractionInfo = new InteractionInfo(
+ (cluster, callback, commandArguments) -> {
+ ((ChipClusters.EnergyCalendarCluster) cluster).readFeatureMapAttribute(
+ (ChipClusters.LongAttributeCallback) callback
+ );
+ },
+ () -> new ClusterInfoMapping.DelegatedLongAttributeCallback(),
+ readEnergyCalendarFeatureMapCommandParams
+ );
+ result.put("readFeatureMapAttribute", readEnergyCalendarFeatureMapAttributeInteractionInfo);
+ Map readEnergyCalendarClusterRevisionCommandParams = new LinkedHashMap();
+ InteractionInfo readEnergyCalendarClusterRevisionAttributeInteractionInfo = new InteractionInfo(
+ (cluster, callback, commandArguments) -> {
+ ((ChipClusters.EnergyCalendarCluster) cluster).readClusterRevisionAttribute(
+ (ChipClusters.IntegerAttributeCallback) callback
+ );
+ },
+ () -> new ClusterInfoMapping.DelegatedIntegerAttributeCallback(),
+ readEnergyCalendarClusterRevisionCommandParams
+ );
+ result.put("readClusterRevisionAttribute", readEnergyCalendarClusterRevisionAttributeInteractionInfo);
+
+ return result;
+ }
private static Map readEnergyPreferenceInteractionInfo() {
Map result = new LinkedHashMap<>();Map readEnergyPreferenceEnergyBalancesCommandParams = new LinkedHashMap();
InteractionInfo readEnergyPreferenceEnergyBalancesAttributeInteractionInfo = new InteractionInfo(
@@ -19639,6 +19786,7 @@ public Map> getReadAttributeMap() {
put("messages", readMessagesInteractionInfo());
put("deviceEnergyManagement", readDeviceEnergyManagementInteractionInfo());
put("energyEvse", readEnergyEvseInteractionInfo());
+ put("energyCalendar", readEnergyCalendarInteractionInfo());
put("energyPreference", readEnergyPreferenceInteractionInfo());
put("powerTopology", readPowerTopologyInteractionInfo());
put("energyEvseMode", readEnergyEvseModeInteractionInfo());
diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterWriteMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterWriteMapping.java
index b61658cc4ef211..c42edcf0a85537 100644
--- a/src/controller/java/generated/java/chip/devicecontroller/ClusterWriteMapping.java
+++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterWriteMapping.java
@@ -1156,6 +1156,8 @@ public Map> getWriteAttributeMap() {
);
writeEnergyEvseInteractionInfo.put("writeApproximateEVEfficiencyAttribute", writeEnergyEvseApproximateEVEfficiencyAttributeInteractionInfo);
writeAttributeMap.put("energyEvse", writeEnergyEvseInteractionInfo);
+ Map writeEnergyCalendarInteractionInfo = new LinkedHashMap<>();
+ writeAttributeMap.put("energyCalendar", writeEnergyCalendarInteractionInfo);
Map writeEnergyPreferenceInteractionInfo = new LinkedHashMap<>();
Map writeEnergyPreferenceCurrentEnergyBalanceCommandParams = new LinkedHashMap();
CommandParameterInfo energyPreferencecurrentEnergyBalanceCommandParameterInfo =
diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni b/src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni
index bbaa6112dd9dea..cdb840b563f936 100644
--- a/src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni
+++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni
@@ -71,6 +71,10 @@ structs_sources = [
"${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct.kt",
"${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyStruct.kt",
"${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementRangeStruct.kt",
+ "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyCalendarClusterCalendarPeriodStruct.kt",
+ "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyCalendarClusterDayStruct.kt",
+ "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyCalendarClusterPeakPeriodStruct.kt",
+ "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyCalendarClusterTransitionStruct.kt",
"${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetScheduleStruct.kt",
"${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt",
"${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseModeClusterModeOptionStruct.kt",
diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyCalendarClusterCalendarPeriodStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyCalendarClusterCalendarPeriodStruct.kt
new file mode 100644
index 00000000000000..33496767f70b5f
--- /dev/null
+++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyCalendarClusterCalendarPeriodStruct.kt
@@ -0,0 +1,81 @@
+/*
+ *
+ * Copyright (c) 2023 Project CHIP Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package chip.devicecontroller.cluster.structs
+
+import chip.devicecontroller.cluster.*
+import matter.tlv.AnonymousTag
+import matter.tlv.ContextSpecificTag
+import matter.tlv.Tag
+import matter.tlv.TlvReader
+import matter.tlv.TlvWriter
+
+class EnergyCalendarClusterCalendarPeriodStruct(
+ val startDate: ULong?,
+ val days: List,
+) {
+ override fun toString(): String = buildString {
+ append("EnergyCalendarClusterCalendarPeriodStruct {\n")
+ append("\tstartDate : $startDate\n")
+ append("\tdays : $days\n")
+ append("}\n")
+ }
+
+ fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) {
+ tlvWriter.apply {
+ startStructure(tlvTag)
+ if (startDate != null) {
+ put(ContextSpecificTag(TAG_START_DATE), startDate)
+ } else {
+ putNull(ContextSpecificTag(TAG_START_DATE))
+ }
+ startArray(ContextSpecificTag(TAG_DAYS))
+ for (item in days.iterator()) {
+ item.toTlv(AnonymousTag, this)
+ }
+ endArray()
+ endStructure()
+ }
+ }
+
+ companion object {
+ private const val TAG_START_DATE = 0
+ private const val TAG_DAYS = 1
+
+ fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyCalendarClusterCalendarPeriodStruct {
+ tlvReader.enterStructure(tlvTag)
+ val startDate =
+ if (!tlvReader.isNull()) {
+ tlvReader.getULong(ContextSpecificTag(TAG_START_DATE))
+ } else {
+ tlvReader.getNull(ContextSpecificTag(TAG_START_DATE))
+ null
+ }
+ val days =
+ buildList {
+ tlvReader.enterArray(ContextSpecificTag(TAG_DAYS))
+ while (!tlvReader.isEndOfContainer()) {
+ add(EnergyCalendarClusterDayStruct.fromTlv(AnonymousTag, tlvReader))
+ }
+ tlvReader.exitContainer()
+ }
+
+ tlvReader.exitContainer()
+
+ return EnergyCalendarClusterCalendarPeriodStruct(startDate, days)
+ }
+ }
+}
diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyCalendarClusterDayStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyCalendarClusterDayStruct.kt
new file mode 100644
index 00000000000000..12b7b7be6cb234
--- /dev/null
+++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyCalendarClusterDayStruct.kt
@@ -0,0 +1,106 @@
+/*
+ *
+ * Copyright (c) 2023 Project CHIP Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package chip.devicecontroller.cluster.structs
+
+import chip.devicecontroller.cluster.*
+import java.util.Optional
+import matter.tlv.AnonymousTag
+import matter.tlv.ContextSpecificTag
+import matter.tlv.Tag
+import matter.tlv.TlvReader
+import matter.tlv.TlvWriter
+
+class EnergyCalendarClusterDayStruct(
+ val date: Optional,
+ val daysOfWeek: Optional,
+ val transitions: List,
+ val calendarID: Optional,
+) {
+ override fun toString(): String = buildString {
+ append("EnergyCalendarClusterDayStruct {\n")
+ append("\tdate : $date\n")
+ append("\tdaysOfWeek : $daysOfWeek\n")
+ append("\ttransitions : $transitions\n")
+ append("\tcalendarID : $calendarID\n")
+ append("}\n")
+ }
+
+ fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) {
+ tlvWriter.apply {
+ startStructure(tlvTag)
+ if (date.isPresent) {
+ val optdate = date.get()
+ put(ContextSpecificTag(TAG_DATE), optdate)
+ }
+ if (daysOfWeek.isPresent) {
+ val optdaysOfWeek = daysOfWeek.get()
+ put(ContextSpecificTag(TAG_DAYS_OF_WEEK), optdaysOfWeek)
+ }
+ startArray(ContextSpecificTag(TAG_TRANSITIONS))
+ for (item in transitions.iterator()) {
+ item.toTlv(AnonymousTag, this)
+ }
+ endArray()
+ if (calendarID.isPresent) {
+ val optcalendarID = calendarID.get()
+ put(ContextSpecificTag(TAG_CALENDAR_ID), optcalendarID)
+ }
+ endStructure()
+ }
+ }
+
+ companion object {
+ private const val TAG_DATE = 0
+ private const val TAG_DAYS_OF_WEEK = 1
+ private const val TAG_TRANSITIONS = 2
+ private const val TAG_CALENDAR_ID = 3
+
+ fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyCalendarClusterDayStruct {
+ tlvReader.enterStructure(tlvTag)
+ val date =
+ if (tlvReader.isNextTag(ContextSpecificTag(TAG_DATE))) {
+ Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_DATE)))
+ } else {
+ Optional.empty()
+ }
+ val daysOfWeek =
+ if (tlvReader.isNextTag(ContextSpecificTag(TAG_DAYS_OF_WEEK))) {
+ Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_DAYS_OF_WEEK)))
+ } else {
+ Optional.empty()
+ }
+ val transitions =
+ buildList {
+ tlvReader.enterArray(ContextSpecificTag(TAG_TRANSITIONS))
+ while (!tlvReader.isEndOfContainer()) {
+ add(EnergyCalendarClusterTransitionStruct.fromTlv(AnonymousTag, tlvReader))
+ }
+ tlvReader.exitContainer()
+ }
+ val calendarID =
+ if (tlvReader.isNextTag(ContextSpecificTag(TAG_CALENDAR_ID))) {
+ Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_CALENDAR_ID)))
+ } else {
+ Optional.empty()
+ }
+
+ tlvReader.exitContainer()
+
+ return EnergyCalendarClusterDayStruct(date, daysOfWeek, transitions, calendarID)
+ }
+ }
+}
diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyCalendarClusterPeakPeriodStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyCalendarClusterPeakPeriodStruct.kt
new file mode 100644
index 00000000000000..c14d78bf9cff5b
--- /dev/null
+++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyCalendarClusterPeakPeriodStruct.kt
@@ -0,0 +1,89 @@
+/*
+ *
+ * Copyright (c) 2023 Project CHIP Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package chip.devicecontroller.cluster.structs
+
+import chip.devicecontroller.cluster.*
+import matter.tlv.ContextSpecificTag
+import matter.tlv.Tag
+import matter.tlv.TlvReader
+import matter.tlv.TlvWriter
+
+class EnergyCalendarClusterPeakPeriodStruct(
+ val severity: UInt,
+ val peakPeriod: UInt,
+ val startTime: ULong?,
+ val endTime: ULong?,
+) {
+ override fun toString(): String = buildString {
+ append("EnergyCalendarClusterPeakPeriodStruct {\n")
+ append("\tseverity : $severity\n")
+ append("\tpeakPeriod : $peakPeriod\n")
+ append("\tstartTime : $startTime\n")
+ append("\tendTime : $endTime\n")
+ append("}\n")
+ }
+
+ fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) {
+ tlvWriter.apply {
+ startStructure(tlvTag)
+ put(ContextSpecificTag(TAG_SEVERITY), severity)
+ put(ContextSpecificTag(TAG_PEAK_PERIOD), peakPeriod)
+ if (startTime != null) {
+ put(ContextSpecificTag(TAG_START_TIME), startTime)
+ } else {
+ putNull(ContextSpecificTag(TAG_START_TIME))
+ }
+ if (endTime != null) {
+ put(ContextSpecificTag(TAG_END_TIME), endTime)
+ } else {
+ putNull(ContextSpecificTag(TAG_END_TIME))
+ }
+ endStructure()
+ }
+ }
+
+ companion object {
+ private const val TAG_SEVERITY = 0
+ private const val TAG_PEAK_PERIOD = 1
+ private const val TAG_START_TIME = 2
+ private const val TAG_END_TIME = 3
+
+ fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyCalendarClusterPeakPeriodStruct {
+ tlvReader.enterStructure(tlvTag)
+ val severity = tlvReader.getUInt(ContextSpecificTag(TAG_SEVERITY))
+ val peakPeriod = tlvReader.getUInt(ContextSpecificTag(TAG_PEAK_PERIOD))
+ val startTime =
+ if (!tlvReader.isNull()) {
+ tlvReader.getULong(ContextSpecificTag(TAG_START_TIME))
+ } else {
+ tlvReader.getNull(ContextSpecificTag(TAG_START_TIME))
+ null
+ }
+ val endTime =
+ if (!tlvReader.isNull()) {
+ tlvReader.getULong(ContextSpecificTag(TAG_END_TIME))
+ } else {
+ tlvReader.getNull(ContextSpecificTag(TAG_END_TIME))
+ null
+ }
+
+ tlvReader.exitContainer()
+
+ return EnergyCalendarClusterPeakPeriodStruct(severity, peakPeriod, startTime, endTime)
+ }
+ }
+}
diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyCalendarClusterTransitionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyCalendarClusterTransitionStruct.kt
new file mode 100644
index 00000000000000..42cb66acd89939
--- /dev/null
+++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyCalendarClusterTransitionStruct.kt
@@ -0,0 +1,99 @@
+/*
+ *
+ * Copyright (c) 2023 Project CHIP Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package chip.devicecontroller.cluster.structs
+
+import chip.devicecontroller.cluster.*
+import java.util.Optional
+import matter.tlv.ContextSpecificTag
+import matter.tlv.Tag
+import matter.tlv.TlvReader
+import matter.tlv.TlvWriter
+
+class EnergyCalendarClusterTransitionStruct(
+ val transitionTime: UInt,
+ val priceTier: Optional,
+ val friendlyCredit: Optional,
+ val auxiliaryLoad: Optional,
+) {
+ override fun toString(): String = buildString {
+ append("EnergyCalendarClusterTransitionStruct {\n")
+ append("\ttransitionTime : $transitionTime\n")
+ append("\tpriceTier : $priceTier\n")
+ append("\tfriendlyCredit : $friendlyCredit\n")
+ append("\tauxiliaryLoad : $auxiliaryLoad\n")
+ append("}\n")
+ }
+
+ fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) {
+ tlvWriter.apply {
+ startStructure(tlvTag)
+ put(ContextSpecificTag(TAG_TRANSITION_TIME), transitionTime)
+ if (priceTier.isPresent) {
+ val optpriceTier = priceTier.get()
+ put(ContextSpecificTag(TAG_PRICE_TIER), optpriceTier)
+ }
+ if (friendlyCredit.isPresent) {
+ val optfriendlyCredit = friendlyCredit.get()
+ put(ContextSpecificTag(TAG_FRIENDLY_CREDIT), optfriendlyCredit)
+ }
+ if (auxiliaryLoad.isPresent) {
+ val optauxiliaryLoad = auxiliaryLoad.get()
+ put(ContextSpecificTag(TAG_AUXILIARY_LOAD), optauxiliaryLoad)
+ }
+ endStructure()
+ }
+ }
+
+ companion object {
+ private const val TAG_TRANSITION_TIME = 0
+ private const val TAG_PRICE_TIER = 1
+ private const val TAG_FRIENDLY_CREDIT = 2
+ private const val TAG_AUXILIARY_LOAD = 3
+
+ fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyCalendarClusterTransitionStruct {
+ tlvReader.enterStructure(tlvTag)
+ val transitionTime = tlvReader.getUInt(ContextSpecificTag(TAG_TRANSITION_TIME))
+ val priceTier =
+ if (tlvReader.isNextTag(ContextSpecificTag(TAG_PRICE_TIER))) {
+ Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_PRICE_TIER)))
+ } else {
+ Optional.empty()
+ }
+ val friendlyCredit =
+ if (tlvReader.isNextTag(ContextSpecificTag(TAG_FRIENDLY_CREDIT))) {
+ Optional.of(tlvReader.getBoolean(ContextSpecificTag(TAG_FRIENDLY_CREDIT)))
+ } else {
+ Optional.empty()
+ }
+ val auxiliaryLoad =
+ if (tlvReader.isNextTag(ContextSpecificTag(TAG_AUXILIARY_LOAD))) {
+ Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_AUXILIARY_LOAD)))
+ } else {
+ Optional.empty()
+ }
+
+ tlvReader.exitContainer()
+
+ return EnergyCalendarClusterTransitionStruct(
+ transitionTime,
+ priceTier,
+ friendlyCredit,
+ auxiliaryLoad,
+ )
+ }
+ }
+}
diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyCalendarCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyCalendarCluster.kt
new file mode 100644
index 00000000000000..182eafbb889c9e
--- /dev/null
+++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyCalendarCluster.kt
@@ -0,0 +1,1924 @@
+/*
+ *
+ * Copyright (c) 2023 Project CHIP Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package matter.controller.cluster.clusters
+
+import java.time.Duration
+import java.util.logging.Level
+import java.util.logging.Logger
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.transform
+import matter.controller.MatterController
+import matter.controller.ReadData
+import matter.controller.ReadRequest
+import matter.controller.SubscribeRequest
+import matter.controller.SubscriptionState
+import matter.controller.UIntSubscriptionState
+import matter.controller.UShortSubscriptionState
+import matter.controller.cluster.structs.*
+import matter.controller.model.AttributePath
+import matter.tlv.AnonymousTag
+import matter.tlv.TlvReader
+
+class EnergyCalendarCluster(
+ private val controller: MatterController,
+ private val endpointId: UShort,
+) {
+ class CalendarIDAttribute(val value: UInt?)
+
+ sealed class CalendarIDAttributeSubscriptionState {
+ data class Success(val value: UInt?) : CalendarIDAttributeSubscriptionState()
+
+ data class Error(val exception: Exception) : CalendarIDAttributeSubscriptionState()
+
+ object SubscriptionEstablished : CalendarIDAttributeSubscriptionState()
+ }
+
+ class NameAttribute(val value: String?)
+
+ sealed class NameAttributeSubscriptionState {
+ data class Success(val value: String?) : NameAttributeSubscriptionState()
+
+ data class Error(val exception: Exception) : NameAttributeSubscriptionState()
+
+ object SubscriptionEstablished : NameAttributeSubscriptionState()
+ }
+
+ class ProviderIDAttribute(val value: UInt?)
+
+ sealed class ProviderIDAttributeSubscriptionState {
+ data class Success(val value: UInt?) : ProviderIDAttributeSubscriptionState()
+
+ data class Error(val exception: Exception) : ProviderIDAttributeSubscriptionState()
+
+ object SubscriptionEstablished : ProviderIDAttributeSubscriptionState()
+ }
+
+ class EventIDAttribute(val value: UInt?)
+
+ sealed class EventIDAttributeSubscriptionState {
+ data class Success(val value: UInt?) : EventIDAttributeSubscriptionState()
+
+ data class Error(val exception: Exception) : EventIDAttributeSubscriptionState()
+
+ object SubscriptionEstablished : EventIDAttributeSubscriptionState()
+ }
+
+ class StartDateAttribute(val value: UInt?)
+
+ sealed class StartDateAttributeSubscriptionState {
+ data class Success(val value: UInt?) : StartDateAttributeSubscriptionState()
+
+ data class Error(val exception: Exception) : StartDateAttributeSubscriptionState()
+
+ object SubscriptionEstablished : StartDateAttributeSubscriptionState()
+ }
+
+ class CalendarPeriodsAttribute(val value: List?)
+
+ sealed class CalendarPeriodsAttributeSubscriptionState {
+ data class Success(val value: List?) :
+ CalendarPeriodsAttributeSubscriptionState()
+
+ data class Error(val exception: Exception) : CalendarPeriodsAttributeSubscriptionState()
+
+ object SubscriptionEstablished : CalendarPeriodsAttributeSubscriptionState()
+ }
+
+ class SpecialDaysAttribute(val value: List?)
+
+ sealed class SpecialDaysAttributeSubscriptionState {
+ data class Success(val value: List?) :
+ SpecialDaysAttributeSubscriptionState()
+
+ data class Error(val exception: Exception) : SpecialDaysAttributeSubscriptionState()
+
+ object SubscriptionEstablished : SpecialDaysAttributeSubscriptionState()
+ }
+
+ class CurrentDayAttribute(val value: EnergyCalendarClusterDayStruct?)
+
+ sealed class CurrentDayAttributeSubscriptionState {
+ data class Success(val value: EnergyCalendarClusterDayStruct?) :
+ CurrentDayAttributeSubscriptionState()
+
+ data class Error(val exception: Exception) : CurrentDayAttributeSubscriptionState()
+
+ object SubscriptionEstablished : CurrentDayAttributeSubscriptionState()
+ }
+
+ class NextDayAttribute(val value: EnergyCalendarClusterDayStruct?)
+
+ sealed class NextDayAttributeSubscriptionState {
+ data class Success(val value: EnergyCalendarClusterDayStruct?) :
+ NextDayAttributeSubscriptionState()
+
+ data class Error(val exception: Exception) : NextDayAttributeSubscriptionState()
+
+ object SubscriptionEstablished : NextDayAttributeSubscriptionState()
+ }
+
+ class CurrentTransitionAttribute(val value: EnergyCalendarClusterTransitionStruct?)
+
+ sealed class CurrentTransitionAttributeSubscriptionState {
+ data class Success(val value: EnergyCalendarClusterTransitionStruct?) :
+ CurrentTransitionAttributeSubscriptionState()
+
+ data class Error(val exception: Exception) : CurrentTransitionAttributeSubscriptionState()
+
+ object SubscriptionEstablished : CurrentTransitionAttributeSubscriptionState()
+ }
+
+ class CurrentPeakPeriodAttribute(val value: EnergyCalendarClusterPeakPeriodStruct?)
+
+ sealed class CurrentPeakPeriodAttributeSubscriptionState {
+ data class Success(val value: EnergyCalendarClusterPeakPeriodStruct?) :
+ CurrentPeakPeriodAttributeSubscriptionState()
+
+ data class Error(val exception: Exception) : CurrentPeakPeriodAttributeSubscriptionState()
+
+ object SubscriptionEstablished : CurrentPeakPeriodAttributeSubscriptionState()
+ }
+
+ class NextPeakPeriodAttribute(val value: EnergyCalendarClusterPeakPeriodStruct?)
+
+ sealed class NextPeakPeriodAttributeSubscriptionState {
+ data class Success(val value: EnergyCalendarClusterPeakPeriodStruct?) :
+ NextPeakPeriodAttributeSubscriptionState()
+
+ data class Error(val exception: Exception) : NextPeakPeriodAttributeSubscriptionState()
+
+ object SubscriptionEstablished : NextPeakPeriodAttributeSubscriptionState()
+ }
+
+ class GeneratedCommandListAttribute(val value: List)
+
+ sealed class GeneratedCommandListAttributeSubscriptionState {
+ data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState()
+
+ data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState()
+
+ object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState()
+ }
+
+ class AcceptedCommandListAttribute(val value: List)
+
+ sealed class AcceptedCommandListAttributeSubscriptionState {
+ data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState()
+
+ data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState()
+
+ object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState()
+ }
+
+ class EventListAttribute(val value: List)
+
+ sealed class EventListAttributeSubscriptionState {
+ data class Success(val value: List) : EventListAttributeSubscriptionState()
+
+ data class Error(val exception: Exception) : EventListAttributeSubscriptionState()
+
+ object SubscriptionEstablished : EventListAttributeSubscriptionState()
+ }
+
+ class AttributeListAttribute(val value: List)
+
+ sealed class AttributeListAttributeSubscriptionState {
+ data class Success(val value: List) : AttributeListAttributeSubscriptionState()
+
+ data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState()
+
+ object SubscriptionEstablished : AttributeListAttributeSubscriptionState()
+ }
+
+ suspend fun readCalendarIDAttribute(): CalendarIDAttribute {
+ val ATTRIBUTE_ID: UInt = 0u
+
+ val attributePath =
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+
+ val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath))
+
+ val response = controller.read(readRequest)
+
+ if (response.successes.isEmpty()) {
+ logger.log(Level.WARNING, "Read command failed")
+ throw IllegalStateException("Read command failed with failures: ${response.failures}")
+ }
+
+ logger.log(Level.FINE, "Read command succeeded")
+
+ val attributeData =
+ response.successes.filterIsInstance().firstOrNull {
+ it.path.attributeId == ATTRIBUTE_ID
+ }
+
+ requireNotNull(attributeData) { "Calendarid attribute not found in response" }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: UInt? =
+ if (!tlvReader.isNull()) {
+ tlvReader.getUInt(AnonymousTag)
+ } else {
+ tlvReader.getNull(AnonymousTag)
+ null
+ }
+
+ return CalendarIDAttribute(decodedValue)
+ }
+
+ suspend fun subscribeCalendarIDAttribute(
+ minInterval: Int,
+ maxInterval: Int,
+ ): Flow {
+ val ATTRIBUTE_ID: UInt = 0u
+ val attributePaths =
+ listOf(
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+ )
+
+ val subscribeRequest: SubscribeRequest =
+ SubscribeRequest(
+ eventPaths = emptyList(),
+ attributePaths = attributePaths,
+ minInterval = Duration.ofSeconds(minInterval.toLong()),
+ maxInterval = Duration.ofSeconds(maxInterval.toLong()),
+ )
+
+ return controller.subscribe(subscribeRequest).transform { subscriptionState ->
+ when (subscriptionState) {
+ is SubscriptionState.SubscriptionErrorNotification -> {
+ emit(
+ CalendarIDAttributeSubscriptionState.Error(
+ Exception(
+ "Subscription terminated with error code: ${subscriptionState.terminationCause}"
+ )
+ )
+ )
+ }
+ is SubscriptionState.NodeStateUpdate -> {
+ val attributeData =
+ subscriptionState.updateState.successes
+ .filterIsInstance()
+ .firstOrNull { it.path.attributeId == ATTRIBUTE_ID }
+
+ requireNotNull(attributeData) { "Calendarid attribute not found in Node State update" }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: UInt? =
+ if (!tlvReader.isNull()) {
+ tlvReader.getUInt(AnonymousTag)
+ } else {
+ tlvReader.getNull(AnonymousTag)
+ null
+ }
+
+ decodedValue?.let { emit(CalendarIDAttributeSubscriptionState.Success(it)) }
+ }
+ SubscriptionState.SubscriptionEstablished -> {
+ emit(CalendarIDAttributeSubscriptionState.SubscriptionEstablished)
+ }
+ }
+ }
+ }
+
+ suspend fun readNameAttribute(): NameAttribute {
+ val ATTRIBUTE_ID: UInt = 1u
+
+ val attributePath =
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+
+ val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath))
+
+ val response = controller.read(readRequest)
+
+ if (response.successes.isEmpty()) {
+ logger.log(Level.WARNING, "Read command failed")
+ throw IllegalStateException("Read command failed with failures: ${response.failures}")
+ }
+
+ logger.log(Level.FINE, "Read command succeeded")
+
+ val attributeData =
+ response.successes.filterIsInstance().firstOrNull {
+ it.path.attributeId == ATTRIBUTE_ID
+ }
+
+ requireNotNull(attributeData) { "Name attribute not found in response" }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: String? =
+ if (!tlvReader.isNull()) {
+ tlvReader.getString(AnonymousTag)
+ } else {
+ tlvReader.getNull(AnonymousTag)
+ null
+ }
+
+ return NameAttribute(decodedValue)
+ }
+
+ suspend fun subscribeNameAttribute(
+ minInterval: Int,
+ maxInterval: Int,
+ ): Flow {
+ val ATTRIBUTE_ID: UInt = 1u
+ val attributePaths =
+ listOf(
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+ )
+
+ val subscribeRequest: SubscribeRequest =
+ SubscribeRequest(
+ eventPaths = emptyList(),
+ attributePaths = attributePaths,
+ minInterval = Duration.ofSeconds(minInterval.toLong()),
+ maxInterval = Duration.ofSeconds(maxInterval.toLong()),
+ )
+
+ return controller.subscribe(subscribeRequest).transform { subscriptionState ->
+ when (subscriptionState) {
+ is SubscriptionState.SubscriptionErrorNotification -> {
+ emit(
+ NameAttributeSubscriptionState.Error(
+ Exception(
+ "Subscription terminated with error code: ${subscriptionState.terminationCause}"
+ )
+ )
+ )
+ }
+ is SubscriptionState.NodeStateUpdate -> {
+ val attributeData =
+ subscriptionState.updateState.successes
+ .filterIsInstance()
+ .firstOrNull { it.path.attributeId == ATTRIBUTE_ID }
+
+ requireNotNull(attributeData) { "Name attribute not found in Node State update" }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: String? =
+ if (!tlvReader.isNull()) {
+ tlvReader.getString(AnonymousTag)
+ } else {
+ tlvReader.getNull(AnonymousTag)
+ null
+ }
+
+ decodedValue?.let { emit(NameAttributeSubscriptionState.Success(it)) }
+ }
+ SubscriptionState.SubscriptionEstablished -> {
+ emit(NameAttributeSubscriptionState.SubscriptionEstablished)
+ }
+ }
+ }
+ }
+
+ suspend fun readProviderIDAttribute(): ProviderIDAttribute {
+ val ATTRIBUTE_ID: UInt = 2u
+
+ val attributePath =
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+
+ val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath))
+
+ val response = controller.read(readRequest)
+
+ if (response.successes.isEmpty()) {
+ logger.log(Level.WARNING, "Read command failed")
+ throw IllegalStateException("Read command failed with failures: ${response.failures}")
+ }
+
+ logger.log(Level.FINE, "Read command succeeded")
+
+ val attributeData =
+ response.successes.filterIsInstance().firstOrNull {
+ it.path.attributeId == ATTRIBUTE_ID
+ }
+
+ requireNotNull(attributeData) { "Providerid attribute not found in response" }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: UInt? =
+ if (!tlvReader.isNull()) {
+ tlvReader.getUInt(AnonymousTag)
+ } else {
+ tlvReader.getNull(AnonymousTag)
+ null
+ }
+
+ return ProviderIDAttribute(decodedValue)
+ }
+
+ suspend fun subscribeProviderIDAttribute(
+ minInterval: Int,
+ maxInterval: Int,
+ ): Flow {
+ val ATTRIBUTE_ID: UInt = 2u
+ val attributePaths =
+ listOf(
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+ )
+
+ val subscribeRequest: SubscribeRequest =
+ SubscribeRequest(
+ eventPaths = emptyList(),
+ attributePaths = attributePaths,
+ minInterval = Duration.ofSeconds(minInterval.toLong()),
+ maxInterval = Duration.ofSeconds(maxInterval.toLong()),
+ )
+
+ return controller.subscribe(subscribeRequest).transform { subscriptionState ->
+ when (subscriptionState) {
+ is SubscriptionState.SubscriptionErrorNotification -> {
+ emit(
+ ProviderIDAttributeSubscriptionState.Error(
+ Exception(
+ "Subscription terminated with error code: ${subscriptionState.terminationCause}"
+ )
+ )
+ )
+ }
+ is SubscriptionState.NodeStateUpdate -> {
+ val attributeData =
+ subscriptionState.updateState.successes
+ .filterIsInstance()
+ .firstOrNull { it.path.attributeId == ATTRIBUTE_ID }
+
+ requireNotNull(attributeData) { "Providerid attribute not found in Node State update" }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: UInt? =
+ if (!tlvReader.isNull()) {
+ tlvReader.getUInt(AnonymousTag)
+ } else {
+ tlvReader.getNull(AnonymousTag)
+ null
+ }
+
+ decodedValue?.let { emit(ProviderIDAttributeSubscriptionState.Success(it)) }
+ }
+ SubscriptionState.SubscriptionEstablished -> {
+ emit(ProviderIDAttributeSubscriptionState.SubscriptionEstablished)
+ }
+ }
+ }
+ }
+
+ suspend fun readEventIDAttribute(): EventIDAttribute {
+ val ATTRIBUTE_ID: UInt = 3u
+
+ val attributePath =
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+
+ val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath))
+
+ val response = controller.read(readRequest)
+
+ if (response.successes.isEmpty()) {
+ logger.log(Level.WARNING, "Read command failed")
+ throw IllegalStateException("Read command failed with failures: ${response.failures}")
+ }
+
+ logger.log(Level.FINE, "Read command succeeded")
+
+ val attributeData =
+ response.successes.filterIsInstance().firstOrNull {
+ it.path.attributeId == ATTRIBUTE_ID
+ }
+
+ requireNotNull(attributeData) { "Eventid attribute not found in response" }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: UInt? =
+ if (!tlvReader.isNull()) {
+ tlvReader.getUInt(AnonymousTag)
+ } else {
+ tlvReader.getNull(AnonymousTag)
+ null
+ }
+
+ return EventIDAttribute(decodedValue)
+ }
+
+ suspend fun subscribeEventIDAttribute(
+ minInterval: Int,
+ maxInterval: Int,
+ ): Flow {
+ val ATTRIBUTE_ID: UInt = 3u
+ val attributePaths =
+ listOf(
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+ )
+
+ val subscribeRequest: SubscribeRequest =
+ SubscribeRequest(
+ eventPaths = emptyList(),
+ attributePaths = attributePaths,
+ minInterval = Duration.ofSeconds(minInterval.toLong()),
+ maxInterval = Duration.ofSeconds(maxInterval.toLong()),
+ )
+
+ return controller.subscribe(subscribeRequest).transform { subscriptionState ->
+ when (subscriptionState) {
+ is SubscriptionState.SubscriptionErrorNotification -> {
+ emit(
+ EventIDAttributeSubscriptionState.Error(
+ Exception(
+ "Subscription terminated with error code: ${subscriptionState.terminationCause}"
+ )
+ )
+ )
+ }
+ is SubscriptionState.NodeStateUpdate -> {
+ val attributeData =
+ subscriptionState.updateState.successes
+ .filterIsInstance()
+ .firstOrNull { it.path.attributeId == ATTRIBUTE_ID }
+
+ requireNotNull(attributeData) { "Eventid attribute not found in Node State update" }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: UInt? =
+ if (!tlvReader.isNull()) {
+ tlvReader.getUInt(AnonymousTag)
+ } else {
+ tlvReader.getNull(AnonymousTag)
+ null
+ }
+
+ decodedValue?.let { emit(EventIDAttributeSubscriptionState.Success(it)) }
+ }
+ SubscriptionState.SubscriptionEstablished -> {
+ emit(EventIDAttributeSubscriptionState.SubscriptionEstablished)
+ }
+ }
+ }
+ }
+
+ suspend fun readStartDateAttribute(): StartDateAttribute {
+ val ATTRIBUTE_ID: UInt = 4u
+
+ val attributePath =
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+
+ val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath))
+
+ val response = controller.read(readRequest)
+
+ if (response.successes.isEmpty()) {
+ logger.log(Level.WARNING, "Read command failed")
+ throw IllegalStateException("Read command failed with failures: ${response.failures}")
+ }
+
+ logger.log(Level.FINE, "Read command succeeded")
+
+ val attributeData =
+ response.successes.filterIsInstance().firstOrNull {
+ it.path.attributeId == ATTRIBUTE_ID
+ }
+
+ requireNotNull(attributeData) { "Startdate attribute not found in response" }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: UInt? =
+ if (!tlvReader.isNull()) {
+ tlvReader.getUInt(AnonymousTag)
+ } else {
+ tlvReader.getNull(AnonymousTag)
+ null
+ }
+
+ return StartDateAttribute(decodedValue)
+ }
+
+ suspend fun subscribeStartDateAttribute(
+ minInterval: Int,
+ maxInterval: Int,
+ ): Flow {
+ val ATTRIBUTE_ID: UInt = 4u
+ val attributePaths =
+ listOf(
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+ )
+
+ val subscribeRequest: SubscribeRequest =
+ SubscribeRequest(
+ eventPaths = emptyList(),
+ attributePaths = attributePaths,
+ minInterval = Duration.ofSeconds(minInterval.toLong()),
+ maxInterval = Duration.ofSeconds(maxInterval.toLong()),
+ )
+
+ return controller.subscribe(subscribeRequest).transform { subscriptionState ->
+ when (subscriptionState) {
+ is SubscriptionState.SubscriptionErrorNotification -> {
+ emit(
+ StartDateAttributeSubscriptionState.Error(
+ Exception(
+ "Subscription terminated with error code: ${subscriptionState.terminationCause}"
+ )
+ )
+ )
+ }
+ is SubscriptionState.NodeStateUpdate -> {
+ val attributeData =
+ subscriptionState.updateState.successes
+ .filterIsInstance()
+ .firstOrNull { it.path.attributeId == ATTRIBUTE_ID }
+
+ requireNotNull(attributeData) { "Startdate attribute not found in Node State update" }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: UInt? =
+ if (!tlvReader.isNull()) {
+ tlvReader.getUInt(AnonymousTag)
+ } else {
+ tlvReader.getNull(AnonymousTag)
+ null
+ }
+
+ decodedValue?.let { emit(StartDateAttributeSubscriptionState.Success(it)) }
+ }
+ SubscriptionState.SubscriptionEstablished -> {
+ emit(StartDateAttributeSubscriptionState.SubscriptionEstablished)
+ }
+ }
+ }
+ }
+
+ suspend fun readCalendarPeriodsAttribute(): CalendarPeriodsAttribute {
+ val ATTRIBUTE_ID: UInt = 5u
+
+ val attributePath =
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+
+ val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath))
+
+ val response = controller.read(readRequest)
+
+ if (response.successes.isEmpty()) {
+ logger.log(Level.WARNING, "Read command failed")
+ throw IllegalStateException("Read command failed with failures: ${response.failures}")
+ }
+
+ logger.log(Level.FINE, "Read command succeeded")
+
+ val attributeData =
+ response.successes.filterIsInstance().firstOrNull {
+ it.path.attributeId == ATTRIBUTE_ID
+ }
+
+ requireNotNull(attributeData) { "Calendarperiods attribute not found in response" }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: List? =
+ if (!tlvReader.isNull()) {
+ buildList {
+ tlvReader.enterArray(AnonymousTag)
+ while (!tlvReader.isEndOfContainer()) {
+ add(EnergyCalendarClusterCalendarPeriodStruct.fromTlv(AnonymousTag, tlvReader))
+ }
+ tlvReader.exitContainer()
+ }
+ } else {
+ tlvReader.getNull(AnonymousTag)
+ null
+ }
+
+ return CalendarPeriodsAttribute(decodedValue)
+ }
+
+ suspend fun subscribeCalendarPeriodsAttribute(
+ minInterval: Int,
+ maxInterval: Int,
+ ): Flow {
+ val ATTRIBUTE_ID: UInt = 5u
+ val attributePaths =
+ listOf(
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+ )
+
+ val subscribeRequest: SubscribeRequest =
+ SubscribeRequest(
+ eventPaths = emptyList(),
+ attributePaths = attributePaths,
+ minInterval = Duration.ofSeconds(minInterval.toLong()),
+ maxInterval = Duration.ofSeconds(maxInterval.toLong()),
+ )
+
+ return controller.subscribe(subscribeRequest).transform { subscriptionState ->
+ when (subscriptionState) {
+ is SubscriptionState.SubscriptionErrorNotification -> {
+ emit(
+ CalendarPeriodsAttributeSubscriptionState.Error(
+ Exception(
+ "Subscription terminated with error code: ${subscriptionState.terminationCause}"
+ )
+ )
+ )
+ }
+ is SubscriptionState.NodeStateUpdate -> {
+ val attributeData =
+ subscriptionState.updateState.successes
+ .filterIsInstance()
+ .firstOrNull { it.path.attributeId == ATTRIBUTE_ID }
+
+ requireNotNull(attributeData) {
+ "Calendarperiods attribute not found in Node State update"
+ }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: List? =
+ if (!tlvReader.isNull()) {
+ buildList {
+ tlvReader.enterArray(AnonymousTag)
+ while (!tlvReader.isEndOfContainer()) {
+ add(EnergyCalendarClusterCalendarPeriodStruct.fromTlv(AnonymousTag, tlvReader))
+ }
+ tlvReader.exitContainer()
+ }
+ } else {
+ tlvReader.getNull(AnonymousTag)
+ null
+ }
+
+ decodedValue?.let { emit(CalendarPeriodsAttributeSubscriptionState.Success(it)) }
+ }
+ SubscriptionState.SubscriptionEstablished -> {
+ emit(CalendarPeriodsAttributeSubscriptionState.SubscriptionEstablished)
+ }
+ }
+ }
+ }
+
+ suspend fun readSpecialDaysAttribute(): SpecialDaysAttribute {
+ val ATTRIBUTE_ID: UInt = 6u
+
+ val attributePath =
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+
+ val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath))
+
+ val response = controller.read(readRequest)
+
+ if (response.successes.isEmpty()) {
+ logger.log(Level.WARNING, "Read command failed")
+ throw IllegalStateException("Read command failed with failures: ${response.failures}")
+ }
+
+ logger.log(Level.FINE, "Read command succeeded")
+
+ val attributeData =
+ response.successes.filterIsInstance().firstOrNull {
+ it.path.attributeId == ATTRIBUTE_ID
+ }
+
+ requireNotNull(attributeData) { "Specialdays attribute not found in response" }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: List? =
+ if (!tlvReader.isNull()) {
+ buildList {
+ tlvReader.enterArray(AnonymousTag)
+ while (!tlvReader.isEndOfContainer()) {
+ add(EnergyCalendarClusterDayStruct.fromTlv(AnonymousTag, tlvReader))
+ }
+ tlvReader.exitContainer()
+ }
+ } else {
+ tlvReader.getNull(AnonymousTag)
+ null
+ }
+
+ return SpecialDaysAttribute(decodedValue)
+ }
+
+ suspend fun subscribeSpecialDaysAttribute(
+ minInterval: Int,
+ maxInterval: Int,
+ ): Flow {
+ val ATTRIBUTE_ID: UInt = 6u
+ val attributePaths =
+ listOf(
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+ )
+
+ val subscribeRequest: SubscribeRequest =
+ SubscribeRequest(
+ eventPaths = emptyList(),
+ attributePaths = attributePaths,
+ minInterval = Duration.ofSeconds(minInterval.toLong()),
+ maxInterval = Duration.ofSeconds(maxInterval.toLong()),
+ )
+
+ return controller.subscribe(subscribeRequest).transform { subscriptionState ->
+ when (subscriptionState) {
+ is SubscriptionState.SubscriptionErrorNotification -> {
+ emit(
+ SpecialDaysAttributeSubscriptionState.Error(
+ Exception(
+ "Subscription terminated with error code: ${subscriptionState.terminationCause}"
+ )
+ )
+ )
+ }
+ is SubscriptionState.NodeStateUpdate -> {
+ val attributeData =
+ subscriptionState.updateState.successes
+ .filterIsInstance()
+ .firstOrNull { it.path.attributeId == ATTRIBUTE_ID }
+
+ requireNotNull(attributeData) { "Specialdays attribute not found in Node State update" }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: List? =
+ if (!tlvReader.isNull()) {
+ buildList {
+ tlvReader.enterArray(AnonymousTag)
+ while (!tlvReader.isEndOfContainer()) {
+ add(EnergyCalendarClusterDayStruct.fromTlv(AnonymousTag, tlvReader))
+ }
+ tlvReader.exitContainer()
+ }
+ } else {
+ tlvReader.getNull(AnonymousTag)
+ null
+ }
+
+ decodedValue?.let { emit(SpecialDaysAttributeSubscriptionState.Success(it)) }
+ }
+ SubscriptionState.SubscriptionEstablished -> {
+ emit(SpecialDaysAttributeSubscriptionState.SubscriptionEstablished)
+ }
+ }
+ }
+ }
+
+ suspend fun readCurrentDayAttribute(): CurrentDayAttribute {
+ val ATTRIBUTE_ID: UInt = 7u
+
+ val attributePath =
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+
+ val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath))
+
+ val response = controller.read(readRequest)
+
+ if (response.successes.isEmpty()) {
+ logger.log(Level.WARNING, "Read command failed")
+ throw IllegalStateException("Read command failed with failures: ${response.failures}")
+ }
+
+ logger.log(Level.FINE, "Read command succeeded")
+
+ val attributeData =
+ response.successes.filterIsInstance().firstOrNull {
+ it.path.attributeId == ATTRIBUTE_ID
+ }
+
+ requireNotNull(attributeData) { "Currentday attribute not found in response" }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: EnergyCalendarClusterDayStruct? =
+ if (!tlvReader.isNull()) {
+ EnergyCalendarClusterDayStruct.fromTlv(AnonymousTag, tlvReader)
+ } else {
+ tlvReader.getNull(AnonymousTag)
+ null
+ }
+
+ return CurrentDayAttribute(decodedValue)
+ }
+
+ suspend fun subscribeCurrentDayAttribute(
+ minInterval: Int,
+ maxInterval: Int,
+ ): Flow {
+ val ATTRIBUTE_ID: UInt = 7u
+ val attributePaths =
+ listOf(
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+ )
+
+ val subscribeRequest: SubscribeRequest =
+ SubscribeRequest(
+ eventPaths = emptyList(),
+ attributePaths = attributePaths,
+ minInterval = Duration.ofSeconds(minInterval.toLong()),
+ maxInterval = Duration.ofSeconds(maxInterval.toLong()),
+ )
+
+ return controller.subscribe(subscribeRequest).transform { subscriptionState ->
+ when (subscriptionState) {
+ is SubscriptionState.SubscriptionErrorNotification -> {
+ emit(
+ CurrentDayAttributeSubscriptionState.Error(
+ Exception(
+ "Subscription terminated with error code: ${subscriptionState.terminationCause}"
+ )
+ )
+ )
+ }
+ is SubscriptionState.NodeStateUpdate -> {
+ val attributeData =
+ subscriptionState.updateState.successes
+ .filterIsInstance()
+ .firstOrNull { it.path.attributeId == ATTRIBUTE_ID }
+
+ requireNotNull(attributeData) { "Currentday attribute not found in Node State update" }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: EnergyCalendarClusterDayStruct? =
+ if (!tlvReader.isNull()) {
+ EnergyCalendarClusterDayStruct.fromTlv(AnonymousTag, tlvReader)
+ } else {
+ tlvReader.getNull(AnonymousTag)
+ null
+ }
+
+ decodedValue?.let { emit(CurrentDayAttributeSubscriptionState.Success(it)) }
+ }
+ SubscriptionState.SubscriptionEstablished -> {
+ emit(CurrentDayAttributeSubscriptionState.SubscriptionEstablished)
+ }
+ }
+ }
+ }
+
+ suspend fun readNextDayAttribute(): NextDayAttribute {
+ val ATTRIBUTE_ID: UInt = 8u
+
+ val attributePath =
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+
+ val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath))
+
+ val response = controller.read(readRequest)
+
+ if (response.successes.isEmpty()) {
+ logger.log(Level.WARNING, "Read command failed")
+ throw IllegalStateException("Read command failed with failures: ${response.failures}")
+ }
+
+ logger.log(Level.FINE, "Read command succeeded")
+
+ val attributeData =
+ response.successes.filterIsInstance().firstOrNull {
+ it.path.attributeId == ATTRIBUTE_ID
+ }
+
+ requireNotNull(attributeData) { "Nextday attribute not found in response" }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: EnergyCalendarClusterDayStruct? =
+ if (!tlvReader.isNull()) {
+ EnergyCalendarClusterDayStruct.fromTlv(AnonymousTag, tlvReader)
+ } else {
+ tlvReader.getNull(AnonymousTag)
+ null
+ }
+
+ return NextDayAttribute(decodedValue)
+ }
+
+ suspend fun subscribeNextDayAttribute(
+ minInterval: Int,
+ maxInterval: Int,
+ ): Flow {
+ val ATTRIBUTE_ID: UInt = 8u
+ val attributePaths =
+ listOf(
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+ )
+
+ val subscribeRequest: SubscribeRequest =
+ SubscribeRequest(
+ eventPaths = emptyList(),
+ attributePaths = attributePaths,
+ minInterval = Duration.ofSeconds(minInterval.toLong()),
+ maxInterval = Duration.ofSeconds(maxInterval.toLong()),
+ )
+
+ return controller.subscribe(subscribeRequest).transform { subscriptionState ->
+ when (subscriptionState) {
+ is SubscriptionState.SubscriptionErrorNotification -> {
+ emit(
+ NextDayAttributeSubscriptionState.Error(
+ Exception(
+ "Subscription terminated with error code: ${subscriptionState.terminationCause}"
+ )
+ )
+ )
+ }
+ is SubscriptionState.NodeStateUpdate -> {
+ val attributeData =
+ subscriptionState.updateState.successes
+ .filterIsInstance()
+ .firstOrNull { it.path.attributeId == ATTRIBUTE_ID }
+
+ requireNotNull(attributeData) { "Nextday attribute not found in Node State update" }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: EnergyCalendarClusterDayStruct? =
+ if (!tlvReader.isNull()) {
+ EnergyCalendarClusterDayStruct.fromTlv(AnonymousTag, tlvReader)
+ } else {
+ tlvReader.getNull(AnonymousTag)
+ null
+ }
+
+ decodedValue?.let { emit(NextDayAttributeSubscriptionState.Success(it)) }
+ }
+ SubscriptionState.SubscriptionEstablished -> {
+ emit(NextDayAttributeSubscriptionState.SubscriptionEstablished)
+ }
+ }
+ }
+ }
+
+ suspend fun readCurrentTransitionAttribute(): CurrentTransitionAttribute {
+ val ATTRIBUTE_ID: UInt = 9u
+
+ val attributePath =
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+
+ val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath))
+
+ val response = controller.read(readRequest)
+
+ if (response.successes.isEmpty()) {
+ logger.log(Level.WARNING, "Read command failed")
+ throw IllegalStateException("Read command failed with failures: ${response.failures}")
+ }
+
+ logger.log(Level.FINE, "Read command succeeded")
+
+ val attributeData =
+ response.successes.filterIsInstance().firstOrNull {
+ it.path.attributeId == ATTRIBUTE_ID
+ }
+
+ requireNotNull(attributeData) { "Currenttransition attribute not found in response" }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: EnergyCalendarClusterTransitionStruct? =
+ if (!tlvReader.isNull()) {
+ EnergyCalendarClusterTransitionStruct.fromTlv(AnonymousTag, tlvReader)
+ } else {
+ tlvReader.getNull(AnonymousTag)
+ null
+ }
+
+ return CurrentTransitionAttribute(decodedValue)
+ }
+
+ suspend fun subscribeCurrentTransitionAttribute(
+ minInterval: Int,
+ maxInterval: Int,
+ ): Flow {
+ val ATTRIBUTE_ID: UInt = 9u
+ val attributePaths =
+ listOf(
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+ )
+
+ val subscribeRequest: SubscribeRequest =
+ SubscribeRequest(
+ eventPaths = emptyList(),
+ attributePaths = attributePaths,
+ minInterval = Duration.ofSeconds(minInterval.toLong()),
+ maxInterval = Duration.ofSeconds(maxInterval.toLong()),
+ )
+
+ return controller.subscribe(subscribeRequest).transform { subscriptionState ->
+ when (subscriptionState) {
+ is SubscriptionState.SubscriptionErrorNotification -> {
+ emit(
+ CurrentTransitionAttributeSubscriptionState.Error(
+ Exception(
+ "Subscription terminated with error code: ${subscriptionState.terminationCause}"
+ )
+ )
+ )
+ }
+ is SubscriptionState.NodeStateUpdate -> {
+ val attributeData =
+ subscriptionState.updateState.successes
+ .filterIsInstance()
+ .firstOrNull { it.path.attributeId == ATTRIBUTE_ID }
+
+ requireNotNull(attributeData) {
+ "Currenttransition attribute not found in Node State update"
+ }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: EnergyCalendarClusterTransitionStruct? =
+ if (!tlvReader.isNull()) {
+ EnergyCalendarClusterTransitionStruct.fromTlv(AnonymousTag, tlvReader)
+ } else {
+ tlvReader.getNull(AnonymousTag)
+ null
+ }
+
+ decodedValue?.let { emit(CurrentTransitionAttributeSubscriptionState.Success(it)) }
+ }
+ SubscriptionState.SubscriptionEstablished -> {
+ emit(CurrentTransitionAttributeSubscriptionState.SubscriptionEstablished)
+ }
+ }
+ }
+ }
+
+ suspend fun readCurrentPeakPeriodAttribute(): CurrentPeakPeriodAttribute {
+ val ATTRIBUTE_ID: UInt = 10u
+
+ val attributePath =
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+
+ val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath))
+
+ val response = controller.read(readRequest)
+
+ if (response.successes.isEmpty()) {
+ logger.log(Level.WARNING, "Read command failed")
+ throw IllegalStateException("Read command failed with failures: ${response.failures}")
+ }
+
+ logger.log(Level.FINE, "Read command succeeded")
+
+ val attributeData =
+ response.successes.filterIsInstance().firstOrNull {
+ it.path.attributeId == ATTRIBUTE_ID
+ }
+
+ requireNotNull(attributeData) { "Currentpeakperiod attribute not found in response" }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: EnergyCalendarClusterPeakPeriodStruct? =
+ if (!tlvReader.isNull()) {
+ if (tlvReader.isNextTag(AnonymousTag)) {
+ EnergyCalendarClusterPeakPeriodStruct.fromTlv(AnonymousTag, tlvReader)
+ } else {
+ null
+ }
+ } else {
+ tlvReader.getNull(AnonymousTag)
+ null
+ }
+
+ return CurrentPeakPeriodAttribute(decodedValue)
+ }
+
+ suspend fun subscribeCurrentPeakPeriodAttribute(
+ minInterval: Int,
+ maxInterval: Int,
+ ): Flow {
+ val ATTRIBUTE_ID: UInt = 10u
+ val attributePaths =
+ listOf(
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+ )
+
+ val subscribeRequest: SubscribeRequest =
+ SubscribeRequest(
+ eventPaths = emptyList(),
+ attributePaths = attributePaths,
+ minInterval = Duration.ofSeconds(minInterval.toLong()),
+ maxInterval = Duration.ofSeconds(maxInterval.toLong()),
+ )
+
+ return controller.subscribe(subscribeRequest).transform { subscriptionState ->
+ when (subscriptionState) {
+ is SubscriptionState.SubscriptionErrorNotification -> {
+ emit(
+ CurrentPeakPeriodAttributeSubscriptionState.Error(
+ Exception(
+ "Subscription terminated with error code: ${subscriptionState.terminationCause}"
+ )
+ )
+ )
+ }
+ is SubscriptionState.NodeStateUpdate -> {
+ val attributeData =
+ subscriptionState.updateState.successes
+ .filterIsInstance()
+ .firstOrNull { it.path.attributeId == ATTRIBUTE_ID }
+
+ requireNotNull(attributeData) {
+ "Currentpeakperiod attribute not found in Node State update"
+ }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: EnergyCalendarClusterPeakPeriodStruct? =
+ if (!tlvReader.isNull()) {
+ if (tlvReader.isNextTag(AnonymousTag)) {
+ EnergyCalendarClusterPeakPeriodStruct.fromTlv(AnonymousTag, tlvReader)
+ } else {
+ null
+ }
+ } else {
+ tlvReader.getNull(AnonymousTag)
+ null
+ }
+
+ decodedValue?.let { emit(CurrentPeakPeriodAttributeSubscriptionState.Success(it)) }
+ }
+ SubscriptionState.SubscriptionEstablished -> {
+ emit(CurrentPeakPeriodAttributeSubscriptionState.SubscriptionEstablished)
+ }
+ }
+ }
+ }
+
+ suspend fun readNextPeakPeriodAttribute(): NextPeakPeriodAttribute {
+ val ATTRIBUTE_ID: UInt = 11u
+
+ val attributePath =
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+
+ val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath))
+
+ val response = controller.read(readRequest)
+
+ if (response.successes.isEmpty()) {
+ logger.log(Level.WARNING, "Read command failed")
+ throw IllegalStateException("Read command failed with failures: ${response.failures}")
+ }
+
+ logger.log(Level.FINE, "Read command succeeded")
+
+ val attributeData =
+ response.successes.filterIsInstance().firstOrNull {
+ it.path.attributeId == ATTRIBUTE_ID
+ }
+
+ requireNotNull(attributeData) { "Nextpeakperiod attribute not found in response" }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: EnergyCalendarClusterPeakPeriodStruct? =
+ if (!tlvReader.isNull()) {
+ if (tlvReader.isNextTag(AnonymousTag)) {
+ EnergyCalendarClusterPeakPeriodStruct.fromTlv(AnonymousTag, tlvReader)
+ } else {
+ null
+ }
+ } else {
+ tlvReader.getNull(AnonymousTag)
+ null
+ }
+
+ return NextPeakPeriodAttribute(decodedValue)
+ }
+
+ suspend fun subscribeNextPeakPeriodAttribute(
+ minInterval: Int,
+ maxInterval: Int,
+ ): Flow {
+ val ATTRIBUTE_ID: UInt = 11u
+ val attributePaths =
+ listOf(
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+ )
+
+ val subscribeRequest: SubscribeRequest =
+ SubscribeRequest(
+ eventPaths = emptyList(),
+ attributePaths = attributePaths,
+ minInterval = Duration.ofSeconds(minInterval.toLong()),
+ maxInterval = Duration.ofSeconds(maxInterval.toLong()),
+ )
+
+ return controller.subscribe(subscribeRequest).transform { subscriptionState ->
+ when (subscriptionState) {
+ is SubscriptionState.SubscriptionErrorNotification -> {
+ emit(
+ NextPeakPeriodAttributeSubscriptionState.Error(
+ Exception(
+ "Subscription terminated with error code: ${subscriptionState.terminationCause}"
+ )
+ )
+ )
+ }
+ is SubscriptionState.NodeStateUpdate -> {
+ val attributeData =
+ subscriptionState.updateState.successes
+ .filterIsInstance()
+ .firstOrNull { it.path.attributeId == ATTRIBUTE_ID }
+
+ requireNotNull(attributeData) {
+ "Nextpeakperiod attribute not found in Node State update"
+ }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: EnergyCalendarClusterPeakPeriodStruct? =
+ if (!tlvReader.isNull()) {
+ if (tlvReader.isNextTag(AnonymousTag)) {
+ EnergyCalendarClusterPeakPeriodStruct.fromTlv(AnonymousTag, tlvReader)
+ } else {
+ null
+ }
+ } else {
+ tlvReader.getNull(AnonymousTag)
+ null
+ }
+
+ decodedValue?.let { emit(NextPeakPeriodAttributeSubscriptionState.Success(it)) }
+ }
+ SubscriptionState.SubscriptionEstablished -> {
+ emit(NextPeakPeriodAttributeSubscriptionState.SubscriptionEstablished)
+ }
+ }
+ }
+ }
+
+ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {
+ val ATTRIBUTE_ID: UInt = 65528u
+
+ val attributePath =
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+
+ val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath))
+
+ val response = controller.read(readRequest)
+
+ if (response.successes.isEmpty()) {
+ logger.log(Level.WARNING, "Read command failed")
+ throw IllegalStateException("Read command failed with failures: ${response.failures}")
+ }
+
+ logger.log(Level.FINE, "Read command succeeded")
+
+ val attributeData =
+ response.successes.filterIsInstance().firstOrNull {
+ it.path.attributeId == ATTRIBUTE_ID
+ }
+
+ requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: List =
+ buildList {
+ tlvReader.enterArray(AnonymousTag)
+ while (!tlvReader.isEndOfContainer()) {
+ add(tlvReader.getUInt(AnonymousTag))
+ }
+ tlvReader.exitContainer()
+ }
+
+ return GeneratedCommandListAttribute(decodedValue)
+ }
+
+ suspend fun subscribeGeneratedCommandListAttribute(
+ minInterval: Int,
+ maxInterval: Int,
+ ): Flow {
+ val ATTRIBUTE_ID: UInt = 65528u
+ val attributePaths =
+ listOf(
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+ )
+
+ val subscribeRequest: SubscribeRequest =
+ SubscribeRequest(
+ eventPaths = emptyList(),
+ attributePaths = attributePaths,
+ minInterval = Duration.ofSeconds(minInterval.toLong()),
+ maxInterval = Duration.ofSeconds(maxInterval.toLong()),
+ )
+
+ return controller.subscribe(subscribeRequest).transform { subscriptionState ->
+ when (subscriptionState) {
+ is SubscriptionState.SubscriptionErrorNotification -> {
+ emit(
+ GeneratedCommandListAttributeSubscriptionState.Error(
+ Exception(
+ "Subscription terminated with error code: ${subscriptionState.terminationCause}"
+ )
+ )
+ )
+ }
+ is SubscriptionState.NodeStateUpdate -> {
+ val attributeData =
+ subscriptionState.updateState.successes
+ .filterIsInstance()
+ .firstOrNull { it.path.attributeId == ATTRIBUTE_ID }
+
+ requireNotNull(attributeData) {
+ "Generatedcommandlist attribute not found in Node State update"
+ }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: List =
+ buildList {
+ tlvReader.enterArray(AnonymousTag)
+ while (!tlvReader.isEndOfContainer()) {
+ add(tlvReader.getUInt(AnonymousTag))
+ }
+ tlvReader.exitContainer()
+ }
+
+ emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue))
+ }
+ SubscriptionState.SubscriptionEstablished -> {
+ emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished)
+ }
+ }
+ }
+ }
+
+ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {
+ val ATTRIBUTE_ID: UInt = 65529u
+
+ val attributePath =
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+
+ val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath))
+
+ val response = controller.read(readRequest)
+
+ if (response.successes.isEmpty()) {
+ logger.log(Level.WARNING, "Read command failed")
+ throw IllegalStateException("Read command failed with failures: ${response.failures}")
+ }
+
+ logger.log(Level.FINE, "Read command succeeded")
+
+ val attributeData =
+ response.successes.filterIsInstance().firstOrNull {
+ it.path.attributeId == ATTRIBUTE_ID
+ }
+
+ requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: List =
+ buildList {
+ tlvReader.enterArray(AnonymousTag)
+ while (!tlvReader.isEndOfContainer()) {
+ add(tlvReader.getUInt(AnonymousTag))
+ }
+ tlvReader.exitContainer()
+ }
+
+ return AcceptedCommandListAttribute(decodedValue)
+ }
+
+ suspend fun subscribeAcceptedCommandListAttribute(
+ minInterval: Int,
+ maxInterval: Int,
+ ): Flow {
+ val ATTRIBUTE_ID: UInt = 65529u
+ val attributePaths =
+ listOf(
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+ )
+
+ val subscribeRequest: SubscribeRequest =
+ SubscribeRequest(
+ eventPaths = emptyList(),
+ attributePaths = attributePaths,
+ minInterval = Duration.ofSeconds(minInterval.toLong()),
+ maxInterval = Duration.ofSeconds(maxInterval.toLong()),
+ )
+
+ return controller.subscribe(subscribeRequest).transform { subscriptionState ->
+ when (subscriptionState) {
+ is SubscriptionState.SubscriptionErrorNotification -> {
+ emit(
+ AcceptedCommandListAttributeSubscriptionState.Error(
+ Exception(
+ "Subscription terminated with error code: ${subscriptionState.terminationCause}"
+ )
+ )
+ )
+ }
+ is SubscriptionState.NodeStateUpdate -> {
+ val attributeData =
+ subscriptionState.updateState.successes
+ .filterIsInstance()
+ .firstOrNull { it.path.attributeId == ATTRIBUTE_ID }
+
+ requireNotNull(attributeData) {
+ "Acceptedcommandlist attribute not found in Node State update"
+ }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: List =
+ buildList {
+ tlvReader.enterArray(AnonymousTag)
+ while (!tlvReader.isEndOfContainer()) {
+ add(tlvReader.getUInt(AnonymousTag))
+ }
+ tlvReader.exitContainer()
+ }
+
+ emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue))
+ }
+ SubscriptionState.SubscriptionEstablished -> {
+ emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished)
+ }
+ }
+ }
+ }
+
+ suspend fun readEventListAttribute(): EventListAttribute {
+ val ATTRIBUTE_ID: UInt = 65530u
+
+ val attributePath =
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+
+ val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath))
+
+ val response = controller.read(readRequest)
+
+ if (response.successes.isEmpty()) {
+ logger.log(Level.WARNING, "Read command failed")
+ throw IllegalStateException("Read command failed with failures: ${response.failures}")
+ }
+
+ logger.log(Level.FINE, "Read command succeeded")
+
+ val attributeData =
+ response.successes.filterIsInstance().firstOrNull {
+ it.path.attributeId == ATTRIBUTE_ID
+ }
+
+ requireNotNull(attributeData) { "Eventlist attribute not found in response" }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: List =
+ buildList {
+ tlvReader.enterArray(AnonymousTag)
+ while (!tlvReader.isEndOfContainer()) {
+ add(tlvReader.getUInt(AnonymousTag))
+ }
+ tlvReader.exitContainer()
+ }
+
+ return EventListAttribute(decodedValue)
+ }
+
+ suspend fun subscribeEventListAttribute(
+ minInterval: Int,
+ maxInterval: Int,
+ ): Flow {
+ val ATTRIBUTE_ID: UInt = 65530u
+ val attributePaths =
+ listOf(
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+ )
+
+ val subscribeRequest: SubscribeRequest =
+ SubscribeRequest(
+ eventPaths = emptyList(),
+ attributePaths = attributePaths,
+ minInterval = Duration.ofSeconds(minInterval.toLong()),
+ maxInterval = Duration.ofSeconds(maxInterval.toLong()),
+ )
+
+ return controller.subscribe(subscribeRequest).transform { subscriptionState ->
+ when (subscriptionState) {
+ is SubscriptionState.SubscriptionErrorNotification -> {
+ emit(
+ EventListAttributeSubscriptionState.Error(
+ Exception(
+ "Subscription terminated with error code: ${subscriptionState.terminationCause}"
+ )
+ )
+ )
+ }
+ is SubscriptionState.NodeStateUpdate -> {
+ val attributeData =
+ subscriptionState.updateState.successes
+ .filterIsInstance()
+ .firstOrNull { it.path.attributeId == ATTRIBUTE_ID }
+
+ requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: List =
+ buildList {
+ tlvReader.enterArray(AnonymousTag)
+ while (!tlvReader.isEndOfContainer()) {
+ add(tlvReader.getUInt(AnonymousTag))
+ }
+ tlvReader.exitContainer()
+ }
+
+ emit(EventListAttributeSubscriptionState.Success(decodedValue))
+ }
+ SubscriptionState.SubscriptionEstablished -> {
+ emit(EventListAttributeSubscriptionState.SubscriptionEstablished)
+ }
+ }
+ }
+ }
+
+ suspend fun readAttributeListAttribute(): AttributeListAttribute {
+ val ATTRIBUTE_ID: UInt = 65531u
+
+ val attributePath =
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+
+ val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath))
+
+ val response = controller.read(readRequest)
+
+ if (response.successes.isEmpty()) {
+ logger.log(Level.WARNING, "Read command failed")
+ throw IllegalStateException("Read command failed with failures: ${response.failures}")
+ }
+
+ logger.log(Level.FINE, "Read command succeeded")
+
+ val attributeData =
+ response.successes.filterIsInstance().firstOrNull {
+ it.path.attributeId == ATTRIBUTE_ID
+ }
+
+ requireNotNull(attributeData) { "Attributelist attribute not found in response" }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: List =
+ buildList {
+ tlvReader.enterArray(AnonymousTag)
+ while (!tlvReader.isEndOfContainer()) {
+ add(tlvReader.getUInt(AnonymousTag))
+ }
+ tlvReader.exitContainer()
+ }
+
+ return AttributeListAttribute(decodedValue)
+ }
+
+ suspend fun subscribeAttributeListAttribute(
+ minInterval: Int,
+ maxInterval: Int,
+ ): Flow {
+ val ATTRIBUTE_ID: UInt = 65531u
+ val attributePaths =
+ listOf(
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+ )
+
+ val subscribeRequest: SubscribeRequest =
+ SubscribeRequest(
+ eventPaths = emptyList(),
+ attributePaths = attributePaths,
+ minInterval = Duration.ofSeconds(minInterval.toLong()),
+ maxInterval = Duration.ofSeconds(maxInterval.toLong()),
+ )
+
+ return controller.subscribe(subscribeRequest).transform { subscriptionState ->
+ when (subscriptionState) {
+ is SubscriptionState.SubscriptionErrorNotification -> {
+ emit(
+ AttributeListAttributeSubscriptionState.Error(
+ Exception(
+ "Subscription terminated with error code: ${subscriptionState.terminationCause}"
+ )
+ )
+ )
+ }
+ is SubscriptionState.NodeStateUpdate -> {
+ val attributeData =
+ subscriptionState.updateState.successes
+ .filterIsInstance()
+ .firstOrNull { it.path.attributeId == ATTRIBUTE_ID }
+
+ requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: List =
+ buildList {
+ tlvReader.enterArray(AnonymousTag)
+ while (!tlvReader.isEndOfContainer()) {
+ add(tlvReader.getUInt(AnonymousTag))
+ }
+ tlvReader.exitContainer()
+ }
+
+ emit(AttributeListAttributeSubscriptionState.Success(decodedValue))
+ }
+ SubscriptionState.SubscriptionEstablished -> {
+ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished)
+ }
+ }
+ }
+ }
+
+ suspend fun readFeatureMapAttribute(): UInt {
+ val ATTRIBUTE_ID: UInt = 65532u
+
+ val attributePath =
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+
+ val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath))
+
+ val response = controller.read(readRequest)
+
+ if (response.successes.isEmpty()) {
+ logger.log(Level.WARNING, "Read command failed")
+ throw IllegalStateException("Read command failed with failures: ${response.failures}")
+ }
+
+ logger.log(Level.FINE, "Read command succeeded")
+
+ val attributeData =
+ response.successes.filterIsInstance().firstOrNull {
+ it.path.attributeId == ATTRIBUTE_ID
+ }
+
+ requireNotNull(attributeData) { "Featuremap attribute not found in response" }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: UInt = tlvReader.getUInt(AnonymousTag)
+
+ return decodedValue
+ }
+
+ suspend fun subscribeFeatureMapAttribute(
+ minInterval: Int,
+ maxInterval: Int,
+ ): Flow {
+ val ATTRIBUTE_ID: UInt = 65532u
+ val attributePaths =
+ listOf(
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+ )
+
+ val subscribeRequest: SubscribeRequest =
+ SubscribeRequest(
+ eventPaths = emptyList(),
+ attributePaths = attributePaths,
+ minInterval = Duration.ofSeconds(minInterval.toLong()),
+ maxInterval = Duration.ofSeconds(maxInterval.toLong()),
+ )
+
+ return controller.subscribe(subscribeRequest).transform { subscriptionState ->
+ when (subscriptionState) {
+ is SubscriptionState.SubscriptionErrorNotification -> {
+ emit(
+ UIntSubscriptionState.Error(
+ Exception(
+ "Subscription terminated with error code: ${subscriptionState.terminationCause}"
+ )
+ )
+ )
+ }
+ is SubscriptionState.NodeStateUpdate -> {
+ val attributeData =
+ subscriptionState.updateState.successes
+ .filterIsInstance()
+ .firstOrNull { it.path.attributeId == ATTRIBUTE_ID }
+
+ requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: UInt = tlvReader.getUInt(AnonymousTag)
+
+ emit(UIntSubscriptionState.Success(decodedValue))
+ }
+ SubscriptionState.SubscriptionEstablished -> {
+ emit(UIntSubscriptionState.SubscriptionEstablished)
+ }
+ }
+ }
+ }
+
+ suspend fun readClusterRevisionAttribute(): UShort {
+ val ATTRIBUTE_ID: UInt = 65533u
+
+ val attributePath =
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+
+ val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath))
+
+ val response = controller.read(readRequest)
+
+ if (response.successes.isEmpty()) {
+ logger.log(Level.WARNING, "Read command failed")
+ throw IllegalStateException("Read command failed with failures: ${response.failures}")
+ }
+
+ logger.log(Level.FINE, "Read command succeeded")
+
+ val attributeData =
+ response.successes.filterIsInstance().firstOrNull {
+ it.path.attributeId == ATTRIBUTE_ID
+ }
+
+ requireNotNull(attributeData) { "Clusterrevision attribute not found in response" }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: UShort = tlvReader.getUShort(AnonymousTag)
+
+ return decodedValue
+ }
+
+ suspend fun subscribeClusterRevisionAttribute(
+ minInterval: Int,
+ maxInterval: Int,
+ ): Flow {
+ val ATTRIBUTE_ID: UInt = 65533u
+ val attributePaths =
+ listOf(
+ AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
+ )
+
+ val subscribeRequest: SubscribeRequest =
+ SubscribeRequest(
+ eventPaths = emptyList(),
+ attributePaths = attributePaths,
+ minInterval = Duration.ofSeconds(minInterval.toLong()),
+ maxInterval = Duration.ofSeconds(maxInterval.toLong()),
+ )
+
+ return controller.subscribe(subscribeRequest).transform { subscriptionState ->
+ when (subscriptionState) {
+ is SubscriptionState.SubscriptionErrorNotification -> {
+ emit(
+ UShortSubscriptionState.Error(
+ Exception(
+ "Subscription terminated with error code: ${subscriptionState.terminationCause}"
+ )
+ )
+ )
+ }
+ is SubscriptionState.NodeStateUpdate -> {
+ val attributeData =
+ subscriptionState.updateState.successes
+ .filterIsInstance()
+ .firstOrNull { it.path.attributeId == ATTRIBUTE_ID }
+
+ requireNotNull(attributeData) {
+ "Clusterrevision attribute not found in Node State update"
+ }
+
+ // Decode the TLV data into the appropriate type
+ val tlvReader = TlvReader(attributeData.data)
+ val decodedValue: UShort = tlvReader.getUShort(AnonymousTag)
+
+ emit(UShortSubscriptionState.Success(decodedValue))
+ }
+ SubscriptionState.SubscriptionEstablished -> {
+ emit(UShortSubscriptionState.SubscriptionEstablished)
+ }
+ }
+ }
+ }
+
+ companion object {
+ private val logger = Logger.getLogger(EnergyCalendarCluster::class.java.name)
+ const val CLUSTER_ID: UInt = 154u
+ }
+}
diff --git a/src/controller/java/generated/java/matter/controller/cluster/files.gni b/src/controller/java/generated/java/matter/controller/cluster/files.gni
index d1a3d9681b21bf..3e99c3837fa529 100644
--- a/src/controller/java/generated/java/matter/controller/cluster/files.gni
+++ b/src/controller/java/generated/java/matter/controller/cluster/files.gni
@@ -71,6 +71,10 @@ matter_structs_sources = [
"${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct.kt",
"${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyStruct.kt",
"${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementRangeStruct.kt",
+ "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyCalendarClusterCalendarPeriodStruct.kt",
+ "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyCalendarClusterDayStruct.kt",
+ "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyCalendarClusterPeakPeriodStruct.kt",
+ "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyCalendarClusterTransitionStruct.kt",
"${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetScheduleStruct.kt",
"${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt",
"${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseModeClusterModeOptionStruct.kt",
@@ -283,6 +287,7 @@ matter_clusters_sources = [
"${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/EcosystemInformationCluster.kt",
"${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalEnergyMeasurementCluster.kt",
"${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalPowerMeasurementCluster.kt",
+ "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyCalendarCluster.kt",
"${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyEvseCluster.kt",
"${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyEvseModeCluster.kt",
"${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyPreferenceCluster.kt",
diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyCalendarClusterCalendarPeriodStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyCalendarClusterCalendarPeriodStruct.kt
new file mode 100644
index 00000000000000..a18bcbe8891118
--- /dev/null
+++ b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyCalendarClusterCalendarPeriodStruct.kt
@@ -0,0 +1,81 @@
+/*
+ *
+ * Copyright (c) 2023 Project CHIP Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package matter.controller.cluster.structs
+
+import matter.controller.cluster.*
+import matter.tlv.AnonymousTag
+import matter.tlv.ContextSpecificTag
+import matter.tlv.Tag
+import matter.tlv.TlvReader
+import matter.tlv.TlvWriter
+
+class EnergyCalendarClusterCalendarPeriodStruct(
+ val startDate: UInt?,
+ val days: List,
+) {
+ override fun toString(): String = buildString {
+ append("EnergyCalendarClusterCalendarPeriodStruct {\n")
+ append("\tstartDate : $startDate\n")
+ append("\tdays : $days\n")
+ append("}\n")
+ }
+
+ fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) {
+ tlvWriter.apply {
+ startStructure(tlvTag)
+ if (startDate != null) {
+ put(ContextSpecificTag(TAG_START_DATE), startDate)
+ } else {
+ putNull(ContextSpecificTag(TAG_START_DATE))
+ }
+ startArray(ContextSpecificTag(TAG_DAYS))
+ for (item in days.iterator()) {
+ item.toTlv(AnonymousTag, this)
+ }
+ endArray()
+ endStructure()
+ }
+ }
+
+ companion object {
+ private const val TAG_START_DATE = 0
+ private const val TAG_DAYS = 1
+
+ fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyCalendarClusterCalendarPeriodStruct {
+ tlvReader.enterStructure(tlvTag)
+ val startDate =
+ if (!tlvReader.isNull()) {
+ tlvReader.getUInt(ContextSpecificTag(TAG_START_DATE))
+ } else {
+ tlvReader.getNull(ContextSpecificTag(TAG_START_DATE))
+ null
+ }
+ val days =
+ buildList {
+ tlvReader.enterArray(ContextSpecificTag(TAG_DAYS))
+ while (!tlvReader.isEndOfContainer()) {
+ add(EnergyCalendarClusterDayStruct.fromTlv(AnonymousTag, tlvReader))
+ }
+ tlvReader.exitContainer()
+ }
+
+ tlvReader.exitContainer()
+
+ return EnergyCalendarClusterCalendarPeriodStruct(startDate, days)
+ }
+ }
+}
diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyCalendarClusterDayStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyCalendarClusterDayStruct.kt
new file mode 100644
index 00000000000000..18e420a49c5e98
--- /dev/null
+++ b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyCalendarClusterDayStruct.kt
@@ -0,0 +1,106 @@
+/*
+ *
+ * Copyright (c) 2023 Project CHIP Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package matter.controller.cluster.structs
+
+import java.util.Optional
+import matter.controller.cluster.*
+import matter.tlv.AnonymousTag
+import matter.tlv.ContextSpecificTag
+import matter.tlv.Tag
+import matter.tlv.TlvReader
+import matter.tlv.TlvWriter
+
+class EnergyCalendarClusterDayStruct(
+ val date: Optional,
+ val daysOfWeek: Optional,
+ val transitions: List,
+ val calendarID: Optional,
+) {
+ override fun toString(): String = buildString {
+ append("EnergyCalendarClusterDayStruct {\n")
+ append("\tdate : $date\n")
+ append("\tdaysOfWeek : $daysOfWeek\n")
+ append("\ttransitions : $transitions\n")
+ append("\tcalendarID : $calendarID\n")
+ append("}\n")
+ }
+
+ fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) {
+ tlvWriter.apply {
+ startStructure(tlvTag)
+ if (date.isPresent) {
+ val optdate = date.get()
+ put(ContextSpecificTag(TAG_DATE), optdate)
+ }
+ if (daysOfWeek.isPresent) {
+ val optdaysOfWeek = daysOfWeek.get()
+ put(ContextSpecificTag(TAG_DAYS_OF_WEEK), optdaysOfWeek)
+ }
+ startArray(ContextSpecificTag(TAG_TRANSITIONS))
+ for (item in transitions.iterator()) {
+ item.toTlv(AnonymousTag, this)
+ }
+ endArray()
+ if (calendarID.isPresent) {
+ val optcalendarID = calendarID.get()
+ put(ContextSpecificTag(TAG_CALENDAR_ID), optcalendarID)
+ }
+ endStructure()
+ }
+ }
+
+ companion object {
+ private const val TAG_DATE = 0
+ private const val TAG_DAYS_OF_WEEK = 1
+ private const val TAG_TRANSITIONS = 2
+ private const val TAG_CALENDAR_ID = 3
+
+ fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyCalendarClusterDayStruct {
+ tlvReader.enterStructure(tlvTag)
+ val date =
+ if (tlvReader.isNextTag(ContextSpecificTag(TAG_DATE))) {
+ Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_DATE)))
+ } else {
+ Optional.empty()
+ }
+ val daysOfWeek =
+ if (tlvReader.isNextTag(ContextSpecificTag(TAG_DAYS_OF_WEEK))) {
+ Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_DAYS_OF_WEEK)))
+ } else {
+ Optional.empty()
+ }
+ val transitions =
+ buildList {
+ tlvReader.enterArray(ContextSpecificTag(TAG_TRANSITIONS))
+ while (!tlvReader.isEndOfContainer()) {
+ add(EnergyCalendarClusterTransitionStruct.fromTlv(AnonymousTag, tlvReader))
+ }
+ tlvReader.exitContainer()
+ }
+ val calendarID =
+ if (tlvReader.isNextTag(ContextSpecificTag(TAG_CALENDAR_ID))) {
+ Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_CALENDAR_ID)))
+ } else {
+ Optional.empty()
+ }
+
+ tlvReader.exitContainer()
+
+ return EnergyCalendarClusterDayStruct(date, daysOfWeek, transitions, calendarID)
+ }
+ }
+}
diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyCalendarClusterPeakPeriodStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyCalendarClusterPeakPeriodStruct.kt
new file mode 100644
index 00000000000000..b12465d88c55f4
--- /dev/null
+++ b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyCalendarClusterPeakPeriodStruct.kt
@@ -0,0 +1,89 @@
+/*
+ *
+ * Copyright (c) 2023 Project CHIP Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package matter.controller.cluster.structs
+
+import matter.controller.cluster.*
+import matter.tlv.ContextSpecificTag
+import matter.tlv.Tag
+import matter.tlv.TlvReader
+import matter.tlv.TlvWriter
+
+class EnergyCalendarClusterPeakPeriodStruct(
+ val severity: UByte,
+ val peakPeriod: UShort,
+ val startTime: UInt?,
+ val endTime: UInt?,
+) {
+ override fun toString(): String = buildString {
+ append("EnergyCalendarClusterPeakPeriodStruct {\n")
+ append("\tseverity : $severity\n")
+ append("\tpeakPeriod : $peakPeriod\n")
+ append("\tstartTime : $startTime\n")
+ append("\tendTime : $endTime\n")
+ append("}\n")
+ }
+
+ fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) {
+ tlvWriter.apply {
+ startStructure(tlvTag)
+ put(ContextSpecificTag(TAG_SEVERITY), severity)
+ put(ContextSpecificTag(TAG_PEAK_PERIOD), peakPeriod)
+ if (startTime != null) {
+ put(ContextSpecificTag(TAG_START_TIME), startTime)
+ } else {
+ putNull(ContextSpecificTag(TAG_START_TIME))
+ }
+ if (endTime != null) {
+ put(ContextSpecificTag(TAG_END_TIME), endTime)
+ } else {
+ putNull(ContextSpecificTag(TAG_END_TIME))
+ }
+ endStructure()
+ }
+ }
+
+ companion object {
+ private const val TAG_SEVERITY = 0
+ private const val TAG_PEAK_PERIOD = 1
+ private const val TAG_START_TIME = 2
+ private const val TAG_END_TIME = 3
+
+ fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyCalendarClusterPeakPeriodStruct {
+ tlvReader.enterStructure(tlvTag)
+ val severity = tlvReader.getUByte(ContextSpecificTag(TAG_SEVERITY))
+ val peakPeriod = tlvReader.getUShort(ContextSpecificTag(TAG_PEAK_PERIOD))
+ val startTime =
+ if (!tlvReader.isNull()) {
+ tlvReader.getUInt(ContextSpecificTag(TAG_START_TIME))
+ } else {
+ tlvReader.getNull(ContextSpecificTag(TAG_START_TIME))
+ null
+ }
+ val endTime =
+ if (!tlvReader.isNull()) {
+ tlvReader.getUInt(ContextSpecificTag(TAG_END_TIME))
+ } else {
+ tlvReader.getNull(ContextSpecificTag(TAG_END_TIME))
+ null
+ }
+
+ tlvReader.exitContainer()
+
+ return EnergyCalendarClusterPeakPeriodStruct(severity, peakPeriod, startTime, endTime)
+ }
+ }
+}
diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyCalendarClusterTransitionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyCalendarClusterTransitionStruct.kt
new file mode 100644
index 00000000000000..57a0db6559ee93
--- /dev/null
+++ b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyCalendarClusterTransitionStruct.kt
@@ -0,0 +1,99 @@
+/*
+ *
+ * Copyright (c) 2023 Project CHIP Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package matter.controller.cluster.structs
+
+import java.util.Optional
+import matter.controller.cluster.*
+import matter.tlv.ContextSpecificTag
+import matter.tlv.Tag
+import matter.tlv.TlvReader
+import matter.tlv.TlvWriter
+
+class EnergyCalendarClusterTransitionStruct(
+ val transitionTime: UShort,
+ val priceTier: Optional,
+ val friendlyCredit: Optional,
+ val auxiliaryLoad: Optional,
+) {
+ override fun toString(): String = buildString {
+ append("EnergyCalendarClusterTransitionStruct {\n")
+ append("\ttransitionTime : $transitionTime\n")
+ append("\tpriceTier : $priceTier\n")
+ append("\tfriendlyCredit : $friendlyCredit\n")
+ append("\tauxiliaryLoad : $auxiliaryLoad\n")
+ append("}\n")
+ }
+
+ fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) {
+ tlvWriter.apply {
+ startStructure(tlvTag)
+ put(ContextSpecificTag(TAG_TRANSITION_TIME), transitionTime)
+ if (priceTier.isPresent) {
+ val optpriceTier = priceTier.get()
+ put(ContextSpecificTag(TAG_PRICE_TIER), optpriceTier)
+ }
+ if (friendlyCredit.isPresent) {
+ val optfriendlyCredit = friendlyCredit.get()
+ put(ContextSpecificTag(TAG_FRIENDLY_CREDIT), optfriendlyCredit)
+ }
+ if (auxiliaryLoad.isPresent) {
+ val optauxiliaryLoad = auxiliaryLoad.get()
+ put(ContextSpecificTag(TAG_AUXILIARY_LOAD), optauxiliaryLoad)
+ }
+ endStructure()
+ }
+ }
+
+ companion object {
+ private const val TAG_TRANSITION_TIME = 0
+ private const val TAG_PRICE_TIER = 1
+ private const val TAG_FRIENDLY_CREDIT = 2
+ private const val TAG_AUXILIARY_LOAD = 3
+
+ fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyCalendarClusterTransitionStruct {
+ tlvReader.enterStructure(tlvTag)
+ val transitionTime = tlvReader.getUShort(ContextSpecificTag(TAG_TRANSITION_TIME))
+ val priceTier =
+ if (tlvReader.isNextTag(ContextSpecificTag(TAG_PRICE_TIER))) {
+ Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PRICE_TIER)))
+ } else {
+ Optional.empty()
+ }
+ val friendlyCredit =
+ if (tlvReader.isNextTag(ContextSpecificTag(TAG_FRIENDLY_CREDIT))) {
+ Optional.of(tlvReader.getBoolean(ContextSpecificTag(TAG_FRIENDLY_CREDIT)))
+ } else {
+ Optional.empty()
+ }
+ val auxiliaryLoad =
+ if (tlvReader.isNextTag(ContextSpecificTag(TAG_AUXILIARY_LOAD))) {
+ Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_AUXILIARY_LOAD)))
+ } else {
+ Optional.empty()
+ }
+
+ tlvReader.exitContainer()
+
+ return EnergyCalendarClusterTransitionStruct(
+ transitionTime,
+ priceTier,
+ friendlyCredit,
+ auxiliaryLoad,
+ )
+ }
+ }
+}
diff --git a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp
index fbbb5be261737f..5aa0af60b4a9bb 100644
--- a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp
+++ b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp
@@ -24953,6 +24953,1334 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR
}
break;
}
+ case app::Clusters::EnergyCalendar::Id: {
+ using namespace app::Clusters::EnergyCalendar;
+ switch (aPath.mAttributeId)
+ {
+ case Attributes::CalendarID::Id: {
+ using TypeInfo = Attributes::CalendarID::TypeInfo;
+ TypeInfo::DecodableType cppValue;
+ *aError = app::DataModel::Decode(aReader, cppValue);
+ if (*aError != CHIP_NO_ERROR)
+ {
+ return nullptr;
+ }
+ jobject value;
+ if (cppValue.IsNull())
+ {
+ value = nullptr;
+ }
+ else
+ {
+ std::string valueClassName = "java/lang/Long";
+ std::string valueCtorSignature = "(J)V";
+ jlong jnivalue = static_cast(cppValue.Value());
+ chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(),
+ jnivalue, value);
+ }
+ return value;
+ }
+ case Attributes::Name::Id: {
+ using TypeInfo = Attributes::Name::TypeInfo;
+ TypeInfo::DecodableType cppValue;
+ *aError = app::DataModel::Decode(aReader, cppValue);
+ if (*aError != CHIP_NO_ERROR)
+ {
+ return nullptr;
+ }
+ jobject value;
+ if (cppValue.IsNull())
+ {
+ value = nullptr;
+ }
+ else
+ {
+ LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue.Value(), value));
+ }
+ return value;
+ }
+ case Attributes::ProviderID::Id: {
+ using TypeInfo = Attributes::ProviderID::TypeInfo;
+ TypeInfo::DecodableType cppValue;
+ *aError = app::DataModel::Decode(aReader, cppValue);
+ if (*aError != CHIP_NO_ERROR)
+ {
+ return nullptr;
+ }
+ jobject value;
+ if (cppValue.IsNull())
+ {
+ value = nullptr;
+ }
+ else
+ {
+ std::string valueClassName = "java/lang/Long";
+ std::string valueCtorSignature = "(J)V";
+ jlong jnivalue = static_cast(cppValue.Value());
+ chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(),
+ jnivalue, value);
+ }
+ return value;
+ }
+ case Attributes::EventID::Id: {
+ using TypeInfo = Attributes::EventID::TypeInfo;
+ TypeInfo::DecodableType cppValue;
+ *aError = app::DataModel::Decode(aReader, cppValue);
+ if (*aError != CHIP_NO_ERROR)
+ {
+ return nullptr;
+ }
+ jobject value;
+ if (cppValue.IsNull())
+ {
+ value = nullptr;
+ }
+ else
+ {
+ std::string valueClassName = "java/lang/Long";
+ std::string valueCtorSignature = "(J)V";
+ jlong jnivalue = static_cast(cppValue.Value());
+ chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(),
+ jnivalue, value);
+ }
+ return value;
+ }
+ case Attributes::StartDate::Id: {
+ using TypeInfo = Attributes::StartDate::TypeInfo;
+ TypeInfo::DecodableType cppValue;
+ *aError = app::DataModel::Decode(aReader, cppValue);
+ if (*aError != CHIP_NO_ERROR)
+ {
+ return nullptr;
+ }
+ jobject value;
+ if (cppValue.IsNull())
+ {
+ value = nullptr;
+ }
+ else
+ {
+ std::string valueClassName = "java/lang/Long";
+ std::string valueCtorSignature = "(J)V";
+ jlong jnivalue = static_cast(cppValue.Value());
+ chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(),
+ jnivalue, value);
+ }
+ return value;
+ }
+ case Attributes::CalendarPeriods::Id: {
+ using TypeInfo = Attributes::CalendarPeriods::TypeInfo;
+ TypeInfo::DecodableType cppValue;
+ *aError = app::DataModel::Decode(aReader, cppValue);
+ if (*aError != CHIP_NO_ERROR)
+ {
+ return nullptr;
+ }
+ jobject value;
+ if (cppValue.IsNull())
+ {
+ value = nullptr;
+ }
+ else
+ {
+ chip::JniReferences::GetInstance().CreateArrayList(value);
+
+ auto iter_value_1 = cppValue.Value().begin();
+ while (iter_value_1.Next())
+ {
+ auto & entry_1 = iter_value_1.GetValue();
+ jobject newElement_1;
+ jobject newElement_1_startDate;
+ if (entry_1.startDate.IsNull())
+ {
+ newElement_1_startDate = nullptr;
+ }
+ else
+ {
+ std::string newElement_1_startDateClassName = "java/lang/Long";
+ std::string newElement_1_startDateCtorSignature = "(J)V";
+ jlong jninewElement_1_startDate = static_cast(entry_1.startDate.Value());
+ chip::JniReferences::GetInstance().CreateBoxedObject(
+ newElement_1_startDateClassName.c_str(), newElement_1_startDateCtorSignature.c_str(),
+ jninewElement_1_startDate, newElement_1_startDate);
+ }
+ jobject newElement_1_days;
+ chip::JniReferences::GetInstance().CreateArrayList(newElement_1_days);
+
+ auto iter_newElement_1_days_3 = entry_1.days.begin();
+ while (iter_newElement_1_days_3.Next())
+ {
+ auto & entry_3 = iter_newElement_1_days_3.GetValue();
+ jobject newElement_3;
+ jobject newElement_3_date;
+ if (!entry_3.date.HasValue())
+ {
+ chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_3_date);
+ }
+ else
+ {
+ jobject newElement_3_dateInsideOptional;
+ std::string newElement_3_dateInsideOptionalClassName = "java/lang/Long";
+ std::string newElement_3_dateInsideOptionalCtorSignature = "(J)V";
+ jlong jninewElement_3_dateInsideOptional = static_cast(entry_3.date.Value());
+ chip::JniReferences::GetInstance().CreateBoxedObject(
+ newElement_3_dateInsideOptionalClassName.c_str(),
+ newElement_3_dateInsideOptionalCtorSignature.c_str(), jninewElement_3_dateInsideOptional,
+ newElement_3_dateInsideOptional);
+ chip::JniReferences::GetInstance().CreateOptional(newElement_3_dateInsideOptional, newElement_3_date);
+ }
+ jobject newElement_3_daysOfWeek;
+ if (!entry_3.daysOfWeek.HasValue())
+ {
+ chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_3_daysOfWeek);
+ }
+ else
+ {
+ jobject newElement_3_daysOfWeekInsideOptional;
+ std::string newElement_3_daysOfWeekInsideOptionalClassName = "java/lang/Integer";
+ std::string newElement_3_daysOfWeekInsideOptionalCtorSignature = "(I)V";
+ jint jninewElement_3_daysOfWeekInsideOptional = static_cast(entry_3.daysOfWeek.Value().Raw());
+ chip::JniReferences::GetInstance().CreateBoxedObject(
+ newElement_3_daysOfWeekInsideOptionalClassName.c_str(),
+ newElement_3_daysOfWeekInsideOptionalCtorSignature.c_str(),
+ jninewElement_3_daysOfWeekInsideOptional, newElement_3_daysOfWeekInsideOptional);
+ chip::JniReferences::GetInstance().CreateOptional(newElement_3_daysOfWeekInsideOptional,
+ newElement_3_daysOfWeek);
+ }
+ jobject newElement_3_transitions;
+ chip::JniReferences::GetInstance().CreateArrayList(newElement_3_transitions);
+
+ auto iter_newElement_3_transitions_5 = entry_3.transitions.begin();
+ while (iter_newElement_3_transitions_5.Next())
+ {
+ auto & entry_5 = iter_newElement_3_transitions_5.GetValue();
+ jobject newElement_5;
+ jobject newElement_5_transitionTime;
+ std::string newElement_5_transitionTimeClassName = "java/lang/Integer";
+ std::string newElement_5_transitionTimeCtorSignature = "(I)V";
+ jint jninewElement_5_transitionTime = static_cast(entry_5.transitionTime);
+ chip::JniReferences::GetInstance().CreateBoxedObject(
+ newElement_5_transitionTimeClassName.c_str(), newElement_5_transitionTimeCtorSignature.c_str(),
+ jninewElement_5_transitionTime, newElement_5_transitionTime);
+ jobject newElement_5_priceTier;
+ if (!entry_5.priceTier.HasValue())
+ {
+ chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_5_priceTier);
+ }
+ else
+ {
+ jobject newElement_5_priceTierInsideOptional;
+ std::string newElement_5_priceTierInsideOptionalClassName = "java/lang/Long";
+ std::string newElement_5_priceTierInsideOptionalCtorSignature = "(J)V";
+ jlong jninewElement_5_priceTierInsideOptional = static_cast(entry_5.priceTier.Value());
+ chip::JniReferences::GetInstance().CreateBoxedObject(
+ newElement_5_priceTierInsideOptionalClassName.c_str(),
+ newElement_5_priceTierInsideOptionalCtorSignature.c_str(),
+ jninewElement_5_priceTierInsideOptional, newElement_5_priceTierInsideOptional);
+ chip::JniReferences::GetInstance().CreateOptional(newElement_5_priceTierInsideOptional,
+ newElement_5_priceTier);
+ }
+ jobject newElement_5_friendlyCredit;
+ if (!entry_5.friendlyCredit.HasValue())
+ {
+ chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_5_friendlyCredit);
+ }
+ else
+ {
+ jobject newElement_5_friendlyCreditInsideOptional;
+ std::string newElement_5_friendlyCreditInsideOptionalClassName = "java/lang/Boolean";
+ std::string newElement_5_friendlyCreditInsideOptionalCtorSignature = "(Z)V";
+ jboolean jninewElement_5_friendlyCreditInsideOptional =
+ static_cast(entry_5.friendlyCredit.Value());
+ chip::JniReferences::GetInstance().CreateBoxedObject