From 1e0a22768a48a39c0bfcafd471972cac3d7df10e Mon Sep 17 00:00:00 2001 From: Josef Zweck <24647999+zweckj@users.noreply.github.com> Date: Sat, 7 Dec 2024 08:27:40 +0100 Subject: [PATCH] add new websocket messages --- docs/websockets.md | 93 +++++++++++++++++++++------------ pylamarzocco/devices/machine.py | 9 +++- pyproject.toml | 2 +- 3 files changed, 68 insertions(+), 36 deletions(-) diff --git a/docs/websockets.md b/docs/websockets.md index c9e460f..576e481 100644 --- a/docs/websockets.md +++ b/docs/websockets.md @@ -7,74 +7,99 @@ ws://IP:8081/api/v1/streaming -H "Authorization: Bearer " ``` # Messages + ## Statistics + ```json [ - { - "MachineStatistics": "{\"groups\":[{\"doses\":[{\"DoseA\":343},{\"DoseB\":0},{\"DoseC\":0},{\"DoseD\":0},{\"ContinuousDose\":0}],\"clean\":0,\"ev_activations\":1012,\"ev_ontime\":11849}],\"tot_doses\":343,\"boilers\":[{\"rsteam_ontime\":25},{\"rcoffee_ontime\":37}],\"tea\":{\"count\":0,\"ev_activation\":0,\"ev_ontime\":0},\"pump_ontime\":11660,\"machine_ontime\":2522,\"refill_ontime\":473,\"count_liter\":0}" - } + { + "MachineStatistics": "{\"groups\":[{\"doses\":[{\"DoseA\":343},{\"DoseB\":0},{\"DoseC\":0},{\"DoseD\":0},{\"ContinuousDose\":0}],\"clean\":0,\"ev_activations\":1012,\"ev_ontime\":11849}],\"tot_doses\":343,\"boilers\":[{\"rsteam_ontime\":25},{\"rcoffee_ontime\":37}],\"tea\":{\"count\":0,\"ev_activation\":0,\"ev_ontime\":0},\"pump_ontime\":11660,\"machine_ontime\":2522,\"refill_ontime\":473,\"count_liter\":0}" + } ] ``` ## SystemInfo + ```json { -    "SystemInfo": "{\"network_interfaces\":[{\"name\":\"wlan0\",\"address\":\"192.168.x.x\",\"mac\":\"\",\"auth\":\"WPA2_WPA3_PSK\",\"channel\":11,\"rssi\":-61}],\"system_ram\":[{\"name\":\"internal\",\"free\":48671,\"allocated\":244116},{\"name\":\"external\",\"free\":4046327,\"allocated\":380152}],\"cpu\":{\"cpu0\":14,\"cpu1\":11},\"connections\":{\"ws\":21,\"ble\":17,\"mqtt\":10,\"wifi\":3},\"up_time\":228801,\"curr_time\":\"2023-07-10 06:03:50\",\"boot_reason\":\"ESP_RST_POWERON\",\"boot_count\":0,\"timezone\":2,\"fs\":{\"total\":4096000,\"used\":16384,\"files\":[{\"path\":\"/storage/auth\",\"size\":175},{\"path\":\"/storage/cert.crt\",\"size\":1224},{\"path\":\"/storage/log.txt\",\"size\":0},{\"path\":\"/storage/private.key\",\"size\":1675}]}}" + "SystemInfo": "{\"network_interfaces\":[{\"name\":\"wlan0\",\"address\":\"192.168.x.x\",\"mac\":\"\",\"auth\":\"WPA2_WPA3_PSK\",\"channel\":11,\"rssi\":-61}],\"system_ram\":[{\"name\":\"internal\",\"free\":48671,\"allocated\":244116},{\"name\":\"external\",\"free\":4046327,\"allocated\":380152}],\"cpu\":{\"cpu0\":14,\"cpu1\":11},\"connections\":{\"ws\":21,\"ble\":17,\"mqtt\":10,\"wifi\":3},\"up_time\":228801,\"curr_time\":\"2023-07-10 06:03:50\",\"boot_reason\":\"ESP_RST_POWERON\",\"boot_count\":0,\"timezone\":2,\"fs\":{\"total\":4096000,\"used\":16384,\"files\":[{\"path\":\"/storage/auth\",\"size\":175},{\"path\":\"/storage/cert.crt\",\"size\":1224},{\"path\":\"/storage/log.txt\",\"size\":0},{\"path\":\"/storage/private.key\",\"size\":1675}]}}" } ``` ## Brewing Snapshot + ```json [ -    { -        "BrewingSnapshotGroup1": "{\"groupConfiguration\":{\"groupNumber\":\"Group1\",\"capabilities\":{\"groupType\":\"AV_Group\",\"boilerId\":\"CoffeeBoiler1\",\"boilerTemperature\":47,\"hasScale\":false,\"hasFlowmeter\":true},\"dose\":{\"doseIndex\":\"DoseA\",\"stopTarget\":0,\"doseType\":\"PulsesType\"},\"doseMode\":{\"brewingType\":\"PulsesType\"}},\"flushInfo\":{\"doseIndex\":\"DoseA\",\"stopReason\":\"Manual\",\"time\":6.7829999923706055,\"stopType\":\"Volumetric\",\"volume\":0}}" -    }, -    { -        "FlushStoppedGroup1DoseIndex": "DoseA" -    }, -    { -        "FlushStoppedGroup1Time": 6.783 -    }, -    { -        "FlushStoppedGroup1Volume": 0 -    } + { + "BrewingSnapshotGroup1": "{\"groupConfiguration\":{\"groupNumber\":\"Group1\",\"capabilities\":{\"groupType\":\"AV_Group\",\"boilerId\":\"CoffeeBoiler1\",\"boilerTemperature\":47,\"hasScale\":false,\"hasFlowmeter\":true},\"dose\":{\"doseIndex\":\"DoseA\",\"stopTarget\":0,\"doseType\":\"PulsesType\"},\"doseMode\":{\"brewingType\":\"PulsesType\"}},\"flushInfo\":{\"doseIndex\":\"DoseA\",\"stopReason\":\"Manual\",\"time\":6.7829999923706055,\"stopType\":\"Volumetric\",\"volume\":0}}" + }, + { + "FlushStoppedGroup1DoseIndex": "DoseA" + }, + { + "FlushStoppedGroup1Time": 6.783 + }, + { + "FlushStoppedGroup1Volume": 0 + } ] ``` ## Brewing Update + ```json [ -    { -        "BrewingUpdateGroup1Time": 6.188 -    }, -    { -        "BrewingUpdateGroup1Ev": true -    }, -    { -        "BrewingUpdateGroup1Volume": 0 -    } + { + "BrewingUpdateGroup1Time": 6.188 + }, + { + "BrewingUpdateGroup1Ev": true + }, + { + "BrewingUpdateGroup1Volume": 0 + } ] ``` ## Brewing stopped + ```json -[{'BrewingStartedGroup1StopType': 'Volume'}, {'BrewingStartedGroup1DoseIndex': 'DoseA'}, {'BrewingStartedGroup1VolumeTarget': 0}] +[ + { "BrewingStartedGroup1StopType": "Volume" }, + { "BrewingStartedGroup1DoseIndex": "DoseA" }, + { "BrewingStartedGroup1VolumeTarget": 0 } +] ``` ## Wake up + ```json [ - { - "WakeUp": "manual" - } + { + "WakeUp": "manual" + } ] ``` -## Sleep +## Sleep + +```json +[ + { + "Sleep": "command" + } +] +``` + +# Flush Snapshot + ```json [ - { - "Sleep": "command" - } + { + "FlushSnapshotGroup1": "{\"groupConfiguration\":{\"groupNumber\":\"Group1\",\"capabilities\":{\"groupType\":\"AV_Group\",\"boilerId\":\"CoffeeBoiler1\",\"boilerTemperature\":97,\"boilerTemperatureAtStart\":97,\"hasScale\":false,\"hasFlowmeter\":true},\"dose\":{\"doseIndex\":\"DoseA\",\"stopTarget\":0,\"doseType\":\"PulsesType\"},\"doseMode\":{\"brewingType\":\"PulsesType\"}},\"flushInfo\":{\"doseIndex\":\"DoseA\",\"stopReason\":\"Manual\",\"time\":4.521,\"stopType\":\"Volumetric\",\"volume\":0}}" + }, + { "FlushStoppedGroup1DoseIndex": "DoseA" }, + { "FlushStoppedGroup1Time": 4.521 }, + { "FlushStoppedGroup1Volume": 0 } ] -``` \ No newline at end of file +``` diff --git a/pylamarzocco/devices/machine.py b/pylamarzocco/devices/machine.py index 95a0a1f..aabdb60 100644 --- a/pylamarzocco/devices/machine.py +++ b/pylamarzocco/devices/machine.py @@ -485,11 +485,18 @@ def _parse_list_message(self, message: list[dict[str, Any]]) -> bool: property_updated = True elif ( - "BrewingStoppedGroup1StopType" in msg or "BrewingSnapshotGroup1" in msg + "BrewingStoppedGroup1StopType" in msg + or "BrewingSnapshotGroup1" in msg + or "FlushSnapshotGroup1" in msg ): self.config.brew_active = False property_updated = True + elif "FlushStoppedGroup1Time" in msg: + self.config.brew_active = False + self.config.brew_active_duration = msg["FlushStoppedGroup1Time"] + property_updated = True + elif "SteamBoilerUpdateSetPoint" in msg: self.config.boilers[BoilerType.STEAM].target_temperature = msg[ "SteamBoilerUpdateSetPoint" diff --git a/pyproject.toml b/pyproject.toml index 1f98183..bb06b8a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "pylamarzocco" -version = "1.3.2" +version = "1.3.3" license = { text = "MIT License" } description = "A Python implementation of the new La Marzocco API" readme = "README.md"