1.1.0 • Published 10 months ago

@episensor/epi-bacnet v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

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 TypeDescriptionCommand
Unit TestsTests for individual functions and componentsnpm run test:unit
Integration TestsTests for node initialization and interactionnpm run test:integration
End-to-End TestsTests for full flows and HTTP endpointsnpm run test:e2e
All TestsRun all test suitesnpm run test:all
Manual Test EnvironmentSet up a persistent Node-RED environment for manual testingnpm run test:manual

Unit Tests

ComponentTestsDescription
BACnet Gateway10Tests for gateway node initialization and configuration
BACnet Read8Tests for read node functionality
BACnet Write8Tests for write node functionality
BACnet Discovery5Tests for device discovery functionality
Utility Functions12Tests for helper functions and utilities

Integration Tests

ComponentTestsDescription
Node Initialization3Tests for proper node registration and initialization
Gateway Configuration4Tests for gateway node configuration and validation
Device Discovery2Tests for device discovery process
Error Handling3Tests for proper error handling in nodes
HTTP Endpoints3Tests for admin HTTP endpoints

End-to-End Tests

ComponentTestsDescription
Flow Deployment2Tests for deploying flows with BACnet nodes
Node Interaction3Tests for interaction between BACnet nodes
HTTP API2Tests 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