Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull #19

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Add support for Chamberlain Gates by adding supported and unsupported…
… device dicts. Add logging when an unsupported or unknown device type id is encountered
wrong-kendall committed Sep 3, 2016
commit aa61a445092211bcc0d7996c325a869395a7a16a
22 changes: 20 additions & 2 deletions myq-garage.py
Original file line number Diff line number Diff line change
@@ -84,6 +84,18 @@
'Closing',
]

# For want of an enum...
SUPPORTED_DEVICES = {
2: 'Doors',
5: 'Gate',
}

UNSUPPORTED_DEVICES = {
1: 'Gateway',
10: 'Structure',
11: 'Thermostat',
}

def setup_log(name):
# Log Location
PATH = os.path.dirname(sys.argv[0])
@@ -257,13 +269,19 @@ def get_doors(token):
if data['ReturnCode'] != '0':
print(data['ErrorMessage'])
sys.exit(2)
LOGGER.debug('devices: %s', data['Devices'])
for device in data['Devices']:
#MyQDeviceTypeId Doors == 2, Gateway == 1, Structure == 10, Thermostat == 11
if device['MyQDeviceTypeId'] == 2:
deviceTypeId = device['MyQDeviceTypeId']
if deviceTypeId in SUPPORTED_DEVICES.keys():
LOGGER.debug('Found supported device (%s)' % SUPPORTED_DEVICES[deviceTypeId])
id = device['DeviceId']
name = get_doorname(token, id)
state, time = get_doorstate(token, id)
DOOR(id, name,state,time)
elif deviceTypeId in UNSUPPORTED_DEVICES.keys():
LOGGER.warning('Unsupported device (%s) found, skipping' % UNSUPPORTED_DEVICES[deviceTypeId])
else:
LOGGER.error('Unknown device (%s) found, skipping' % deviceTypeId)
return DOOR.instances

def get_doorstate(token, id):