Create services for smart buildings using the Lemonbeat smart meters and sensors.
The Lemonbeat Connector can be used to exchange data from devices connected through the Lemonbeat IoT Platform.
System Architecture
The Lemonbeat Connector is based on a specific micro-service letting Servitly to communicate with the AMQP server, the endpoint where IoT data are initially collected.
Periodically (every 5 minutes) through the API, the connector retrieves from each customer the AMQP connection information.
In this way, the connector verifies the presence of new connections to be established with an AMQP server or invalid ones to be evicted.
This means that when a new customer is created within Servitly or a Lemonbeat Connector configuration is updated (e.g. expired certificate), IoT data may take at most 5 minutes to be read and displayed within the dashboards.
Data Listening
The flow of data from the remote device to Servitly follows the following steps:
-
A device data is published to the AMQP server.
-
An LsDl message is notified to the Lemonbeat Connector.
-
The LsDl message is parsed and converted to the Servitly standard JSON format, using the field names as metric names.
-
The transformed message is forwarded to Servitly by using the standard MQTT channel and the device UUID and topic part.
Data Publishing
The flow of data from Servitly to the remote device follows the following steps:
-
A user changes a configuration parameter or executes a command from the dashboard.
-
A message is published on the MQTT channel and made available to the Lemonbeat Connector.
-
An LsBl message is created encapsulating the data.
-
The LsBl message is sent to the Lemonbeat backend through the REST API and finally dispatched to the remote device.
Plugin Configuration
To enable this plugin, you need to:- Go to the Integrations / Plugins page.
- Select the IoT Connectors category.
- Locate the Lemonbeat card.
- Click on the card switch to activate the plugin.
- Configure the plugin properties and save.
Here is the list of all the properties that can be used in the plugin configuration.
PROPERTIES | |
---|---|
Base API URL | The Lemonbeat backend URL used for managing automations. Type: STRING | Optional |
Username | The username used for Lemonbeat backend authentication. Type: STRING | Optional |
Password | The password used for Lemonbeat backend authentication. Type: PASSWORD | Optional |
Connector Configuration
Once enabled, on the tenant level or for each customer, it is possible to configure the Lemonbeat Connector.
The connector configuration requires to provide:
-
broker endpoints and credentials for listening to device IoT data.
-
backend credentials for performing REST API requests.
-
certificates for client authentication and secure channel establishment.
Meta Data Events
The connector subscribes to events published under the topic EVENT.APP.METADATASERVICE.
According to the received event type the connector updates the things and gateways.
METADATA_DEVICE_INCLUDED
When an event is received, the connector performs the following steps:
- Reads the message UUID and retrieves all the things having the mapping Asset Id equals to the UUID.
- Reads all the attribute inside the metadata report message node.
- Reads the value description report and group properties by prefix (name part before "_").
- Filter the found things having the mapping path equals to the prefix (if preset).
- If the thing is missing:
- Retrieves the Location by using the LocationId present into the attributes.
- Retrieves the Thing Definition having the "deviceTypeId" property equals to the DeviceTypeId present into the attributes.
- A new thing is created under the location.
- The thing is activated
- The Serial Number is updated by using the "SerialNumber" attribute.
- The "GTW_SGTIN" thing property is updated by using the gateway SGTIN present into the event.
- The "UUID" thing property is updated by using the UUID present into the event.
- The "SGTIN" thing property is updated by using the device SGTIN present into the event.
- The "deviceUsageId" thing property is updated by using the metadata report "DeviceUsageId" value.
- The "PATH" thing property is updated by using the metadata indexed prefix path (if present).
- The "MeterSerialNumber" thing property is updated by using the metadata report "MeterSerialNumber" value.
- The "MeterDeviceUsage" thing property is updated by using the metadata report "MeterDeviceUsage" value.
- Update any other property with group "Connector" with the relative metadata report value, by suing the thing property name as key (also replacing "-" with "_").
- Updates thing properties whose name is prefixed by "device_".
METADATA_CHANGED
When an event is received, the connector performs the sames steps as per METADATA_DEVICE_INCLUDED events without the thing provisioning steps.
METADATA_DEVICE_REMOVED
When an event is received, the connector performs the following steps:
- Reads the message UUID and retrieves all the things having the mapping Asset Id equals to the UUID.
- Deletes all the found things.
- Optionally uses the metadata report "LocationId" attribute to search for things to delete.
METADATA_DEVICE_EXCLUDED
When an event is received, the connector performs the following steps:
- Reads the message UUID and retrieves all the things having the mapping Asset Id equals to the UUID.
- Deactivates all the found things.
- Optionally uses the metadata report "LocationId" attribute to search for things to deactivate.
METADATA_GATEWAY_INCLUDED
When an event is received, the connector performs the same steps for the METADATA_DEVICE_INCLUDED, but limited to the gateway device type creation. You must have a thing definition having the same "DeviceTypeId" property value, or "Gateway" as fallback "DeviceTypeId" value.
METADATA_GATEWAY_REMOVED
When an event is received, the connector performs no steps, so the event at the moment is discarded.
Device Description Reported Events
The connector subscribes to events published to this topic EVENT.APP.TOPOSERVICE.DEVICE_DESCRIPTION_REPORTED.
You can define properties of things with the prefix "device_" in the name; the connector updates these properties based on the contents of the DEVICE_DESCRIPTION_REPORTED event.
Note that, to identify the thing to be updated, it is mandatory to define the thing property named "SGTIN". This property is automatically updated by the connector during METADATA events processing (e.g. METADATA_DEVICE_INCLUDED, METADATA_CHANGED).
When an event is received, the connector performs the following steps:
- Retrieves the Thing by SGTIN.
- Extracts all the "device_description_report" child nodes having the "name" attribute equal to "info".
- For each element, reads the "type_id" attribute.
- Searches for a property whose name is equal to "device_<@type_id>".
- If the property is missing replaces the "-" character with "_" and searches again.
- Retrieves the value by reading one of these attributes: "number", "string", "hex".
- Converts the value according to the property type (e.g. boolean 1 -> true).
- Updates the property.
Status Reported Events
The connector subscribes to events published to this topic EVENT.APP.STATUSSERVICE.STATUS_REPORTED.
When an event is received, the connector performs the following steps:
- Retrieves the thing by using the SGTIN property which must be equal to the device SGTIN included in the message.
- For each status report item, computes a JSON message and publish under the "LBStatusReport" thing metric.
TOPIC: <USERNAME>/<ASSET_ID>/ms
PAYLOAD:
{
"ts" : 1719478178000,
"data": {
"LBStatusReport" : "<StatusReportItem as JSON>"
}
}
Heartbeat Events
The connector subscribes to events published to this topic EVENT.APP.METADATASERVICE.METADATA_HEARTBEAT_REPORTED.
When an event is received, the connector performs the following steps:
- Reads the message UUID and retrieves the gateway thing having the mapping Asset Id equals to the Gateway UUID.
- For each metadata device retrieves the thing having the mapping Asset Id equals to the Device UUID.
- If the gateway has been found, the heartbeat timestamp is publised under the "heartbeat" metric.
TOPIC: <USERNAME>/<ASSET_ID>/ms
PAYLOAD:
{
"ts" : 1719478178000,
"data": {
"heartbeat" : 1719478178000
}
} - For each identified thing, the location property "gatewayHeartbeat" is updated with the heartbeat timestamp.
Comments
0 comments
Please sign in to leave a comment.