Connection nodes speak of listener and sender, and of send_queue_size
mqtt and http take websocket's vocabulary: their Mode is LISTENER/SENDER, default names read mqtt_listener_… and http_listener_…, and mqtt's publish_queue_size is send_queue_size. No alias stays behind, so the flow store rewrites the old setting in every published and draft mqtt node when it opens, in the same migration as trigger → debounce. Every mqtt and http setting carries a one-line description for the editor, and the node-types reference uses one wording for direction and says that an http sender publishes a JSON object response on its outputs.
This commit is contained in:
@@ -169,15 +169,16 @@ class FlowStore:
|
||||
self._migrate()
|
||||
|
||||
def _migrate(self) -> None:
|
||||
"""Rewrite node types stored under a name they no longer have.
|
||||
"""Rewrite node types and settings stored under a name they no longer have.
|
||||
|
||||
The node type ``trigger`` became ``debounce`` on 2026-10-15, with no
|
||||
alias left for the old name. Each published and draft document is read
|
||||
as plain JSON and only the ``type`` of a matching node changes, so a
|
||||
field this version does not model survives, and the old document stays
|
||||
in git. The version goes up by one, so an editor still holding the old
|
||||
document gets a conflict on its next save instead of writing the old
|
||||
name back. A store with nothing to rename is left alone.
|
||||
On 2026-10-15 the node type ``trigger`` became ``debounce`` and the mqtt
|
||||
setting ``publish_queue_size`` became ``send_queue_size``, with no alias
|
||||
left for the old names. Each published and draft document is read as
|
||||
plain JSON and only the matching node changes, so a field this version
|
||||
does not model survives, and the old document stays in git. The version
|
||||
goes up by one, so an editor still holding the old document gets a
|
||||
conflict on its next save instead of writing the old name back. A store
|
||||
with nothing to rename is left alone.
|
||||
"""
|
||||
changed = []
|
||||
paths = [*self.root.glob("*/flow.json"), *self.root.glob("*/flow.draft.json")]
|
||||
@@ -185,21 +186,31 @@ class FlowStore:
|
||||
try:
|
||||
data = json.loads(path.read_text())
|
||||
nodes = [n for n in data["nodes"] if n.get("type") == "trigger"]
|
||||
queues = [
|
||||
n["params"]
|
||||
for n in data["nodes"]
|
||||
if n.get("type") == "mqtt"
|
||||
and "publish_queue_size" in (n.get("params") or {})
|
||||
]
|
||||
except Exception:
|
||||
# Unreadable to the engine too, which reports it when it loads.
|
||||
continue
|
||||
if not nodes:
|
||||
if not nodes and not queues:
|
||||
continue
|
||||
for node in nodes:
|
||||
node["type"] = "debounce"
|
||||
for params in queues:
|
||||
params["send_queue_size"] = params.pop("publish_queue_size")
|
||||
data["version"] = data.get("version", 1) + 1
|
||||
path.write_text(json.dumps(data, indent=2, ensure_ascii=False) + "\n")
|
||||
changed.append(f"{path.parent.name}/{path.name}")
|
||||
if changed:
|
||||
logger.warning(
|
||||
"Renamed node type 'trigger' to 'debounce' in %s", ", ".join(changed)
|
||||
"Renamed node type 'trigger' to 'debounce' and mqtt "
|
||||
"'publish_queue_size' to 'send_queue_size' in %s",
|
||||
", ".join(changed),
|
||||
)
|
||||
self._commit("Rename node type 'trigger' to 'debounce'")
|
||||
self._commit("Rename 'trigger' nodes and mqtt 'publish_queue_size'")
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# git
|
||||
|
||||
Reference in New Issue
Block a user