WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit eab06ef

Browse files
authored
Merge pull request #133 from zweckj/copilot/add-tank-status-to-dashboard
Add tank status to get_dashboard_from_bluetooth
2 parents be89a56 + b2a67b7 commit eab06ef

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

pylamarzocco/devices/_machine.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
CoffeeBoiler,
2727
LastCoffeeList,
2828
MachineStatus,
29+
NoWater,
2930
PrebrewSettingTimes,
3031
SecondsInOut,
3132
SteamBoilerLevel,
@@ -196,6 +197,24 @@ async def get_dashboard_from_bluetooth(self) -> None:
196197
# Remove level widget if it exists (not applicable for this model)
197198
self.dashboard.config.pop(WidgetType.CM_STEAM_BOILER_LEVEL, None)
198199

200+
# Get tank status and update dashboard
201+
try:
202+
tank_status = await self._bluetooth_client.get_tank_status()
203+
except (BleakError, BluetoothConnectionFailed) as exc:
204+
_LOGGER.error("Failed to get tank status from Bluetooth: %s", exc)
205+
raise
206+
207+
# Initialize or update no water widget
208+
no_water = cast(
209+
NoWater,
210+
self.dashboard.config.get(
211+
WidgetType.CM_NO_WATER,
212+
NoWater(allarm=not tank_status),
213+
),
214+
)
215+
no_water.allarm = not tank_status
216+
self.dashboard.config[WidgetType.CM_NO_WATER] = no_water
217+
199218
async def set_power(self, enabled: bool) -> bool:
200219
"""Set the power of the machine.
201220

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "pylamarzocco"
3-
version = "2.2.0"
3+
version = "2.2.1"
44
license = { text = "MIT" }
55
description = "A Python implementation of the La Marzocco API"
66
readme = "README.md"

tests/__snapshots__/test_bluetooth_dashboard.ambr

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
'next_status': None,
2626
'status': 'StandBy',
2727
}),
28+
'CMNoWater': dict({
29+
'allarm': False,
30+
}),
2831
'CMSteamBoilerLevel': dict({
2932
'enabled': False,
3033
'enabled_supported': True,
@@ -75,6 +78,9 @@
7578
'next_status': None,
7679
'status': 'StandBy',
7780
}),
81+
'CMNoWater': dict({
82+
'allarm': False,
83+
}),
7884
'CMSteamBoilerLevel': dict({
7985
'enabled': True,
8086
'enabled_supported': True,

tests/test_bluetooth_dashboard.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
BluetoothMachineCapabilities,
2626
CoffeeBoiler,
2727
MachineStatus,
28+
NoWater,
2829
SteamBoilerLevel,
2930
SteamBoilerTemperature,
3031
)
@@ -131,13 +132,15 @@ async def test_get_dashboard_from_bluetooth(
131132
),
132133
]
133134
)
135+
mock_bluetooth_client.get_tank_status = AsyncMock(return_value=True)
134136

135137
await mock_machine_with_dashboard.get_dashboard_from_bluetooth()
136138

137139
# Verify calls - capabilities should NOT be called automatically anymore
138140
mock_bluetooth_client.get_machine_capabilities.assert_not_called()
139141
mock_bluetooth_client.get_machine_mode.assert_called_once()
140142
mock_bluetooth_client.get_boilers.assert_called_once()
143+
mock_bluetooth_client.get_tank_status.assert_called_once()
141144

142145
# Snapshot test includes model_name, model_code, and config
143146
assert mock_machine_with_dashboard.dashboard.to_dict() == snapshot
@@ -169,6 +172,13 @@ async def test_get_dashboard_from_bluetooth(
169172
not in mock_machine_with_dashboard.dashboard.config
170173
)
171174

175+
# Verify tank status widget
176+
no_water = cast(
177+
NoWater,
178+
mock_machine_with_dashboard.dashboard.config[WidgetType.CM_NO_WATER],
179+
)
180+
assert no_water.allarm is False # Tank status is True, so allarm should be False
181+
172182

173183
async def test_get_dashboard_no_bluetooth(
174184
mock_machine_with_dashboard: LaMarzoccoMachine,
@@ -251,6 +261,7 @@ async def test_get_dashboard_initializes_missing_widgets(
251261
),
252262
]
253263
)
264+
mock_bluetooth_client.get_tank_status = AsyncMock(return_value=True)
254265

255266
# First fetch model info explicitly
256267
await mock_machine_with_dashboard.get_model_info_from_bluetooth()
@@ -317,6 +328,7 @@ async def test_get_dashboard_without_steam_level_support(
317328
),
318329
]
319330
)
331+
mock_bluetooth_client.get_tank_status = AsyncMock(return_value=True)
320332

321333
# First fetch model info explicitly
322334
await mock_machine_with_dashboard.get_model_info_from_bluetooth()
@@ -391,6 +403,7 @@ async def test_get_dashboard_mini_original_temperature_only(
391403
),
392404
]
393405
)
406+
mock_bluetooth_client.get_tank_status = AsyncMock(return_value=True)
394407

395408
# First fetch model info explicitly
396409
await mock_machine_with_dashboard.get_model_info_from_bluetooth()

0 commit comments

Comments
 (0)