@episensor/epi-bacnet

1.1.0 • Public • Published

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-bacnet

Usage

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 device
  • bacnet-simple-test.json: A simple flow for testing BACnet connectivity
  • bacnet-test-flow.json: A basic flow for testing BACnet read and write operations
  • bacnet-test-flow-http.json: A flow that exposes BACnet operations via HTTP endpoints

To import a flow:

npm run test:manual:import

Testing

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:import

The 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:stop

Repository Structure

  • bacnet_gateway.js and bacnet_gateway.html: BACnet Gateway node
  • bacnet_read.js and bacnet_read.html: BACnet Read node
  • bacnet_write.js and bacnet_write.html: BACnet Write node
  • bacnet_client.js: BACnet client implementation
  • bacnet_server.js: BACnet server implementation
  • common.js: Common utilities
  • resources/: Resources for the nodes
  • icons/: Icons for the nodes
  • scripts/: Utility scripts
  • test/: Test files
    • unit/: Unit tests
    • integration/: Integration tests
    • e2e/: End-to-end tests
    • flows/: Example flows
    • manual/: Manual test scripts
    • helpers/: 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

Package Sidebar

Install

npm i @episensor/epi-bacnet

Weekly Downloads

7

Version

1.1.0

License

MIT

Unpacked Size

1.76 MB

Total Files

76

Last publish

Collaborators

  • episensor