Skip to content

[HELP] Custom Connector, Bacnet Extension guidelines #2115

@AdrienAdB

Description

@AdrienAdB

Bacnet custom config

I'm trying to extend existing bacnet connector but I'm lost in documentation, folder structure and file naming.

The final goal is to populate attributes, telemetry and RPC automatically. We would simply have to add device without heavy configuration. (100+ attributes)

Where the extension python file should be located and how to register the module in tb_gateway.json?

Registration error

I've tried multiple options but I always endup with:

|WARNING| - [tb_gateway_service.py] - tb_gateway_service - _load_connectors - 902 - Connector implementation not found for Custom Bacnet Connector

tb_gateway.json

...
  "connectors": [
    {
      "type": "custom",
      "name": "Custom Bacnet Connector",
      "configuration": "bacnetCustom.json",
      "class": "CustomBacnetConnector"
    }
  ]
...

Python class CustomBacnetConnector

from thingsboard_gateway.connectors.bacnet.bacnet_connector import AsyncBACnetConnector
from thingsboard_gateway.connectors.bacnet.bacnet_converter import AsyncBACnetConverter

import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("BacnetExtension")

# Define attributes
ATTRIBUTES = [
    {
        "key": "temp",
        "objectType": "analogValue",
        "objectId": 1,
        "propertyId": "presentValue"
    }
]

class CustomBacnetUplinkConverter(AsyncBACnetConverter):
    def __init__(self, config):
        logger.info(f"CustomBacnetUplinkConverter: {config}")
        super().__init__(config)


class CustomBacnetConnector(AsyncBACnetConnector):
    def __init__(self, gateway, config, connector_name):
        logger.info(f"CustomBacnetConnector: {config}")
        # do something with config (rewrite attributes....)
        
        super().__init__(gateway, config, connector_name)
        self._converter = CustomBacnetUplinkConverter(self._config)

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions