Skip to main content

matter_kit/clusters/generated/
thermostat.rs

1// Generated by `cargo xtask` from the CSA data model 1.6. Do not edit.
2//
3// Thermostat — cluster 0x0201.
4//
5// Regenerate with `cargo xtask clusters --dm <checkout>/data_model/1.6`; `cargo xtask check`
6// is the CI gate that keeps this file honest. The XML itself is not vendored here — it
7// carries the CSA's own copyright notice and is not redistributable.
8
9//! Thermostat (cluster `0x0201`, revision 11).
10//!
11//! 75 identifiers, 10 feature bits, and the specification's own conformance for
12//! every element. `CLUSTER` is the whole table.
13
14#![allow(unused_imports)]
15
16use crate::dm::conformance::{Clause, Condition, Conform, Conformance};
17use crate::dm::meta::{EventPriority, Reporting};
18use crate::dm::spec::{Attribute, Cluster, Command, Event, Feature};
19use crate::dm::{Access, AccessQualities, AttributeQualities, Privilege};
20use crate::error::Result;
21use crate::im::{AttributeId, ClusterId, CommandId, EventId};
22use crate::tlv::{
23    ContainerKind, Element, FromTlv, Nullable, Tag, TlvList, TlvReader, TlvWriter, ToTlv, Value,
24};
25
26/// The cluster id.
27pub const ID: ClusterId = 0x0201;
28
29/// The highest revision the specification's history defines — what `ClusterRevision`
30/// must report (Core §7.13.1).
31pub const REVISION: u16 = 11;
32
33/// The PICS code, which a certification declaration names the cluster by.
34pub const PICS: &str = "TSTAT";
35
36/// The `FeatureMap` bits (Core §7.13.2).
37///
38/// A feature has conformance of its own: a device may not claim one the
39/// specification forbids it alongside another.
40pub mod feature {
41    /// Thermostat is capable of managing a heating device
42    ///
43    /// Code `HEAT`, bit 0.
44    pub const HEATING: u32 = 1 << 0;
45    /// Thermostat is capable of managing a cooling device
46    ///
47    /// Code `COOL`, bit 1.
48    pub const COOLING: u32 = 1 << 1;
49    /// Supports Occupied and Unoccupied setpoints
50    ///
51    /// Code `OCC`, bit 2.
52    pub const OCCUPANCY: u32 = 1 << 2;
53    /// `Setback`, the cluster's feature bit 4.
54    ///
55    /// Code `SB`, bit 4.
56    pub const SETBACK: u32 = 1 << 4;
57    /// Supports a System Mode of Auto
58    ///
59    /// Code `AUTO`, bit 5.
60    pub const AUTO_MODE: u32 = 1 << 5;
61    /// Thermostat does not expose the LocalTemperature Value in the LocalTemperature attribute
62    ///
63    /// Code `LTNE`, bit 6.
64    pub const LOCAL_TEMPERATURE_NOT_EXPOSED: u32 = 1 << 6;
65    /// Supports enhanced schedules
66    ///
67    /// Code `MSCH`, bit 7.
68    pub const MATTER_SCHEDULE_CONFIGURATION: u32 = 1 << 7;
69    /// Thermostat supports setpoint presets
70    ///
71    /// Code `PRES`, bit 8.
72    pub const PRESETS: u32 = 1 << 8;
73    /// Thermostat supports events
74    ///
75    /// Code `TEVT`, bit 9.
76    pub const EVENTS: u32 = 1 << 9;
77    /// Thermostat supports suggestions
78    ///
79    /// Code `TSUGGEST`, bit 10.
80    pub const THERMOSTAT_SUGGESTIONS: u32 = 1 << 10;
81}
82
83/// Every feature bit, with its conformance.
84pub const FEATURES: &[Feature] = &[
85    Feature {
86        bit: 0,
87        code: "HEAT",
88        name: "Heating",
89        conform: Conform {
90            clauses: &[
91                Clause {
92                    verdict: Conformance::Mandatory,
93                    when: Condition::Feature(5),
94                },
95                Clause {
96                    verdict: Conformance::Optional,
97                    when: Condition::Always,
98                },
99            ],
100        },
101    },
102    Feature {
103        bit: 1,
104        code: "COOL",
105        name: "Cooling",
106        conform: Conform {
107            clauses: &[
108                Clause {
109                    verdict: Conformance::Mandatory,
110                    when: Condition::Feature(5),
111                },
112                Clause {
113                    verdict: Conformance::Optional,
114                    when: Condition::Always,
115                },
116            ],
117        },
118    },
119    Feature {
120        bit: 2,
121        code: "OCC",
122        name: "Occupancy",
123        conform: Conform::OPTIONAL,
124    },
125    Feature {
126        bit: 4,
127        code: "SB",
128        name: "Setback",
129        conform: Conform {
130            clauses: &[Clause::always(Conformance::Deprecated)],
131        },
132    },
133    Feature {
134        bit: 5,
135        code: "AUTO",
136        name: "AutoMode",
137        conform: Conform::OPTIONAL,
138    },
139    Feature {
140        bit: 6,
141        code: "LTNE",
142        name: "LocalTemperatureNotExposed",
143        conform: Conform::OPTIONAL,
144    },
145    Feature {
146        bit: 7,
147        code: "MSCH",
148        name: "MatterScheduleConfiguration",
149        conform: Conform::OPTIONAL,
150    },
151    Feature {
152        bit: 8,
153        code: "PRES",
154        name: "Presets",
155        conform: Conform::OPTIONAL,
156    },
157    Feature {
158        bit: 9,
159        code: "TEVT",
160        name: "Events",
161        conform: Conform {
162            clauses: &[
163                Clause {
164                    verdict: Conformance::Provisional,
165                    when: Condition::Always,
166                },
167                Clause {
168                    verdict: Conformance::Optional,
169                    when: Condition::Always,
170                },
171            ],
172        },
173    },
174    Feature {
175        bit: 10,
176        code: "TSUGGEST",
177        name: "ThermostatSuggestions",
178        conform: Conform {
179            clauses: &[Clause {
180                verdict: Conformance::Optional,
181                when: Condition::Feature(8),
182            }],
183        },
184    },
185];
186
187/// The attribute ids.
188pub mod attribute {
189    use crate::im::AttributeId;
190
191    /// `LocalTemperature`.
192    pub const LOCAL_TEMPERATURE: AttributeId = 0x00;
193    /// `OutdoorTemperature`.
194    pub const OUTDOOR_TEMPERATURE: AttributeId = 0x01;
195    /// `Occupancy`.
196    pub const OCCUPANCY: AttributeId = 0x02;
197    /// `AbsMinHeatSetpointLimit`.
198    pub const ABS_MIN_HEAT_SETPOINT_LIMIT: AttributeId = 0x03;
199    /// `AbsMaxHeatSetpointLimit`.
200    pub const ABS_MAX_HEAT_SETPOINT_LIMIT: AttributeId = 0x04;
201    /// `AbsMinCoolSetpointLimit`.
202    pub const ABS_MIN_COOL_SETPOINT_LIMIT: AttributeId = 0x05;
203    /// `AbsMaxCoolSetpointLimit`.
204    pub const ABS_MAX_COOL_SETPOINT_LIMIT: AttributeId = 0x06;
205    /// `PICoolingDemand`.
206    pub const PI_COOLING_DEMAND: AttributeId = 0x07;
207    /// `PIHeatingDemand`.
208    pub const PI_HEATING_DEMAND: AttributeId = 0x08;
209    /// `HVACSystemTypeConfiguration`.
210    pub const HVAC_SYSTEM_TYPE_CONFIGURATION: AttributeId = 0x09;
211    /// `LocalTemperatureCalibration`.
212    pub const LOCAL_TEMPERATURE_CALIBRATION: AttributeId = 0x10;
213    /// `OccupiedCoolingSetpoint`.
214    pub const OCCUPIED_COOLING_SETPOINT: AttributeId = 0x11;
215    /// `OccupiedHeatingSetpoint`.
216    pub const OCCUPIED_HEATING_SETPOINT: AttributeId = 0x12;
217    /// `UnoccupiedCoolingSetpoint`.
218    pub const UNOCCUPIED_COOLING_SETPOINT: AttributeId = 0x13;
219    /// `UnoccupiedHeatingSetpoint`.
220    pub const UNOCCUPIED_HEATING_SETPOINT: AttributeId = 0x14;
221    /// `MinHeatSetpointLimit`.
222    pub const MIN_HEAT_SETPOINT_LIMIT: AttributeId = 0x15;
223    /// `MaxHeatSetpointLimit`.
224    pub const MAX_HEAT_SETPOINT_LIMIT: AttributeId = 0x16;
225    /// `MinCoolSetpointLimit`.
226    pub const MIN_COOL_SETPOINT_LIMIT: AttributeId = 0x17;
227    /// `MaxCoolSetpointLimit`.
228    pub const MAX_COOL_SETPOINT_LIMIT: AttributeId = 0x18;
229    /// `MinSetpointDeadBand`.
230    pub const MIN_SETPOINT_DEAD_BAND: AttributeId = 0x19;
231    /// `RemoteSensing`.
232    pub const REMOTE_SENSING: AttributeId = 0x1A;
233    /// `ControlSequenceOfOperation`.
234    pub const CONTROL_SEQUENCE_OF_OPERATION: AttributeId = 0x1B;
235    /// `SystemMode`.
236    pub const SYSTEM_MODE: AttributeId = 0x1C;
237    /// `ThermostatRunningMode`.
238    pub const THERMOSTAT_RUNNING_MODE: AttributeId = 0x1E;
239    /// `TemperatureSetpointHold`.
240    pub const TEMPERATURE_SETPOINT_HOLD: AttributeId = 0x23;
241    /// `TemperatureSetpointHoldDuration`.
242    pub const TEMPERATURE_SETPOINT_HOLD_DURATION: AttributeId = 0x24;
243    /// `ThermostatProgrammingOperationMode`.
244    pub const THERMOSTAT_PROGRAMMING_OPERATION_MODE: AttributeId = 0x25;
245    /// `ThermostatRunningState`.
246    pub const THERMOSTAT_RUNNING_STATE: AttributeId = 0x29;
247    /// `SetpointChangeSource`.
248    pub const SETPOINT_CHANGE_SOURCE: AttributeId = 0x30;
249    /// `SetpointChangeAmount`.
250    pub const SETPOINT_CHANGE_AMOUNT: AttributeId = 0x31;
251    /// `SetpointChangeSourceTimestamp`.
252    pub const SETPOINT_CHANGE_SOURCE_TIMESTAMP: AttributeId = 0x32;
253    /// `OccupiedSetback`.
254    pub const OCCUPIED_SETBACK: AttributeId = 0x34;
255    /// `OccupiedSetbackMin`.
256    pub const OCCUPIED_SETBACK_MIN: AttributeId = 0x35;
257    /// `OccupiedSetbackMax`.
258    pub const OCCUPIED_SETBACK_MAX: AttributeId = 0x36;
259    /// `UnoccupiedSetback`.
260    pub const UNOCCUPIED_SETBACK: AttributeId = 0x37;
261    /// `UnoccupiedSetbackMin`.
262    pub const UNOCCUPIED_SETBACK_MIN: AttributeId = 0x38;
263    /// `UnoccupiedSetbackMax`.
264    pub const UNOCCUPIED_SETBACK_MAX: AttributeId = 0x39;
265    /// `EmergencyHeatDelta`.
266    pub const EMERGENCY_HEAT_DELTA: AttributeId = 0x3A;
267    /// `ACType`.
268    pub const AC_TYPE: AttributeId = 0x40;
269    /// `ACCapacity`.
270    pub const AC_CAPACITY: AttributeId = 0x41;
271    /// `ACRefrigerantType`.
272    pub const AC_REFRIGERANT_TYPE: AttributeId = 0x42;
273    /// `ACCompressorType`.
274    pub const AC_COMPRESSOR_TYPE: AttributeId = 0x43;
275    /// `ACErrorCode`.
276    pub const AC_ERROR_CODE: AttributeId = 0x44;
277    /// `ACLouverPosition`.
278    pub const AC_LOUVER_POSITION: AttributeId = 0x45;
279    /// `ACCoilTemperature`.
280    pub const AC_COIL_TEMPERATURE: AttributeId = 0x46;
281    /// `ACCapacityFormat`.
282    pub const AC_CAPACITY_FORMAT: AttributeId = 0x47;
283    /// `PresetTypes`.
284    pub const PRESET_TYPES: AttributeId = 0x48;
285    /// `ScheduleTypes`.
286    pub const SCHEDULE_TYPES: AttributeId = 0x49;
287    /// `NumberOfPresets`.
288    pub const NUMBER_OF_PRESETS: AttributeId = 0x4A;
289    /// `NumberOfSchedules`.
290    pub const NUMBER_OF_SCHEDULES: AttributeId = 0x4B;
291    /// `NumberOfScheduleTransitions`.
292    pub const NUMBER_OF_SCHEDULE_TRANSITIONS: AttributeId = 0x4C;
293    /// `NumberOfScheduleTransitionPerDay`.
294    pub const NUMBER_OF_SCHEDULE_TRANSITION_PER_DAY: AttributeId = 0x4D;
295    /// `ActivePresetHandle`.
296    pub const ACTIVE_PRESET_HANDLE: AttributeId = 0x4E;
297    /// `ActiveScheduleHandle`.
298    pub const ACTIVE_SCHEDULE_HANDLE: AttributeId = 0x4F;
299    /// `Presets`.
300    pub const PRESETS: AttributeId = 0x50;
301    /// `Schedules`.
302    pub const SCHEDULES: AttributeId = 0x51;
303    /// `SetpointHoldExpiryTimestamp`.
304    pub const SETPOINT_HOLD_EXPIRY_TIMESTAMP: AttributeId = 0x52;
305    /// `MaxThermostatSuggestions`.
306    pub const MAX_THERMOSTAT_SUGGESTIONS: AttributeId = 0x53;
307    /// `ThermostatSuggestions`.
308    pub const THERMOSTAT_SUGGESTIONS: AttributeId = 0x54;
309    /// `CurrentThermostatSuggestion`.
310    pub const CURRENT_THERMOSTAT_SUGGESTION: AttributeId = 0x55;
311    /// `ThermostatSuggestionNotFollowingReason`.
312    pub const THERMOSTAT_SUGGESTION_NOT_FOLLOWING_REASON: AttributeId = 0x56;
313}
314
315/// The command ids.
316pub mod command {
317    use crate::im::CommandId;
318
319    /// `SetpointRaiseLower`.
320    pub const SETPOINT_RAISE_LOWER: CommandId = 0x00;
321    /// `AddThermostatSuggestionResponse`.
322    pub const ADD_THERMOSTAT_SUGGESTION_RESPONSE: CommandId = 0x02;
323    /// `SetActiveScheduleRequest`.
324    pub const SET_ACTIVE_SCHEDULE_REQUEST: CommandId = 0x05;
325    /// `SetActivePresetRequest`.
326    pub const SET_ACTIVE_PRESET_REQUEST: CommandId = 0x06;
327    /// `AddThermostatSuggestion`.
328    pub const ADD_THERMOSTAT_SUGGESTION: CommandId = 0x07;
329    /// `RemoveThermostatSuggestion`.
330    pub const REMOVE_THERMOSTAT_SUGGESTION: CommandId = 0x08;
331}
332
333/// The event ids.
334pub mod event {
335    use crate::im::EventId;
336
337    /// `SystemModeChange`.
338    pub const SYSTEM_MODE_CHANGE: EventId = 0x00;
339    /// `LocalTemperatureChange`.
340    pub const LOCAL_TEMPERATURE_CHANGE: EventId = 0x01;
341    /// `OccupancyChange`.
342    pub const OCCUPANCY_CHANGE: EventId = 0x02;
343    /// `SetpointChange`.
344    pub const SETPOINT_CHANGE: EventId = 0x03;
345    /// `RunningStateChange`.
346    pub const RUNNING_STATE_CHANGE: EventId = 0x04;
347    /// `RunningModeChange`.
348    pub const RUNNING_MODE_CHANGE: EventId = 0x05;
349    /// `ActiveScheduleChange`.
350    pub const ACTIVE_SCHEDULE_CHANGE: EventId = 0x06;
351    /// `ActivePresetChange`.
352    pub const ACTIVE_PRESET_CHANGE: EventId = 0x07;
353}
354
355/// `ACCapacityFormatEnum`.
356#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
357#[repr(u8)]
358pub enum ACCapacityFormatEnum {
359    /// British Thermal Unit per Hour
360    BTUh = 0,
361}
362
363impl ACCapacityFormatEnum {
364    /// Reads a wire value, or `None` for one this revision does not define.
365    #[must_use]
366    pub const fn from_value(value: u8) -> Option<Self> {
367        match value {
368            0 => Some(Self::BTUh),
369            _ => None,
370        }
371    }
372
373    /// Its wire value.
374    #[must_use]
375    pub const fn value(self) -> u8 {
376        self as u8
377    }
378}
379
380impl ToTlv for ACCapacityFormatEnum {
381    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
382        self.value().to_tlv(w, tag)
383    }
384}
385
386impl<'a> FromTlv<'a> for ACCapacityFormatEnum {
387    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
388        let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
389        Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
390    }
391}
392
393/// `ACCompressorTypeEnum`.
394#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
395#[repr(u8)]
396pub enum ACCompressorTypeEnum {
397    /// Unknown compressor type
398    Unknown = 0,
399    /// Max working ambient 43 °C
400    T1 = 1,
401    /// Max working ambient 35 °C
402    T2 = 2,
403    /// Max working ambient 52 °C
404    T3 = 3,
405}
406
407impl ACCompressorTypeEnum {
408    /// Reads a wire value, or `None` for one this revision does not define.
409    #[must_use]
410    pub const fn from_value(value: u8) -> Option<Self> {
411        match value {
412            0 => Some(Self::Unknown),
413            1 => Some(Self::T1),
414            2 => Some(Self::T2),
415            3 => Some(Self::T3),
416            _ => None,
417        }
418    }
419
420    /// Its wire value.
421    #[must_use]
422    pub const fn value(self) -> u8 {
423        self as u8
424    }
425}
426
427impl ToTlv for ACCompressorTypeEnum {
428    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
429        self.value().to_tlv(w, tag)
430    }
431}
432
433impl<'a> FromTlv<'a> for ACCompressorTypeEnum {
434    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
435        let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
436        Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
437    }
438}
439
440/// `ACLouverPositionEnum`.
441#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
442#[repr(u8)]
443pub enum ACLouverPositionEnum {
444    /// Fully Closed
445    Closed = 1,
446    /// Fully Open
447    Open = 2,
448    /// Quarter Open
449    Quarter = 3,
450    /// Half Open
451    Half = 4,
452    /// Three Quarters Open
453    ThreeQuarters = 5,
454}
455
456impl ACLouverPositionEnum {
457    /// Reads a wire value, or `None` for one this revision does not define.
458    #[must_use]
459    pub const fn from_value(value: u8) -> Option<Self> {
460        match value {
461            1 => Some(Self::Closed),
462            2 => Some(Self::Open),
463            3 => Some(Self::Quarter),
464            4 => Some(Self::Half),
465            5 => Some(Self::ThreeQuarters),
466            _ => None,
467        }
468    }
469
470    /// Its wire value.
471    #[must_use]
472    pub const fn value(self) -> u8 {
473        self as u8
474    }
475}
476
477impl ToTlv for ACLouverPositionEnum {
478    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
479        self.value().to_tlv(w, tag)
480    }
481}
482
483impl<'a> FromTlv<'a> for ACLouverPositionEnum {
484    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
485        let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
486        Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
487    }
488}
489
490/// `ACRefrigerantTypeEnum`.
491#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
492#[repr(u8)]
493pub enum ACRefrigerantTypeEnum {
494    /// Unknown Refrigerant Type
495    Unknown = 0,
496    /// R22 Refrigerant
497    R22 = 1,
498    /// R410a Refrigerant
499    R410A = 2,
500    /// R407c Refrigerant
501    R407C = 3,
502}
503
504impl ACRefrigerantTypeEnum {
505    /// Reads a wire value, or `None` for one this revision does not define.
506    #[must_use]
507    pub const fn from_value(value: u8) -> Option<Self> {
508        match value {
509            0 => Some(Self::Unknown),
510            1 => Some(Self::R22),
511            2 => Some(Self::R410A),
512            3 => Some(Self::R407C),
513            _ => None,
514        }
515    }
516
517    /// Its wire value.
518    #[must_use]
519    pub const fn value(self) -> u8 {
520        self as u8
521    }
522}
523
524impl ToTlv for ACRefrigerantTypeEnum {
525    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
526        self.value().to_tlv(w, tag)
527    }
528}
529
530impl<'a> FromTlv<'a> for ACRefrigerantTypeEnum {
531    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
532        let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
533        Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
534    }
535}
536
537/// `ACTypeEnum`.
538#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
539#[repr(u8)]
540pub enum ACTypeEnum {
541    /// Unknown AC Type
542    Unknown = 0,
543    /// Cooling and Fixed Speed
544    CoolingFixed = 1,
545    /// Heat Pump and Fixed Speed
546    HeatPumpFixed = 2,
547    /// Cooling and Inverter
548    CoolingInverter = 3,
549    /// Heat Pump and Inverter
550    HeatPumpInverter = 4,
551}
552
553impl ACTypeEnum {
554    /// Reads a wire value, or `None` for one this revision does not define.
555    #[must_use]
556    pub const fn from_value(value: u8) -> Option<Self> {
557        match value {
558            0 => Some(Self::Unknown),
559            1 => Some(Self::CoolingFixed),
560            2 => Some(Self::HeatPumpFixed),
561            3 => Some(Self::CoolingInverter),
562            4 => Some(Self::HeatPumpInverter),
563            _ => None,
564        }
565    }
566
567    /// Its wire value.
568    #[must_use]
569    pub const fn value(self) -> u8 {
570        self as u8
571    }
572}
573
574impl ToTlv for ACTypeEnum {
575    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
576        self.value().to_tlv(w, tag)
577    }
578}
579
580impl<'a> FromTlv<'a> for ACTypeEnum {
581    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
582        let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
583        Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
584    }
585}
586
587/// `ControlSequenceOfOperationEnum`.
588#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
589#[repr(u8)]
590pub enum ControlSequenceOfOperationEnum {
591    /// Heat and Emergency are not possible
592    CoolingOnly = 0,
593    /// Heat and Emergency are not possible
594    CoolingWithReheat = 1,
595    /// Cool and precooling (see Terms) are not possible
596    HeatingOnly = 2,
597    /// Cool and precooling are not possible
598    HeatingWithReheat = 3,
599    /// All modes are possible
600    CoolingAndHeating = 4,
601    /// All modes are possible
602    CoolingAndHeatingWithReheat = 5,
603}
604
605impl ControlSequenceOfOperationEnum {
606    /// Reads a wire value, or `None` for one this revision does not define.
607    #[must_use]
608    pub const fn from_value(value: u8) -> Option<Self> {
609        match value {
610            0 => Some(Self::CoolingOnly),
611            1 => Some(Self::CoolingWithReheat),
612            2 => Some(Self::HeatingOnly),
613            3 => Some(Self::HeatingWithReheat),
614            4 => Some(Self::CoolingAndHeating),
615            5 => Some(Self::CoolingAndHeatingWithReheat),
616            _ => None,
617        }
618    }
619
620    /// Its wire value.
621    #[must_use]
622    pub const fn value(self) -> u8 {
623        self as u8
624    }
625}
626
627impl ToTlv for ControlSequenceOfOperationEnum {
628    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
629        self.value().to_tlv(w, tag)
630    }
631}
632
633impl<'a> FromTlv<'a> for ControlSequenceOfOperationEnum {
634    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
635        let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
636        Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
637    }
638}
639
640/// `PresetScenarioEnum`.
641#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
642#[repr(u8)]
643pub enum PresetScenarioEnum {
644    /// The thermostat-controlled area is occupied
645    Occupied = 1,
646    /// The thermostat-controlled area is unoccupied
647    Unoccupied = 2,
648    /// Users are likely to be sleeping
649    Sleep = 3,
650    /// Users are likely to be waking up
651    Wake = 4,
652    /// Users are on vacation
653    Vacation = 5,
654    /// Users are likely to be going to sleep
655    GoingToSleep = 6,
656    /// Custom presets
657    UserDefined = 254,
658}
659
660impl PresetScenarioEnum {
661    /// Reads a wire value, or `None` for one this revision does not define.
662    #[must_use]
663    pub const fn from_value(value: u8) -> Option<Self> {
664        match value {
665            1 => Some(Self::Occupied),
666            2 => Some(Self::Unoccupied),
667            3 => Some(Self::Sleep),
668            4 => Some(Self::Wake),
669            5 => Some(Self::Vacation),
670            6 => Some(Self::GoingToSleep),
671            254 => Some(Self::UserDefined),
672            _ => None,
673        }
674    }
675
676    /// Its wire value.
677    #[must_use]
678    pub const fn value(self) -> u8 {
679        self as u8
680    }
681}
682
683impl ToTlv for PresetScenarioEnum {
684    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
685        self.value().to_tlv(w, tag)
686    }
687}
688
689impl<'a> FromTlv<'a> for PresetScenarioEnum {
690    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
691        let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
692        Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
693    }
694}
695
696/// `SetpointChangeSourceEnum`.
697#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
698#[repr(u8)]
699pub enum SetpointChangeSourceEnum {
700    /// Manual, user-initiated setpoint change via the thermostat
701    Manual = 0,
702    /// Schedule/internal programming-initiated setpoint change
703    Schedule = 1,
704    /// Externally-initiated setpoint change (e.g., DRLC cluster command, attribute write)
705    External = 2,
706}
707
708impl SetpointChangeSourceEnum {
709    /// Reads a wire value, or `None` for one this revision does not define.
710    #[must_use]
711    pub const fn from_value(value: u8) -> Option<Self> {
712        match value {
713            0 => Some(Self::Manual),
714            1 => Some(Self::Schedule),
715            2 => Some(Self::External),
716            _ => None,
717        }
718    }
719
720    /// Its wire value.
721    #[must_use]
722    pub const fn value(self) -> u8 {
723        self as u8
724    }
725}
726
727impl ToTlv for SetpointChangeSourceEnum {
728    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
729        self.value().to_tlv(w, tag)
730    }
731}
732
733impl<'a> FromTlv<'a> for SetpointChangeSourceEnum {
734    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
735        let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
736        Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
737    }
738}
739
740/// `SetpointRaiseLowerModeEnum`.
741#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
742#[repr(u8)]
743pub enum SetpointRaiseLowerModeEnum {
744    /// Adjust Heat Setpoint
745    Heat = 0,
746    /// Adjust Cool Setpoint
747    Cool = 1,
748    /// Adjust Heat Setpoint and Cool Setpoint
749    Both = 2,
750}
751
752impl SetpointRaiseLowerModeEnum {
753    /// Reads a wire value, or `None` for one this revision does not define.
754    #[must_use]
755    pub const fn from_value(value: u8) -> Option<Self> {
756        match value {
757            0 => Some(Self::Heat),
758            1 => Some(Self::Cool),
759            2 => Some(Self::Both),
760            _ => None,
761        }
762    }
763
764    /// Its wire value.
765    #[must_use]
766    pub const fn value(self) -> u8 {
767        self as u8
768    }
769}
770
771impl ToTlv for SetpointRaiseLowerModeEnum {
772    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
773        self.value().to_tlv(w, tag)
774    }
775}
776
777impl<'a> FromTlv<'a> for SetpointRaiseLowerModeEnum {
778    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
779        let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
780        Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
781    }
782}
783
784/// `StartOfWeekEnum`.
785#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
786#[repr(u8)]
787pub enum StartOfWeekEnum {
788    /// `Sunday`.
789    Sunday = 0,
790    /// `Monday`.
791    Monday = 1,
792    /// `Tuesday`.
793    Tuesday = 2,
794    /// `Wednesday`.
795    Wednesday = 3,
796    /// `Thursday`.
797    Thursday = 4,
798    /// `Friday`.
799    Friday = 5,
800    /// `Saturday`.
801    Saturday = 6,
802}
803
804impl StartOfWeekEnum {
805    /// Reads a wire value, or `None` for one this revision does not define.
806    #[must_use]
807    pub const fn from_value(value: u8) -> Option<Self> {
808        match value {
809            0 => Some(Self::Sunday),
810            1 => Some(Self::Monday),
811            2 => Some(Self::Tuesday),
812            3 => Some(Self::Wednesday),
813            4 => Some(Self::Thursday),
814            5 => Some(Self::Friday),
815            6 => Some(Self::Saturday),
816            _ => None,
817        }
818    }
819
820    /// Its wire value.
821    #[must_use]
822    pub const fn value(self) -> u8 {
823        self as u8
824    }
825}
826
827impl ToTlv for StartOfWeekEnum {
828    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
829        self.value().to_tlv(w, tag)
830    }
831}
832
833impl<'a> FromTlv<'a> for StartOfWeekEnum {
834    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
835        let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
836        Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
837    }
838}
839
840/// `SystemModeEnum`.
841#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
842#[repr(u8)]
843pub enum SystemModeEnum {
844    /// The Thermostat does not generate demand for Cooling or Heating
845    Off = 0,
846    /// Demand is generated for either Cooling or Heating, as required
847    Auto = 1,
848    /// Demand is only generated for Cooling
849    Cool = 3,
850    /// Demand is only generated for Heating
851    Heat = 4,
852    /// 2nd stage heating is in use to achieve desired temperature
853    EmergencyHeat = 5,
854    /// (see Terms)
855    Precooling = 6,
856    /// `FanOnly`.
857    FanOnly = 7,
858    /// `Dry`.
859    Dry = 8,
860    /// `Sleep`.
861    Sleep = 9,
862}
863
864impl SystemModeEnum {
865    /// Reads a wire value, or `None` for one this revision does not define.
866    #[must_use]
867    pub const fn from_value(value: u8) -> Option<Self> {
868        match value {
869            0 => Some(Self::Off),
870            1 => Some(Self::Auto),
871            3 => Some(Self::Cool),
872            4 => Some(Self::Heat),
873            5 => Some(Self::EmergencyHeat),
874            6 => Some(Self::Precooling),
875            7 => Some(Self::FanOnly),
876            8 => Some(Self::Dry),
877            9 => Some(Self::Sleep),
878            _ => None,
879        }
880    }
881
882    /// Its wire value.
883    #[must_use]
884    pub const fn value(self) -> u8 {
885        self as u8
886    }
887}
888
889impl ToTlv for SystemModeEnum {
890    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
891        self.value().to_tlv(w, tag)
892    }
893}
894
895impl<'a> FromTlv<'a> for SystemModeEnum {
896    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
897        let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
898        Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
899    }
900}
901
902/// `TemperatureSetpointHoldEnum`.
903#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
904#[repr(u8)]
905pub enum TemperatureSetpointHoldEnum {
906    /// Follow scheduling program
907    SetpointHoldOff = 0,
908    /// Maintain current setpoint, regardless of schedule transitions
909    SetpointHoldOn = 1,
910}
911
912impl TemperatureSetpointHoldEnum {
913    /// Reads a wire value, or `None` for one this revision does not define.
914    #[must_use]
915    pub const fn from_value(value: u8) -> Option<Self> {
916        match value {
917            0 => Some(Self::SetpointHoldOff),
918            1 => Some(Self::SetpointHoldOn),
919            _ => None,
920        }
921    }
922
923    /// Its wire value.
924    #[must_use]
925    pub const fn value(self) -> u8 {
926        self as u8
927    }
928}
929
930impl ToTlv for TemperatureSetpointHoldEnum {
931    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
932        self.value().to_tlv(w, tag)
933    }
934}
935
936impl<'a> FromTlv<'a> for TemperatureSetpointHoldEnum {
937    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
938        let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
939        Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
940    }
941}
942
943/// `ThermostatRunningModeEnum`.
944#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
945#[repr(u8)]
946pub enum ThermostatRunningModeEnum {
947    /// The Thermostat does not generate demand for Cooling or Heating
948    Off = 0,
949    /// Demand is only generated for Cooling
950    Cool = 3,
951    /// Demand is only generated for Heating
952    Heat = 4,
953}
954
955impl ThermostatRunningModeEnum {
956    /// Reads a wire value, or `None` for one this revision does not define.
957    #[must_use]
958    pub const fn from_value(value: u8) -> Option<Self> {
959        match value {
960            0 => Some(Self::Off),
961            3 => Some(Self::Cool),
962            4 => Some(Self::Heat),
963            _ => None,
964        }
965    }
966
967    /// Its wire value.
968    #[must_use]
969    pub const fn value(self) -> u8 {
970        self as u8
971    }
972}
973
974impl ToTlv for ThermostatRunningModeEnum {
975    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
976        self.value().to_tlv(w, tag)
977    }
978}
979
980impl<'a> FromTlv<'a> for ThermostatRunningModeEnum {
981    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
982        let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
983        Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
984    }
985}
986
987bitflags::bitflags! {
988    /// `ACErrorCodeBitmap`.
989    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
990    pub struct ACErrorCodeBitmap: u8 {
991        /// Compressor Failure or Refrigerant Leakage
992        const COMPRESSOR_FAIL = 1 << 0;
993        /// Room Temperature Sensor Failure
994        const ROOM_SENSOR_FAIL = 1 << 1;
995        /// Outdoor Temperature Sensor Failure
996        const OUTDOOR_SENSOR_FAIL = 1 << 2;
997        /// Indoor Coil Temperature Sensor Failure
998        const COIL_SENSOR_FAIL = 1 << 3;
999        /// Fan Failure
1000        const FAN_FAIL = 1 << 4;
1001    }
1002}
1003
1004impl ToTlv for ACErrorCodeBitmap {
1005    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1006        self.bits().to_tlv(w, tag)
1007    }
1008}
1009
1010impl<'a> FromTlv<'a> for ACErrorCodeBitmap {
1011    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1012        let bits = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
1013        Self::from_bits(bits).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
1014    }
1015}
1016
1017bitflags::bitflags! {
1018    /// `OccupancyBitmap`.
1019    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
1020    pub struct OccupancyBitmap: u8 {
1021        /// Indicates the occupancy state
1022        const OCCUPIED = 1 << 0;
1023    }
1024}
1025
1026impl ToTlv for OccupancyBitmap {
1027    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1028        self.bits().to_tlv(w, tag)
1029    }
1030}
1031
1032impl<'a> FromTlv<'a> for OccupancyBitmap {
1033    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1034        let bits = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
1035        Self::from_bits(bits).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
1036    }
1037}
1038
1039bitflags::bitflags! {
1040    /// `PresetTypeFeaturesBitmap`.
1041    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
1042    pub struct PresetTypeFeaturesBitmap: u8 {
1043        /// Preset may be automatically activated by the thermostat
1044        const AUTOMATIC = 1 << 0;
1045        /// Preset supports user-provided names
1046        const SUPPORTS_NAMES = 1 << 1;
1047    }
1048}
1049
1050impl ToTlv for PresetTypeFeaturesBitmap {
1051    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1052        self.bits().to_tlv(w, tag)
1053    }
1054}
1055
1056impl<'a> FromTlv<'a> for PresetTypeFeaturesBitmap {
1057    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1058        let bits = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
1059        Self::from_bits(bits).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
1060    }
1061}
1062
1063bitflags::bitflags! {
1064    /// `RelayStateBitmap`.
1065    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
1066    pub struct RelayStateBitmap: u8 {
1067        /// Heat Stage On
1068        const HEAT = 1 << 0;
1069        /// Cool Stage On
1070        const COOL = 1 << 1;
1071        /// Fan Stage On
1072        const FAN = 1 << 2;
1073        /// Heat 2nd Stage On
1074        const HEAT_STAGE2 = 1 << 3;
1075        /// Cool 2nd Stage On
1076        const COOL_STAGE2 = 1 << 4;
1077        /// Fan 2nd Stage On
1078        const FAN_STAGE2 = 1 << 5;
1079        /// Fan 3rd Stage On
1080        const FAN_STAGE3 = 1 << 6;
1081    }
1082}
1083
1084impl ToTlv for RelayStateBitmap {
1085    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1086        self.bits().to_tlv(w, tag)
1087    }
1088}
1089
1090impl<'a> FromTlv<'a> for RelayStateBitmap {
1091    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1092        let bits = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
1093        Self::from_bits(bits).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
1094    }
1095}
1096
1097bitflags::bitflags! {
1098    /// `RemoteSensingBitmap`.
1099    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
1100    pub struct RemoteSensingBitmap: u8 {
1101        /// Calculated Local Temperature is derived from a remote node
1102        const LOCAL_TEMPERATURE = 1 << 0;
1103        /// OutdoorTemperature is derived from a remote node
1104        const OUTDOOR_TEMPERATURE = 1 << 1;
1105        /// Occupancy is derived from a remote node
1106        const OCCUPANCY = 1 << 2;
1107    }
1108}
1109
1110impl ToTlv for RemoteSensingBitmap {
1111    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1112        self.bits().to_tlv(w, tag)
1113    }
1114}
1115
1116impl<'a> FromTlv<'a> for RemoteSensingBitmap {
1117    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1118        let bits = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
1119        Self::from_bits(bits).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
1120    }
1121}
1122
1123bitflags::bitflags! {
1124    /// `ScheduleDayOfWeekBitmap`.
1125    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
1126    pub struct ScheduleDayOfWeekBitmap: u8 {
1127        /// Sunday
1128        const SUNDAY = 1 << 0;
1129        /// Monday
1130        const MONDAY = 1 << 1;
1131        /// Tuesday
1132        const TUESDAY = 1 << 2;
1133        /// Wednesday
1134        const WEDNESDAY = 1 << 3;
1135        /// Thursday
1136        const THURSDAY = 1 << 4;
1137        /// Friday
1138        const FRIDAY = 1 << 5;
1139        /// Saturday
1140        const SATURDAY = 1 << 6;
1141        /// Away or Vacation
1142        const AWAY = 1 << 7;
1143    }
1144}
1145
1146impl ToTlv for ScheduleDayOfWeekBitmap {
1147    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1148        self.bits().to_tlv(w, tag)
1149    }
1150}
1151
1152impl<'a> FromTlv<'a> for ScheduleDayOfWeekBitmap {
1153    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1154        let bits = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
1155        Self::from_bits(bits).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
1156    }
1157}
1158
1159bitflags::bitflags! {
1160    /// `ScheduleModeBitmap`.
1161    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
1162    pub struct ScheduleModeBitmap: u8 {
1163        /// Adjust Heat Setpoint
1164        const HEAT_SETPOINT_PRESENT = 1 << 0;
1165        /// Adjust Cool Setpoint
1166        const COOL_SETPOINT_PRESENT = 1 << 1;
1167    }
1168}
1169
1170impl ToTlv for ScheduleModeBitmap {
1171    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1172        self.bits().to_tlv(w, tag)
1173    }
1174}
1175
1176impl<'a> FromTlv<'a> for ScheduleModeBitmap {
1177    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1178        let bits = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
1179        Self::from_bits(bits).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
1180    }
1181}
1182
1183bitflags::bitflags! {
1184    /// `ScheduleTypeFeaturesBitmap`.
1185    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
1186    pub struct ScheduleTypeFeaturesBitmap: u8 {
1187        /// Supports presets
1188        const SUPPORTS_PRESETS = 1 << 0;
1189        /// Supports setpoints
1190        const SUPPORTS_SETPOINTS = 1 << 1;
1191        /// Supports user-provided names
1192        const SUPPORTS_NAMES = 1 << 2;
1193        /// Supports transitioning to SystemModeOff
1194        const SUPPORTS_OFF = 1 << 3;
1195    }
1196}
1197
1198impl ToTlv for ScheduleTypeFeaturesBitmap {
1199    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1200        self.bits().to_tlv(w, tag)
1201    }
1202}
1203
1204impl<'a> FromTlv<'a> for ScheduleTypeFeaturesBitmap {
1205    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1206        let bits = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
1207        Self::from_bits(bits).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
1208    }
1209}
1210
1211bitflags::bitflags! {
1212    /// `ThermostatSuggestionNotFollowingReasonBitmap`.
1213    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
1214    pub struct ThermostatSuggestionNotFollowingReasonBitmap: u8 {
1215        /// Thermostat is responding to a Demand Response event
1216        const DEMAND_RESPONSE_EVENT = 1 << 0;
1217        /// Thermostat has an ongoing setpoint hold
1218        const ONGOING_HOLD = 1 << 1;
1219        /// Thermostat is following a schedule
1220        const SCHEDULE = 1 << 2;
1221        /// Thermostat is following the occupancy signal
1222        const OCCUPANCY = 1 << 3;
1223        /// Thermostat is set to Vacation mode
1224        const VACATION_MODE = 1 << 4;
1225        /// Thermostat is following a Time Of Use based cost savings plan
1226        const TIME_OF_USE_COST_SAVINGS = 1 << 5;
1227        /// Thermostat is precooling or preheating based on an energy forecast signal
1228        const PRE_COOLING_OR_PRE_HEATING = 1 << 6;
1229        /// Thermostat has conflicting suggestions and is unable to choose one
1230        const CONFLICTING_SUGGESTIONS = 1 << 7;
1231    }
1232}
1233
1234impl ToTlv for ThermostatSuggestionNotFollowingReasonBitmap {
1235    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1236        self.bits().to_tlv(w, tag)
1237    }
1238}
1239
1240impl<'a> FromTlv<'a> for ThermostatSuggestionNotFollowingReasonBitmap {
1241    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1242        let bits = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
1243        Self::from_bits(bits).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
1244    }
1245}
1246
1247/// `PresetStruct`.
1248#[derive(Debug, Clone, Copy, PartialEq)]
1249pub struct PresetStruct<'a> {
1250    /// `PresetHandle`, field 0.
1251    pub preset_handle: Nullable<&'a [u8]>,
1252    /// `PresetScenario`, field 1.
1253    pub preset_scenario: PresetScenarioEnum,
1254    /// `Name`, field 2.
1255    pub name: Option<Nullable<&'a str>>,
1256    /// `CoolingSetpoint`, field 3.
1257    pub cooling_setpoint: Option<i16>,
1258    /// `HeatingSetpoint`, field 4.
1259    pub heating_setpoint: Option<i16>,
1260    /// `BuiltIn`, field 5.
1261    pub built_in: Nullable<bool>,
1262}
1263
1264impl<'a> ToTlv for PresetStruct<'a> {
1265    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1266        w.start_structure(tag)?;
1267        self.preset_handle.to_tlv(w, Tag::Context(0))?;
1268        self.preset_scenario.to_tlv(w, Tag::Context(1))?;
1269        if let Some(value) = &self.name {
1270            value.to_tlv(w, Tag::Context(2))?;
1271        }
1272        if let Some(value) = &self.cooling_setpoint {
1273            value.to_tlv(w, Tag::Context(3))?;
1274        }
1275        if let Some(value) = &self.heating_setpoint {
1276            value.to_tlv(w, Tag::Context(4))?;
1277        }
1278        self.built_in.to_tlv(w, Tag::Context(5))?;
1279        w.end_container()
1280    }
1281}
1282
1283impl<'a> FromTlv<'a> for PresetStruct<'a> {
1284    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1285        if element.value.container() != Some(ContainerKind::Structure) {
1286            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1287        }
1288        let mut preset_handle = None;
1289        let mut preset_scenario = None;
1290        let mut name = None;
1291        let mut cooling_setpoint = None;
1292        let mut heating_setpoint = None;
1293        let mut built_in = None;
1294        loop {
1295            let Some(field) = reader.next_element()? else {
1296                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1297            };
1298            if field.value == Value::EndOfContainer {
1299                break;
1300            }
1301            match field.tag.context() {
1302                Some(0) => preset_handle = Some(<Nullable<&'a [u8]>>::from_tlv(reader, &field)?),
1303                Some(1) => preset_scenario = Some(<PresetScenarioEnum>::from_tlv(reader, &field)?),
1304                Some(2) => name = Some(<Nullable<&'a str>>::from_tlv(reader, &field)?),
1305                Some(3) => cooling_setpoint = Some(<i16>::from_tlv(reader, &field)?),
1306                Some(4) => heating_setpoint = Some(<i16>::from_tlv(reader, &field)?),
1307                Some(5) => built_in = Some(<Nullable<bool>>::from_tlv(reader, &field)?),
1308                // A field this revision does not define. §7.19.2: a receiver
1309                // ignores what it does not know rather than refusing the whole
1310                // structure, which is what lets a newer peer talk to an older one.
1311                _ => reader.skip_value(&field)?,
1312            }
1313        }
1314        Ok(Self {
1315            preset_handle: preset_handle.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1316            preset_scenario: preset_scenario
1317                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1318            name,
1319            cooling_setpoint,
1320            heating_setpoint,
1321            built_in: built_in.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1322        })
1323    }
1324}
1325
1326/// `PresetTypeStruct`.
1327#[derive(Debug, Clone, Copy, PartialEq)]
1328pub struct PresetTypeStruct {
1329    /// `PresetScenario`, field 0.
1330    pub preset_scenario: PresetScenarioEnum,
1331    /// `NumberOfPresets`, field 1.
1332    pub number_of_presets: u8,
1333    /// `PresetTypeFeatures`, field 2.
1334    pub preset_type_features: PresetTypeFeaturesBitmap,
1335}
1336
1337impl ToTlv for PresetTypeStruct {
1338    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1339        w.start_structure(tag)?;
1340        self.preset_scenario.to_tlv(w, Tag::Context(0))?;
1341        self.number_of_presets.to_tlv(w, Tag::Context(1))?;
1342        self.preset_type_features.to_tlv(w, Tag::Context(2))?;
1343        w.end_container()
1344    }
1345}
1346
1347impl<'a> FromTlv<'a> for PresetTypeStruct {
1348    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1349        if element.value.container() != Some(ContainerKind::Structure) {
1350            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1351        }
1352        let mut preset_scenario = None;
1353        let mut number_of_presets = None;
1354        let mut preset_type_features = None;
1355        loop {
1356            let Some(field) = reader.next_element()? else {
1357                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1358            };
1359            if field.value == Value::EndOfContainer {
1360                break;
1361            }
1362            match field.tag.context() {
1363                Some(0) => preset_scenario = Some(<PresetScenarioEnum>::from_tlv(reader, &field)?),
1364                Some(1) => number_of_presets = Some(<u8>::from_tlv(reader, &field)?),
1365                Some(2) => {
1366                    preset_type_features =
1367                        Some(<PresetTypeFeaturesBitmap>::from_tlv(reader, &field)?)
1368                }
1369                // A field this revision does not define. §7.19.2: a receiver
1370                // ignores what it does not know rather than refusing the whole
1371                // structure, which is what lets a newer peer talk to an older one.
1372                _ => reader.skip_value(&field)?,
1373            }
1374        }
1375        Ok(Self {
1376            preset_scenario: preset_scenario
1377                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1378            number_of_presets: number_of_presets
1379                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1380            preset_type_features: preset_type_features
1381                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1382        })
1383    }
1384}
1385
1386/// `ScheduleStruct`.
1387#[derive(Debug, Clone, Copy, PartialEq)]
1388pub struct ScheduleStruct<'a> {
1389    /// `ScheduleHandle`, field 0.
1390    pub schedule_handle: Nullable<&'a [u8]>,
1391    /// `SystemMode`, field 1.
1392    pub system_mode: SystemModeEnum,
1393    /// `Name`, field 2.
1394    pub name: Option<&'a str>,
1395    /// `PresetHandle`, field 3.
1396    pub preset_handle: Option<&'a [u8]>,
1397    /// `Transitions`, field 4.
1398    pub transitions: TlvList<'a, ScheduleTransitionStruct<'a>>,
1399    /// `BuiltIn`, field 5.
1400    pub built_in: Nullable<bool>,
1401}
1402
1403impl<'a> ToTlv for ScheduleStruct<'a> {
1404    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1405        w.start_structure(tag)?;
1406        self.schedule_handle.to_tlv(w, Tag::Context(0))?;
1407        self.system_mode.to_tlv(w, Tag::Context(1))?;
1408        if let Some(value) = &self.name {
1409            value.to_tlv(w, Tag::Context(2))?;
1410        }
1411        if let Some(value) = &self.preset_handle {
1412            value.to_tlv(w, Tag::Context(3))?;
1413        }
1414        self.transitions.to_tlv(w, Tag::Context(4))?;
1415        self.built_in.to_tlv(w, Tag::Context(5))?;
1416        w.end_container()
1417    }
1418}
1419
1420impl<'a> FromTlv<'a> for ScheduleStruct<'a> {
1421    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1422        if element.value.container() != Some(ContainerKind::Structure) {
1423            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1424        }
1425        let mut schedule_handle = None;
1426        let mut system_mode = None;
1427        let mut name = None;
1428        let mut preset_handle = None;
1429        let mut transitions = None;
1430        let mut built_in = None;
1431        loop {
1432            let Some(field) = reader.next_element()? else {
1433                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1434            };
1435            if field.value == Value::EndOfContainer {
1436                break;
1437            }
1438            match field.tag.context() {
1439                Some(0) => schedule_handle = Some(<Nullable<&'a [u8]>>::from_tlv(reader, &field)?),
1440                Some(1) => system_mode = Some(<SystemModeEnum>::from_tlv(reader, &field)?),
1441                Some(2) => name = Some(<&'a str>::from_tlv(reader, &field)?),
1442                Some(3) => preset_handle = Some(<&'a [u8]>::from_tlv(reader, &field)?),
1443                Some(4) => {
1444                    transitions = Some(<TlvList<'a, ScheduleTransitionStruct<'a>>>::from_tlv(
1445                        reader, &field,
1446                    )?)
1447                }
1448                Some(5) => built_in = Some(<Nullable<bool>>::from_tlv(reader, &field)?),
1449                // A field this revision does not define. §7.19.2: a receiver
1450                // ignores what it does not know rather than refusing the whole
1451                // structure, which is what lets a newer peer talk to an older one.
1452                _ => reader.skip_value(&field)?,
1453            }
1454        }
1455        Ok(Self {
1456            schedule_handle: schedule_handle
1457                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1458            system_mode: system_mode.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1459            name,
1460            preset_handle,
1461            transitions: transitions.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1462            built_in: built_in.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1463        })
1464    }
1465}
1466
1467/// `ScheduleTransitionStruct`.
1468#[derive(Debug, Clone, Copy, PartialEq)]
1469pub struct ScheduleTransitionStruct<'a> {
1470    /// `DayOfWeek`, field 0.
1471    pub day_of_week: ScheduleDayOfWeekBitmap,
1472    /// `TransitionTime`, field 1.
1473    pub transition_time: u16,
1474    /// `PresetHandle`, field 2.
1475    pub preset_handle: Option<&'a [u8]>,
1476    /// `SystemMode`, field 3.
1477    pub system_mode: Option<SystemModeEnum>,
1478    /// `CoolingSetpoint`, field 4.
1479    pub cooling_setpoint: Option<i16>,
1480    /// `HeatingSetpoint`, field 5.
1481    pub heating_setpoint: Option<i16>,
1482}
1483
1484impl<'a> ToTlv for ScheduleTransitionStruct<'a> {
1485    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1486        w.start_structure(tag)?;
1487        self.day_of_week.to_tlv(w, Tag::Context(0))?;
1488        self.transition_time.to_tlv(w, Tag::Context(1))?;
1489        if let Some(value) = &self.preset_handle {
1490            value.to_tlv(w, Tag::Context(2))?;
1491        }
1492        if let Some(value) = &self.system_mode {
1493            value.to_tlv(w, Tag::Context(3))?;
1494        }
1495        if let Some(value) = &self.cooling_setpoint {
1496            value.to_tlv(w, Tag::Context(4))?;
1497        }
1498        if let Some(value) = &self.heating_setpoint {
1499            value.to_tlv(w, Tag::Context(5))?;
1500        }
1501        w.end_container()
1502    }
1503}
1504
1505impl<'a> FromTlv<'a> for ScheduleTransitionStruct<'a> {
1506    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1507        if element.value.container() != Some(ContainerKind::Structure) {
1508            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1509        }
1510        let mut day_of_week = None;
1511        let mut transition_time = None;
1512        let mut preset_handle = None;
1513        let mut system_mode = None;
1514        let mut cooling_setpoint = None;
1515        let mut heating_setpoint = None;
1516        loop {
1517            let Some(field) = reader.next_element()? else {
1518                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1519            };
1520            if field.value == Value::EndOfContainer {
1521                break;
1522            }
1523            match field.tag.context() {
1524                Some(0) => day_of_week = Some(<ScheduleDayOfWeekBitmap>::from_tlv(reader, &field)?),
1525                Some(1) => transition_time = Some(<u16>::from_tlv(reader, &field)?),
1526                Some(2) => preset_handle = Some(<&'a [u8]>::from_tlv(reader, &field)?),
1527                Some(3) => system_mode = Some(<SystemModeEnum>::from_tlv(reader, &field)?),
1528                Some(4) => cooling_setpoint = Some(<i16>::from_tlv(reader, &field)?),
1529                Some(5) => heating_setpoint = Some(<i16>::from_tlv(reader, &field)?),
1530                // A field this revision does not define. §7.19.2: a receiver
1531                // ignores what it does not know rather than refusing the whole
1532                // structure, which is what lets a newer peer talk to an older one.
1533                _ => reader.skip_value(&field)?,
1534            }
1535        }
1536        Ok(Self {
1537            day_of_week: day_of_week.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1538            transition_time: transition_time
1539                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1540            preset_handle,
1541            system_mode,
1542            cooling_setpoint,
1543            heating_setpoint,
1544        })
1545    }
1546}
1547
1548/// `ScheduleTypeStruct`.
1549#[derive(Debug, Clone, Copy, PartialEq)]
1550pub struct ScheduleTypeStruct {
1551    /// `SystemMode`, field 0.
1552    pub system_mode: SystemModeEnum,
1553    /// `NumberOfSchedules`, field 1.
1554    pub number_of_schedules: u8,
1555    /// `ScheduleTypeFeatures`, field 2.
1556    pub schedule_type_features: ScheduleTypeFeaturesBitmap,
1557}
1558
1559impl ToTlv for ScheduleTypeStruct {
1560    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1561        w.start_structure(tag)?;
1562        self.system_mode.to_tlv(w, Tag::Context(0))?;
1563        self.number_of_schedules.to_tlv(w, Tag::Context(1))?;
1564        self.schedule_type_features.to_tlv(w, Tag::Context(2))?;
1565        w.end_container()
1566    }
1567}
1568
1569impl<'a> FromTlv<'a> for ScheduleTypeStruct {
1570    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1571        if element.value.container() != Some(ContainerKind::Structure) {
1572            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1573        }
1574        let mut system_mode = None;
1575        let mut number_of_schedules = None;
1576        let mut schedule_type_features = None;
1577        loop {
1578            let Some(field) = reader.next_element()? else {
1579                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1580            };
1581            if field.value == Value::EndOfContainer {
1582                break;
1583            }
1584            match field.tag.context() {
1585                Some(0) => system_mode = Some(<SystemModeEnum>::from_tlv(reader, &field)?),
1586                Some(1) => number_of_schedules = Some(<u8>::from_tlv(reader, &field)?),
1587                Some(2) => {
1588                    schedule_type_features =
1589                        Some(<ScheduleTypeFeaturesBitmap>::from_tlv(reader, &field)?)
1590                }
1591                // A field this revision does not define. §7.19.2: a receiver
1592                // ignores what it does not know rather than refusing the whole
1593                // structure, which is what lets a newer peer talk to an older one.
1594                _ => reader.skip_value(&field)?,
1595            }
1596        }
1597        Ok(Self {
1598            system_mode: system_mode.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1599            number_of_schedules: number_of_schedules
1600                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1601            schedule_type_features: schedule_type_features
1602                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1603        })
1604    }
1605}
1606
1607/// `ThermostatSuggestionStruct`.
1608#[derive(Debug, Clone, Copy, PartialEq)]
1609pub struct ThermostatSuggestionStruct<'a> {
1610    /// `UniqueID`, field 0.
1611    pub unique_id: u8,
1612    /// `PresetHandle`, field 1.
1613    pub preset_handle: &'a [u8],
1614    /// `EffectiveTime`, field 2.
1615    pub effective_time: u32,
1616    /// `ExpirationTime`, field 3.
1617    pub expiration_time: u32,
1618}
1619
1620impl<'a> ToTlv for ThermostatSuggestionStruct<'a> {
1621    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1622        w.start_structure(tag)?;
1623        self.unique_id.to_tlv(w, Tag::Context(0))?;
1624        self.preset_handle.to_tlv(w, Tag::Context(1))?;
1625        self.effective_time.to_tlv(w, Tag::Context(2))?;
1626        self.expiration_time.to_tlv(w, Tag::Context(3))?;
1627        w.end_container()
1628    }
1629}
1630
1631impl<'a> FromTlv<'a> for ThermostatSuggestionStruct<'a> {
1632    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1633        if element.value.container() != Some(ContainerKind::Structure) {
1634            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1635        }
1636        let mut unique_id = None;
1637        let mut preset_handle = None;
1638        let mut effective_time = None;
1639        let mut expiration_time = None;
1640        loop {
1641            let Some(field) = reader.next_element()? else {
1642                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1643            };
1644            if field.value == Value::EndOfContainer {
1645                break;
1646            }
1647            match field.tag.context() {
1648                Some(0) => unique_id = Some(<u8>::from_tlv(reader, &field)?),
1649                Some(1) => preset_handle = Some(<&'a [u8]>::from_tlv(reader, &field)?),
1650                Some(2) => effective_time = Some(<u32>::from_tlv(reader, &field)?),
1651                Some(3) => expiration_time = Some(<u32>::from_tlv(reader, &field)?),
1652                // A field this revision does not define. §7.19.2: a receiver
1653                // ignores what it does not know rather than refusing the whole
1654                // structure, which is what lets a newer peer talk to an older one.
1655                _ => reader.skip_value(&field)?,
1656            }
1657        }
1658        Ok(Self {
1659            unique_id: unique_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1660            preset_handle: preset_handle.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1661            effective_time: effective_time
1662                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1663            expiration_time: expiration_time
1664                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1665        })
1666    }
1667}
1668
1669/// `WeeklyScheduleTransitionStruct`.
1670#[derive(Debug, Clone, Copy, PartialEq)]
1671pub struct WeeklyScheduleTransitionStruct {
1672    /// `TransitionTime`, field 0.
1673    pub transition_time: u16,
1674    /// `HeatSetpoint`, field 1.
1675    pub heat_setpoint: Nullable<i16>,
1676    /// `CoolSetpoint`, field 2.
1677    pub cool_setpoint: Nullable<i16>,
1678}
1679
1680impl ToTlv for WeeklyScheduleTransitionStruct {
1681    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1682        w.start_structure(tag)?;
1683        self.transition_time.to_tlv(w, Tag::Context(0))?;
1684        self.heat_setpoint.to_tlv(w, Tag::Context(1))?;
1685        self.cool_setpoint.to_tlv(w, Tag::Context(2))?;
1686        w.end_container()
1687    }
1688}
1689
1690impl<'a> FromTlv<'a> for WeeklyScheduleTransitionStruct {
1691    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1692        if element.value.container() != Some(ContainerKind::Structure) {
1693            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1694        }
1695        let mut transition_time = None;
1696        let mut heat_setpoint = None;
1697        let mut cool_setpoint = None;
1698        loop {
1699            let Some(field) = reader.next_element()? else {
1700                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1701            };
1702            if field.value == Value::EndOfContainer {
1703                break;
1704            }
1705            match field.tag.context() {
1706                Some(0) => transition_time = Some(<u16>::from_tlv(reader, &field)?),
1707                Some(1) => heat_setpoint = Some(<Nullable<i16>>::from_tlv(reader, &field)?),
1708                Some(2) => cool_setpoint = Some(<Nullable<i16>>::from_tlv(reader, &field)?),
1709                // A field this revision does not define. §7.19.2: a receiver
1710                // ignores what it does not know rather than refusing the whole
1711                // structure, which is what lets a newer peer talk to an older one.
1712                _ => reader.skip_value(&field)?,
1713            }
1714        }
1715        Ok(Self {
1716            transition_time: transition_time
1717                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1718            heat_setpoint: heat_setpoint.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1719            cool_setpoint: cool_setpoint.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1720        })
1721    }
1722}
1723
1724/// The fields of `SetpointRaiseLower` (command `0x00`).
1725#[derive(Debug, Clone, Copy, PartialEq)]
1726pub struct SetpointRaiseLowerFields {
1727    /// `Mode`, field 0.
1728    pub mode: SetpointRaiseLowerModeEnum,
1729    /// `Amount`, field 1.
1730    pub amount: i8,
1731}
1732
1733impl ToTlv for SetpointRaiseLowerFields {
1734    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1735        w.start_structure(tag)?;
1736        self.mode.to_tlv(w, Tag::Context(0))?;
1737        self.amount.to_tlv(w, Tag::Context(1))?;
1738        w.end_container()
1739    }
1740}
1741
1742impl<'a> FromTlv<'a> for SetpointRaiseLowerFields {
1743    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1744        if element.value.container() != Some(ContainerKind::Structure) {
1745            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1746        }
1747        let mut mode = None;
1748        let mut amount = None;
1749        loop {
1750            let Some(field) = reader.next_element()? else {
1751                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1752            };
1753            if field.value == Value::EndOfContainer {
1754                break;
1755            }
1756            match field.tag.context() {
1757                Some(0) => mode = Some(<SetpointRaiseLowerModeEnum>::from_tlv(reader, &field)?),
1758                Some(1) => amount = Some(<i8>::from_tlv(reader, &field)?),
1759                // A field this revision does not define. §7.19.2: a receiver
1760                // ignores what it does not know rather than refusing the whole
1761                // structure, which is what lets a newer peer talk to an older one.
1762                _ => reader.skip_value(&field)?,
1763            }
1764        }
1765        Ok(Self {
1766            mode: mode.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1767            amount: amount.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1768        })
1769    }
1770}
1771
1772/// The fields of `AddThermostatSuggestionResponse` (command `0x02`).
1773#[derive(Debug, Clone, Copy, PartialEq)]
1774pub struct AddThermostatSuggestionResponseFields {
1775    /// `UniqueID`, field 0.
1776    pub unique_id: u8,
1777}
1778
1779impl ToTlv for AddThermostatSuggestionResponseFields {
1780    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1781        w.start_structure(tag)?;
1782        self.unique_id.to_tlv(w, Tag::Context(0))?;
1783        w.end_container()
1784    }
1785}
1786
1787impl<'a> FromTlv<'a> for AddThermostatSuggestionResponseFields {
1788    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1789        if element.value.container() != Some(ContainerKind::Structure) {
1790            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1791        }
1792        let mut unique_id = None;
1793        loop {
1794            let Some(field) = reader.next_element()? else {
1795                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1796            };
1797            if field.value == Value::EndOfContainer {
1798                break;
1799            }
1800            match field.tag.context() {
1801                Some(0) => unique_id = Some(<u8>::from_tlv(reader, &field)?),
1802                // A field this revision does not define. §7.19.2: a receiver
1803                // ignores what it does not know rather than refusing the whole
1804                // structure, which is what lets a newer peer talk to an older one.
1805                _ => reader.skip_value(&field)?,
1806            }
1807        }
1808        Ok(Self {
1809            unique_id: unique_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1810        })
1811    }
1812}
1813
1814/// The fields of `SetActiveScheduleRequest` (command `0x05`).
1815#[derive(Debug, Clone, Copy, PartialEq)]
1816pub struct SetActiveScheduleRequestFields<'a> {
1817    /// `ScheduleHandle`, field 0.
1818    pub schedule_handle: &'a [u8],
1819}
1820
1821impl<'a> ToTlv for SetActiveScheduleRequestFields<'a> {
1822    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1823        w.start_structure(tag)?;
1824        self.schedule_handle.to_tlv(w, Tag::Context(0))?;
1825        w.end_container()
1826    }
1827}
1828
1829impl<'a> FromTlv<'a> for SetActiveScheduleRequestFields<'a> {
1830    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1831        if element.value.container() != Some(ContainerKind::Structure) {
1832            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1833        }
1834        let mut schedule_handle = None;
1835        loop {
1836            let Some(field) = reader.next_element()? else {
1837                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1838            };
1839            if field.value == Value::EndOfContainer {
1840                break;
1841            }
1842            match field.tag.context() {
1843                Some(0) => schedule_handle = Some(<&'a [u8]>::from_tlv(reader, &field)?),
1844                // A field this revision does not define. §7.19.2: a receiver
1845                // ignores what it does not know rather than refusing the whole
1846                // structure, which is what lets a newer peer talk to an older one.
1847                _ => reader.skip_value(&field)?,
1848            }
1849        }
1850        Ok(Self {
1851            schedule_handle: schedule_handle
1852                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1853        })
1854    }
1855}
1856
1857/// The fields of `SetActivePresetRequest` (command `0x06`).
1858#[derive(Debug, Clone, Copy, PartialEq)]
1859pub struct SetActivePresetRequestFields<'a> {
1860    /// `PresetHandle`, field 0.
1861    pub preset_handle: Nullable<&'a [u8]>,
1862}
1863
1864impl<'a> ToTlv for SetActivePresetRequestFields<'a> {
1865    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1866        w.start_structure(tag)?;
1867        self.preset_handle.to_tlv(w, Tag::Context(0))?;
1868        w.end_container()
1869    }
1870}
1871
1872impl<'a> FromTlv<'a> for SetActivePresetRequestFields<'a> {
1873    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1874        if element.value.container() != Some(ContainerKind::Structure) {
1875            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1876        }
1877        let mut preset_handle = None;
1878        loop {
1879            let Some(field) = reader.next_element()? else {
1880                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1881            };
1882            if field.value == Value::EndOfContainer {
1883                break;
1884            }
1885            match field.tag.context() {
1886                Some(0) => preset_handle = Some(<Nullable<&'a [u8]>>::from_tlv(reader, &field)?),
1887                // A field this revision does not define. §7.19.2: a receiver
1888                // ignores what it does not know rather than refusing the whole
1889                // structure, which is what lets a newer peer talk to an older one.
1890                _ => reader.skip_value(&field)?,
1891            }
1892        }
1893        Ok(Self {
1894            preset_handle: preset_handle.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1895        })
1896    }
1897}
1898
1899/// The fields of `AddThermostatSuggestion` (command `0x07`).
1900#[derive(Debug, Clone, Copy, PartialEq)]
1901pub struct AddThermostatSuggestionFields<'a> {
1902    /// `PresetHandle`, field 0.
1903    pub preset_handle: &'a [u8],
1904    /// `EffectiveTime`, field 1.
1905    pub effective_time: Nullable<u32>,
1906    /// `ExpirationInMinutes`, field 2.
1907    pub expiration_in_minutes: u16,
1908}
1909
1910impl<'a> ToTlv for AddThermostatSuggestionFields<'a> {
1911    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1912        w.start_structure(tag)?;
1913        self.preset_handle.to_tlv(w, Tag::Context(0))?;
1914        self.effective_time.to_tlv(w, Tag::Context(1))?;
1915        self.expiration_in_minutes.to_tlv(w, Tag::Context(2))?;
1916        w.end_container()
1917    }
1918}
1919
1920impl<'a> FromTlv<'a> for AddThermostatSuggestionFields<'a> {
1921    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1922        if element.value.container() != Some(ContainerKind::Structure) {
1923            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1924        }
1925        let mut preset_handle = None;
1926        let mut effective_time = None;
1927        let mut expiration_in_minutes = None;
1928        loop {
1929            let Some(field) = reader.next_element()? else {
1930                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1931            };
1932            if field.value == Value::EndOfContainer {
1933                break;
1934            }
1935            match field.tag.context() {
1936                Some(0) => preset_handle = Some(<&'a [u8]>::from_tlv(reader, &field)?),
1937                Some(1) => effective_time = Some(<Nullable<u32>>::from_tlv(reader, &field)?),
1938                Some(2) => expiration_in_minutes = Some(<u16>::from_tlv(reader, &field)?),
1939                // A field this revision does not define. §7.19.2: a receiver
1940                // ignores what it does not know rather than refusing the whole
1941                // structure, which is what lets a newer peer talk to an older one.
1942                _ => reader.skip_value(&field)?,
1943            }
1944        }
1945        Ok(Self {
1946            preset_handle: preset_handle.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1947            effective_time: effective_time
1948                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1949            expiration_in_minutes: expiration_in_minutes
1950                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1951        })
1952    }
1953}
1954
1955/// The fields of `RemoveThermostatSuggestion` (command `0x08`).
1956#[derive(Debug, Clone, Copy, PartialEq)]
1957pub struct RemoveThermostatSuggestionFields {
1958    /// `UniqueID`, field 0.
1959    pub unique_id: u8,
1960}
1961
1962impl ToTlv for RemoveThermostatSuggestionFields {
1963    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1964        w.start_structure(tag)?;
1965        self.unique_id.to_tlv(w, Tag::Context(0))?;
1966        w.end_container()
1967    }
1968}
1969
1970impl<'a> FromTlv<'a> for RemoveThermostatSuggestionFields {
1971    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1972        if element.value.container() != Some(ContainerKind::Structure) {
1973            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1974        }
1975        let mut unique_id = None;
1976        loop {
1977            let Some(field) = reader.next_element()? else {
1978                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1979            };
1980            if field.value == Value::EndOfContainer {
1981                break;
1982            }
1983            match field.tag.context() {
1984                Some(0) => unique_id = Some(<u8>::from_tlv(reader, &field)?),
1985                // A field this revision does not define. §7.19.2: a receiver
1986                // ignores what it does not know rather than refusing the whole
1987                // structure, which is what lets a newer peer talk to an older one.
1988                _ => reader.skip_value(&field)?,
1989            }
1990        }
1991        Ok(Self {
1992            unique_id: unique_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1993        })
1994    }
1995}
1996
1997/// Every attribute the specification defines, with its conformance.
1998pub const ATTRIBUTES: &[Attribute] = &[
1999    Attribute {
2000        id: 0x0000,
2001        name: "LocalTemperature",
2002        kind: "temperature",
2003        access: Access::read_only(Privilege::View),
2004        qualities: AttributeQualities::NULLABLE,
2005        reporting: Reporting::OnChange,
2006        conform: Conform::MANDATORY,
2007    },
2008    Attribute {
2009        id: 0x0001,
2010        name: "OutdoorTemperature",
2011        kind: "temperature",
2012        access: Access::read_only(Privilege::View),
2013        qualities: AttributeQualities::NULLABLE,
2014        reporting: Reporting::OnChange,
2015        conform: Conform::OPTIONAL,
2016    },
2017    Attribute {
2018        id: 0x0002,
2019        name: "Occupancy",
2020        kind: "OccupancyBitmap",
2021        access: Access::read_only(Privilege::View),
2022        qualities: AttributeQualities::empty(),
2023        reporting: Reporting::OnChange,
2024        conform: Conform {
2025            clauses: &[Clause {
2026                verdict: Conformance::Mandatory,
2027                when: Condition::Feature(2),
2028            }],
2029        },
2030    },
2031    Attribute {
2032        id: 0x0003,
2033        name: "AbsMinHeatSetpointLimit",
2034        kind: "temperature",
2035        access: Access::read_only(Privilege::View),
2036        qualities: AttributeQualities::FIXED,
2037        reporting: Reporting::OnChange,
2038        conform: Conform {
2039            clauses: &[Clause {
2040                verdict: Conformance::Optional,
2041                when: Condition::Feature(0),
2042            }],
2043        },
2044    },
2045    Attribute {
2046        id: 0x0004,
2047        name: "AbsMaxHeatSetpointLimit",
2048        kind: "temperature",
2049        access: Access::read_only(Privilege::View),
2050        qualities: AttributeQualities::FIXED,
2051        reporting: Reporting::OnChange,
2052        conform: Conform {
2053            clauses: &[Clause {
2054                verdict: Conformance::Optional,
2055                when: Condition::Feature(0),
2056            }],
2057        },
2058    },
2059    Attribute {
2060        id: 0x0005,
2061        name: "AbsMinCoolSetpointLimit",
2062        kind: "temperature",
2063        access: Access::read_only(Privilege::View),
2064        qualities: AttributeQualities::FIXED,
2065        reporting: Reporting::OnChange,
2066        conform: Conform {
2067            clauses: &[Clause {
2068                verdict: Conformance::Optional,
2069                when: Condition::Feature(1),
2070            }],
2071        },
2072    },
2073    Attribute {
2074        id: 0x0006,
2075        name: "AbsMaxCoolSetpointLimit",
2076        kind: "temperature",
2077        access: Access::read_only(Privilege::View),
2078        qualities: AttributeQualities::FIXED,
2079        reporting: Reporting::OnChange,
2080        conform: Conform {
2081            clauses: &[Clause {
2082                verdict: Conformance::Optional,
2083                when: Condition::Feature(1),
2084            }],
2085        },
2086    },
2087    Attribute {
2088        id: 0x0007,
2089        name: "PICoolingDemand",
2090        kind: "",
2091        access: Access::read_only(Privilege::View),
2092        qualities: AttributeQualities::empty(),
2093        reporting: Reporting::OnChange,
2094        conform: Conform {
2095            clauses: &[Clause::always(Conformance::Deprecated)],
2096        },
2097    },
2098    Attribute {
2099        id: 0x0008,
2100        name: "PIHeatingDemand",
2101        kind: "",
2102        access: Access::read_only(Privilege::View),
2103        qualities: AttributeQualities::empty(),
2104        reporting: Reporting::OnChange,
2105        conform: Conform {
2106            clauses: &[Clause::always(Conformance::Deprecated)],
2107        },
2108    },
2109    Attribute {
2110        id: 0x0009,
2111        name: "HVACSystemTypeConfiguration",
2112        kind: "",
2113        access: Access::read_only(Privilege::View),
2114        qualities: AttributeQualities::empty(),
2115        reporting: Reporting::OnChange,
2116        conform: Conform {
2117            clauses: &[Clause::always(Conformance::Deprecated)],
2118        },
2119    },
2120    Attribute {
2121        id: 0x0010,
2122        name: "LocalTemperatureCalibration",
2123        kind: "SignedTemperature",
2124        access: Access::read_write_with(Privilege::View, Privilege::Manage),
2125        qualities: AttributeQualities::NON_VOLATILE,
2126        reporting: Reporting::OnChange,
2127        conform: Conform {
2128            clauses: &[Clause {
2129                verdict: Conformance::Optional,
2130                when: Condition::Not(&Condition::Feature(6)),
2131            }],
2132        },
2133    },
2134    Attribute {
2135        id: 0x0011,
2136        name: "OccupiedCoolingSetpoint",
2137        kind: "temperature",
2138        access: Access::read_write_with(Privilege::View, Privilege::Operate),
2139        qualities: AttributeQualities::NON_VOLATILE,
2140        reporting: Reporting::OnChange,
2141        conform: Conform {
2142            clauses: &[Clause {
2143                verdict: Conformance::Mandatory,
2144                when: Condition::Feature(1),
2145            }],
2146        },
2147    },
2148    Attribute {
2149        id: 0x0012,
2150        name: "OccupiedHeatingSetpoint",
2151        kind: "temperature",
2152        access: Access::read_write_with(Privilege::View, Privilege::Operate),
2153        qualities: AttributeQualities::NON_VOLATILE,
2154        reporting: Reporting::OnChange,
2155        conform: Conform {
2156            clauses: &[Clause {
2157                verdict: Conformance::Mandatory,
2158                when: Condition::Feature(0),
2159            }],
2160        },
2161    },
2162    Attribute {
2163        id: 0x0013,
2164        name: "UnoccupiedCoolingSetpoint",
2165        kind: "temperature",
2166        access: Access::read_write_with(Privilege::View, Privilege::Operate),
2167        qualities: AttributeQualities::NON_VOLATILE,
2168        reporting: Reporting::OnChange,
2169        conform: Conform {
2170            clauses: &[Clause {
2171                verdict: Conformance::Mandatory,
2172                when: Condition::All(&[Condition::Feature(1), Condition::Feature(2)]),
2173            }],
2174        },
2175    },
2176    Attribute {
2177        id: 0x0014,
2178        name: "UnoccupiedHeatingSetpoint",
2179        kind: "temperature",
2180        access: Access::read_write_with(Privilege::View, Privilege::Operate),
2181        qualities: AttributeQualities::NON_VOLATILE,
2182        reporting: Reporting::OnChange,
2183        conform: Conform {
2184            clauses: &[Clause {
2185                verdict: Conformance::Mandatory,
2186                when: Condition::All(&[Condition::Feature(0), Condition::Feature(2)]),
2187            }],
2188        },
2189    },
2190    Attribute {
2191        id: 0x0015,
2192        name: "MinHeatSetpointLimit",
2193        kind: "temperature",
2194        access: Access::read_write_with(Privilege::View, Privilege::Manage),
2195        qualities: AttributeQualities::NON_VOLATILE,
2196        reporting: Reporting::OnChange,
2197        conform: Conform {
2198            clauses: &[Clause {
2199                verdict: Conformance::Optional,
2200                when: Condition::Feature(0),
2201            }],
2202        },
2203    },
2204    Attribute {
2205        id: 0x0016,
2206        name: "MaxHeatSetpointLimit",
2207        kind: "temperature",
2208        access: Access::read_write_with(Privilege::View, Privilege::Manage),
2209        qualities: AttributeQualities::NON_VOLATILE,
2210        reporting: Reporting::OnChange,
2211        conform: Conform {
2212            clauses: &[Clause {
2213                verdict: Conformance::Optional,
2214                when: Condition::Feature(0),
2215            }],
2216        },
2217    },
2218    Attribute {
2219        id: 0x0017,
2220        name: "MinCoolSetpointLimit",
2221        kind: "temperature",
2222        access: Access::read_write_with(Privilege::View, Privilege::Manage),
2223        qualities: AttributeQualities::NON_VOLATILE,
2224        reporting: Reporting::OnChange,
2225        conform: Conform {
2226            clauses: &[Clause {
2227                verdict: Conformance::Optional,
2228                when: Condition::Feature(1),
2229            }],
2230        },
2231    },
2232    Attribute {
2233        id: 0x0018,
2234        name: "MaxCoolSetpointLimit",
2235        kind: "temperature",
2236        access: Access::read_write_with(Privilege::View, Privilege::Manage),
2237        qualities: AttributeQualities::NON_VOLATILE,
2238        reporting: Reporting::OnChange,
2239        conform: Conform {
2240            clauses: &[Clause {
2241                verdict: Conformance::Optional,
2242                when: Condition::Feature(1),
2243            }],
2244        },
2245    },
2246    Attribute {
2247        id: 0x0019,
2248        name: "MinSetpointDeadBand",
2249        kind: "SignedTemperature",
2250        access: Access::read_only(Privilege::View),
2251        qualities: AttributeQualities::NON_VOLATILE,
2252        reporting: Reporting::OnChange,
2253        conform: Conform {
2254            clauses: &[Clause {
2255                verdict: Conformance::Mandatory,
2256                when: Condition::Feature(5),
2257            }],
2258        },
2259    },
2260    Attribute {
2261        id: 0x001A,
2262        name: "RemoteSensing",
2263        kind: "RemoteSensingBitmap",
2264        access: Access::read_write_with(Privilege::View, Privilege::Manage),
2265        qualities: AttributeQualities::NON_VOLATILE,
2266        reporting: Reporting::OnChange,
2267        conform: Conform::OPTIONAL,
2268    },
2269    Attribute {
2270        id: 0x001B,
2271        name: "ControlSequenceOfOperation",
2272        kind: "ControlSequenceOfOperationEnum",
2273        access: Access::read_write_with(Privilege::View, Privilege::Manage),
2274        qualities: AttributeQualities::NON_VOLATILE,
2275        reporting: Reporting::OnChange,
2276        conform: Conform::MANDATORY,
2277    },
2278    Attribute {
2279        id: 0x001C,
2280        name: "SystemMode",
2281        kind: "SystemModeEnum",
2282        access: Access::read_write_with(Privilege::View, Privilege::Manage),
2283        qualities: AttributeQualities::NON_VOLATILE,
2284        reporting: Reporting::OnChange,
2285        conform: Conform::MANDATORY,
2286    },
2287    Attribute {
2288        id: 0x001E,
2289        name: "ThermostatRunningMode",
2290        kind: "ThermostatRunningModeEnum",
2291        access: Access::read_only(Privilege::View),
2292        qualities: AttributeQualities::empty(),
2293        reporting: Reporting::OnChange,
2294        conform: Conform {
2295            clauses: &[
2296                Clause {
2297                    verdict: Conformance::Mandatory,
2298                    when: Condition::All(&[Condition::Feature(9), Condition::Feature(5)]),
2299                },
2300                Clause {
2301                    verdict: Conformance::Optional,
2302                    when: Condition::Feature(5),
2303                },
2304            ],
2305        },
2306    },
2307    Attribute {
2308        id: 0x0023,
2309        name: "TemperatureSetpointHold",
2310        kind: "TemperatureSetpointHoldEnum",
2311        access: Access::read_write_with(Privilege::View, Privilege::Manage),
2312        qualities: AttributeQualities::NON_VOLATILE,
2313        reporting: Reporting::OnChange,
2314        conform: Conform::OPTIONAL,
2315    },
2316    Attribute {
2317        id: 0x0024,
2318        name: "TemperatureSetpointHoldDuration",
2319        kind: "uint16",
2320        access: Access::read_write_with(Privilege::View, Privilege::Manage),
2321        qualities: AttributeQualities::NULLABLE.union(AttributeQualities::NON_VOLATILE),
2322        reporting: Reporting::OnChange,
2323        conform: Conform::OPTIONAL,
2324    },
2325    Attribute {
2326        id: 0x0025,
2327        name: "ThermostatProgrammingOperationMode",
2328        kind: "",
2329        access: Access::read_only(Privilege::View),
2330        qualities: AttributeQualities::empty(),
2331        reporting: Reporting::OnChange,
2332        conform: Conform {
2333            clauses: &[Clause::always(Conformance::Deprecated)],
2334        },
2335    },
2336    Attribute {
2337        id: 0x0029,
2338        name: "ThermostatRunningState",
2339        kind: "RelayStateBitmap",
2340        access: Access::read_only(Privilege::View),
2341        qualities: AttributeQualities::empty(),
2342        reporting: Reporting::OnChange,
2343        conform: Conform::OPTIONAL,
2344    },
2345    Attribute {
2346        id: 0x0030,
2347        name: "SetpointChangeSource",
2348        kind: "SetpointChangeSourceEnum",
2349        access: Access::read_only(Privilege::View),
2350        qualities: AttributeQualities::empty(),
2351        reporting: Reporting::OnChange,
2352        conform: Conform::OPTIONAL,
2353    },
2354    Attribute {
2355        id: 0x0031,
2356        name: "SetpointChangeAmount",
2357        kind: "int16s",
2358        access: Access::read_only(Privilege::View),
2359        qualities: AttributeQualities::NULLABLE,
2360        reporting: Reporting::OnChange,
2361        conform: Conform::OPTIONAL,
2362    },
2363    Attribute {
2364        id: 0x0032,
2365        name: "SetpointChangeSourceTimestamp",
2366        kind: "epoch-s",
2367        access: Access::read_only(Privilege::View),
2368        qualities: AttributeQualities::empty(),
2369        reporting: Reporting::OnChange,
2370        conform: Conform::OPTIONAL,
2371    },
2372    Attribute {
2373        id: 0x0034,
2374        name: "OccupiedSetback",
2375        kind: "",
2376        access: Access::read_only(Privilege::View),
2377        qualities: AttributeQualities::empty(),
2378        reporting: Reporting::OnChange,
2379        conform: Conform {
2380            clauses: &[Clause::always(Conformance::Deprecated)],
2381        },
2382    },
2383    Attribute {
2384        id: 0x0035,
2385        name: "OccupiedSetbackMin",
2386        kind: "",
2387        access: Access::read_only(Privilege::View),
2388        qualities: AttributeQualities::empty(),
2389        reporting: Reporting::OnChange,
2390        conform: Conform {
2391            clauses: &[Clause::always(Conformance::Deprecated)],
2392        },
2393    },
2394    Attribute {
2395        id: 0x0036,
2396        name: "OccupiedSetbackMax",
2397        kind: "",
2398        access: Access::read_only(Privilege::View),
2399        qualities: AttributeQualities::empty(),
2400        reporting: Reporting::OnChange,
2401        conform: Conform {
2402            clauses: &[Clause::always(Conformance::Deprecated)],
2403        },
2404    },
2405    Attribute {
2406        id: 0x0037,
2407        name: "UnoccupiedSetback",
2408        kind: "",
2409        access: Access::read_only(Privilege::View),
2410        qualities: AttributeQualities::empty(),
2411        reporting: Reporting::OnChange,
2412        conform: Conform {
2413            clauses: &[Clause::always(Conformance::Deprecated)],
2414        },
2415    },
2416    Attribute {
2417        id: 0x0038,
2418        name: "UnoccupiedSetbackMin",
2419        kind: "",
2420        access: Access::read_only(Privilege::View),
2421        qualities: AttributeQualities::empty(),
2422        reporting: Reporting::OnChange,
2423        conform: Conform {
2424            clauses: &[Clause::always(Conformance::Deprecated)],
2425        },
2426    },
2427    Attribute {
2428        id: 0x0039,
2429        name: "UnoccupiedSetbackMax",
2430        kind: "",
2431        access: Access::read_only(Privilege::View),
2432        qualities: AttributeQualities::empty(),
2433        reporting: Reporting::OnChange,
2434        conform: Conform {
2435            clauses: &[Clause::always(Conformance::Deprecated)],
2436        },
2437    },
2438    Attribute {
2439        id: 0x003A,
2440        name: "EmergencyHeatDelta",
2441        kind: "UnsignedTemperature",
2442        access: Access::read_write_with(Privilege::View, Privilege::Manage),
2443        qualities: AttributeQualities::NON_VOLATILE,
2444        reporting: Reporting::OnChange,
2445        conform: Conform::OPTIONAL,
2446    },
2447    Attribute {
2448        id: 0x0040,
2449        name: "ACType",
2450        kind: "ACTypeEnum",
2451        access: Access::read_write_with(Privilege::View, Privilege::Manage),
2452        qualities: AttributeQualities::NON_VOLATILE,
2453        reporting: Reporting::OnChange,
2454        conform: Conform::OPTIONAL,
2455    },
2456    Attribute {
2457        id: 0x0041,
2458        name: "ACCapacity",
2459        kind: "uint16",
2460        access: Access::read_write_with(Privilege::View, Privilege::Manage),
2461        qualities: AttributeQualities::NON_VOLATILE,
2462        reporting: Reporting::OnChange,
2463        conform: Conform::OPTIONAL,
2464    },
2465    Attribute {
2466        id: 0x0042,
2467        name: "ACRefrigerantType",
2468        kind: "ACRefrigerantTypeEnum",
2469        access: Access::read_write_with(Privilege::View, Privilege::Manage),
2470        qualities: AttributeQualities::NON_VOLATILE,
2471        reporting: Reporting::OnChange,
2472        conform: Conform::OPTIONAL,
2473    },
2474    Attribute {
2475        id: 0x0043,
2476        name: "ACCompressorType",
2477        kind: "ACCompressorTypeEnum",
2478        access: Access::read_write_with(Privilege::View, Privilege::Manage),
2479        qualities: AttributeQualities::NON_VOLATILE,
2480        reporting: Reporting::OnChange,
2481        conform: Conform::OPTIONAL,
2482    },
2483    Attribute {
2484        id: 0x0044,
2485        name: "ACErrorCode",
2486        kind: "ACErrorCodeBitmap",
2487        access: Access::read_write_with(Privilege::View, Privilege::Manage),
2488        qualities: AttributeQualities::empty(),
2489        reporting: Reporting::OnChange,
2490        conform: Conform::OPTIONAL,
2491    },
2492    Attribute {
2493        id: 0x0045,
2494        name: "ACLouverPosition",
2495        kind: "ACLouverPositionEnum",
2496        access: Access::read_write_with(Privilege::View, Privilege::Manage),
2497        qualities: AttributeQualities::NON_VOLATILE,
2498        reporting: Reporting::OnChange,
2499        conform: Conform::OPTIONAL,
2500    },
2501    Attribute {
2502        id: 0x0046,
2503        name: "ACCoilTemperature",
2504        kind: "temperature",
2505        access: Access::read_only(Privilege::View),
2506        qualities: AttributeQualities::NULLABLE,
2507        reporting: Reporting::OnChange,
2508        conform: Conform::OPTIONAL,
2509    },
2510    Attribute {
2511        id: 0x0047,
2512        name: "ACCapacityFormat",
2513        kind: "ACCapacityFormatEnum",
2514        access: Access::read_write_with(Privilege::View, Privilege::Manage),
2515        qualities: AttributeQualities::NON_VOLATILE,
2516        reporting: Reporting::OnChange,
2517        conform: Conform::OPTIONAL,
2518    },
2519    Attribute {
2520        id: 0x0048,
2521        name: "PresetTypes",
2522        kind: "list[PresetTypeStruct]",
2523        access: Access::read_only(Privilege::View),
2524        qualities: AttributeQualities::FIXED,
2525        reporting: Reporting::OnChange,
2526        conform: Conform {
2527            clauses: &[Clause {
2528                verdict: Conformance::Mandatory,
2529                when: Condition::Feature(8),
2530            }],
2531        },
2532    },
2533    Attribute {
2534        id: 0x0049,
2535        name: "ScheduleTypes",
2536        kind: "list[ScheduleTypeStruct]",
2537        access: Access::read_only(Privilege::View),
2538        qualities: AttributeQualities::FIXED,
2539        reporting: Reporting::OnChange,
2540        conform: Conform {
2541            clauses: &[Clause {
2542                verdict: Conformance::Mandatory,
2543                when: Condition::Feature(7),
2544            }],
2545        },
2546    },
2547    Attribute {
2548        id: 0x004A,
2549        name: "NumberOfPresets",
2550        kind: "uint8",
2551        access: Access::read_only(Privilege::View),
2552        qualities: AttributeQualities::FIXED,
2553        reporting: Reporting::OnChange,
2554        conform: Conform {
2555            clauses: &[Clause {
2556                verdict: Conformance::Mandatory,
2557                when: Condition::Feature(8),
2558            }],
2559        },
2560    },
2561    Attribute {
2562        id: 0x004B,
2563        name: "NumberOfSchedules",
2564        kind: "uint8",
2565        access: Access::read_only(Privilege::View),
2566        qualities: AttributeQualities::FIXED,
2567        reporting: Reporting::OnChange,
2568        conform: Conform {
2569            clauses: &[Clause {
2570                verdict: Conformance::Mandatory,
2571                when: Condition::Feature(7),
2572            }],
2573        },
2574    },
2575    Attribute {
2576        id: 0x004C,
2577        name: "NumberOfScheduleTransitions",
2578        kind: "uint8",
2579        access: Access::read_only(Privilege::View),
2580        qualities: AttributeQualities::FIXED,
2581        reporting: Reporting::OnChange,
2582        conform: Conform {
2583            clauses: &[Clause {
2584                verdict: Conformance::Mandatory,
2585                when: Condition::Feature(7),
2586            }],
2587        },
2588    },
2589    Attribute {
2590        id: 0x004D,
2591        name: "NumberOfScheduleTransitionPerDay",
2592        kind: "uint8",
2593        access: Access::read_only(Privilege::View),
2594        qualities: AttributeQualities::NULLABLE.union(AttributeQualities::FIXED),
2595        reporting: Reporting::OnChange,
2596        conform: Conform {
2597            clauses: &[Clause {
2598                verdict: Conformance::Mandatory,
2599                when: Condition::Feature(7),
2600            }],
2601        },
2602    },
2603    Attribute {
2604        id: 0x004E,
2605        name: "ActivePresetHandle",
2606        kind: "octstr",
2607        access: Access::read_only(Privilege::View),
2608        qualities: AttributeQualities::NULLABLE.union(AttributeQualities::NON_VOLATILE),
2609        reporting: Reporting::OnChange,
2610        conform: Conform {
2611            clauses: &[Clause {
2612                verdict: Conformance::Mandatory,
2613                when: Condition::Feature(8),
2614            }],
2615        },
2616    },
2617    Attribute {
2618        id: 0x004F,
2619        name: "ActiveScheduleHandle",
2620        kind: "octstr",
2621        access: Access::read_only(Privilege::View),
2622        qualities: AttributeQualities::NULLABLE.union(AttributeQualities::NON_VOLATILE),
2623        reporting: Reporting::OnChange,
2624        conform: Conform {
2625            clauses: &[Clause {
2626                verdict: Conformance::Mandatory,
2627                when: Condition::Feature(7),
2628            }],
2629        },
2630    },
2631    Attribute {
2632        id: 0x0050,
2633        name: "Presets",
2634        kind: "list[PresetStruct]",
2635        access: Access::read_write_with(Privilege::View, Privilege::Manage),
2636        qualities: AttributeQualities::NON_VOLATILE.union(AttributeQualities::ATOMIC),
2637        reporting: Reporting::OnChange,
2638        conform: Conform {
2639            clauses: &[Clause {
2640                verdict: Conformance::Mandatory,
2641                when: Condition::Feature(8),
2642            }],
2643        },
2644    },
2645    Attribute {
2646        id: 0x0051,
2647        name: "Schedules",
2648        kind: "list[ScheduleStruct]",
2649        access: Access::read_write_with(Privilege::View, Privilege::Manage),
2650        qualities: AttributeQualities::NON_VOLATILE.union(AttributeQualities::ATOMIC),
2651        reporting: Reporting::OnChange,
2652        conform: Conform {
2653            clauses: &[Clause {
2654                verdict: Conformance::Mandatory,
2655                when: Condition::Feature(7),
2656            }],
2657        },
2658    },
2659    Attribute {
2660        id: 0x0052,
2661        name: "SetpointHoldExpiryTimestamp",
2662        kind: "epoch-s",
2663        access: Access::read_only(Privilege::View),
2664        qualities: AttributeQualities::NULLABLE.union(AttributeQualities::NON_VOLATILE),
2665        reporting: Reporting::OnChange,
2666        conform: Conform::OPTIONAL,
2667    },
2668    Attribute {
2669        id: 0x0053,
2670        name: "MaxThermostatSuggestions",
2671        kind: "uint8",
2672        access: Access::read_only(Privilege::View),
2673        qualities: AttributeQualities::FIXED,
2674        reporting: Reporting::OnChange,
2675        conform: Conform {
2676            clauses: &[Clause {
2677                verdict: Conformance::Mandatory,
2678                when: Condition::Feature(10),
2679            }],
2680        },
2681    },
2682    Attribute {
2683        id: 0x0054,
2684        name: "ThermostatSuggestions",
2685        kind: "list[ThermostatSuggestionStruct]",
2686        access: Access::read_only(Privilege::View),
2687        qualities: AttributeQualities::NON_VOLATILE,
2688        reporting: Reporting::OnChange,
2689        conform: Conform {
2690            clauses: &[Clause {
2691                verdict: Conformance::Mandatory,
2692                when: Condition::Feature(10),
2693            }],
2694        },
2695    },
2696    Attribute {
2697        id: 0x0055,
2698        name: "CurrentThermostatSuggestion",
2699        kind: "ThermostatSuggestionStruct",
2700        access: Access::read_only(Privilege::View),
2701        qualities: AttributeQualities::NULLABLE,
2702        reporting: Reporting::OnChange,
2703        conform: Conform {
2704            clauses: &[Clause {
2705                verdict: Conformance::Mandatory,
2706                when: Condition::Feature(10),
2707            }],
2708        },
2709    },
2710    Attribute {
2711        id: 0x0056,
2712        name: "ThermostatSuggestionNotFollowingReason",
2713        kind: "ThermostatSuggestionNotFollowingReasonBitmap",
2714        access: Access::read_only(Privilege::View),
2715        qualities: AttributeQualities::NULLABLE,
2716        reporting: Reporting::OnChange,
2717        conform: Conform {
2718            clauses: &[Clause {
2719                verdict: Conformance::Mandatory,
2720                when: Condition::Feature(10),
2721            }],
2722        },
2723    },
2724];
2725
2726/// Every command, with its conformance.
2727pub const COMMANDS: &[Command] = &[
2728    Command {
2729        id: 0x00,
2730        name: "SetpointRaiseLower",
2731        to_server: true,
2732        response: None,
2733        access: Access::invoke(Privilege::Operate),
2734        conform: Conform::MANDATORY,
2735    },
2736    Command {
2737        id: 0x02,
2738        name: "AddThermostatSuggestionResponse",
2739        to_server: false,
2740        response: None,
2741        access: Access::invoke(Privilege::Operate),
2742        conform: Conform {
2743            clauses: &[Clause {
2744                verdict: Conformance::Mandatory,
2745                when: Condition::Feature(10),
2746            }],
2747        },
2748    },
2749    Command {
2750        id: 0x05,
2751        name: "SetActiveScheduleRequest",
2752        to_server: true,
2753        response: None,
2754        access: Access::invoke(Privilege::Operate),
2755        conform: Conform {
2756            clauses: &[Clause {
2757                verdict: Conformance::Mandatory,
2758                when: Condition::Feature(7),
2759            }],
2760        },
2761    },
2762    Command {
2763        id: 0x06,
2764        name: "SetActivePresetRequest",
2765        to_server: true,
2766        response: None,
2767        access: Access::invoke(Privilege::Operate),
2768        conform: Conform {
2769            clauses: &[Clause {
2770                verdict: Conformance::Mandatory,
2771                when: Condition::Feature(8),
2772            }],
2773        },
2774    },
2775    Command {
2776        id: 0x07,
2777        name: "AddThermostatSuggestion",
2778        to_server: true,
2779        response: Some(0x02),
2780        access: Access::invoke(Privilege::Manage),
2781        conform: Conform {
2782            clauses: &[Clause {
2783                verdict: Conformance::Mandatory,
2784                when: Condition::Feature(10),
2785            }],
2786        },
2787    },
2788    Command {
2789        id: 0x08,
2790        name: "RemoveThermostatSuggestion",
2791        to_server: true,
2792        response: None,
2793        access: Access::invoke(Privilege::Manage),
2794        conform: Conform {
2795            clauses: &[Clause {
2796                verdict: Conformance::Mandatory,
2797                when: Condition::Feature(10),
2798            }],
2799        },
2800    },
2801];
2802
2803/// Every event, with its conformance.
2804pub const EVENTS: &[Event] = &[
2805    Event {
2806        id: 0x00,
2807        name: "SystemModeChange",
2808        priority: EventPriority::Info,
2809        access: Access::read_only(Privilege::View),
2810        conform: Conform {
2811            clauses: &[
2812                Clause {
2813                    verdict: Conformance::Provisional,
2814                    when: Condition::Always,
2815                },
2816                Clause {
2817                    verdict: Conformance::Mandatory,
2818                    when: Condition::Feature(9),
2819                },
2820            ],
2821        },
2822    },
2823    Event {
2824        id: 0x01,
2825        name: "LocalTemperatureChange",
2826        priority: EventPriority::Info,
2827        access: Access::read_only(Privilege::View),
2828        conform: Conform {
2829            clauses: &[
2830                Clause {
2831                    verdict: Conformance::Provisional,
2832                    when: Condition::Always,
2833                },
2834                Clause {
2835                    verdict: Conformance::Mandatory,
2836                    when: Condition::All(&[
2837                        Condition::Feature(9),
2838                        Condition::Not(&Condition::Feature(6)),
2839                    ]),
2840                },
2841            ],
2842        },
2843    },
2844    Event {
2845        id: 0x02,
2846        name: "OccupancyChange",
2847        priority: EventPriority::Info,
2848        access: Access::read_only(Privilege::View),
2849        conform: Conform {
2850            clauses: &[
2851                Clause {
2852                    verdict: Conformance::Provisional,
2853                    when: Condition::Always,
2854                },
2855                Clause {
2856                    verdict: Conformance::Mandatory,
2857                    when: Condition::All(&[Condition::Feature(9), Condition::Feature(2)]),
2858                },
2859            ],
2860        },
2861    },
2862    Event {
2863        id: 0x03,
2864        name: "SetpointChange",
2865        priority: EventPriority::Info,
2866        access: Access::read_only(Privilege::View),
2867        conform: Conform {
2868            clauses: &[
2869                Clause {
2870                    verdict: Conformance::Provisional,
2871                    when: Condition::Always,
2872                },
2873                Clause {
2874                    verdict: Conformance::Mandatory,
2875                    when: Condition::Feature(9),
2876                },
2877            ],
2878        },
2879    },
2880    Event {
2881        id: 0x04,
2882        name: "RunningStateChange",
2883        priority: EventPriority::Info,
2884        access: Access::read_only(Privilege::View),
2885        conform: Conform {
2886            clauses: &[
2887                Clause {
2888                    verdict: Conformance::Provisional,
2889                    when: Condition::Always,
2890                },
2891                Clause {
2892                    verdict: Conformance::Mandatory,
2893                    when: Condition::Feature(9),
2894                },
2895            ],
2896        },
2897    },
2898    Event {
2899        id: 0x05,
2900        name: "RunningModeChange",
2901        priority: EventPriority::Info,
2902        access: Access::read_only(Privilege::View),
2903        conform: Conform {
2904            clauses: &[
2905                Clause {
2906                    verdict: Conformance::Provisional,
2907                    when: Condition::Always,
2908                },
2909                Clause {
2910                    verdict: Conformance::Mandatory,
2911                    when: Condition::All(&[Condition::Feature(9), Condition::Feature(5)]),
2912                },
2913            ],
2914        },
2915    },
2916    Event {
2917        id: 0x06,
2918        name: "ActiveScheduleChange",
2919        priority: EventPriority::Info,
2920        access: Access::read_only(Privilege::View),
2921        conform: Conform {
2922            clauses: &[
2923                Clause {
2924                    verdict: Conformance::Provisional,
2925                    when: Condition::Always,
2926                },
2927                Clause {
2928                    verdict: Conformance::Mandatory,
2929                    when: Condition::All(&[Condition::Feature(9), Condition::Feature(7)]),
2930                },
2931            ],
2932        },
2933    },
2934    Event {
2935        id: 0x07,
2936        name: "ActivePresetChange",
2937        priority: EventPriority::Info,
2938        access: Access::read_only(Privilege::View),
2939        conform: Conform {
2940            clauses: &[
2941                Clause {
2942                    verdict: Conformance::Provisional,
2943                    when: Condition::Always,
2944                },
2945                Clause {
2946                    verdict: Conformance::Mandatory,
2947                    when: Condition::All(&[Condition::Feature(9), Condition::Feature(8)]),
2948                },
2949            ],
2950        },
2951    },
2952];
2953
2954/// The whole cluster, as the specification defines it.
2955pub const CLUSTER: Cluster = Cluster {
2956    id: ID,
2957    name: "Thermostat",
2958    revision: REVISION,
2959    pics: "TSTAT",
2960    derived_from: None,
2961    features: FEATURES,
2962    attributes: ATTRIBUTES,
2963    commands: COMMANDS,
2964    events: EVENTS,
2965};