Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix temperature_sensor device revision #26

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions circuitmatter/clusters/measurement/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-FileCopyrightText: Copyright (c) 2024 Scott Shawcroft for Adafruit Industries
#
# SPDX-License-Identifier: MIT
6 changes: 6 additions & 0 deletions circuitmatter/clusters/measurement/temperature_measurement.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# SPDX-FileCopyrightText: Copyright (c) 2024 Scott Shawcroft for Adafruit Industries
#
# SPDX-License-Identifier: MIT

"""Temperature cluster."""

from circuitmatter import data_model


Expand Down
3 changes: 3 additions & 0 deletions circuitmatter/device_types/sensor/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-FileCopyrightText: Copyright (c) 2024 Scott Shawcroft for Adafruit Industries
#
# SPDX-License-Identifier: MIT
20 changes: 13 additions & 7 deletions circuitmatter/device_types/sensor/temperature_sensor.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
# SPDX-FileCopyrightText: Copyright (c) 2024 Scott Shawcroft for Adafruit Industries
#
# SPDX-License-Identifier: MIT

"""Temperature sensor device with an random temperature."""

import random

from circuitmatter.clusters.general.identify import Identify
from circuitmatter.clusters.measurement.temperature_measurement import (
TemperatureMeasurement,
)
from .. import simple_device

import random
from .. import simple_device


class TemperatureSensor(simple_device.SimpleDevice):
"""Temperature sensor device with an random temperature."""

DEVICE_TYPE_ID = 0x0302
REVISION = 4
REVISION = 2

def __init__(self, name):
super().__init__(name)
Expand All @@ -19,7 +28,4 @@ def __init__(self, name):

self._temp = TemperatureMeasurement()
self.servers.append(self._temp)

self._temp.MeasuredValue = random.randint(
1500, 2500
) # Random temp between 15°C and 25°C
self._temp.MeasuredValue = random.randint(1500, 2500) # Random temp between 15°C and 25°C