1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
import logging
from enum import IntEnum
import click
from .click_common import command, format_output
from .device import Device
_LOGGER = logging.getLogger(__name__)
MODEL = "scishare.coffee.s1102"
class Status(IntEnum):
Unknown = -1
Off = 1
On = 2
SelfCheck = 3
StopPreheat = 4
CoffeeReady = 5
StopDescaling = 6
Standby = 7
Preheating = 8
Brewing = 201
NoWater = 203
class ScishareCoffee(Device):
"""Main class for Scishare coffee maker (scishare.coffee.s1102)."""
_supported_models = ["scishare.coffee.s1102"]
@command()
def status(self) -> int:
"""Device status."""
status_code = self.send("Query_Machine_Status")[1]
try:
return Status(status_code)
except ValueError:
_LOGGER.warning(
"Status code unknown, please report the state of the machine for code %s",
status_code,
)
return Status.Unknown
@command(
click.argument("temperature", type=int),
default_output=format_output("Setting preheat to {temperature}"),
)
def preheat(self, temperature: int):
"""Pre-heat to given temperature."""
return self.send("Boiler_Preheating_Set", [temperature])
@command(default_output=format_output("Stopping pre-heating"))
def stop_preheat(self) -> bool:
"""Stop pre-heating."""
return self.send("Stop_Boiler_Preheat")[0] == "ok"
@command()
def cancel_alarm(self) -> bool:
"""Unknown."""
raise NotImplementedError()
return self.send("Cancel_Work_Alarm")[0] == "ok"
@command(
click.argument("amount", type=int),
click.argument("temperature", type=int),
default_output=format_output("Boiling {amount} ml water ({temperature}C)"),
)
def boil_water(self, amount: int, temperature: int) -> bool:
"""Boil water.
:param amount: in milliliters
:param temperature: in degrees
"""
return self.send("Hot_Wate", [amount, temperature])[0] == "ok"
@command(
click.argument("amount", type=int),
click.argument("temperature", type=int),
default_output=format_output("Brewing {amount} ml espresso ({temperature}C)"),
)
def brew_espresso(self, amount: int, temperature: int):
"""Brew espresso.
:param amount: in milliliters
:param temperature: in degrees
"""
return self.send("Espresso_Coffee", [amount, temperature])[0] == "ok"
@command(
click.argument("water_amount", type=int),
click.argument("water_temperature", type=int),
click.argument("coffee_amount", type=int),
click.argument("coffee_temperature", type=int),
default_output=format_output(
"Brewing americano using {water_amount} ({water_temperature}C) water and {coffee_amount} ml ({coffee_temperature}C) coffee"
),
)
def brew_americano(
self,
water_amount: int,
water_temperature: int,
coffee_amount: int,
coffee_temperature: int,
) -> bool:
"""Brew americano.
:param water_amount: water in milliliters
:param water_temperature: water temperature
:param coffee_amount: coffee amount in milliliters
:param coffee_temperature: coffee temperature
"""
return (
self.send(
"Americano_Coffee",
[water_amount, water_temperature, coffee_amount, coffee_temperature],
)[0]
== "ok"
)
@command(default_output=format_output("Powering on"))
def on(self) -> bool:
"""Power on."""
return self.send("Machine_ON")[0] == "ok"
@command(default_output=format_output("Powering off"))
def off(self) -> bool:
"""Power off."""
return self.send("Machine_OFF")[0] == "ok"
@command()
def buzzer_frequency(self):
"""Unknown."""
raise NotImplementedError()
return self.send("Buzzer_Frequency_Time")[0] == "ok"
|