firstof9 / tplink-ess-lib

Python package to control TP-Link Easy Smart switches (version 1.0)
2 stars 1 forks source link

Add query method, parse results into list of key:value dict #13

Closed lyricnz closed 1 year ago

lyricnz commented 1 year ago

Sample output for discovery + stats + vlan (embedded)

{'auto_save': True,
  'dhcp': True,
  'firmware': '1.0.0 Build 20220414 Rel.52733',
  'gateway': IPv4Address('192.168.30.212'),
  'hardware': 'TL-SG105PE 2.0',
  'hostname': 'Back-TL-SG105PE',
  'ip_addr': IPv4Address('192.168.30.50'),
  'ip_mask': IPv4Address('255.255.255.0'),
  'is_factory': False,
  'mac': 'b4:b0:24:3a:f1:3b',
  'stats': {'stats': [{'Link Status': '100Full',
                       'Port': 1,
                       'RxBadPkt': 0,
                       'RxGoodPkt': 172720973,
                       'Status': 'Disabled',
                       'TxBadPkt': 0,
                       'TxGoodPkt': 69318949},
                      {'Link Status': 'Link Down',
                       'Port': 2,
                       'RxBadPkt': 0,
                       'RxGoodPkt': 0,
                       'Status': 'Disabled',
                       'TxBadPkt': 0,
                       'TxGoodPkt': 0},
                      {'Link Status': '1000Full',
                       'Port': 3,
                       'RxBadPkt': 0,
                       'RxGoodPkt': 31201393,
                       'Status': 'Disabled',
                       'TxBadPkt': 0,
                       'TxGoodPkt': 137783851},
                      {'Link Status': 'Link Down',
                       'Port': 4,
                       'RxBadPkt': 0,
                       'RxGoodPkt': 0,
                       'Status': 'Disabled',
                       'TxBadPkt': 0,
                       'TxGoodPkt': 0},
                      {'Link Status': '1000Full',
                       'Port': 5,
                       'RxBadPkt': 0,
                       'RxGoodPkt': 204638914,
                       'Status': 'Disabled',
                       'TxBadPkt': 0,
                       'TxGoodPkt': 204166787}]},
  'type': 'TL-SG105PE',
  'vlan': {'vlan': [{'Member Ports': '1,2,3,4,5',
                     'Tagged Ports': '',
                     'VLAN ID': 1,
                     'VLAN Name': 'Default'},
                    {'Member Ports': '1,3,4,5',
                     'Tagged Ports': '',
                     'VLAN ID': 4040,
                     'VLAN Name': 'test1'},
                    {'Member Ports': '2',
                     'Tagged Ports': '',
                     'VLAN ID': 4041,
                     'VLAN Name': 'test2'}],
           'vlan_enabled': '01',
           'vlan_filler': ' '}}]
lyricnz commented 1 year ago

Added raw values to output (with " Raw" suffix) when field-values are mapped

  'stats': {'stats': [{'Link Status': '100Full',
                       'Link Status Raw': 5,
                       'Port': 1,
                       'RxBadPkt': 0,
                       'RxGoodPkt': 173208911,
                       'Status': 'Disabled',
                       'Status Raw': 1,
                       'TxBadPkt': 0,
                       'TxGoodPkt': 69512764},