Skip to content

Commit

Permalink
Clean up spurioous hass_timout flags in code and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
acockburn committed Feb 26, 2025
1 parent 19f3b37 commit 70a8f2d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
9 changes: 0 additions & 9 deletions appdaemon/adapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1809,7 +1809,6 @@ async def call_service(
timeout: int | float | None = None,
return_result: bool = True,
callback: Callable | None = None,
hass_result: bool = True,
hass_timeout: float = 10,
suppress_log_messages: bool = False,
**data,
Expand Down Expand Up @@ -1850,13 +1849,6 @@ async def call_service(
return values this may seem pointless, but it does force the call to be synchronous with respect to Home Assistant
whcih can in turn highlight slow performing services if they timeout or trigger thread warnings.
callback: The non-async callback to be executed when complete.
hass_result (False, Home Assistant Specific): Mark the service call to Home Assistant as returnng a
value. If set to ``True``, the call to Home Assistant will specifically request a return result.
If this flag is set for a service that does not return a result, Home Assistant will respond with an error,
which AppDaemon will log. If this flag is NOT set for a service that does returns a result,
Home Assistant will respond with an error, which AppDaemon will log. Note: if you specify ``hass_result``
you must also set ``return_result`` or the result from HomeAssistant will not be
propagated to your app. See `Some Notes on Service Calls <APPGUIDE.html#some-notes-on-service-calls>`__
hass_timeout (Home Assistant Specific): time in seconds to wait for Home Assistant's
response for this specific service call. If not specified defaults to the value of
the ``q_timeout`` parameter in the HASS plugin configuration, which itself defaults
Expand Down Expand Up @@ -1886,7 +1878,6 @@ async def call_service(
start_date_time="2024-08-25 00:00:00",
end_date_time="2024-08-27 00:00:00",
return_result=True,
hass_result=True,
hass_timeout=10
)
Expand Down
16 changes: 5 additions & 11 deletions docs/APPGUIDE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3138,15 +3138,11 @@ to propagate return values from Home Assitant service calls to the App. As a res
service calls even if no return data is requested, this is beneficial as it is now possible to detect errors that were previously unreported. In addition, waiting for the
response also allows the app and AppDaemon to identify poorly performing Home Assistant services (such as ZWave communication slowdowns) that previously would have gone unnoticed.

To tell AppDaemon that you are expecting Home Assistant to return a value, set the ``hass_result`` parameter to True. In addition, you should also set either the ``callback`` or ``return_result``
flags depending on how you want to recieve the result - both methods are supported. In order to force the call to be synchronous for a Home Assistant service that does not return a value, simply set ``return_result``
to ``True`` but don't set ``hass_result`` to anything.
To tell AppDaemon that you are expecting Home Assistant to return a value, set the ``return_result`` parameter to True. In addition, you should also set either the ``callback`` or ``return_result``
flags depending on how you want to recieve the result - both methods are supported. This will force the call to be synchronous for a Home Assistant service that does not return a value, and will also
return any results from HomeAssistant if the underlying service call supports it.

Note that Home Assistant requires that you tell it explicitly whether or not you want a result. If you ask for a result from a service that doesn't return one, you will get an error.
If you don't ask for a result from a service that returns one, you will also get an error, so be sure to read the HomeAssistant docs and specify ``hass_result`` only if the
Home Assistant service returns a value.

Specifically for Home Assistant service calls there is also an optional ``timeout`` value that specifies how long to wait for the response from Home Assistant before returning to the
Specifically for Home Assistant service calls there is also an optional ``hass_timeout`` value that specifies how long to wait for the response from Home Assistant before returning to the
app with an error. There are a couple of other timers already in AppDaemon that are related and will give information on slow service.

* The callback tracking timer will issue warnings if a callback takes longer than 10 seconds to return
Expand All @@ -3166,7 +3162,6 @@ Here are a couple of examples of getting results from HomeAssistant services:
start_date_time="2024-08-25 00:00:00",
end_date_time="2024-08-27 00:00:00",
return_result=True,
hass_result=True,
hass_timeout=10,
)
Expand All @@ -3175,8 +3170,8 @@ Here are a couple of examples of getting results from HomeAssistant services:
entity_id="calendar.home",
start_date_time="2024-08-25 00:00:00",
end_date_time="2024-08-27 00:00:00",
hass_result=True,
hass_timeout=10,
return_result=True,
callback=self.calendar_cb,
)
Expand Down Expand Up @@ -3226,7 +3221,6 @@ This example shows how to use the return data with full error handling:
start_date_time="2024-08-25 00:00:00",
end_date_time="2024-08-27 00:00:00",
return_result=True,
hass_result=True,
hass_timeout=10,
)
Expand Down

0 comments on commit 70a8f2d

Please sign in to comment.