Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Brewed = 5
CleaningBrewing = 6
CleaningSoaking = 7
BrewFailCarafeRemoved = 8
MODE_NAMES = {
CoffeeMakerMode.Refill: "Refill",
CoffeeMakerMode.PlaceCarafe: "PlaceCarafe",
CoffeeMakerMode.RefillWater: "RefillWater",
CoffeeMakerMode.Ready: "Ready",
CoffeeMakerMode.Brewing: "Brewing",
CoffeeMakerMode.Brewed: "Brewed",
CoffeeMakerMode.CleaningBrewing: "CleaningBrewing",
CoffeeMakerMode.CleaningSoaking: "CleaningSoaking",
CoffeeMakerMode.BrewFailCarafeRemoved: "BrewFailCarafeRemoved",
}
def attribute_xml_to_dict(xml_blob):
"""Return integer value of Mode from an attributesList blob, if present."""
xml_blob = "" + xml_blob + ""
xml_blob = xml_blob.replace(">", ">")
xml_blob = xml_blob.replace("<", "<")
result = {}
attributes = et.fromstring(xml_blob)
for attribute in attributes:
# The coffee maker might also send unrelated xml blobs, e.g.:
# coffee-brewed
#
# so be sure to check the length of attribute
if len(attribute) >= 2:
PlaceCarafe = 1 # reservoir has water but carafe not present
RefillWater = 2 # carafe present but reservoir is empty
Ready = 3
Brewing = 4
Brewed = 5
CleaningBrewing = 6
CleaningSoaking = 7
BrewFailCarafeRemoved = 8
MODE_NAMES = {
CoffeeMakerMode.Refill: "Refill",
CoffeeMakerMode.PlaceCarafe: "PlaceCarafe",
CoffeeMakerMode.RefillWater: "RefillWater",
CoffeeMakerMode.Ready: "Ready",
CoffeeMakerMode.Brewing: "Brewing",
CoffeeMakerMode.Brewed: "Brewed",
CoffeeMakerMode.CleaningBrewing: "CleaningBrewing",
CoffeeMakerMode.CleaningSoaking: "CleaningSoaking",
CoffeeMakerMode.BrewFailCarafeRemoved: "BrewFailCarafeRemoved",
}
def attribute_xml_to_dict(xml_blob):
"""Return integer value of Mode from an attributesList blob, if present."""
xml_blob = "" + xml_blob + ""
xml_blob = xml_blob.replace(">", ">")
xml_blob = xml_blob.replace("<", "<")
result = {}
attributes = et.fromstring(xml_blob)
for attribute in attributes:
# The coffee maker might also send unrelated xml blobs, e.g.:
RefillWater = 2 # carafe present but reservoir is empty
Ready = 3
Brewing = 4
Brewed = 5
CleaningBrewing = 6
CleaningSoaking = 7
BrewFailCarafeRemoved = 8
MODE_NAMES = {
CoffeeMakerMode.Refill: "Refill",
CoffeeMakerMode.PlaceCarafe: "PlaceCarafe",
CoffeeMakerMode.RefillWater: "RefillWater",
CoffeeMakerMode.Ready: "Ready",
CoffeeMakerMode.Brewing: "Brewing",
CoffeeMakerMode.Brewed: "Brewed",
CoffeeMakerMode.CleaningBrewing: "CleaningBrewing",
CoffeeMakerMode.CleaningSoaking: "CleaningSoaking",
CoffeeMakerMode.BrewFailCarafeRemoved: "BrewFailCarafeRemoved",
}
def attribute_xml_to_dict(xml_blob):
"""Return integer value of Mode from an attributesList blob, if present."""
xml_blob = "" + xml_blob + ""
xml_blob = xml_blob.replace(">", ">")
xml_blob = xml_blob.replace("<", "<")
result = {}
attributes = et.fromstring(xml_blob)
for attribute in attributes:
# The coffee maker might also send unrelated xml blobs, e.g.:
# coffee-brewed
Brewing = 4
Brewed = 5
CleaningBrewing = 6
CleaningSoaking = 7
BrewFailCarafeRemoved = 8
MODE_NAMES = {
CoffeeMakerMode.Refill: "Refill",
CoffeeMakerMode.PlaceCarafe: "PlaceCarafe",
CoffeeMakerMode.RefillWater: "RefillWater",
CoffeeMakerMode.Ready: "Ready",
CoffeeMakerMode.Brewing: "Brewing",
CoffeeMakerMode.Brewed: "Brewed",
CoffeeMakerMode.CleaningBrewing: "CleaningBrewing",
CoffeeMakerMode.CleaningSoaking: "CleaningSoaking",
CoffeeMakerMode.BrewFailCarafeRemoved: "BrewFailCarafeRemoved",
}
def attribute_xml_to_dict(xml_blob):
"""Return integer value of Mode from an attributesList blob, if present."""
xml_blob = "" + xml_blob + ""
xml_blob = xml_blob.replace(">", ">")
xml_blob = xml_blob.replace("<", "<")
result = {}
attributes = et.fromstring(xml_blob)
for attribute in attributes:
# The coffee maker might also send unrelated xml blobs, e.g.:
# coffee-brewed
#
# so be sure to check the length of attribute
"""Enum to map WeMo modes to human-readable strings."""
Refill = 0 # reservoir empty and carafe not in place
PlaceCarafe = 1 # reservoir has water but carafe not present
RefillWater = 2 # carafe present but reservoir is empty
Ready = 3
Brewing = 4
Brewed = 5
CleaningBrewing = 6
CleaningSoaking = 7
BrewFailCarafeRemoved = 8
MODE_NAMES = {
CoffeeMakerMode.Refill: "Refill",
CoffeeMakerMode.PlaceCarafe: "PlaceCarafe",
CoffeeMakerMode.RefillWater: "RefillWater",
CoffeeMakerMode.Ready: "Ready",
CoffeeMakerMode.Brewing: "Brewing",
CoffeeMakerMode.Brewed: "Brewed",
CoffeeMakerMode.CleaningBrewing: "CleaningBrewing",
CoffeeMakerMode.CleaningSoaking: "CleaningSoaking",
CoffeeMakerMode.BrewFailCarafeRemoved: "BrewFailCarafeRemoved",
}
def attribute_xml_to_dict(xml_blob):
"""Return integer value of Mode from an attributesList blob, if present."""
xml_blob = "" + xml_blob + ""
xml_blob = xml_blob.replace(">", ">")
xml_blob = xml_blob.replace("<", "<")
result = {}
Refill = 0 # reservoir empty and carafe not in place
PlaceCarafe = 1 # reservoir has water but carafe not present
RefillWater = 2 # carafe present but reservoir is empty
Ready = 3
Brewing = 4
Brewed = 5
CleaningBrewing = 6
CleaningSoaking = 7
BrewFailCarafeRemoved = 8
MODE_NAMES = {
CoffeeMakerMode.Refill: "Refill",
CoffeeMakerMode.PlaceCarafe: "PlaceCarafe",
CoffeeMakerMode.RefillWater: "RefillWater",
CoffeeMakerMode.Ready: "Ready",
CoffeeMakerMode.Brewing: "Brewing",
CoffeeMakerMode.Brewed: "Brewed",
CoffeeMakerMode.CleaningBrewing: "CleaningBrewing",
CoffeeMakerMode.CleaningSoaking: "CleaningSoaking",
CoffeeMakerMode.BrewFailCarafeRemoved: "BrewFailCarafeRemoved",
}
def attribute_xml_to_dict(xml_blob):
"""Return integer value of Mode from an attributesList blob, if present."""
xml_blob = "" + xml_blob + ""
xml_blob = xml_blob.replace(">", ">")
xml_blob = xml_blob.replace("<", "<")
result = {}
attributes = et.fromstring(xml_blob)
Ready = 3
Brewing = 4
Brewed = 5
CleaningBrewing = 6
CleaningSoaking = 7
BrewFailCarafeRemoved = 8
MODE_NAMES = {
CoffeeMakerMode.Refill: "Refill",
CoffeeMakerMode.PlaceCarafe: "PlaceCarafe",
CoffeeMakerMode.RefillWater: "RefillWater",
CoffeeMakerMode.Ready: "Ready",
CoffeeMakerMode.Brewing: "Brewing",
CoffeeMakerMode.Brewed: "Brewed",
CoffeeMakerMode.CleaningBrewing: "CleaningBrewing",
CoffeeMakerMode.CleaningSoaking: "CleaningSoaking",
CoffeeMakerMode.BrewFailCarafeRemoved: "BrewFailCarafeRemoved",
}
def attribute_xml_to_dict(xml_blob):
"""Return integer value of Mode from an attributesList blob, if present."""
xml_blob = "" + xml_blob + ""
xml_blob = xml_blob.replace(">", ">")
xml_blob = xml_blob.replace("<", "<")
result = {}
attributes = et.fromstring(xml_blob)
for attribute in attributes:
# The coffee maker might also send unrelated xml blobs, e.g.:
# coffee-brewed
#
class CoffeeMakerMode(IntEnum):
"""Enum to map WeMo modes to human-readable strings."""
Refill = 0 # reservoir empty and carafe not in place
PlaceCarafe = 1 # reservoir has water but carafe not present
RefillWater = 2 # carafe present but reservoir is empty
Ready = 3
Brewing = 4
Brewed = 5
CleaningBrewing = 6
CleaningSoaking = 7
BrewFailCarafeRemoved = 8
MODE_NAMES = {
CoffeeMakerMode.Refill: "Refill",
CoffeeMakerMode.PlaceCarafe: "PlaceCarafe",
CoffeeMakerMode.RefillWater: "RefillWater",
CoffeeMakerMode.Ready: "Ready",
CoffeeMakerMode.Brewing: "Brewing",
CoffeeMakerMode.Brewed: "Brewed",
CoffeeMakerMode.CleaningBrewing: "CleaningBrewing",
CoffeeMakerMode.CleaningSoaking: "CleaningSoaking",
CoffeeMakerMode.BrewFailCarafeRemoved: "BrewFailCarafeRemoved",
}
def attribute_xml_to_dict(xml_blob):
"""Return integer value of Mode from an attributesList blob, if present."""
xml_blob = "" + xml_blob + ""
xml_blob = xml_blob.replace(">", ">")
xml_blob = xml_blob.replace("<", "<")
Refill = 0 # reservoir empty and carafe not in place
PlaceCarafe = 1 # reservoir has water but carafe not present
RefillWater = 2 # carafe present but reservoir is empty
Ready = 3
Brewing = 4
Brewed = 5
CleaningBrewing = 6
CleaningSoaking = 7
BrewFailCarafeRemoved = 8
MODE_NAMES = {
CoffeeMakerMode.Refill: "Refill",
CoffeeMakerMode.PlaceCarafe: "PlaceCarafe",
CoffeeMakerMode.RefillWater: "RefillWater",
CoffeeMakerMode.Ready: "Ready",
CoffeeMakerMode.Brewing: "Brewing",
CoffeeMakerMode.Brewed: "Brewed",
CoffeeMakerMode.CleaningBrewing: "CleaningBrewing",
CoffeeMakerMode.CleaningSoaking: "CleaningSoaking",
CoffeeMakerMode.BrewFailCarafeRemoved: "BrewFailCarafeRemoved",
}
def attribute_xml_to_dict(xml_blob):
"""Return integer value of Mode from an attributesList blob, if present."""
xml_blob = "" + xml_blob + ""
xml_blob = xml_blob.replace(">", ">")
xml_blob = xml_blob.replace("<", "<")
result = {}
attributes = et.fromstring(xml_blob)
for attribute in attributes: