From fc70ba1dd8b5cbdbba99cd5341b9097ba91c20e2 Mon Sep 17 00:00:00 2001
From: Oliver Kleinecke <okleinecke@web.de>
Date: Wed, 5 Feb 2025 17:39:30 +0100
Subject: [PATCH] Update __init__.py

---
 esphome/components/mcp4461/output/__init__.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/esphome/components/mcp4461/output/__init__.py b/esphome/components/mcp4461/output/__init__.py
index efa2bafb31..2124d67a55 100644
--- a/esphome/components/mcp4461/output/__init__.py
+++ b/esphome/components/mcp4461/output/__init__.py
@@ -51,4 +51,5 @@ async def to_code(config):
         config[CONF_TERMINAL_W],
     )
     await output.register_output(var, config)
-    cg.add(var.set_initial_value(config[CONF_INITIAL_VALUE]))
+    if CONF_INITIAL_VALUE in config:
+        cg.add(var.set_initial_value(config[CONF_INITIAL_VALUE]))