Skip to content

Commit cea5377

Browse files
committed
materializing device_info in the constructor
1 parent 34fcba6 commit cea5377

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/ham/manager.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ def __init__(self, host='localhost', port=1883, username=None,
9090
self.name = self.node_id
9191

9292
self.things = defaultdict(list)
93+
self.device_info = self._gen_device_info()
9394

9495
logger.debug("Initialization parameters: node_id=%s, base_topic=%s, discovery_prefix=%s, name=%s",
9596
self.node_id, self.base_topic, self.discovery_prefix, self.name)
@@ -166,23 +167,21 @@ def on_connect(self, _, userdata, flags, rc):
166167
# reconnect then subscriptions will be renewed.
167168
self.client.subscribe(self.subscribe_topic)
168169

169-
self_device_info = self._gen_device_info()
170-
171-
logger.debug("Device information for this manager: %s", self_device_info)
170+
logger.debug("Device information for this manager: %s", self.device_info)
172171

173172
for origin, things in self.things.items():
174173
if origin is None:
175174
common_config = {
176175
"~": self.base_topic,
177176
"availability_topic": self.availability_topic,
178-
"device": self_device_info,
177+
"device": self.device_info,
179178
}
180179
else:
181180
common_config = {
182181
"~": self.base_topic,
183182
"availability_topic": self.availability_topic,
184183
"device": origin,
185-
"via": self_device_info["identifiers"][0]
184+
"via": self.device_info["identifiers"][0]
186185
}
187186

188187
for thing in things:

0 commit comments

Comments
 (0)