mirror of
https://github.com/esphome/esphome.git
synced 2026-09-11 23:37:34 +00:00
[climate] Pass codegen-known length for static custom_fan_mode/custom_preset
This commit is contained in:
@@ -515,6 +515,11 @@ async def climate_control_to_code(config, action_id, template_arg, args):
|
||||
if isinstance(value, Lambda):
|
||||
inner = await cg.process_lambda(value, args, return_type=type_)
|
||||
body_lines.append(f"call.{setter}(({inner})({fwd_args}));")
|
||||
elif type_ is cg.std_string:
|
||||
# Static custom strings: emit a flash literal and pass the codegen-known
|
||||
# length to skip the runtime strlen inside set_fan_mode/set_preset.
|
||||
literal = cg.safe_exp(value)
|
||||
body_lines.append(f"call.{setter}({literal}, {len(value)});")
|
||||
else:
|
||||
body_lines.append(f"call.{setter}({cg.safe_exp(value)});")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user