magico13 / PyEmVue

Python Library for the Emporia Vue Energy Monitor
MIT License
185 stars 36 forks source link

TypeError: unsupported operand type(s) for /: 'NoneType' and 'int' #8

Closed ai7 closed 1 year ago

ai7 commented 3 years ago

Running python -m pyemvue keys.json, I get an exception at the end:

$ python -m pyemvue keys.json
Logged in. Authtoken follows:
...

id1 id2 VUE002 Vue2-id3
         id4 None 1,2,3 1.0
... info about my vue, and 16 circuit breaker info...

Traceback (most recent call last):   <--- error starts here
  File "/Users/raymochi/.pyenv/versions/3.6.6/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/Users/raymochi/.pyenv/versions/3.6.6/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/raymochi/.pyenv/versions/3.6.6/lib/python3.6/site-packages/pyemvue/__main__.py", line 86, in <module>
    main()
  File "/Users/raymochi/.pyenv/versions/3.6.6/lib/python3.6/site-packages/pyemvue/__main__.py", line 60, in main
    print(vue.get_total_usage(devices[0].channels[0], TotalTimeFrame.MONTH.value) / 1000, 'kwh used month to date')
TypeError: unsupported operand type(s) for /: 'NoneType' and 'int'

My vue2 does not have the main clamp installed (won't fit), but I do have the individual circuit breaker clamps installed.

In the Emporia app, the result for total shows 0.000 and 100% respectively. Individual circuit shows usage, but with 0%.

magico13 commented 3 years ago

Not too surprising since the main clamp isn't set up, I can add some more checking to that application. Since that app only writes out data as a quick check of functionality/quick way to get your access token it's not too big of a deal as long as the actual calls you're making to the library are working as expected.

magico13 commented 1 year ago

Cleaning up old issues. I know I've done some work to handle Nones a little better, but they do still crop up for the usage value. The built-in test script definitely isn't the most resilient, so I definitely recommend accounting for Nones in your own applications.