Skip to content

Commit

Permalink
Merge pull request #6 from jm-73/develop
Browse files Browse the repository at this point in the history
Handle unknown alert codes
  • Loading branch information
jm-73 authored Aug 20, 2019
2 parents 79b9946 + 6b6e651 commit 61e147e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
14 changes: 12 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@
# .gitignore #
#############################################################

.git
.gitignore

# Python cache
__pycache__/
pyIndego/__pycache__/

# Test script
config.py
test_pyIndego.py

# Log files
*.log

# Python cache
__pycache__/
# Python wheel build package
build/
dist/
pyIndego.egg-info/
_build.cmd
27 changes: 21 additions & 6 deletions pyIndego/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,28 +813,43 @@ def AlertsDescription(self):
if (tmp_cnt == 1):
self._alert1_time = self.ConvertBoschDateTime(alert['date'])
self._alert1_error = alert['error_code']
self._alert1_friendly_description = ALERT_ERROR_CODE[tmp_code]
#self._alert1_friendly_description = ALERT_ERROR_CODE[tmp_code]
self._alert1_friendly_description = self.FriendlyAlertErrorCode(tmp_code)
self._alert2_time = None
self._alert2_error = None
self._alert3_name = None
self._alert3_error = None
if (tmp_cnt == 2):
self._alert2_time = self.ConvertBoschDateTime(alert['date'])
self._alert2_error = alert['error_code']
self._alert2_friendly_description = ALERT_ERROR_CODE[tmp_code]
#self._alert2_friendly_description = ALERT_ERROR_CODE[tmp_code]
self._alert2_friendly_description = self.FriendlyAlertErrorCode(tmp_code)
self._alert3_time = None
self._alert3_error = None
if (tmp_cnt == 3):
self._alert3_time = self.ConvertBoschDateTime(alert['date'])
self._alert3_error = alert['error_code']
self._alert3_friendly_description = ALERT_ERROR_CODE[tmp_code]
print(tmp_cnt, alert['date'], alert['error_code'], alert['headline'])
tmp_code = alert['error_code']
print("Friendly Description: " + ALERT_ERROR_CODE[tmp_code])
#self._alert3_friendly_description = ALERT_ERROR_CODE[tmp_code]
self._alert3_friendly_description = self.FriendlyAlertErrorCode(tmp_code)
#print(tmp_cnt, alert['date'], alert['error_code'], alert['headline'])
#tmp_code = alert['error_code']
#print("Friendly Description: " + ALERT_ERROR_CODE[tmp_code])
#ALERT_ERROR_CODE = {
#alerts_list.update(date = alert['date'])
return self._alerts

def FriendlyAlertErrorCode(self, tmp):
tmp_val = tmp

if str(tmp_val) in ALERT_ERROR_CODE.keys():
_LOGGER.debug(f"Alert value in dict = {tmp_val}")
alert_description = ALERT_ERROR_CODE[tmp_val]
_LOGGER.debug(f"Mower state description: {alert_description}")
else:
_LOGGER.debug(f"Alert value not in dict = {tmp_val}")
alert_description = "Not in database!"
return alert_description

def ConvertBoschDateTime(self, boshdatetime):
return boshdatetime[0:10] + " " + boshdatetime[11:16]

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="pyIndego",
version="0.7.4",
version="0.7.5",
author="jm-73",
author_email="[email protected]",
description="API for Bosch Indego mower",
Expand Down

0 comments on commit 61e147e

Please sign in to comment.