Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 59 additions & 3 deletions docs/HASS_API_REFERENCE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -393,16 +393,60 @@ Here's one example


class MyApp(Hass):
def initialize(self):
def initialize(self) -> None:
self.call_service(
"notify/alexa_media",
service_data={
"target": "media_player.tom_office",
"data": {"type": "announce"}
}
},
# other kwargs also will be included in service_data
message="This is a test message"
)

.. code-block:: JSON

// JSON sent to Home Assistant over websocket API
{
"type": "call_service",
"domain": "notify",
"service": "alexa_media",
"service_data": {
"target": "media_player.tom_office",
"data": {
"type": "announce"
},
"message": "This is a test message"
},
"id": 7 // This ID is generated by AppDaemon and is used to match the response whenever it arrives
}

The kwarg ``target`` can't be used directly because it would conflict with ``target`` being used in other services, like
this:

.. code-block:: python

from appdaemon.plugins.hass import Hass


class SimpleApp(Hass):
def initialize(self) -> None:
self.call_service("light/turn_on", target="light.kitchen", brightness=255)

.. code-block:: JSON

// JSON sent to Home Assistant over websocket API
{
"type": "call_service",
"domain": "light",
"service": "turn_on",
"service_data": {
"brightness": 255
},
"target": "light.kitchen",
"id": 7 // This ID is generated by AppDaemon and is used to match the response whenever it arrives
}

Debugging
^^^^^^^^^

Expand Down Expand Up @@ -455,6 +499,18 @@ internally. This contains a little more detail than is visible in the Home Assis

Turning up the logging level to ``DEBUG`` to inspect the raw JSON being sent over the websocket.

.. code-block:: YAML

# conf/appdaemon.yaml
appdaemon:
... # rest of AppDaemon config here
module_debug:
HASS: DEBUG # This must match the name of the plugin
plugins:
HASS: # This is the name of the plugin, which can be changed
type: hass # This must be exactly "hass"
... # rest of Hass plugin config here

Error Handling
^^^^^^^^^^^^^^

Expand Down Expand Up @@ -493,7 +549,7 @@ a per-call basis you can set the ``suppress_log_messages`` argument to ``True``
setting ``suppress_log_messages`` to true in the plugin configuration.

.. code-block:: python
:emphasize-lines: 10
:emphasize-lines: 11

from appdaemon.plugins.hass import Hass

Expand Down
Loading