mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 23:27:37 +00:00
Add sensor for brew start time to lamarzocco (#144423)
* Add sensor for brew start time to lamarzocco * pytestmark
This commit is contained in:
parent
f5c67e2fd1
commit
4cc538b5ae
@ -82,6 +82,9 @@
|
|||||||
"steam_boiler_ready_time": {
|
"steam_boiler_ready_time": {
|
||||||
"default": "mdi:av-timer"
|
"default": "mdi:av-timer"
|
||||||
},
|
},
|
||||||
|
"brewing_start_time": {
|
||||||
|
"default": "mdi:clock-start"
|
||||||
|
},
|
||||||
"total_coffees_made": {
|
"total_coffees_made": {
|
||||||
"default": "mdi:coffee"
|
"default": "mdi:coffee"
|
||||||
},
|
},
|
||||||
|
@ -11,6 +11,7 @@ from pylamarzocco.models import (
|
|||||||
BaseWidgetOutput,
|
BaseWidgetOutput,
|
||||||
CoffeeAndFlushCounter,
|
CoffeeAndFlushCounter,
|
||||||
CoffeeBoiler,
|
CoffeeBoiler,
|
||||||
|
MachineStatus,
|
||||||
SteamBoilerLevel,
|
SteamBoilerLevel,
|
||||||
SteamBoilerTemperature,
|
SteamBoilerTemperature,
|
||||||
)
|
)
|
||||||
@ -72,6 +73,18 @@ ENTITIES: tuple[LaMarzoccoSensorEntityDescription, ...] = (
|
|||||||
in (ModelName.LINEA_MICRA, ModelName.LINEA_MINI_R)
|
in (ModelName.LINEA_MICRA, ModelName.LINEA_MINI_R)
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
LaMarzoccoSensorEntityDescription(
|
||||||
|
key="brewing_start_time",
|
||||||
|
translation_key="brewing_start_time",
|
||||||
|
device_class=SensorDeviceClass.TIMESTAMP,
|
||||||
|
value_fn=(
|
||||||
|
lambda config: cast(
|
||||||
|
MachineStatus, config[WidgetType.CM_MACHINE_STATUS]
|
||||||
|
).brewing_start_time
|
||||||
|
),
|
||||||
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
|
available_fn=(lambda coordinator: not coordinator.websocket_terminated),
|
||||||
|
),
|
||||||
LaMarzoccoSensorEntityDescription(
|
LaMarzoccoSensorEntityDescription(
|
||||||
key="steam_boiler_ready_time",
|
key="steam_boiler_ready_time",
|
||||||
translation_key="steam_boiler_ready_time",
|
translation_key="steam_boiler_ready_time",
|
||||||
|
@ -147,6 +147,9 @@
|
|||||||
"steam_boiler_ready_time": {
|
"steam_boiler_ready_time": {
|
||||||
"name": "Steam boiler ready time"
|
"name": "Steam boiler ready time"
|
||||||
},
|
},
|
||||||
|
"brewing_start_time": {
|
||||||
|
"name": "Brewing start time"
|
||||||
|
},
|
||||||
"total_coffees_made": {
|
"total_coffees_made": {
|
||||||
"name": "Total coffees made",
|
"name": "Total coffees made",
|
||||||
"unit_of_measurement": "coffees"
|
"unit_of_measurement": "coffees"
|
||||||
|
@ -128,3 +128,13 @@ def mock_ble_device() -> BLEDevice:
|
|||||||
return BLEDevice(
|
return BLEDevice(
|
||||||
"00:00:00:00:00:00", "GS_GS012345", details={"path": "path"}, rssi=50
|
"00:00:00:00:00:00", "GS_GS012345", details={"path": "path"}, rssi=50
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def mock_websocket_terminated() -> Generator[bool]:
|
||||||
|
"""Mock websocket terminated."""
|
||||||
|
with patch(
|
||||||
|
"homeassistant.components.lamarzocco.coordinator.LaMarzoccoUpdateCoordinator.websocket_terminated",
|
||||||
|
new=False,
|
||||||
|
) as mock_websocket_terminated:
|
||||||
|
yield mock_websocket_terminated
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
"status": "StandBy",
|
"status": "StandBy",
|
||||||
"startTime": 1742857195332
|
"startTime": 1742857195332
|
||||||
},
|
},
|
||||||
"brewingStartTime": null
|
"brewingStartTime": 1746641060000
|
||||||
},
|
},
|
||||||
"tutorialUrl": null
|
"tutorialUrl": null
|
||||||
},
|
},
|
||||||
|
@ -90,7 +90,7 @@
|
|||||||
'BrewingMode',
|
'BrewingMode',
|
||||||
'StandBy',
|
'StandBy',
|
||||||
]),
|
]),
|
||||||
'brewing_start_time': None,
|
'brewing_start_time': '2025-05-07T18:04:20+00:00',
|
||||||
'mode': 'BrewingMode',
|
'mode': 'BrewingMode',
|
||||||
'next_status': dict({
|
'next_status': dict({
|
||||||
'start_time': '2025-03-24T22:59:55.332000+00:00',
|
'start_time': '2025-03-24T22:59:55.332000+00:00',
|
||||||
@ -297,7 +297,7 @@
|
|||||||
'BrewingMode',
|
'BrewingMode',
|
||||||
'StandBy',
|
'StandBy',
|
||||||
]),
|
]),
|
||||||
'brewing_start_time': None,
|
'brewing_start_time': '2025-05-07T18:04:20+00:00',
|
||||||
'mode': 'BrewingMode',
|
'mode': 'BrewingMode',
|
||||||
'next_status': dict({
|
'next_status': dict({
|
||||||
'start_time': '2025-03-24T22:59:55.332000+00:00',
|
'start_time': '2025-03-24T22:59:55.332000+00:00',
|
||||||
|
@ -1,4 +1,52 @@
|
|||||||
# serializer version: 1
|
# serializer version: 1
|
||||||
|
# name: test_sensors[sensor.gs012345_brewing_start_time-entry]
|
||||||
|
EntityRegistryEntrySnapshot({
|
||||||
|
'aliases': set({
|
||||||
|
}),
|
||||||
|
'area_id': None,
|
||||||
|
'capabilities': None,
|
||||||
|
'config_entry_id': <ANY>,
|
||||||
|
'config_subentry_id': <ANY>,
|
||||||
|
'device_class': None,
|
||||||
|
'device_id': <ANY>,
|
||||||
|
'disabled_by': None,
|
||||||
|
'domain': 'sensor',
|
||||||
|
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
|
||||||
|
'entity_id': 'sensor.gs012345_brewing_start_time',
|
||||||
|
'has_entity_name': True,
|
||||||
|
'hidden_by': None,
|
||||||
|
'icon': None,
|
||||||
|
'id': <ANY>,
|
||||||
|
'labels': set({
|
||||||
|
}),
|
||||||
|
'name': None,
|
||||||
|
'options': dict({
|
||||||
|
}),
|
||||||
|
'original_device_class': <SensorDeviceClass.TIMESTAMP: 'timestamp'>,
|
||||||
|
'original_icon': None,
|
||||||
|
'original_name': 'Brewing start time',
|
||||||
|
'platform': 'lamarzocco',
|
||||||
|
'previous_unique_id': None,
|
||||||
|
'supported_features': 0,
|
||||||
|
'translation_key': 'brewing_start_time',
|
||||||
|
'unique_id': 'GS012345_brewing_start_time',
|
||||||
|
'unit_of_measurement': None,
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_sensors[sensor.gs012345_brewing_start_time-state]
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'device_class': 'timestamp',
|
||||||
|
'friendly_name': 'GS012345 Brewing start time',
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'sensor.gs012345_brewing_start_time',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_reported': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': '2025-05-07T18:04:20+00:00',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
# name: test_sensors[sensor.gs012345_coffee_boiler_ready_time-entry]
|
# name: test_sensors[sensor.gs012345_coffee_boiler_ready_time-entry]
|
||||||
EntityRegistryEntrySnapshot({
|
EntityRegistryEntrySnapshot({
|
||||||
'aliases': set({
|
'aliases': set({
|
||||||
|
@ -17,6 +17,8 @@ from . import async_init_integration
|
|||||||
|
|
||||||
from tests.common import MockConfigEntry, async_fire_time_changed, snapshot_platform
|
from tests.common import MockConfigEntry, async_fire_time_changed, snapshot_platform
|
||||||
|
|
||||||
|
pytestmark = pytest.mark.usefixtures("mock_websocket_terminated")
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||||
async def test_binary_sensors(
|
async def test_binary_sensors(
|
||||||
|
@ -14,6 +14,8 @@ from . import async_init_integration
|
|||||||
|
|
||||||
from tests.common import MockConfigEntry, snapshot_platform
|
from tests.common import MockConfigEntry, snapshot_platform
|
||||||
|
|
||||||
|
pytestmark = pytest.mark.usefixtures("mock_websocket_terminated")
|
||||||
|
|
||||||
|
|
||||||
async def test_sensors(
|
async def test_sensors(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user