In get_leaf_status() if logging in fails because a 404 is returned then we crash! See traceback below.
Jan 25 14:52:28 hapi3 python[29483]: DEBUG:pycarwings2.pycarwings2:Response HTTP Status Code: 200
Jan 25 14:52:28 hapi3 python[29483]: DEBUG:pycarwings2.pycarwings2:Response HTTP Response Body: {"status":404}
Jan 25 14:52:28 hapi3 python[29483]: ERROR:root:CarWings API error
Jan 25 14:52:28 hapi3 python[29483]: INFO:root:get_latest_battery_status
Jan 25 14:52:28 hapi3 python[29483]: Traceback (most recent call last):
Jan 25 14:52:28 hapi3 python[29483]: File "/srv/leafd/leaf-python-mqtt/leaf-python-mqtt.py", line 228, in <module>
Jan 25 14:52:28 hapi3 python[29483]: schedule.run_pending()
Jan 25 14:52:28 hapi3 python[29483]: File "/srv/leafd/venv/local/lib/python2.7/site-packages/schedule/__init__.py", line 493, in run_pending
Jan 25 14:52:28 hapi3 python[29483]: default_scheduler.run_pending()
Jan 25 14:52:28 hapi3 python[29483]: File "/srv/leafd/venv/local/lib/python2.7/site-packages/schedule/__init__.py", line 78, in run_pending
Jan 25 14:52:28 hapi3 python[29483]: self._run_job(job)
Jan 25 14:52:28 hapi3 python[29483]: File "/srv/leafd/venv/local/lib/python2.7/site-packages/schedule/__init__.py", line 131, in _run_job
Jan 25 14:52:28 hapi3 python[29483]: ret = job.run()
Jan 25 14:52:28 hapi3 python[29483]: File "/srv/leafd/venv/local/lib/python2.7/site-packages/schedule/__init__.py", line 411, in run
Jan 25 14:52:28 hapi3 python[29483]: ret = self.job_func()
Jan 25 14:52:28 hapi3 python[29483]: File "/srv/leafd/leaf-python-mqtt/leaf-python-mqtt.py", line 158, in get_leaf_status
Jan 25 14:52:28 hapi3 python[29483]: leaf_info = l.get_latest_battery_status()
Jan 25 14:52:28 hapi3 python[29483]: UnboundLocalError: local variable 'l' referenced before assignment
In get_leaf_status() if logging in fails because a 404 is returned then we crash! See traceback below.