Skip to content

Commit 934bbb1

Browse files
committed
added parameter helper for clock timer intent
1 parent 654a299 commit 934bbb1

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

anki_vector/behavior.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
from . import connection, faces, objects, util
4343
from .messaging import protocol
4444
from .exceptions import VectorException
45+
from typing import Union
4546

4647
# Constants
4748

@@ -258,21 +259,25 @@ def say_localized_text(self, text: str, use_vector_voice: bool = True, duration_
258259

259260
# TODO Make this cancellable with is_cancellable_behavior
260261
@connection.on_connection_thread(requires_control=False)
261-
async def app_intent(self, intent: str, param: str = None) -> protocol.AppIntentResponse:
262+
async def app_intent(self, intent: str, param: Union[str, int] = None) -> protocol.AppIntentResponse:
262263
"""Send Vector an intention to do something.
263264
264265
.. testcode::
265266
266267
import anki_vector
267-
with anki_vector.Robot() as robot:
268+
with anki_vector.Robot(behavior_control_level=None) as robot:
268269
robot.behavior.app_intent(intent='intent_system_sleep')
269270
270271
:param intent: The intention key
271-
:param param: Intention parameter
272+
:param param: Intention parameter, usually a json encoded string or an int of secounds for the clock timer
272273
273274
:return: object that provides the status
274275
"""
275276

277+
# clock timer uses the length of `param` as the number of seconds to set the timer for
278+
if intent=='intent_clock_settimer' and type(param) == int:
279+
param = 'x' * param
280+
276281
app_intent_request = protocol.AppIntentRequest(intent=intent, param=param)
277282
return await self.conn.grpc_interface.AppIntent(app_intent_request)
278283

0 commit comments

Comments
 (0)