Files
homeassistant-core/tests/components/notify/common.py
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
645 B
Python
Raw Normal View History

2018-09-26 18:02:05 +02:00
"""Collection of helper methods.
All containing methods are legacy helpers that should not be used by new
components. Instead call the service directly.
"""
2018-09-26 18:02:05 +02:00
from homeassistant.components.notify import (
ATTR_DATA,
ATTR_MESSAGE,
ATTR_TITLE,
DOMAIN,
SERVICE_NOTIFY,
)
from homeassistant.loader import bind_hass
@bind_hass
def send_message(hass, message, title=None, data=None):
"""Send a notification message."""
info = {ATTR_MESSAGE: message}
if title is not None:
info[ATTR_TITLE] = title
if data is not None:
info[ATTR_DATA] = data
hass.services.call(DOMAIN, SERVICE_NOTIFY, info)