Gephi and Indigo
Posted: Thu Feb 02, 2017 5:29 pm
Continuing to play with Gephi. Here is a screenshot where the nodes have been arrayed like they are in our house. The green lines represent a gross approximation of our external walls, with the nodes placed (generally) where the devices are in the house. The blue nodes indicate battery operated devices, which I plan to adjust to show relative battery health. I'm not at all happy with the color scheme yet.
Here is the (still evolving) script I'm using to generate the CSV files for Gephi import:
Here is the (still evolving) script I'm using to generate the CSV files for Gephi import:
- Code: Select all
##### Script to generate CSV files for Gephi visualizations. #####
dev_address_list = []
edges_counter = 0
neighbors_dict = {}
##### nodes #####
node_file = open('/Users/username/Dropbox/Indigo Logs/zwave_nodes.csv', 'w')
node_file.write(u"Id,Label,Battery,Battery Health,Type\n")
node_file.write(u"1,Controller,0,100,Static Controller\n")
for dev in indigo.devices.itervalues('indigo.zwave'):
if dev.address not in dev_address_list:
try:
class_name = dev.globalProps['com.perceptiveautomation.indigoplugin.zwave']['zwClassName']
dev_address_list.append(dev.address)
neighbors_dict[str(dev.address)] = dev.globalProps['com.perceptiveautomation.indigoplugin.zwave']['zwNodeNeighbors']
try:
if dev.globalProps['com.perceptiveautomation.indigoplugin.zwave']['SupportsBatteryLevel']:
battery = 1
battery_level = dev.batteryLevel
else:
battery = 0
battery_level = 100
except:
battery = 0
node_file.write(u"{0},{1},{2},{3},{4}\n".format(dev.address, dev.name, battery, battery_level, class_name))
except:
pass
node_file.close
##### Edges #####
edges_file = open('/Users/username/Dropbox/Indigo Logs/zwave_edges.csv', 'w')
edges_file.write(u"Source,Target,Type,Id,Weight,Average Degree\n")
for k, v in neighbors_dict.iteritems():
for neighbor in v:
edges_file.write(u"{0},{1},{2},{3},{4},{5}\n".format(k, neighbor, 'Undirected', edges_counter, 1.0, 1.0))
edges_counter += 1
edges_file.close