diff --git a/circuitmatter/clusters/measurement/temperature_measurement.py b/circuitmatter/clusters/measurement/temperature_measurement.py new file mode 100644 index 0000000..ef3ce24 --- /dev/null +++ b/circuitmatter/clusters/measurement/temperature_measurement.py @@ -0,0 +1,16 @@ +from circuitmatter import data_model + + +class TemperatureMeasurement(data_model.Cluster): + CLUSTER_ID = 0x0402 + REVISION = 4 + + MeasuredValue = data_model.NumberAttribute( + 0x0000, signed=True, bits=16, default=0, X_nullable=True, P_reportable=True + ) + MinMeasuredValue = data_model.NumberAttribute( + 0x0001, signed=True, bits=16, default=-5000, X_nullable=True + ) + MaxMeasuredValue = data_model.NumberAttribute( + 0x0002, signed=True, bits=16, default=15000, X_nullable=True + ) diff --git a/circuitmatter/device_types/sensor/temperature_sensor.py b/circuitmatter/device_types/sensor/temperature_sensor.py new file mode 100644 index 0000000..a77ac09 --- /dev/null +++ b/circuitmatter/device_types/sensor/temperature_sensor.py @@ -0,0 +1,25 @@ +from circuitmatter.clusters.general.identify import Identify +from circuitmatter.clusters.measurement.temperature_measurement import ( + TemperatureMeasurement, +) +from .. import simple_device + +import random + + +class TemperatureSensor(simple_device.SimpleDevice): + DEVICE_TYPE_ID = 0x0302 + REVISION = 4 + + def __init__(self, name): + super().__init__(name) + + self._identify = Identify() + self.servers.append(self._identify) + + self._temp = TemperatureMeasurement() + self.servers.append(self._temp) + + self._temp.MeasuredValue = random.randint( + 1500, 2500 + ) # Random temp between 15°C and 25°C