Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def set_state(self, state):
"""Set the state of this device to on or off."""
# CoffeeMaker cannot be turned off remotely,
# so ignore the request if state is "falsey"
if state:
# Coffee Maker always responds with an error if
# SetBinaryState is called. Use SetAttributes
# to change the Mode to "Brewing"
# pylint: disable=maybe-no-member
self.deviceevent.SetAttributes(attributeList=quote_xml(
"Mode4"))
# The Coffee Maker might not be ready - so it's not safe
# to assume the state is what you just set,
# so re-read it from the device
self.get_state(True)
def set_fan_mode(self, fan_mode):
"""
Set the fan mode of this device (as int index of the FanMode IntEnum).
Provided for compatibility with the Switch base class.
"""
# Send the attribute list to the device
# pylint: disable=maybe-no-member
self.deviceevent.SetAttributes(attributeList=quote_xml(
"FanMode" +
str(int(fan_mode)) + ""))
# Refresh the device state
self.get_state(True)
def set_humidity(self, desired_humidity):
"""Set the desired humidity (as int index of the IntEnum)."""
# Send the attribute list to the device
# pylint: disable=maybe-no-member
self.deviceevent.SetAttributes(attributeList=quote_xml(
"DesiredHumidity" +
str(int(desired_humidity)) + ""))
# Refresh the device state
self.get_state(True)
def set_fan_mode_and_humidity(self, fan_mode, desired_humidity):
"""
Set the desired humidity and fan mode.
(as int index of their respective IntEnums)
"""
# Send the attribute list to the device
# pylint: disable=maybe-no-member
self.deviceevent.SetAttributes(attributeList=quote_xml(
"FanMode" +
str(int(fan_mode)) + "" +
"DesiredHumidity" +
str(int(desired_humidity)) + ""))
# Refresh the device state
self.get_state(True)
def reset_filter_life(self):
"""Reset the filter life (call this when you install a new filter)."""
# Send the attribute list to the device
# pylint: disable=maybe-no-member
self.deviceevent.SetAttributes(attributeList=quote_xml(
"FilterLife" +
str(FILTER_LIFE_MAX) + ""))
# Refresh the device state
self.get_state(True)
def set_state(self, state):
"""
Set the state of this device to on or off.
"""
# CoffeeMaker cannot be turned off remotely, so ignore the request if state is "falsey"
if state:
# Coffee Maker always responds with an error if SetBinaryState is called. Use SetAttributes
# to change the Mode to "Brewing"
self.deviceevent.SetAttributes(attributeList =
quote_xml("Mode4"))
# The Coffee Maker might not be ready - so it's not safe to assume the state is what you just set
# so re-read it from the device
self.get_state(True)