thingsboard-endpoint 0.2.0__tar.gz → 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. {thingsboard_endpoint-0.2.0/src/thingsboard_endpoint.egg-info → thingsboard_endpoint-0.2.2}/PKG-INFO +1 -1
  2. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/attribute/type.py +35 -1
  3. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/endpoint.py +1 -1
  4. thingsboard_endpoint-0.2.2/src/thingsboard/endpoint/exception/invalid_attribute_type_exception.py +12 -0
  5. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/mqtt/client.py +1 -1
  6. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/object/object.py +7 -11
  7. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/version.py +1 -1
  8. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2/src/thingsboard_endpoint.egg-info}/PKG-INFO +1 -1
  9. thingsboard_endpoint-0.2.0/src/thingsboard/endpoint/exception/invalid_attribute_type_exception.py +0 -6
  10. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/LICENSE +0 -0
  11. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/README.md +0 -0
  12. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/pyproject.toml +0 -0
  13. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/setup.cfg +0 -0
  14. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/setup.py +0 -0
  15. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/__init__.py +0 -0
  16. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/__init__.py +0 -0
  17. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/attribute/__init__.py +0 -0
  18. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/attribute/attribute.py +0 -0
  19. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/attribute/constraint.py +0 -0
  20. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/attribute/decorator.py +0 -0
  21. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/connector/__init__.py +0 -0
  22. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/connector/model_to_cloud.py +0 -0
  23. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/exception/__init__.py +0 -0
  24. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/exception/invalid_attribute_exception.py +0 -0
  25. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/exception/invalid_property_exception.py +0 -0
  26. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/exception/modification_exception.py +0 -0
  27. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/factory/__init__.py +0 -0
  28. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/factory/xml.py +0 -0
  29. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/interface/__init__.py +0 -0
  30. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/interface/attribute_container.py +0 -0
  31. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/interface/attribute_listener.py +0 -0
  32. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/interface/message_format.py +0 -0
  33. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/interface/named_item.py +0 -0
  34. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/interface/node_container.py +0 -0
  35. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/interface/object_container.py +0 -0
  36. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/interface/unique_identifiable.py +0 -0
  37. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/interface/uuid.py +0 -0
  38. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/message_format/__init__.py +0 -0
  39. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/message_format/factory.py +0 -0
  40. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/message_format/json_format.py +0 -0
  41. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/message_format/jsonzip_format.py +0 -0
  42. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/message_format/thingsboard_format.py +0 -0
  43. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/mqtt/__init__.py +0 -0
  44. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/mqtt/pending_update.py +0 -0
  45. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/mqtt/persistence.py +0 -0
  46. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/node/__init__.py +0 -0
  47. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/node/node.py +0 -0
  48. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/object/__init__.py +0 -0
  49. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/properties_endpoint_configuration.py +0 -0
  50. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/runtime/__init__.py +0 -0
  51. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/runtime/node.py +0 -0
  52. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/runtime/object.py +0 -0
  53. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard/endpoint/topicuuid.py +0 -0
  54. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard_endpoint.egg-info/SOURCES.txt +0 -0
  55. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard_endpoint.egg-info/dependency_links.txt +0 -0
  56. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard_endpoint.egg-info/requires.txt +0 -0
  57. {thingsboard_endpoint-0.2.0 → thingsboard_endpoint-0.2.2}/src/thingsboard_endpoint.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: thingsboard-endpoint
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: ThingsBoard endpoint package
5
5
  Home-page: https://gitlab.com/things-board
6
6
  Author: HES-SO Valais, School of Engineering, Sion
@@ -1,6 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
- from thingsboard.endpoint.exception.invalid_attribute_type_exception import InvalidAttributeTypeException
3
+ from thingsboard.endpoint.exception.invalid_attribute_type_exception import (
4
+ InvalidAttributeTypeException,
5
+ InvalidAttributeStringTypeException)
4
6
 
5
7
 
6
8
  class AttributeType(object):
@@ -54,6 +56,38 @@ class AttributeType(object):
54
56
  else:
55
57
  return 'Invalid'
56
58
 
