Skip to content

Commit 503027e

Browse files
authored
Merge pull request #7 from infincia/fix_undefined
Fix variable used before defined
2 parents 3022060 + 95f1a89 commit 503027e

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

pymyq/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,18 +160,18 @@ def get_status(self, device_id):
160160
"""List only MyQ garage door devices."""
161161
devices = self.get_devices()
162162

163+
garage_state = False
164+
163165
if devices != False:
164166
for device in devices:
165167
if device['MyQDeviceTypeName'] in self.SUPPORTED_DEVICE_TYPE_NAMES and device['MyQDeviceId'] == device_id:
166168
dev = {}
167169
for attribute in device['Attributes']:
168-
if attribute['AttributeDisplayName'] == 'doorstate':
169-
garage_state = attribute['Value']
170-
171-
garage_state = self.DOOR_STATE[garage_state]
172-
return garage_state
173-
else:
174-
return False
170+
if attribute['AttributeDisplayName'] == 'doorstate':
171+
myq_garage_state = attribute['Value']
172+
garage_state = self.DOOR_STATE[myq_garage_state]
173+
174+
return garage_state
175175

176176
def close_device(self, device_id):
177177
"""Close MyQ Device."""

0 commit comments

Comments
 (0)