Giter Club home page Giter Club logo

ucnb's Introduction

UCNB - Unifi Controller Notification Bridge

UCNB is a helper application built to extend the Unifi Controller notifications by allowing more output methods other than eMail. In it core this is just an SMTP server with some logic to forward eMails to other resources. This was initially built to forward notifications to IFTTT so that they trigger notifications in a phone, but it is possible to use this project for many other purposes.

Getting Started

These instructions are meant to get you up and running with your very own UCNB to the point where you can send a test notification with IFTTT.

Installing

The easiest way to get started is to download the precompiled binaries found under releases. You will also need a IFTTT webhook setup if you haven't already, my suggestion is to have the webhook trigger a notification initially just to verify that everything is working. UCNB requires a minimal configuration to start the application to work with IFTTT webhooks. All that you need to change is the event_name and api_key. Please consider using a better username and password combination, as these were only chosen for demonstration purposes.

ucnb -username=username -password=password -output-plugin='{"type": "ifttt", "value": {"event_name": "<event_name>", "api_key": "<api_key>"}}'

This will start a SMTP server bound to 127.0.0.1:1025 and forward any notification eMail it receives from the Unifi Controller to the IFTTT webhook. To bind to a different address or port simply specify it when starting ucnf. The following example will listen to 0.0.0.0:25.

ucnb -addr=0.0.0.0:25 -username=username -password=password -output-plugin='{"type": "ifttt", "value": {"event_name": "<event_name>", "api_key": "<api_key>"}}'

UCNB should now be running, make sure that it is listening to a port and interface that is accessible by the device running the cloud controller software. Sign into the cloud controller and go to the settings page. Under Settings>Controller>Mail Server check Enable mail server and fill in the ip, port, username and password that you have configured ucnb with. If you have the IFTTT webhook setup properly you should be able to send a test notification and see it trigger in IFTTT. The notification you should receive should be similar to the following message.

You have received a message generated by UniFi Controller Your SMTP Server settings appear to be working correctly!

Controller URL: https://unifi.yourdomain.com:8443/manage/site/default

Under Settings>Notifications you should be able to select which events that you want to receive notifications for. As UCNB works by forwarding email notifications, you will need to check the email box, to receive a IFTTT notification for that event.

Docker

There are Docker images built to make deployment of UCNB event easier, and they are available for arm, arm64 and amd64 architectures. Go to Docker Hub for more information about how to use the Docker image.

Output Plugin

Currently there are only two output plugins that are supported. This is mainly because I created this project so that I could use it with IFTTT. The output plugins are written in a modular way so that it is possible to add more in the future. If you need another method feel free to contribute. The output plugin is configured with the -output-plugin option when running UCNB.

IFTTT

This output method will trigger a IFTTT webhook with the specified event_name and authenticating with the api_key". Currently the whole email is sent as one value to the webhook, value1, but there is work to add support for parsing the text and splitting it into two values.

{
    "type": "ifttt",
    "value": {
        "event_name": "test_event",
        "api_key": "test_key"
    }
}

HTTP

Will send a POST request to the specified endpoint with the notification message in the request body field message.

{
    "type": "http",
    "value": {
        "endpoint": "https://example.com"
    }
}

The example above would create a POST request that can be represented as the following curl command.

curl -X POST --header "application/x-www-form-urlencoded" --data "message=<message_data>" https://example.com

License

This project is licensed under the MIT License - see the LICENSE.md file for details

ucnb's People

Contributors

phillebaba avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

robertdwhite

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.