Skip to content

Commit

Permalink
separate boiler state and operation
Browse files Browse the repository at this point in the history
  • Loading branch information
zweckj committed Aug 13, 2023
1 parent 66ab1ac commit 6fad64d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 17 deletions.
4 changes: 4 additions & 0 deletions custom_components/lamarzocco/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@
ENTITY_TAG = "tag"
ENTITY_TEMP_TAG = "temp_tag"
ENTITY_TSET_TAG = "tset_tag"
ENTITY_TOPERATION_TAG = "toperation_tag"
ENTITY_TSTATE_TAG = "tstate_tag"
ENTITY_NAME = "name"
ENTITY_MAP = "map"
Expand All @@ -278,3 +279,6 @@
PLATFORM = "platform"
PLATFORM_SENSOR = "sensor"
PLATFORM_SWITCH = "switch"

COFFEE_BOILER_STATE = "coffee_boiler_on"
STEAM_BOILER_STATE = "steam_boiler_on"
2 changes: 1 addition & 1 deletion custom_components/lamarzocco/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/rccoleman/lamarzocco/issues",
"loggers": ["lmcloud"],
"requirements": ["lmcloud==0.3.32"],
"requirements": ["lmcloud==0.3.33"],
"ssdp": [],
"version": "0.12.1"
}
51 changes: 35 additions & 16 deletions custom_components/lamarzocco/water_heater.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
from .const import (
ATTR_MAP_COFFEE,
ATTR_MAP_STEAM,
COFFEE_BOILER_STATE,
DOMAIN,
ENTITY_ICON,
ENTITY_MAP,
ENTITY_NAME,
ENTITY_TOPERATION_TAG,
ENTITY_TEMP_TAG,
ENTITY_TSET_TAG,
ENTITY_TSTATE_TAG,
Expand All @@ -27,6 +29,7 @@
MODEL_LMU,
POWER,
STEAM_BOILER_ENABLE,
STEAM_BOILER_STATE,
TEMP_COFFEE,
TSET_COFFEE,
TEMP_STEAM,
Expand All @@ -38,22 +41,23 @@
from .services import async_setup_entity_services, call_service

"""Min/Max coffee and team temps."""
# COFFEE_MIN_TEMP = 87
# COFFEE_MAX_TEMP = 100
COFFEE_MIN_TEMP_LMU = 85
COFFEE_MAX_TEMP_LMU = 104
COFFEE_MIN_TEMP = 85
COFFEE_MAX_TEMP = 104

# STEAM_MIN_TEMP = 110
# STEAM_MAX_TEMP = 132
LMU_STEAM_STEPS = [126, 128, 131]
STEAM_STEPS = [126, 128, 131]

MODE_ENABLED = "Enabled"
MODE_DISABLED = "Disabled"
OPERATION_MODES = [MODE_ENABLED, MODE_DISABLED]

_LOGGER = logging.getLogger(__name__)

ENTITIES = {
"coffee": {
ENTITY_TEMP_TAG: TEMP_COFFEE,
ENTITY_TSET_TAG: TSET_COFFEE,
ENTITY_TSTATE_TAG: POWER,
ENTITY_TOPERATION_TAG: POWER,
ENTITY_TSTATE_TAG: COFFEE_BOILER_STATE,
ENTITY_NAME: "Coffee",
ENTITY_MAP: {
MODEL_GS3_AV: ATTR_MAP_COFFEE,
Expand All @@ -67,7 +71,8 @@
"steam": {
ENTITY_TEMP_TAG: TEMP_STEAM,
ENTITY_TSET_TAG: TSET_STEAM,
ENTITY_TSTATE_TAG: STEAM_BOILER_ENABLE,
ENTITY_TOPERATION_TAG: STEAM_BOILER_ENABLE,
ENTITY_TSTATE_TAG: STEAM_BOILER_STATE,
ENTITY_NAME: "Steam",
ENTITY_MAP: {
MODEL_GS3_AV: ATTR_MAP_STEAM,
Expand Down Expand Up @@ -104,7 +109,7 @@ def __init__(self, coordinator, water_heater_type, hass, config_entry):
@property
def supported_features(self):
"""Return the list of supported features."""
return WaterHeaterEntityFeature.TARGET_TEMPERATURE | WaterHeaterEntityFeature.ON_OFF
return WaterHeaterEntityFeature.TARGET_TEMPERATURE | WaterHeaterEntityFeature.ON_OFF | WaterHeaterEntityFeature.OPERATION_MODE

@property
def temperature_unit(self):
Expand All @@ -122,10 +127,7 @@ def state(self):
is_on = self._lm.current_status.get(
self._entities[self._object_id][ENTITY_TSTATE_TAG], False
)
if is_on:
return STATE_ELECTRIC
else:
return STATE_OFF
return STATE_ELECTRIC if is_on else STATE_OFF

@property
def current_temperature(self):
Expand All @@ -143,11 +145,22 @@ def target_temperature(self):

@property
def min_temp(self):
return COFFEE_MIN_TEMP_LMU if self._object_id == "coffee" else min(LMU_STEAM_STEPS)
return COFFEE_MIN_TEMP if self._object_id == "coffee" else min(STEAM_STEPS)

@property
def max_temp(self):
return COFFEE_MAX_TEMP_LMU if self._object_id == "coffee" else max(LMU_STEAM_STEPS)
return COFFEE_MAX_TEMP if self._object_id == "coffee" else max(STEAM_STEPS)

@property
def operation_list(self):
return OPERATION_MODES

@property
def current_operation(self):
is_on = self._lm.current_status.get(
self._entities[self._object_id][ENTITY_TOPERATION_TAG], False
)
return MODE_ENABLED if is_on else MODE_DISABLED

async def async_set_temperature(self, **kwargs):
"""Service call to set the temp of either the coffee or steam boilers."""
Expand All @@ -168,3 +181,9 @@ async def async_turn_off(self):
_LOGGER.debug(f"Turning {self._object_id} on")
func = getattr(self._lm, f"set_{self._entities[self._object_id][ENTITY_TSTATE_TAG]}")
await call_service(func, state=False)

async def async_set_operation_mode(self, operation_mode):
if operation_mode == MODE_ENABLED:
await self.async_turn_on()
else:
await self.async_turn_off()

0 comments on commit 6fad64d

Please sign in to comment.