Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setup_url_for_address(host, port):
"""Determine setup.xml url for given host and port pair."""
if not port:
port = pywemo.ouimeaux_device.probe_wemo(host)
if not port:
return None
return 'http://{}:{}/setup.xml'.format(host, port)
def setup_url_for_address(host, port):
"""Determine setup.xml url for given host and port pair."""
if not port:
port = pywemo.ouimeaux_device.probe_wemo(host)
if not port:
return None
return f"http://{host}:{port}/setup.xml"
def set_hardware_state(self, state, force = False):
port = pywemo.ouimeaux_device.probe_wemo(self.get_address())
device = pywemo.discovery.device_from_description(terrariumPowerSwitchWeMo.URL.format(self.get_address(), port), None)
if state is terrariumPowerSwitch.ON:
device.on()
else:
device.off()
def get_hardware_state(self):
data = None
try:
port = pywemo.ouimeaux_device.probe_wemo(self.get_address())
if port is not None:
device = pywemo.discovery.device_from_description(terrariumPowerSwitchWeMo.URL.format(self.get_address(), port), None)
data = device.get_state()
except Exception as err:
# Ignore for now
print(err)
return terrariumPowerSwitch.ON if terrariumUtils.is_true(data) else terrariumPowerSwitch.OFF