@episensor/epi-bacnet v1.1.0
EpiSensor BACnet Nodes for Node-RED
A comprehensive set of BACnet nodes for Node-RED and EpiSensor Edge.
Overview
This package provides a set of nodes for interacting with BACnet devices:
- BACnet Gateway: Manages the BACnet client and server
- BACnet Read: Reads values from BACnet devices
- BACnet Write: Writes values to BACnet devices
Installation
npm install @episensor/epi-bacnetUsage
BACnet Gateway
The BACnet Gateway node manages the BACnet client and server. It provides the following functionality:
- Device discovery
- Device management
- BACnet server (optional)
BACnet Read
The BACnet Read node reads values from BACnet devices. It provides the following functionality:
- Read property values
- Read multiple properties
- Read object lists
BACnet Write
The BACnet Write node writes values to BACnet devices. It provides the following functionality:
- Write property values
- Set priorities
Example Flows
Example flows are provided in the test/flows directory:
bacnet-interface-test.json: A comprehensive dashboard for monitoring and controlling a BACnet devicebacnet-simple-test.json: A simple flow for testing BACnet connectivitybacnet-test-flow.json: A basic flow for testing BACnet read and write operationsbacnet-test-flow-http.json: A flow that exposes BACnet operations via HTTP endpoints
To import a flow:
npm run test:manual:importTesting
For comprehensive testing information, see test/README.md.
Test Suite Overview
| Test Type | Description | Command |
|---|---|---|
| Unit Tests | Tests for individual functions and components | npm run test:unit |
| Integration Tests | Tests for node initialization and interaction | npm run test:integration |
| End-to-End Tests | Tests for full flows and HTTP endpoints | npm run test:e2e |
| All Tests | Run all test suites | npm run test:all |
| Manual Test Environment | Set up a persistent Node-RED environment for manual testing | npm run test:manual |
Unit Tests
| Component | Tests | Description |
|---|---|---|
| BACnet Gateway | 10 | Tests for gateway node initialization and configuration |
| BACnet Read | 8 | Tests for read node functionality |
| BACnet Write | 8 | Tests for write node functionality |
| BACnet Discovery | 5 | Tests for device discovery functionality |
| Utility Functions | 12 | Tests for helper functions and utilities |
Integration Tests
| Component | Tests | Description |
|---|---|---|
| Node Initialization | 3 | Tests for proper node registration and initialization |
| Gateway Configuration | 4 | Tests for gateway node configuration and validation |
| Device Discovery | 2 | Tests for device discovery process |
| Error Handling | 3 | Tests for proper error handling in nodes |
| HTTP Endpoints | 3 | Tests for admin HTTP endpoints |
End-to-End Tests
| Component | Tests | Description |
|---|---|---|
| Flow Deployment | 2 | Tests for deploying flows with BACnet nodes |
| Node Interaction | 3 | Tests for interaction between BACnet nodes |
| HTTP API | 2 | Tests for HTTP API endpoints |
Manual Test Environment
For manual testing and debugging, you can set up a persistent Node-RED environment with the BACnet nodes installed:
# Start a basic Node-RED environment with BACnet nodes
npm run test:manual
# Reset flows and start Node-RED
npm run test:manual:reset
# Import a test flow and start Node-RED
npm run test:manual:importThe Node-RED editor will be available at http://localhost:1881 (or the next available port if 1881 is in use).
Features of the Manual Test Environment
- Persistent Node-RED instance that doesn't shut down after tests
- BACnet nodes pre-installed and ready to use
- Option to import test flows for quick testing
- Automatic port selection if the default port is in use
- Logs available at
test-env/node-red/node-red-output.log
Stopping the Manual Test Environment
To stop the Node-RED instance:
# Stop any running Node-RED instances
npm run test:manual:stopRepository Structure
bacnet_gateway.jsandbacnet_gateway.html: BACnet Gateway nodebacnet_read.jsandbacnet_read.html: BACnet Read nodebacnet_write.jsandbacnet_write.html: BACnet Write nodebacnet_client.js: BACnet client implementationbacnet_server.js: BACnet server implementationcommon.js: Common utilitiesresources/: Resources for the nodesicons/: Icons for the nodesscripts/: Utility scriptstest/: Test filesunit/: Unit testsintegration/: Integration testse2e/: End-to-end testsflows/: Example flowsmanual/: Manual test scriptshelpers/: Helper functions for tests
test-env/: Self-contained test environment
Recent Improvements
- Fixed tests to handle null nodes properly
- Added flow import tests
- Increased timeouts for tests to prevent flaky failures
- Added manual test environment with scripts for setup and management
- Fixed E2E tests to properly handle message formats
- Improved error handling in tests
- Added more detailed logging to help with debugging
- Fixed integration tests to properly handle error events
- Added automatic port selection for the manual test environment
- Improved documentation for test environment setup
License
MIT