therealmko / Domoticz_Wifi_presence_checker

Python script and JSON files to check Wifi presence for Domoticz Home Automation application
7 stars 0 forks source link

Error TypeError: 'NoneType' object has no attribute '__getitem__' #1

Open korniza opened 8 years ago

korniza commented 8 years ago

I face an error on script. I can not get it run. As you see, ruuning on debug script can read from snmp connected clients but for an unkown reason to me, can not read Name of the idx from domoticz. Any idea?

$python /home/pi/Domoticz_Wifi_presence_checker/wifi_presence_check.py -d localhost:8080 -s 20 -f /home/pi/Domoticz_Wifi_presence_checker/wifi_devices.json -r /home/pi/Domoticz_Wifi_presence_checker/snmp_routers.json --verbose

2016/04/22 18:49:24 DEBUG: MAC address presence: B0:C5:54:05:69:96 A4:77:33:A8:44:36 94:10:3E:CD:25:C9 EE:22:80:6C:1A:91 B0:C5:54:01:55:3C B0:C5:54:03:70:67 30:75:12:E4:52:B9 Traceback (most recent call last): File "/home/pi/Domoticz_Wifi_presence_checker/wifi_presence_check.py", line 446, in main() File "/home/pi/Domoticz_Wifi_presence_checker/wifi_presence_check.py", line 410, in main switch_name_device = d.get_device(switch_idx)['Name'] TypeError: 'NoneType' object has no attribute 'getitem'

therealmko commented 8 years ago

I think I found a solution by moving to urllib2 instead of httplib. It works for me again it seems.

therealmko commented 8 years ago

Latest version uploaded. Please give it a try.