Fix C1 (switch discovery), C2 (power write_fn), I2 (golden oracle)
C1: SwitchDesc MQTT discovery now emits payload_on/off='On'/'Off', state_on/off='On'/'Off', and a Jinja2 boolean-to-string value_template so HA can correctly interpret and command switch entities. C2: POWER write_fn corrected — path is ['power','vs','0'] segment list (not a single slash-prefixed string), and payload comparison is p == 'On' (not truthiness) so 'Off' can actually be sent. I2: Golden regression oracle strengthened to exact equality for both state_keys and discovery_unique_ids; prior subset-only check allowed over-production to go undetected. Two golden tests now fail revealing stale fixtures (dishwasher: +3 keys; refrigerator: +9 keys) — fixtures intentionally NOT updated, human review required.
This commit is contained in:
1 parent
5906aabd7c
commit
1a76bf6d47
4 files changed
+36
-5
No files matched your search
@@ -204,7 +204,11 @@ def _discovery_payloads(bound, topic_prefix, ha_prefix, device_name, model):
|
||||
cfg['options'] = list(opts) if isinstance(opts, (list, tuple)) else []
|
||||
elif isinstance(d, SwitchDesc):
|
||||
cfg['state_topic'] = state_topic
|
||||
cfg['value_template'] = f"{{{{ value_json.{key} }}}}"
|
||||
cfg['value_template'] = f"{{% if value_json.{key} %}}On{{% else %}}Off{{% endif %}}"
|
||||
cfg['state_on'] = 'On'
|
||||
cfg['state_off'] = 'Off'
|
||||
cfg['payload_on'] = 'On'
|
||||
cfg['payload_off'] = 'Off'
|
||||
cfg['command_topic'] = f"{topic_prefix}/cmd/{key}"
|
||||
elif isinstance(d, ButtonDesc):
|
||||
cfg['command_topic'] = f"{topic_prefix}/cmd/{key}"
|
||||
|
||||
Reference in new issue
Block a user