Skip to content

Commit b500d96

Browse files
authored
Merge pull request #10 from bcmi-labs/cloudinit
ucloud: Allow None sub-records in init values.
2 parents 1fd5139 + 42e80f1 commit b500d96

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

arduino_iot_cloud/ucloud.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,16 @@ def _build_rec_dict(self, naming_map, appendTo):
139139

140140
def add_to_pack(self, pack, push=False):
141141
# This function adds records that will be pushed to (or updated from) the cloud, to the SenML pack.
142-
# NOTE: When adding records to be pushed to the cloud (push=True) Only initialized records are added
143-
# to the pack. And when adding records to be updated from the cloud (push=False), records whose values
144-
# are None are allowed to be added to the pack, so they can be initialized from the cloud.
142+
# NOTE: When pushing records to the cloud (push==True) only fully initialized records are added to
143+
# the pack. And when updating records from the cloud (push==False), partially initialized records
144+
# are allowed in the pack, so they can be initialized from the cloud.
145145
# NOTE: all initialized sub-records are added to the pack whether they changed their state since the
146146
# last update or not, because the cloud currently does not support partial objects updates.
147-
if isinstance(self.value, dict):
148-
for r in self.value.values():
149-
if r._value is not None or (r._value is None and not push):
147+
if isinstance(self._value, dict):
148+
if not push or self.initialized:
149+
for r in self._value.values():
150150
pack.add(r)
151-
elif self._value is not None or (self._value is None and not push):
151+
elif not push or self._value is not None:
152152
pack.add(self)
153153
self.updated = False
154154

0 commit comments

Comments
 (0)