Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions PyISY/Nodes/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ def parse_xml_properties(xmldoc):
#print "prop=",prop.toprettyxml();
units = uom if uom == 'n/a' else uom.split('/')
if (val == ""):
val = 0
val = -1
else:
val = int(val.replace(' ', '0'))
val = int(val.replace(' ', '-1'))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line would cause problems if the value was ' 5'. I'm not sure if that every happens, but it feels plausible. I really don't like any of the original logic on these lines. What if we did something like this:

val = val.strip()
if val == "":
    val = -1
val = int(val)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ha, that didn't occur to me. I wasn't exactly sure what that original logic was trying to catch in the first place I couldn't get that condition to occur from my actual ISY responses. Stripping is the much better way to go; I'll change it to that.


if prop_id == STATE_PROPERTY:
state_val = val
Expand Down