Skip to content

Commit 6806443

Browse files
committed
Fix for attributes sending
1 parent 31e1987 commit 6806443

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
with open(path.join(this_directory, 'README.md')) as f:
2222
long_description = f.read()
2323

24-
VERSION = "1.10.3"
24+
VERSION = "1.10.4"
2525

2626
setup(
2727
version=VERSION,

tb_device_mqtt.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import logging
1616
from copy import deepcopy
1717
from inspect import signature
18+
from re import split
1819
from time import sleep
1920

2021
import paho.mqtt.client as paho
@@ -246,20 +247,20 @@ def get_rate_limits_by_host(host, rate_limit, dp_rate_limit):
246247
def get_rate_limit_by_host(host, rate_limit):
247248
if rate_limit == "DEFAULT_TELEMETRY_RATE_LIMIT":
248249
if "thingsboard.cloud" in host:
249-
rate_limit = "5:1,60:60,"
250+
rate_limit = "10:1,60:60,"
250251
elif "tb" in host and "cloud" in host:
251-
rate_limit = "5:1,60:60,"
252+
rate_limit = "10:1,60:60,"
252253
elif "demo.thingsboard.io" in host:
253-
rate_limit = "5:1,60:60,"
254+
rate_limit = "10:1,60:60,"
254255
else:
255256
rate_limit = "0:0,"
256257
elif rate_limit == "DEFAULT_MESSAGES_RATE_LIMIT":
257258
if "thingsboard.cloud" in host:
258-
rate_limit = "5:1,60:60,"
259+
rate_limit = "10:1,60:60,"
259260
elif "tb" in host and "cloud" in host:
260-
rate_limit = "5:1,60:60,"
261+
rate_limit = "10:1,60:60,"
261262
elif "demo.thingsboard.io" in host:
262-
rate_limit = "5:1,60:60,"
263+
rate_limit = "10:1,60:60,"
263264
else:
264265
rate_limit = "0:0,"
265266
else:
@@ -767,13 +768,16 @@ def __send_publish_with_limitations(self, kwargs, timeout, device=None, msg_rate
767768
data = kwargs.get("payload")
768769
if isinstance(data, str):
769770
data = loads(data)
770-
payload = data
771771
topic = kwargs.get("topic", '')
772-
if topic.endswith('telemetry') or topic.endswith('attributes'):
772+
attributes_format = topic.endswith('attributes')
773+
if topic.endswith('telemetry') or attributes_format:
773774
if device is None or data.get(device) is None:
774775
device_split_messages = self._split_message(data, dp_rate_limit.get_minimal_limit(),
775776
self.max_payload_size)
776-
split_messages = [{'message': split_message['data'], 'datapoints': split_message['datapoints']}
777+
if attributes_format:
778+
split_messages = [{'message': msg_data, 'datapoints': len(msg_data)} for split_message in device_split_messages for msg_data in split_message['data']]
779+
else:
780+
split_messages = [{'message': split_message['data'], 'datapoints': split_message['datapoints']}
777781
for split_message in device_split_messages]
778782
else:
779783
device_data = data.get(device)
@@ -784,9 +788,6 @@ def __send_publish_with_limitations(self, kwargs, timeout, device=None, msg_rate
784788
else:
785789
split_messages = [{'message': data, 'datapoints': 0}]
786790

787-
if len(split_messages) == 0:
788-
log.debug("Cannot split message to smaller parts: %r", payload)
789-
790791
results = []
791792
for part in split_messages:
792793
if not part:

0 commit comments

Comments
 (0)