-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathhelpers.py
21 lines (18 loc) · 897 Bytes
/
helpers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
def device_instances(services):
return dict( map( lambda s : (s, services[s].device_instance), services ))
def build_dbus_payload(portal_id, services):
# { "portalId": self.portalId, "topicPath": device.topic_paths(self.portalId), "deviceInstance": device.device_instances() } ) )
topic_path = {
"N": "N/{}/{}/{}",
"R": "R/{}/{}/{}",
"W": "W/{}/{}/{}",
}
return {
"portalId": portal_id,
"deviceInstance": device_instances(services),
"topicPath": dict( map( lambda s : (s, {
"N": topic_path["N"].format(portal_id, services[s].serviceType, services[s].device_instance),
"R": topic_path["R"].format(portal_id, services[s].serviceType, services[s].device_instance),
"W": topic_path["W"].format(portal_id, services[s].serviceType, services[s].device_instance)
}), services ))
}