The Problem
I am in multiple Slack teams and have messages coming in frequently throughout the day. I am also on phone calls with clients all day who don’t want to feel like I’m distracted during the call. I could put myself DND (do not disturb) on each slack instance but that’s time consuming and I cannot always predict when I’ll have a call.
My Current Solution
I found a brilliant Slack app, called “OTTT”, that allows you to issue slash commands to set your DND for a specified amount of time. To make this more awesome it also allows you, for a modest service fee, to link your Slack team instances so that one slash command sets all of your workspaces to DND. This is what I need!
Now with use of the Ariela app call state sensor and the Slack notify component, with a few small tweaks, I can auto DND when I’m on a call…ah, sweet silence.
Install Instructions
- Create a folder called “slack” in your “custom_components” folder in Home Assistant directory.
NOTE: If this is your first custom component you may need to create it. It must be in the same folder that your configuration.yaml file exists
-
Use the files from this gist and place them in individual files. Each file in the gist has the required file names (manifest.json, notify.py, __init__.py).
-
The chat.command API, which does all the magic, isn’t officially supported so we need a Legacy Token for this to work. Go to https://api.slack.com/custom-integrations/legacy-tokens, under “Legacy Token Generator” should be a table with your Workspace listed. Click the green button to “Create Token”. Keep the page open to copy the token in a later step.
-
Setting up the component configuration in Home Assistant, now, is the same as following the Home Assistant configuration steps https://www.home-assistant.io/integrations/slack.
notify:
- name: Slack
platform: slack
api_key: {YOUR_LEGACY_API_TOKEN_HERE}
default_channel: "#home-assistant"
username: Bob
NOTE: I repeat “configuration” a couple times there because you do not want to follow their “Setup” section instructions.
NOTE 2: This is also where you need to copy/paste your token from step 3.
-
Restart Home Assistant.
-
In Developer Tools -> Services type in notify.slack (or whatever you named it in your configuration) under “Service”. If it shows up you’re in business. If not try walking through the steps again, or post your error.
Extra credit: Since you’re on the services page give it a test with a payload like “message: Hello there!” or “message: /shrug” you should see it show up in the default channel specified in the configuration setup.