-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TemperatureMeasurement
- Loading branch information
Showing
3 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from circuitmatter import data_model | ||
|
||
|
||
class TemperatureMeasurement(data_model.Cluster): | ||
CLUSTER_ID = 0x0402 | ||
|
||
MeasuredValue = data_model.NumberAttribute(0x0000, signed=True, bits=16, default=0) | ||
MinMeasuredValue = data_model.NumberAttribute( | ||
0x0001, signed=True, bits=16, default=-5000 | ||
) | ||
MaxMeasuredValue = data_model.NumberAttribute( | ||
0x0002, signed=True, bits=16, default=15000 | ||
) |
25 changes: 25 additions & 0 deletions
25
circuitmatter/device_types/measurement/temperature_sensor.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from circuitmatter.clusters.general.identify import Identify | ||
from circuitmatter.clusters.general.temperature_measurement import ( | ||
TemperatureMeasurement, | ||
) | ||
from .. import simple_device | ||
|
||
import random | ||
|
||
|
||
class TemperatureSensor(simple_device.SimpleDevice): | ||
DEVICE_TYPE_ID = 0x0302 | ||
REVISION = 2 | ||
|
||
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 |