Gephi and Indigo

Posted on
Thu Feb 02, 2017 5:29 pm
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Gephi and Indigo

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.

Screen Shot 2017-02-02 at 5.22.36 PM.png
Screen Shot 2017-02-02 at 5.22.36 PM.png (250.83 KiB) Viewed 2687 times


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

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Feb 06, 2017 5:09 pm
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Gephi and Indigo

Relative battery health (lower right node showing low battery).

Screen Shot 2017-02-06 at 5.00.42 PM.png
Screen Shot 2017-02-06 at 5.00.42 PM.png (214.03 KiB) Viewed 2607 times

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Feb 06, 2017 9:03 pm
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Gephi and Indigo

Distribution by type of device ('zwClassName').

Screen Shot 2017-02-06 at 8.35.19 PM.png
Screen Shot 2017-02-06 at 8.35.19 PM.png (395.41 KiB) Viewed 2589 times

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest