Skip to content

Commit 1294d29

Browse files
read sensor
1 parent f1dcc2d commit 1294d29

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

functions/information.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,11 @@ def read_status(self):
142142
self.state.print_status(update_only=True, endpoint_json=status_tree)
143143
return status_tree
144144

145-
def read_sensor(self, peripheral_id):
145+
def read_sensor(self, sensor_id):
146146
"""Reads the given pin by id."""
147147

148-
peripheral_str = self.api_get("peripherals", peripheral_id)
149-
mode = peripheral_str["mode"]
148+
sensor = self.api_get("sensors", sensor_id)
149+
mode = sensor["mode"]
150150

151151
sensor_message = {
152152
"kind": "read_pin",
@@ -156,8 +156,8 @@ def read_sensor(self, peripheral_id):
156156
"pin_number": {
157157
"kind": "named_pin",
158158
"args": {
159-
"pin_type": "Peripheral",
160-
"pin_id": peripheral_id,
159+
"pin_type": "Sensor",
160+
"pin_id": sensor_id,
161161
}
162162
}
163163
}

functions/peripherals.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ def control_peripheral(self, peripheral_id, value, mode=None):
4545
"""Set peripheral value and mode."""
4646

4747
if mode is None:
48-
peripheral_str = self.info.api_get("peripherals", peripheral_id)
49-
mode = peripheral_str["mode"]
48+
peripheral = self.info.api_get("peripherals", peripheral_id)
49+
mode = peripheral["mode"]
5050

5151
control_peripheral_message = {
5252
"kind": "write_pin",
@@ -90,8 +90,8 @@ def toggle_peripheral(self, peripheral_id):
9090
def on(self, peripheral_id):
9191
"""Turns specified peripheral `on` (100%)."""
9292

93-
peripheral_str = self.info.api_get("peripherals", peripheral_id)
94-
mode = peripheral_str["mode"]
93+
peripheral = self.info.api_get("peripherals", peripheral_id)
94+
mode = peripheral["mode"]
9595

9696
if mode == 1:
9797
self.control_peripheral(peripheral_id, 255)

tests/tests_main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ def exec_command():
720720
'label': '---',
721721
'pin_number': {
722722
'kind': 'named_pin',
723-
'args': {'pin_type': 'Peripheral', 'pin_id': 123},
723+
'args': {'pin_type': 'Sensor', 'pin_id': 123},
724724
},
725725
},
726726
},

0 commit comments

Comments
 (0)