Send notifications of availible Zaptec chargers that are availible in your Zaptec account to Slack or Teams
Node.js & npm: This is the runtime environment for executing JavaScript code server-side.
git clone https://github.com/PierreGode/ZaptecUnifiedNotifier.git
cd ZaptecUnifiedNotifier
Before you proceed, ensure you have the following:
sudo apt-get install npm
npm install axios @slack/web-api
npm install dotenv
Create a .env file: At the root of your project, create a file named .env
touch .env
Add your secrets/configuration: Inside this file, you can set your environment variables as key-value pairs:
ZAPTEC_USERNAME=myUsername
ZAPTEC_PASSWORD=myPassword
SLACKBOT_NAME=ZaptecBot
SLACKBOT_ICON=https://raw.githubusercontent.com/PierreGode/ZaptecSlackNotifier/main/images/zaptec.png
SLACK_WEBHOOK_URL=myWebhookURL
SLACK_TOKEN=BotUserOAuthToken
SLACK_WEBHOOK_PRIVATE_URL=myPrivateWebhookURL
TEAMS_WEBHOOK_URL=myTeamsWebhookURL
TEAMS_WEBHOOK_PRIVATE_URL=myPrivateTeamsWebhookURL
# General Settings
COMPANY_NAME=word
EXCLUDE_DEVICES=devicename1,devicename2
Note Descriptions COMPANY_NAME: Removes specified word from status (e.g., 'company' from 'company 01'). SLACK_WEBHOOK_PRIVATE_URL: Posts charge complete notifications privately. Defaults to SLACK_WEBHOOK_URL if not set. TEAMS_WEBHOOK_PRIVATE_URL: Same as SLACK_WEBHOOK_PRIVATE_URL but for Teams. SLACKBOT_ICON/SLACKBOT_NAME: Customize Slack message appearance. EXCLUDE_DEVICES: Exclude specific devices from notifications.
Security Note: Avoid storing sensitive information in plaintext. Use secure methods for production.
Once you've set up the configurations, run the notifier using:
node node.js
preferably setup an @reboot sleep 60 && /usr/local/bin/node /home/pi/ZaptecSlackNotifier/node.js >> /var/log/slack.log 2>&1 in crontab
/Created by Pierre Gode