I think youâre going to suffer from the same problem. When you call the notify service, youâll still have to use templates to get the data. It doesnât matter if youâre referencing variables of the script, or pulling the state of something from the state machine. And, BTW, you still need to have icon & displaytime under another data item.
FWIW, I looked at the docs for every notify platform, as well as various general examples, and I didnât find one that used data_template where the values under data (as in data_template -> data -> xxx) used templates. Hmm.
If youâre feeling brave, you might try making a minor modification to the kodi notification platform code that will output more useful info to the log. This is what Iâd do. E.g., copy kodi.py from the HA notify directory into a directory under your HA configuration directory. To be specific, copy:
/usr/lib/python3.6/site-packages/homeassistant/components/notify/kodi.py
to:
your_config_dir/custom_components/notify/kodi.py
where âyour_config_dirâ is the directory containing your configuration.yaml file.
Modify the following function at the end of the file:
@asyncio.coroutine
def async_send_message(self, message="", **kwargs):
"""Send a message to Kodi."""
import jsonrpc_async
try:
data = kwargs.get(ATTR_DATA) or {}
displaytime = data.get(ATTR_DISPLAYTIME, 10000)
icon = data.get(ATTR_ICON, "info")
title = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT)
yield from self._server.GUI.ShowNotification(
title, message, icon, displaytime)
except jsonrpc_async.TransportError:
_LOGGER.warning("Unable to fetch Kodi data. Is Kodi online?")
by inserting a call to _LOGGER.debug right before the call to ShowNotification(). I.e.:
@asyncio.coroutine
def async_send_message(self, message="", **kwargs):
"""Send a message to Kodi."""
import jsonrpc_async
try:
data = kwargs.get(ATTR_DATA) or {}
displaytime = data.get(ATTR_DISPLAYTIME, 10000)
icon = data.get(ATTR_ICON, "info")
title = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT)
# Dump parameters to log...
_LOGGER.debug('title="{}", message="{}", icon="{}", displaytime={}'.format(
title, message, icon, displaytime))
yield from self._server.GUI.ShowNotification(
title, message, icon, displaytime)
except jsonrpc_async.TransportError:
_LOGGER.warning("Unable to fetch Kodi data. Is Kodi online?")
After youâre done using this you can just delete this file (or the whole your_config_dir/custom_components/notify directory if youâre not using it for anything else.)