59
+ @classmethod
60
+ def from_string_to_type(cls, str_type: str):
61
+ """Converts a string to a standard type representation."""
62
+ if str_type.lower() == 'bool' or str_type.lower() == 'boolean':
63
+ the_type = cls.Boolean
64
+ elif str_type.lower() in ('short', 'long', 'integer'):
65
+ the_type = cls.Integer
66
+ elif str_type.lower() == 'float' or str_type.lower() == 'double' or str_type.lower() == 'number':
67
+ the_type = cls.Number
68
+ elif str_type.lower() == 'str' or str_type.lower() == 'string':
69
+ the_type = cls.String
70
+ else:
71
+ the_type = cls.Invalid
72
+
73
+ return the_type
74
+
75
+ @classmethod
76
+ def from_string_to_raw_type(cls, str_type: str):
77
+ """Converts a string to a standard type representation."""
78
+ if str_type.lower() == 'bool' or str_type.lower() == 'boolean':
79
+ the_raw_type = bool
80
+ elif str_type.lower() in ('short', 'long', 'integer'):
81
+ the_raw_type = int
82
+ elif str_type.lower() == 'float' or str_type.lower() == 'double' or str_type.lower() == 'number':
83
+ the_raw_type = float
84
+ elif str_type.lower() == 'str' or str_type.lower() == 'string':
85
+ the_raw_type = str
86
+ else:
87
+ raise InvalidAttributeTypeException(str_type)
88
+
89
+ return the_raw_type
90
+
57
91
  @property
58
92
  def type(self):
59
93
  return self._type
@@ -600,7 +600,7 @@ class Endpoint(Threaded, NodeContainer):
600
600
  msg_id = 'PendingNodeAdded-' + ';'.join(topic_levels) + '-' + str(int(timestamp))
601
601
  self.persistence.put(msg_id, mqtt.PendingUpdate(payload))
602
602
  else:
603
- raise Exception('Unknown action type!')
603
+ raise Exception(f'Unknown action type \'{action}\'!')
604
604
  except Exception as exception:
605
605
  self.log.error(exception, exc_info=True)
606
606
 
@@ -0,0 +1,12 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ class InvalidAttributeTypeException(Exception):
4
+ def __init__(self, type):
5
+ super(InvalidAttributeTypeException, self).__init__(
6
+ str(type) + ' is not a valid endpoint attribute type!')
7
+
8
+
9
+ class InvalidAttributeStringTypeException(Exception):
10
+ def __init__(self, str_type : str):
11
+ super(InvalidAttributeStringTypeException, self).__init__(
12
+ str_type + ' is not a known attribute string type!')
@@ -92,7 +92,7 @@ class MqttClient(object):
92
92
  clean_session=self._client_clean_session)
93
93
 
94
94
  if self._client:
95
- if not options.client_cert_file:
95
+ if not options.ca_file:
96
96
  # Connect without TLS
97
97
  self._client.connect(callback=self.on_connect)
98
98
  else:
@@ -139,12 +139,10 @@ class _InternalObject(ObjectContainer, AttributeContainer):
139
139
  if location:
140
140
  if len(location) > 0:
141
141
  if len(location) > 1: # Check if it's an object (not attribute)
142
- location.pop() # Remove last item
143
- if len(location) > 0:
144
- if location[-1] in self.get_objects():
145
- obj = self.get_objects()[location.pop()]
146
- if obj:
147
- return obj.find_attribute(location)
142
+ if location[-1] in self.get_objects():
143
+ obj = self.get_objects()[location.pop()]
144
+ if obj:
145
+ return obj.find_attribute(location)
148
146
  else: # It's an attribute
149
147
  self.get_attributes() # Update attributes list
150
148
  if location[-1] in self.get_attributes():
@@ -163,11 +161,9 @@ class _InternalObject(ObjectContainer, AttributeContainer):
163
161
  if location:
164
162
  if len(location) > 0:
165
163
  if len(location) > 1: # Check if it's an object (not attribute)
166
- location.pop() # Remove last item
167
- if len(location) > 0:
168
- if location[-1] in self.get_objects():
169
- obj = self.get_objects()[location.pop()]
170
- return obj
164
+ if location[-1] in self.get_objects():
165
+ obj = self.get_objects()[location.pop()]
166
+ return obj
171
167
  else: # It's an attribute
172
168
  obj = self.get_attributes() # Update attributes list
173
169
  location.pop() # Remove last item
@@ -3,7 +3,7 @@
3
3
 
4
4
  __author__ = 'Thomas Sterren'
5
5
  __contributors__ = []
6
- __version__ = '0.2.0'
6
+ __version__ = '0.2.2'
7
7
 
8
8
 
9
9
  def main():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: thingsboard-endpoint
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: ThingsBoard endpoint package
5
5
  Home-page: https://gitlab.com/things-board
6
6
  Author: HES-SO Valais, School of Engineering, Sion
@@ -1,6 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- class InvalidAttributeTypeException(Exception):
4
- def __init__(self, type):
5
- super(InvalidAttributeTypeException, self).__init__(
6
- str(type) + ' is not a valid endpoint attribute type!')