/ha-slack-user

Slack User sensor for Home Assistant

Primary LanguagePythonMIT LicenseMIT

Slack User Sensor

HACS GitHub Release Project Maintenance License

Description

This is a custom integration for Home Assistant. It provides a sensor for a slack user by a given token.

Installation

ha-slack-user is available through HACS. Open HACS -> Integrations -> Exlpore & Add repositories and search for "Slack User".

Or, install manually by downloading the custom_components/slack_user folder from this repo and placing it in your config/custom_components/ folder.

Setup

ha-slack-user is set up with Config Flow. After installing the integration, go to Configuration -> Integrations, click the + button at the bottom right, and search for "Slack User".

The component requires a Slack Member ID (User ID), and API Token.

Tokens

If you are using the deprecated Legacy Tokens, this should work out of the box.

If you are using a token from a Slack App, it'll need to have access to the following scopes:

  • users.profile:read - to get general profile information - title, profile, status, etc
  • users.profile:write - to set user status
  • users:read - to get presence information
  • dnd:read - to get DND information

Sensor data

After setting up a Slack User sensor, you'll have a sensor.name (with the name you specified during config) with the following attributes:

title: string
real_name: string
display_name: string
status_text: string
status_emoji: string
entity_picture: string

# Presence Info
presence: "online" or "away"
online: boolean
auto_away: boolean
manual_away: boolean
connection_count: number
last_activity: timestamp

# DND Info
dnd_enabled: boolean
next_dnd_start_ts: timestamp
next_dnd_end_ts: timestamp
snooze_enabled: boolean

Here's an example:

Example sensor

Services

slack_user.set_status

Sets the user's slack status.

Field Value Necessity Description
entity_id sensor.slack_user Required Name(s) of the sensor entities
status_text Commuting Optional New status. Pass empty string ("") to clear. Don't pass anything to keep current status.
status_emoji :car: Optional New status emoji. Pass empty string ("") to clear. Don't pass anything to keep current emoji. Will throw an error if emoji doesn't exist.
expiration 2021-06-12 15:00:001 Optional Expiration date. Must be in format yyyy-mm-dd hh:mm:ss

slack_user.clear_status

Clears the user's slack status.

Field Value Necessity Description
entity_id sensor.slack_user Required Name(s) of the sensor entities

Meta

Georgi Gardev