{"id":15329160,"url":"https://github.com/2pk03/bacnet-mqtt-gateway","last_synced_at":"2025-04-09T10:09:14.831Z","repository":{"id":40933193,"uuid":"177027857","full_name":"2pk03/bacnet-mqtt-gateway","owner":"2pk03","description":"BACnet MQTT Gateway","archived":false,"fork":false,"pushed_at":"2025-01-18T13:42:48.000Z","size":257,"stargazers_count":51,"open_issues_count":2,"forks_count":27,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-02T03:41:49.263Z","etag":null,"topics":["bacnet","iot-device","mqtt-broker","npm","opensource"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/2pk03.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-21T21:41:19.000Z","updated_at":"2025-01-18T13:41:55.000Z","dependencies_parsed_at":"2024-08-23T18:13:51.330Z","dependency_job_id":"e79f897d-5460-469c-856d-9bcc18fbb0cc","html_url":"https://github.com/2pk03/bacnet-mqtt-gateway","commit_stats":{"total_commits":29,"total_committers":5,"mean_commits":5.8,"dds":0.5172413793103448,"last_synced_commit":"4cb7e21792c2273325215e5e6c3e60087d93d8b7"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2pk03%2Fbacnet-mqtt-gateway","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2pk03%2Fbacnet-mqtt-gateway/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2pk03%2Fbacnet-mqtt-gateway/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2pk03%2Fbacnet-mqtt-gateway/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/2pk03","download_url":"https://codeload.github.com/2pk03/bacnet-mqtt-gateway/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248018061,"owners_count":21034048,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bacnet","iot-device","mqtt-broker","npm","opensource"],"created_at":"2024-10-01T09:46:36.022Z","updated_at":"2025-04-09T10:09:14.811Z","avatar_url":"https://github.com/2pk03.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BACnet MQTT Gateway\n\nBACnet MQTT Gateway is gateway that connects BACnet devices via MQTT to the cloud. It is written in Javascript and uses node.\n\nFor BACnet connection the [Node BACstack](https://github.com/fh1ch/node-bacstack) is used.\n\n## Functionalities\n\n* Discover BACnet devices in network (WhoIs)\n* Read object list from BACnet device (Read Property)\n* Read present value from defined list of BACnet objects and send it to an MQTT broker\n* REST and web interface for configuration\n\n## Getting started\n\n1. Clone repo and install npm dependencies:\n\n    ```shell\n    git clone https://github.com/2pk03/bacnet-mqtt-gateway.git\n    cd bacnet-mqtt-gateway\n    npm install\n    ```\n\n2. Configure gateway:\n\n    By default the gateway is configured to use [infinimesh.cloud](https://console.infinimesh.cloud) platform, but it can be used with any MQTT broker.\n    \n    Open `config/default.json` and change MQTT configuration by defining your device id and the path to the device certificate files.\n    \n    ```\n    {\n        \"mqtt\": {\n            \"gatewayId\": \"{{device id}}\",\n            \"host\": \"mqtt.api.infinimesh.cloud\",\n            \"port\": 8883,\n            \"authentication\": {\n                \"certPath\": \"{{device .crt file path}}\",\n                \"keyPath\": \"{{device .key file path}}\"\n            }\n        },\n        \"bacnet\": {\n            \"configFolder\": \"./devices/\"\n        },\n        \"httpServer\": {\n            \"enabled\": true,\n            \"port\": 8082\n        }\n    }\n    ```\n    \n3. Start the gateway and open admin interface\n\n    ```shell\n    npm start\n    open http://localhost:8082/admin\n    ```\n\n## Device polling configuration\n\nThe 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.\n\n```json\n{\n    \"device\": {\n        \"deviceId\": 114,\n        \"address\": \"192.168.178.55\"\n    },\n    \"polling\": {\n        \"schedule\": \"*/15 * * * * *\"\n    },\n    \"objects\": [{\n        \"objectId\": {\n            \"type\": 2,\n            \"instance\": 202\n        }\n    }, {\n        \"objectId\": {\n            \"type\": 2,\n            \"instance\": 203\n        }\n    }]\n}\n```\n\nYou need to define the device id, ip address, schedule interval (as CRON expression) and the objects to poll.\n\nWhen the gateway is started it automatically reads the list of files from the directory and starts the polling for all devices.\n \n## REST API\n\nTo execute commands the gateway offers a REST API under `http://localhost:8082/api/bacnet`.\n\nThe following endpoints are supported:\n\n* `PUT /api/bacnet`: Scan for devices (WhoIs)\n    \n    Scans for BACnet devices in the network (5s) and returns the answers. Body is empty.\n    \n    Example:\n    ```\n    PUT http://localhost:8082/api/bacnet/scan\n    ```  \n    \n* `PUT /api/bacnet/{deviceId}/objects`: Scan device for object\n\n    Scans a specific device for objects and returns the list of found objects. Device ID and IP address must be provided.\n    \n    Example:\n    ```\n    PUT http://localhost:8082/api/bacnet/22/objects\n    {\n        \"deviceId\":\"22\",\n        \"address\":\"192.168.178.99\"\n    }\n    ```\n    \n* `PUT /api/{deviceId}/config`: Configure polling for device\n\n    Configures and starts polling for a specific device. Body is the same as the polling configuration files described in the previous section.\n    \n    Example:\n    ```\n    PUT http://localhost:8082/api/bacnet/114/config\n    {\n        \"device\": {\n            \"deviceId\": 114,\n            \"address\": \"192.168.178.55\"\n        },\n        \"polling\": {\n            \"schedule\": \"*/15 * * * * *\"\n        },\n        \"objects\": [{\n            \"objectId\": {\n                \"type\": 2,\n                \"instance\": 202\n            }\n        }, {\n            \"objectId\": {\n                \"type\": 2,\n                \"instance\": 203\n            }\n        }]\n    }\n    ```\n\n## Run with Docker\n\nGateway can also be run as a docker container. Just build the image and start a container:\n\n```shell\ndocker build -t bacnet-mqtt-gateway\ndocker 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\n```\n\nWith 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.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2pk03%2Fbacnet-mqtt-gateway","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F2pk03%2Fbacnet-mqtt-gateway","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2pk03%2Fbacnet-mqtt-gateway/lists"}