Skip to content

Commit 281259c

Browse files
committed
feat: add card.power api
1 parent 8f66a36 commit 281259c

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

notecard/card.py

+23
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,26 @@ def transport(card, method=None, allow=None):
184184
if allow is not None:
185185
req["allow"] = allow
186186
return card.Transaction(req)
187+
188+
189+
@validate_card_object
190+
def power(card, minutes=None, reset=None):
191+
"""Configure a connected Mojo device or request power consumption readings in firmware.
192+
193+
Args:
194+
card (Notecard): The current Notecard object.
195+
minutes (int): The number of minutes to log power consumption. Default is 720 minutes (12 hours).
196+
reset (bool): When True, resets the power consumption counter back to 0.
197+
198+
Returns:
199+
dict: The result of the Notecard request. The response will contain the following fields:
200+
"voltage": The current voltage.
201+
"milliamp_hours": The cumulative energy consumption in milliamp hours.
202+
"temperature": The Notecard's internal temperature in degrees centigrade, including offset.
203+
"""
204+
req = {"req": "card.power"}
205+
if minutes:
206+
req["minutes"] = minutes
207+
if reset:
208+
req["reset"] = reset
209+
return card.Transaction(req)

test/fluent_api/test_card.py

+8
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@
6161
'method': 'wifi-cell-ntn',
6262
'allow': True
6363
}
64+
),
65+
(
66+
card.power,
67+
'card.power',
68+
{
69+
'minutes': 10,
70+
'reset': True
71+
}
6472
)
6573
]
6674
)

0 commit comments

Comments
 (0)