From 8eb66ac2b8649d5a7403bf1afda53c91cc7d1581 Mon Sep 17 00:00:00 2001 From: Josh Nichols Date: Sat, 20 Aug 2016 08:36:28 -0400 Subject: [PATCH] Ensure Slack messages appear as correct user (#2893) Current documentation suggests to use personal API tokens. This isn't ideal because for a few reasons: * messages will come as your own user, so it's hard to tell it's coming from hass * it's harder to manage if multiple people are using Slack and home * assistant, since you'd have to coordinate rolling of it It is possible to use Slack bot users already. Just make a new one from https://your-team.slack.com/apps/build/custom-integration, and use the token for that. You can even add an icon from the web frontend for home assistant. However, the message will appear as a bot without a name or icon. This pull requests fixes this by passing the as_user parameter, which uses the bot user's name and icon. One caveat is you need to invite the bot user into the room you want to post to. This probably was an issue before though. :tophat: to @jnewland who pointed me to this in his branch --- homeassistant/components/notify/slack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/notify/slack.py b/homeassistant/components/notify/slack.py index 141cf6887e9..99d0c4ef663 100644 --- a/homeassistant/components/notify/slack.py +++ b/homeassistant/components/notify/slack.py @@ -52,6 +52,6 @@ class SlackNotificationService(BaseNotificationService): channel = kwargs.get('target') or self._default_channel try: - self.slack.chat.post_message(channel, message) + self.slack.chat.post_message(channel, message, as_user=True) except slacker.Error: _LOGGER.exception("Could not send slack notification")