balenaSense stopped working after update to v1.5.6

After updating to v1.5.6 which bumped BSEC version to 1.4.7.4, I am getting “TypeError: ‘NoneType’ object is not subscriptable” errors, and no measurements are recorded to influxDb.

Anyone else seeing the same errors? @chrisys

09.07.19 11:17:10 (+0000) Exception happened during processing of request from (‘removed’, removed)
09.07.19 11:17:10 (+0000) Traceback (most recent call last):
09.07.19 11:17:10 (+0000) File “/usr/local/lib/python3.5/socketserver.py”, line 313, in _handle_request_noblock
09.07.19 11:17:10 (+0000) self.process_request(request, client_address)
09.07.19 11:17:10 (+0000) File “/usr/local/lib/python3.5/socketserver.py”, line 341, in process_request
09.07.19 11:17:10 (+0000) self.finish_request(request, client_address)
09.07.19 11:17:10 (+0000) File “/usr/local/lib/python3.5/socketserver.py”, line 354, in finish_request
09.07.19 11:17:10 (+0000) self.RequestHandlerClass(request, client_address, self)
09.07.19 11:17:10 (+0000) File “/usr/local/lib/python3.5/socketserver.py”, line 681, in init
09.07.19 11:17:10 (+0000) self.handle()
09.07.19 11:17:10 (+0000) File “/usr/local/lib/python3.5/http/server.py”, line 422, in handle
09.07.19 11:17:10 (+0000) self.handle_one_request()
09.07.19 11:17:10 (+0000) File “/usr/local/lib/python3.5/http/server.py”, line 410, in handle_one_request
09.07.19 11:17:10 (+0000) method()
09.07.19 11:17:10 (+0000) File “/usr/src/app/scripts/sensor.py”, line 96, in do_GET
09.07.19 11:17:10 (+0000) measurements = balenasense.sample()
09.07.19 11:17:10 (+0000) File “/usr/src/app/scripts/sensor.py”, line 68, in sample
09.07.19 11:17:10 (+0000) return self.apply_offsets(self.sensor.get_readings(self.sensor))
09.07.19 11:17:10 (+0000) File “/usr/src/app/scripts/bme680.py”, line 45, in get_readings
09.07.19 11:17:10 (+0000) ‘temperature’: float(self.data[‘temperature’]),
09.07.19 11:17:10 (+0000) TypeError: ‘NoneType’ object is not subscriptable
09.07.19 11:17:10 (+0000) ----------------------------------------
09.07.19 11:17:11 (+0000) Capture thread exited; restarting

Hey @danielgr could you try pushing again this time with --nocache and let me know if this resolves the issue?

Tried it now, but ufortunately it didn’t solve it. Still getting the same errors.

Hmm this is an interesting one, I’ve managed to reproduce by upgrading some older Pi Zero devices, but a newly provisioned one works fine. I’ll do some investigation with these two devices and see if I can work out why this is happening.

@danielgr I think I’ve figured out the issue. It looks like since Bosch updated the library your existing bsec_iaq.config and bsec_iaq.state files are no longer compatible. These are stored in /data/sensor. If you delete them the reading should start working again.

I’ll push a version bump to the main repo that handles this going forward.

Thank you so much, removing the files in data/sensor solved it for me! Up and running again now:)

1 Like

@danielgr no problem, thank you for reporting. The version has just been bumped to v1.5.7 which will automatically clear these files if it sees a version difference in the BSEC download, so hopefully nobody else will get stuck on this going forward.

The error is self-explanatory. You are trying to subscript an object which you think is a list or dict, but actually is None. This means that you tried to do:

None[something]

This error means that you attempted to index an object that doesn’t have that functionality. You might have noticed that the method sort() that only modify the list have no return value printed – they return the default None. ‘NoneType’ object is not subscriptable is the one thrown by python when you use the square bracket notation object[key] where an object doesn’t define the getitem method . This is a design principle for all mutable data structures in Python.