@@ -48,7 +48,7 @@ For example, applications ``my_app1`` and ``my_app2`` would be configured as:
4848
4949 Note that if you used the UI flow to configure pyscript, the ``allow_all_imports `` and
5050``hass_is_global `` configuration settings will be ignored in the yaml file. In that case
51- you should omit them from the yaml, and just use yaml for pycript app configuration.
51+ you should omit them from the yaml, and just use yaml for pyscript app configuration.
5252
5353As explained below, the use of ``apps `` with entries for each application by name below,
5454is used to determine which application scripts are autoloaded. That's the only configuration
@@ -210,6 +210,11 @@ called by:
210210
211211 service.call(" myservice" , " flash_light" , light_name = " front" , light_color = " red" )
212212
213+ When making a service call, either using the ``service.call `` function or the service name as the
214+ function, you can optionally pass the keyword argument ``blocking=True `` if you would like to wait
215+ for the service to finish execution before continuing execution in your function. You can also
216+ specify a timeout for a blocking service call using the ``limit=<number_of_seconds> `` parameters.
217+
213218Firing events
214219-------------
215220
@@ -535,7 +540,7 @@ When any trigger occurs (whether time, state or event), the ``@state_active`` ex
535540evaluated. If it evaluates to ``False `` (or zero), the trigger is ignored and the trigger function
536541is not called. This decorator is roughly equivalent to starting the trigger function with an
537542``if `` statement with the ``str_expr `` (the minor difference is that this decorator uses the
538- ``@state_trigger `` variable value, if present, when evalauting ``str_expr ``, whereas an
543+ ``@state_trigger `` variable value, if present, when evaluating ``str_expr ``, whereas an
539544``if `` statement at the start of the function uses its current value, which might be different
540545if the state variable was changed immediately after the trigger, and the ``.old `` value is
541546not available).
@@ -691,8 +696,11 @@ or ``float()``). Attributes keep their native type.
691696Service Calls
692697^^^^^^^^^^^^^
693698
694- ``service.call(domain, name, **kwargs) ``
695- calls the service ``domain.name `` with the given keyword arguments as parameters.
699+ ``service.call(domain, name, blocking=False, limit=10, **kwargs) ``
700+ calls the service ``domain.name `` with the given keyword arguments as parameters. If ``blocking ``
701+ is ``True ``, pyscript will wait for the service to finish executing before continuing the current
702+ routine, or will wait a maximum of the number of seconds specified in the `limit ` keyword
703+ argument.
696704``service.has_service(domain, name) ``
697705 returns whether the service ``domain.name `` exists.
698706
@@ -992,7 +1000,7 @@ makes it convenient to just reload the script file or application you are develo
9921000affecting the others.
9931001
9941002A much better alternative to repeatedly modifying a script file and reloading it is to use Jupyter
995- notebook to interactively deveop and test functions, triggers and services.
1003+ notebook to interactively develop and test functions, triggers and services.
9961004
9971005Jupyter auto-completion (with `<TAB> `) is supported in Jupyter notebook, console and lab. It should
9981006work after you have typed at least the first character. After you hit `<TAB> ` you should see a list
@@ -1275,7 +1283,7 @@ Access to Hass
12751283^^^^^^^^^^^^^^
12761284
12771285If the ``hass_is_global `` configuration setting is set (default is off), then the variable ``hass ``
1278- is available as a global variable in all pyscript contexts. That provides significant flexiblity
1286+ is available as a global variable in all pyscript contexts. That provides significant flexibility
12791287in accessing HASS internals for cases where pyscript doesn't provide some binding or access.
12801288
12811289Ideally you should only use ``hass `` for read-only access. However, you do need a good understanding
@@ -1297,7 +1305,7 @@ You can use ``hass`` to compute sunrise and sunset times using the same method H
12971305 print (f " today sunrise = { sunrise} , sunset = { sunset} " )
12981306
12991307 Here's another method that uses the installed version of ``astral `` directly, rather than the HASS
1300- helper function. It's a bit more crytpic since it's a very old version of ``astral ``, but you can
1308+ helper function. It's a bit more cryptic since it's a very old version of ``astral ``, but you can
13011309see how the HASS configuration values are used:
13021310
13031311.. code :: python
@@ -1332,7 +1340,7 @@ be blocked, which will delay all other tasks.
13321340
13331341All the built-in functionality in pyscript is written using asynchronous code, which runs seamlessly
13341342together with all the other tasks in the main event loop. However, if you import Python packages and
1335- call functions that block (eg, file or networrk I/O) then you need to run those functions outside
1343+ call functions that block (eg, file or network I/O) then you need to run those functions outside
13361344the main event loop. That can be accomplished wrapping those function calls with the
13371345``task.executor `` function, which runs the function in a separate thread:
13381346
@@ -1440,5 +1448,5 @@ A handful of language features are not supported:
14401448 functions that can be called and used in-line. There is a feature request to add this.
14411449
14421450Pyscript can call Python modules and packages, so you can always write your own native Python code
1443- (eg, if you need a generator or other unsupported feature) that can be called by psycript
1451+ (eg, if you need a generator or other unsupported feature) that can be called by pyscript
14441452(see `Importing <#importing >`__ for how to create and import native Python modules in pyscript).
0 commit comments