Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions SUPPORT_STATUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
2 changes: 1 addition & 1 deletion devices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ manufacturers:
protocols:
- protocol: mqtt
driver: "heishamon"
version: "0.8.0"
version: "0.8.1"
ders: [heatpump]
control: true
firmware_versions: ""
Expand Down
37 changes: 29 additions & 8 deletions drivers/lua/heishamon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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.",
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -217,23 +223,38 @@ 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

host.log("debug", "Heishamon: ignoring unsupported action=" .. tostring(action))
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
Expand Down
72 changes: 72 additions & 0 deletions drivers/tests/lua_harness/test_heishamon_offset_reset.lua
Original file line number Diff line number Diff line change
@@ -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")
18 changes: 18 additions & 0 deletions drivers/tests/test_heishamon_offset_reset.py
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions manifests/heishamon.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "heishamon"
version: "0.8.0"
version: "0.8.1"
tier: core
author: "Sourceful Labs AB"
protocol: mqtt
Expand All @@ -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: ""
Expand Down
2 changes: 1 addition & 1 deletion support-status.json
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@
},
{
"catalog_source": true,
"catalog_version": "0.8.0",
"catalog_version": "0.8.1",
"driver_id": "heishamon",
"targets": {
"blixt-l1": {
Expand Down
Loading