Open-source IoT Gateway - integrates devices connected to legacy and third-party systems with ThingsBoard IoT Platform using Modbus, CAN bus, BACnet, BLE, OPC-UA, MQTT, ODBC and REST protocols
Describe the issue
Hi, I'm trying to make a barebones/simpel custom connector that just writes some messages in the logger. But when doing so I keep running into an error message and I'm not sure how I can fix this. Any help with this is appreciated.
|ERROR| - [tb_logger.py] - tb_logger - exception - 127 - 'config'
And the extensions folder I have added the folder CustomGRPC folder and added the following python file (partially copies as the rest is standard, if required I will update it):
from threading import Thread
from random import choice
from string import ascii_lowercase
from thingsboard_gateway.tb_utility.tb_utility import TBUtility
# Libraries required for custom connector
import grpc
try:
from chirpstack_api import api
except ImportError:
print("tb-gateway - chirpstack_api not found - installing....")
TBUtility.install_package("chirpstack-api")
from chirpstack_api import api
from thingsboard_gateway.connectors.connector import Connector # Import base class for connector and logger
from thingsboard_gateway.tb_utility.tb_loader import TBModuleLoader
from thingsboard_gateway.tb_utility.tb_logger import init_logger
class CustomGRPCConnector(Thread, Connector): # Define a connector class, it should inherit from "Connector" class.
def __init__(self, gateway, config, connector_type):
super().__init__() # Initialize parents classes
self.statistics = {'MessagesReceived': 0,
'MessagesSent': 0} # Dictionary, will save information about count received and sent messages.
self.__config = config
self.__id = self.__config.get('id')
self.__gateway = gateway # Save gateway object, we will use some gateway methods for adding devices and saving data from them.
#self.__connector_type = connector_type # Saving type for connector, need for loading converter
self.setName(self.__config.get("name",
"Custom %s connector " % self.get_name() + ''.join(choice(ascii_lowercase) for _ in range(5)))) # get from the configuration or create name for logs.
self._log = init_logger(self.__gateway, self.name, level=self.__config.get('logLevel'),
enable_remote_logging=self.__config.get('enableRemoteLogging', False))
#self._log.info("\n")
#self._log.info("Starting Custom %s connector", self.get_name()) # Send message to logger
#self._log.info("\n")
#self.daemon = True # Set self thread as daemon
#self.stopped = True # Service variable for check state
#self.connected = False # Service variable for check connection to device
#self.devices = {} # Dictionary with devices, will contain devices configurations, converters for devices and serial port objects
#self.__load_converters() # Call function to load converters and save it into devices dictionary
#self.__connect_to_host() # Call function for connect to devices
#self._log.info('Custom connector %s initialization success.', self.get_name()) # Message to logger
#self._log.info("Devices in configuration file found: %s ", '\n'.join(device for device in self.devices)) # Message to logger
A lot I have commented to try and locate the origin of the issue but was unsuccessful, hence the ticket.
Versions (please complete the following information):
Describe the issue Hi, I'm trying to make a barebones/simpel custom connector that just writes some messages in the logger. But when doing so I keep running into an error message and I'm not sure how I can fix this. Any help with this is appreciated.
|ERROR| - [tb_logger.py] - tb_logger - exception - 127 - 'config'
I use the following configuration json:
in tb_gateway.json I have added the following:
Error traceback (If it was raised):
And the extensions folder I have added the folder CustomGRPC folder and added the following python file (partially copies as the rest is standard, if required I will update it):
A lot I have commented to try and locate the origin of the issue but was unsuccessful, hence the ticket. Versions (please complete the following information):