diff --git a/CHANGELOG.md b/CHANGELOG.md index aaf58aa..1f4d1e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,17 @@ ## [Unreleased] +### heishamon 0.8.1 + +Default mode and cleanup reset `Z1_Heat_Request_Temp` to `safe_offset` only +after FTW wrote an offset. Core runs default mode at every start and on +watchdog trips, so an offset the owner set from Home Assistant was put back +to 0 each time, even on a site where FTW never commanded the pump (#233). +A failed reset keeps trying on the next default mode. After a Core crash the +driver no longer knows FTW wrote, so that offset stays; today only the +operator's control on the heating card writes it. Not yet checked on +hardware. + ### easee_cloud 1.4.1 The driver says its session energy is coarse, with `session_wh_coarse`. Easee diff --git a/SUPPORT_STATUS.md b/SUPPORT_STATUS.md index 1574553..5c50b7c 100644 --- a/SUPPORT_STATUS.md +++ b/SUPPORT_STATUS.md @@ -76,8 +76,8 @@ Catalog source is not proof that a target can install or run a driver. | growatt | 2.1.3 | blixt-l1 | not_assessed | — | not_recorded | not_assessed | | hardybarth | 1.0.1 | ftw-core | not_assessed | — | not_recorded | not_assessed | | hardybarth | 1.0.1 | blixt-l1 | not_assessed | — | not_recorded | not_assessed | -| heishamon | 0.8.0 | ftw-core | not_assessed | — | not_recorded | not_assessed | -| heishamon | 0.8.0 | blixt-l1 | not_assessed | — | not_recorded | not_assessed | +| heishamon | 0.8.1 | ftw-core | not_assessed | — | not_recorded | not_assessed | +| heishamon | 0.8.1 | blixt-l1 | not_assessed | — | not_recorded | not_assessed | | hello | 1.1.2 | ftw-core | not_assessed | — | not_recorded | not_assessed | | hello | 1.1.2 | blixt-l1 | not_assessed | — | not_recorded | not_assessed | | home_assistant_vehicle | 0.1.0 | ftw-core | not_assessed | — | not_recorded | not_assessed | diff --git a/devices.yaml b/devices.yaml index 317220b..f758c58 100644 --- a/devices.yaml +++ b/devices.yaml @@ -1021,7 +1021,7 @@ manufacturers: protocols: - protocol: mqtt driver: "heishamon" - version: "0.8.0" + version: "0.8.1" ders: [heatpump] control: true firmware_versions: "" diff --git a/drivers/lua/heishamon.lua b/drivers/lua/heishamon.lua index a0f466e..8914be3 100644 --- a/drivers/lua/heishamon.lua +++ b/drivers/lua/heishamon.lua @@ -8,6 +8,8 @@ -- -- This driver controls Zone 1 heat curve offset (Z1_Heat_Request_Temp) -- in the range -3..+3 °C relative to the configured heat curve. +-- Default mode and cleanup reset the offset to safe_offset only after FTW +-- wrote one; an offset set elsewhere (Home Assistant, the pump) is left alone. -- -- Config example (config.yaml): -- drivers: @@ -39,7 +41,7 @@ DRIVER = { id = "heishamon", name = "Panasonic Aquarea (Heishamon)", manufacturer = "Panasonic", - version = "0.8.0", + version = "0.8.1", protocols = { "mqtt" }, capabilities = { "heatpump" }, description = "Panasonic Aquarea H/J/K/L/M-series heat pump via Heishamon MQTT bridge. Controls Zone 1 heat curve offset (Z1_Heat_Request_Temp) in range -3..+3 °C.", @@ -49,7 +51,7 @@ DRIVER = { verification_status = "experimental", verified_by = { "Rolf (Runneval)" }, verified_at = "2026-06-21", - verification_notes = "Existing metrics and offset control tested on WH-SXC09H3E8 (H-series) with Heishamon Large v4.1.6 on ESP32 on 2026-06-21. The new hp_power_w reading is not hardware-verified; its default topic reports heat-mode input, not total input in cooling or DHW mode.", + verification_notes = "Existing metrics and offset control tested on WH-SXC09H3E8 (H-series) with Heishamon Large v4.1.6 on ESP32 on 2026-06-21. The new hp_power_w reading is not hardware-verified; its default topic reports heat-mode input, not total input in cooling or DHW mode. 0.8.1 resets the offset only after FTW wrote one; that change is not yet checked on hardware.", -- What an operator may command, in terms a host UI can render without -- knowing this driver. The bounds are the defaults below; min_offset and -- max_offset can narrow them in config, and driver_command clamps to @@ -83,6 +85,10 @@ local power_w = nil local last_msg_ts = 0 local last_power_ts = 0 local STALE_AFTER_MS = 60000 +-- True once FTW has sent an offset since this driver started. Default mode +-- and cleanup reset only what FTW wrote, so an offset the owner sets from +-- Home Assistant or the pump survives restarts and watchdog trips. +local ftw_wrote_offset = false -- Config (overridable via config.yaml) local base_topic = "panasonic_heat_pump" @@ -217,6 +223,9 @@ function driver_command(action, _power_w, cmd) host.log("warn", "Heishamon: set_heat_curve_offset missing value in cmd") return false end + -- Mark before publishing: a failed publish may still have reached + -- the broker, and a needless reset is the old, safe behaviour. + ftw_wrote_offset = true return apply_offset(offset) end @@ -224,16 +233,28 @@ function driver_command(action, _power_w, cmd) return false end --- Called by FTW watchdog when control is released or EMS stops. --- Return to safe/neutral offset so the pump runs on its own heat curve. +-- Return the offset FTW wrote to safe_offset, so the pump runs on its own +-- heat curve. If FTW wrote nothing since start, leave the pump alone: the +-- offset belongs to whoever set it. A failed reset keeps the mark so the +-- next default mode tries again. +local function release_offset(reason) + if not ftw_wrote_offset then + host.log("info", "Heishamon: " .. reason .. " — FTW wrote no offset, leaving it as is") + return + end + host.log("info", "Heishamon: " .. reason .. " — resetting offset to " .. tostring(safe_offset)) + if apply_offset(safe_offset) then + ftw_wrote_offset = false + end +end + +-- Called by Core at startup, on watchdog trips and when control is released. function driver_default_mode() - host.log("info", "Heishamon: default_mode — resetting offset to " .. tostring(safe_offset)) - apply_offset(safe_offset) + release_offset("default_mode") end function driver_cleanup() - host.log("info", "Heishamon: cleanup — resetting offset to " .. tostring(safe_offset)) - apply_offset(safe_offset) + release_offset("cleanup") outside_temp = nil outlet_temp = nil inlet_temp = nil diff --git a/drivers/tests/lua_harness/test_heishamon_offset_reset.lua b/drivers/tests/lua_harness/test_heishamon_offset_reset.lua new file mode 100644 index 0000000..a61c84c --- /dev/null +++ b/drivers/tests/lua_harness/test_heishamon_offset_reset.lua @@ -0,0 +1,72 @@ +-- Default mode and cleanup must reset only an offset FTW wrote. An owner +-- who sets Z1_Heat_Request_Temp from Home Assistant keeps it across Core +-- restarts and watchdog trips (srcfl/device-drivers#233). +dofile("drivers/tests/lua_harness/host_mock.lua") + +-- FTW's host.mqtt_publish returns nothing on success and an error string on +-- failure (go/internal/drivers/lua.go). The shared mock returns true, which +-- this driver reads as an error, so record publishes the way the host does. +host.mqtt_publish = function(topic, payload) + table.insert(host._calls, { func = "mqtt_publish", args = { topic, payload } }) + return nil +end + +local SET = "panasonic_heat_pump/set/Z1_Heat_Request_Temp" + +local function publishes() + local out = {} + for _, c in ipairs(host._calls) do + if c.func == "mqtt_publish" and c.args[1] == SET then + table.insert(out, c.args[2]) + end + end + return out +end + +local function fresh_driver(config) + host.reset() + dofile("drivers/lua/heishamon.lua") + driver_init(config or {}) +end + +-- Startup default mode, before FTW sent anything: no write. +fresh_driver() +driver_default_mode() +assert(#publishes() == 0, "startup default mode overwrote an offset FTW never wrote") + +-- Cleanup without a command: no write. +driver_cleanup() +assert(#publishes() == 0, "cleanup overwrote an offset FTW never wrote") + +-- After FTW writes, default mode resets once, then leaves the pump alone. +fresh_driver({ safe_offset = 1 }) +assert(driver_command("set_heat_curve_offset", 0, { value = 3 }) == true, "command failed") +driver_default_mode() +local p = publishes() +assert(#p == 2 and p[1] == "3" and p[2] == "1", "default mode did not reset FTW's offset to safe_offset") +driver_default_mode() +assert(#publishes() == 2, "a second default mode wrote again after the reset") + +-- After FTW writes, cleanup resets. +fresh_driver() +driver_command("set_heat_curve_offset", 0, { offset = -2 }) +driver_cleanup() +p = publishes() +assert(#p == 2 and p[2] == "0", "cleanup did not reset FTW's offset") + +-- A rejected command (no value) writes nothing and arms no reset. +fresh_driver() +assert(driver_command("set_heat_curve_offset", 0, {}) == false, "command without value succeeded") +driver_default_mode() +assert(#publishes() == 0, "a rejected command armed a reset") + +-- A failed reset keeps the mark, so the next default mode tries again. +fresh_driver() +driver_command("set_heat_curve_offset", 0, { value = 2 }) +local real_publish = host.mqtt_publish +host.mqtt_publish = function() return "broker down" end +driver_default_mode() +host.mqtt_publish = real_publish +driver_default_mode() +p = publishes() +assert(#p == 2 and p[2] == "0", "a failed reset was not retried") diff --git a/drivers/tests/test_heishamon_offset_reset.py b/drivers/tests/test_heishamon_offset_reset.py new file mode 100644 index 0000000..6b7bd00 --- /dev/null +++ b/drivers/tests/test_heishamon_offset_reset.py @@ -0,0 +1,18 @@ +"""heishamon resets the heat curve offset only after FTW wrote one.""" + +from pathlib import Path +import subprocess + + +ROOT = Path(__file__).resolve().parents[2] + + +def test_heishamon_default_mode_resets_only_what_ftw_wrote(): + result = subprocess.run( + [str(ROOT / "lua55"), "drivers/tests/lua_harness/test_heishamon_offset_reset.lua"], + cwd=ROOT, + text=True, + capture_output=True, + check=False, + ) + assert result.returncode == 0, result.stdout + result.stderr diff --git a/index.yaml b/index.yaml index 0f09d7f..0fe786c 100644 --- a/index.yaml +++ b/index.yaml @@ -331,15 +331,15 @@ drivers: size_bytes: 2193 sha256: "517e086af899dc511c86b00460cd8ce052a8d4973edee8b018e5824d4b550d6e" - name: "heishamon" - version: "0.8.0" + version: "0.8.1" tier: core protocol: mqtt connectivity: local setup: [bridge] ders: [heatpump] control: true - size_bytes: 9855 - sha256: "5c322f14e58a2b9aad900813bea9438127249ebae2e76a4208cd74536703d7b6" + size_bytes: 10923 + sha256: "1bae5c3d4caa0adc8b42cb5d470b7faff66b1e1c3b456182cdd66728a48b9800" - name: "hello" version: "1.1.2" tier: community diff --git a/manifests/heishamon.yaml b/manifests/heishamon.yaml index 6ac59b8..f26defc 100644 --- a/manifests/heishamon.yaml +++ b/manifests/heishamon.yaml @@ -1,5 +1,5 @@ name: "heishamon" -version: "0.8.0" +version: "0.8.1" tier: core author: "Sourceful Labs AB" protocol: mqtt @@ -16,9 +16,9 @@ tested_devices: notes: "Panasonic Aquarea H/J/K/L/M-series heat pump via Heishamon MQTT bridge. Controls Zone 1 heat curve offset (Z1_Heat_Request_Temp) in range -3..+3 °C." min_driver_version: "0.4.0" min_host_version: "2.0.0" -size_bytes: 9855 +size_bytes: 10923 dkb_id: "heishamon" -sha256: "5c322f14e58a2b9aad900813bea9438127249ebae2e76a4208cd74536703d7b6" +sha256: "1bae5c3d4caa0adc8b42cb5d470b7faff66b1e1c3b456182cdd66728a48b9800" signature: "" bytecode_sha256: "" diff --git a/support-status.json b/support-status.json index 65543b7..c6ee121 100644 --- a/support-status.json +++ b/support-status.json @@ -758,7 +758,7 @@ }, { "catalog_source": true, - "catalog_version": "0.8.0", + "catalog_version": "0.8.1", "driver_id": "heishamon", "targets": { "blixt-l1": {