Skip to content

Commit 40b9765

Browse files
Amit Sethclaude
andcommitted
fix: add default values to optional switch/select templates in HA component
Same fix as bridge — fields like bzr, acec, acpm, acng, acdc, cnv are not present in all device status payloads (model-dependent), causing HA template warnings on every status update. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent ca97074 commit 40b9765

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

custom_components/kpr_miraie_mqtt/coordinator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ def _build_discovery(self, device_id: str, dev: dict) -> list[tuple]:
305305
"object_id": f"{slug}_{key}",
306306
"device": device_block,
307307
"state_topic": status_topic,
308-
"value_template": f"{{{{ value_json.{key} }}}}",
308+
"value_template": f"{{{{ value_json.{key} | default('off') }}}}",
309309
"state_on": "on",
310310
"state_off": "off",
311311
"command_topic": control_topic,
@@ -361,7 +361,7 @@ def _build_discovery(self, device_id: str, dev: dict) -> list[tuple]:
361361
"object_id": f"{slug}_converti",
362362
"device": device_block,
363363
"state_topic": status_topic,
364-
"value_template": "{{ value_json.cnv }}",
364+
"value_template": "{{ value_json.cnv | default('0') }}",
365365
"command_topic": control_topic,
366366
"command_template": '{"cnv":{{ value }},"ki":0,"cnt":"an","sid":"0"}',
367367
"options": ["0", "40", "50", "60", "70", "80", "90", "100", "110"],

0 commit comments

Comments
 (0)