|
42 | 42 | from . import connection, faces, objects, util
|
43 | 43 | from .messaging import protocol
|
44 | 44 | from .exceptions import VectorException
|
| 45 | +from typing import Union |
45 | 46 |
|
46 | 47 | # Constants
|
47 | 48 |
|
@@ -258,21 +259,25 @@ def say_localized_text(self, text: str, use_vector_voice: bool = True, duration_
|
258 | 259 |
|
259 | 260 | # TODO Make this cancellable with is_cancellable_behavior
|
260 | 261 | @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: |
262 | 263 | """Send Vector an intention to do something.
|
263 | 264 |
|
264 | 265 | .. testcode::
|
265 | 266 |
|
266 | 267 | import anki_vector
|
267 |
| - with anki_vector.Robot() as robot: |
| 268 | + with anki_vector.Robot(behavior_control_level=None) as robot: |
268 | 269 | robot.behavior.app_intent(intent='intent_system_sleep')
|
269 | 270 |
|
270 | 271 | :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 |
272 | 273 |
|
273 | 274 | :return: object that provides the status
|
274 | 275 | """
|
275 | 276 |
|
| 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 | + |
276 | 281 | app_intent_request = protocol.AppIntentRequest(intent=intent, param=param)
|
277 | 282 | return await self.conn.grpc_interface.AppIntent(app_intent_request)
|
278 | 283 |
|
|
0 commit comments