Skip to content

Commit

Permalink
Merge pull request #24 from djtimca/develop
Browse files Browse the repository at this point in the history
Add error catching for XML conversion and JSON conversion
  • Loading branch information
djtimca authored Jun 6, 2022
2 parents ae70b53 + c537dfb commit 35a1a4e
Show file tree
Hide file tree
Showing 5 changed files with 1,297 additions and 8 deletions.
4 changes: 2 additions & 2 deletions omnilogic.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Metadata-Version: 2.1
Name: omnilogic
Version: 0.4.4
Version: 0.4.5
Summary: Integration for the Hayward OmniLogic pool control system
Home-page: https://github.com/djtimca/omnilogic-api
Author: Tim Empringham
Author-email: tim.empringham@live.ca
License: apache-2.0
Download-URL: https://github.com/djtimca/omnilogic-api/archive/v_044.tar.gz
Download-URL: https://github.com/djtimca/omnilogic-api/archive/v_045.tar.gz
Description: # Hayward OmniLogic Integration
Integration library for Hayward Omnilogic pool controllers to allow easy integration through their API to your home automation system.

Expand Down
3 changes: 3 additions & 0 deletions omnilogic/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,6 @@ dmypy.json
# VSCode config
.vscode/

# Testing Files
test.py
test_data/
14 changes: 10 additions & 4 deletions omnilogic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,11 @@ def alarms_to_json(self, alarms):
return alarmslist

def telemetry_to_json(self, telemetry, config_data, site_alarms):
telemetryXML = ElementTree.fromstring(telemetry)
try:
telemetryXML = ElementTree.fromstring(telemetry)
except:
raise OmniLogicException("Error loading Hayward data.")

backyard = {}

BOW = {}
Expand Down Expand Up @@ -1045,9 +1049,11 @@ async def get_telemetry_data(self):
# def get_alarm_list(self):

def convert_to_json(self, xmlString):
my_dict = xmltodict.parse(xmlString)
json_data = json.dumps(my_dict)
# print(json_data)
try:
my_dict = xmltodict.parse(xmlString)
json_data = json.dumps(my_dict)
except:
raise OmniLogicException("Error converting Hayward data to JSON.")

return json.loads(json_data)["Response"]["MSPConfig"]

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
setup(
name = 'omnilogic',
packages = ['omnilogic'],
version = '0.4.5',
version = '0.4.6',
license='apache-2.0',
description = 'Integration for the Hayward OmniLogic pool control system',
long_description = long_description,
long_description_content_type = "text/markdown",
author = 'Tim Empringham',
author_email = 'tim.empringham@live.ca',
url = 'https://github.com/djtimca/omnilogic-api',
download_url = 'https://github.com/djtimca/omnilogic-api/archive/v_045.tar.gz',
download_url = 'https://github.com/djtimca/omnilogic-api/archive/v_046.tar.gz',
keywords = ['OmniLogic', 'Hayward', 'Pool', 'Spa'],
install_requires=[
'xmltodict',
Expand Down
Loading

0 comments on commit 35a1a4e

Please sign in to comment.