From 562f47147e332edfd3e830f7ba1668f0883f14fc Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Mon, 30 Jun 2025 14:41:42 +0000 Subject: [PATCH] Check badly formatted dhcp addresses in tests --- homeassistant/helpers/service_info/dhcp.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/homeassistant/helpers/service_info/dhcp.py b/homeassistant/helpers/service_info/dhcp.py index d46c7a59004..94441749c65 100644 --- a/homeassistant/helpers/service_info/dhcp.py +++ b/homeassistant/helpers/service_info/dhcp.py @@ -18,3 +18,9 @@ class DhcpServiceInfo(BaseServiceInfo): as a lowercase string without colons. eg. "AA:BB:CC:12:34:56" is stored as "aabbcc123456" """ + + def __post_init__(self) -> None: + """Post-init processing.""" + # Ensure macaddress is always a lowercase string without colons + if self.macaddress != self.macaddress.lower().replace(":", ""): + raise ValueError("macaddress is not correctly formatted")