Giter Site home page Giter Site logo

lasithac / bacnet-mqtt-gateway Goto Github PK

View Code? Open in Web Editor NEW

This project forked from 2pk03/bacnet-mqtt-gateway

0.0 0.0 0.0 131 KB

BACnet MQTT Gateway

Home Page: https://infinimesh.io

License: Apache License 2.0

Dockerfile 0.71% JavaScript 76.49% CSS 1.42% HTML 21.39%

bacnet-mqtt-gateway's Introduction

BACnet MQTT Gateway

BACnet MQTT Gateway is gateway that connects BACnet devices via MQTT to the cloud. It is written in Javascript and uses node.

For BACnet connection the Node BACstack is used.

Functionalities

  • Discover BACnet devices in network (WhoIs)
  • Read object list from BACnet device (Read Property)
  • Read present value from defined list of BACnet objects and send it to an MQTT broker
  • REST and web interface for configuration

Getting started

  1. Clone repo and install npm dependencies:

    git clone https://github.com/infinimesh/bacnet-mqtt-gateway.git
    cd bacnet-mqtt-gateway
    npm install
  2. Configure gateway:

    By default the gateway is configured to use infinimesh.cloud platform, but it can be used with any MQTT broker.

    Open config/default.json and change MQTT configuration by defining your device id and the path to the device certificate files.

    {
        "mqtt": {
            "gatewayId": "{{device id}}",
            "host": "mqtt.api.infinimesh.cloud",
            "port": 8883,
            "authentication": {
                "certPath": "{{device .crt file path}}",
                "keyPath": "{{device .key file path}}"
            }
        },
        "bacnet": {
            "configFolder": "./devices/"
        },
        "httpServer": {
            "enabled": true,
            "port": 8082
        }
    }
    
  3. Start the gateway and open admin interface

    npm start
    open http://localhost:8082/admin

Device polling configuration

The gateway can poll BACnet object present values and send the values via MQTT into the cloud. To configure polling for a BACnet device you can put a .json file into the devices folder.

{
    "device": {
        "deviceId": 114,
        "address": "192.168.178.55"
    },
    "polling": {
        "schedule": "*/15 * * * * *"
    },
    "objects": [{
        "objectId": {
            "type": 2,
            "instance": 202
        }
    }, {
        "objectId": {
            "type": 2,
            "instance": 203
        }
    }]
}

You need to define the device id, ip address, schedule interval (as CRON expression) and the objects to poll.

When the gateway is started it automatically reads the list of files from the directory and starts the polling for all devices.

REST API

To execute commands the gateway offers a REST API under http://localhost:8082/api/bacnet.

The following endpoints are supported:

  • PUT /api/bacnet: Scan for devices (WhoIs)

    Scans for BACnet devices in the network (5s) and returns the answers. Body is empty.

    Example:

    PUT http://localhost:8082/api/bacnet/scan
    
  • PUT /api/bacnet/{deviceId}/objects: Scan device for object

    Scans a specific device for objects and returns the list of found objects. Device ID and IP address must be provided.

    Example:

    PUT http://localhost:8082/api/bacnet/22/objects
    {
        "deviceId":"22",
        "address":"192.168.178.99"
    }
    
  • PUT /api/{deviceId}/config: Configure polling for device

    Configures and starts polling for a specific device. Body is the same as the polling configuration files described in the previous section.

    Example:

    PUT http://localhost:8082/api/bacnet/114/config
    {
        "device": {
            "deviceId": 114,
            "address": "192.168.178.55"
        },
        "polling": {
            "schedule": "*/15 * * * * *"
        },
        "objects": [{
            "objectId": {
                "type": 2,
                "instance": 202
            }
        }, {
            "objectId": {
                "type": 2,
                "instance": 203
            }
        }]
    }
    

Run with Docker

Gateway can also be run as a docker container. Just build the image and start a container:

docker build -t bacnet-mqtt-gateway
docker run -p 8082:8082 -v /mnt/bacnet-gateway/devices:/usr/src/app/devices -v /mnt/bacnet-gateway/config:/usr/src/app/config bacnet-mqtt-gateway

With the specified file mountings you can put the config file under /mnt/bacnet-gateway/config and the device configs under /mnt/bacnet-gateway/devices on the host system.

bacnet-mqtt-gateway's People

Contributors

2pk03 avatar birdayz avatar dependabot[bot] avatar dnobel avatar

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.