Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def device_from_uuid_and_location(uuid, mac, location,
rediscovery_enabled=True):
"""Determine device class based on the device uuid."""
if uuid is None:
return None
if uuid.startswith('uuid:Socket'):
return Switch(url=location, mac=mac,
rediscovery_enabled=rediscovery_enabled)
if uuid.startswith('uuid:Lightswitch'):
return LightSwitch(url=location, mac=mac,
rediscovery_enabled=rediscovery_enabled)
if uuid.startswith('uuid:Dimmer'):
return Dimmer(url=location, mac=mac,
rediscovery_enabled=rediscovery_enabled)
if uuid.startswith('uuid:Insight'):
return Insight(url=location, mac=mac,
rediscovery_enabled=rediscovery_enabled)
if uuid.startswith('uuid:Sensor'):
return Motion(url=location, mac=mac,
rediscovery_enabled=rediscovery_enabled)
if uuid.startswith('uuid:Maker'):
return Maker(url=location, mac=mac,
rediscovery_enabled=rediscovery_enabled)
if uuid.startswith('uuid:Bridge'):
return Bridge(url=location, mac=mac,
rediscovery_enabled=rediscovery_enabled)
if uuid.startswith('uuid:CoffeeMaker'):
return CoffeeMaker(url=location, mac=mac,
rediscovery_enabled=rediscovery_enabled)
if uuid.startswith('uuid:Humidifier'):
return Humidifier(url=location, mac=mac,
rediscovery_enabled=rediscovery_enabled)
def device_from_uuid_and_location(uuid, location):
""" Tries to determine which device it is based on the uuid. """
if uuid.startswith('uuid:Socket'):
return Switch(location)
elif uuid.startswith('uuid:Lightswitch'):
return LightSwitch(location)
elif uuid.startswith('uuid:Insight'):
return Insight(location)
elif uuid.startswith('uuid:Sensor'):
return Motion(location)
else:
return None