pyanova-api icon indicating copy to clipboard operation
pyanova-api copied to clipboard

AttributeError: 'NoneType' object has no attribute 'get'

Open TheAmitMa opened this issue 4 years ago • 10 comments

When setting the cooker variable with AnovaCooker('my device ID') I'm getting this error: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.6/dist-packages/anova/AnovaCooker.py", line 48, in __init__ self.update_state() File "/usr/local/lib/python3.6/dist-packages/anova/AnovaCooker.py", line 63, in update_state self.heater_duty_cycle = float(device_state.get('heater-control').get('duty-cycle')) AttributeError: 'NoneType' object has no attribute 'get' Funny thing that last week it worked... Tried it with 2 different systems.. Any Idea?

TheAmitMa avatar Jan 19 '20 20:01 TheAmitMa

I’ve only seen this error when I use an invalid cooker ID - have you tried to hit the API directly with your cooker ID?

ammarzuberi avatar Jan 19 '20 22:01 ammarzuberi

Yes. I've tried the query my device with https://anovaculinary.io/devices/MYANOVAID/states/?limit=1&max-age=10s and I'm getting the results.

My firmware version is: VM176_A_01.04.03 if it matters.

TheAmitMa avatar Jan 20 '20 08:01 TheAmitMa

Can you post the output of that request? Please remove any identifying fields.

ammarzuberi avatar Jan 20 '20 08:01 ammarzuberi

[ { "body": { "boot-id": "XXXXXXXXX", "job": { "cook-time-seconds": 0, "id": "XXXXXXXXX", "mode": "IDLE", "ota-url": "", "target-temperature": 56, "temperature-unit": "C" }, "job-status": { "cook-time-remaining": 0, "job-start-systick": 1736, "provisioning-pairing-code": 0, "state": "", "state-change-systick": 1736 }, "network-info": { "bssid": "XXXXXXXXX", "connection-status": "connected-station", "is-provisioning": false, "mac-address": "XXXXXXXXX", "mode": "station", "security-type": "XXXXXXXXX", "ssid": "XXXXXXXXX" }, "pin-info": { "device-safe": 1, "water-leak": 0, "water-level-critical": 1, "water-temp-too-high": 0 }, "system-info-3220": { "firmware-version": "VM176_A_01.04.03", "largest-free-heap-size": 26648, "systick": 48330561, "total-free-heap-size": 27856, "total-heap-size": 65536 }, "system-info-nxp": { "version-string": "VM171_A_01.04.03" }, "temperature-info": { "heater-temperature": 17.25, "triac-temperature": 20.28, "water-temperature": 17.68 } }, "header": { "created-at": "2020-01-20T09:08:18.975188Z", "e-tag": "XXXXXXXXX", "entity-id": "XXXXXXXXX" } } ]

TheAmitMa avatar Jan 20 '20 09:01 TheAmitMa

Anything?

TheAmitMa avatar Feb 02 '20 08:02 TheAmitMa

Apologies for the delay. What type of Anova device do you have?

ammarzuberi avatar Apr 16 '20 10:04 ammarzuberi

Precision. The new model.

TheAmitMa avatar Apr 22 '20 18:04 TheAmitMa

Precision. The new model.

Same here - I have the precision 2.0 and get the same error message.

niekbuurmah2o avatar Jul 14 '20 14:07 niekbuurmah2o

I compared the output of the device query and noticed that the website doesn't report the answers to the following lines in the script (not sure whether this is Precision 2.0 specific, but I guess it is if others find the script still works):

	# self.heater_duty_cycle = float(device_state.get('heater-control').get('duty-cycle'))
	# self.motor_duty_cycle = float(device_state.get('motor-control').get('duty-cycle'))

These lines are also exactly where I get the NoneType error. As you see above, I've #ed them out and the script works again!

The easiest option to allow cross-cooker compatibility might be to first identify the type of cooker and then place if-statements before the lines above. I wonder whether the following bit might identify the cooker?

"system-info-nxp": { "version-string": "VM171_A_01.04.04"

niekbuurmah2o avatar Jul 14 '20 14:07 niekbuurmah2o

I forked this with something similar to what niekbuurmah2o mentioned there, and it works. It seems to expose much fewer details than the old api used to (eg: https://github.com/bmedicke/anova.py ) , I am not sure if this is limitation of this code, or of the new API

fabriba avatar Mar 01 '21 11:03 fabriba