Skip to content

Commit

Permalink
Merge pull request #11 from NREL/configure_device_name_id
Browse files Browse the repository at this point in the history
Configurable device name and id
  • Loading branch information
TShapinsky authored May 25, 2023
2 parents de539d1 + 9cf0019 commit bdff51d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ALFALFA_HOST=https://alfalfa.nrel.gov
ALFALFA_SITE=bacnet

ALFALFA_DEVICE_NAME=AlfalfaProxy
ALFALFA_DEVICE_ID=599
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ These are variables used to describe the bridge's connection to Alfalfa.
| --- | -------- | --- |
| `ALFALFA_SITE` | The Alfalfa Site ID of the model of interest or an alias which points to a site of interest | MUST BE SET |
| `ALFALFA_HOST` | The URL of the Alfalfa instance | MUST BE SET |
| `ALFALFA_DEVICE_NAME` | The name of the BACnet device | `AlfalfaProxy` |
| `ALFALFA_DEVICE_ID` | The ID of the BACnet device | `599` |

When the specified `ALFALFA_SITE` is an alias the bridge will automatically switch sites when the alias is updated.

Expand Down
5 changes: 3 additions & 2 deletions alfalfa_bacnet_bridge/alfalfa_bacnet_bridge.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from datetime import datetime
import sys
import os
from bacpypes.app import BIPSimpleApplication
from bacpypes.core import deferred, run
from bacpypes.debugging import bacpypes_debugging, ModuleLogger
Expand Down Expand Up @@ -57,8 +58,8 @@ def __init__(self, host, site_id: SiteID) -> None:
self.site_id = site_id

self.device = AlfalfaBACnetDevice(
objectName="AlfalfaProxy",
objectIdentifier=int(599),
objectName=os.getenv("ALFALFA_DEVICE_NAME","AlfalfaProxy"),
objectIdentifier=int(os.getenv("ALFALFA_DEVICE_ID", 599)),
maxApduLengthAccepted=int(1024),
segmentationSupported="segmentedBoth",
vendorIdentifier=555,
Expand Down

0 comments on commit bdff51d

Please sign in to comment.