From 75886d7213b92d1bf0b9b302a0ef5ec36145b3e6 Mon Sep 17 00:00:00 2001 From: ollo69 <60491700+ollo69@users.noreply.github.com> Date: Wed, 12 Oct 2022 10:04:48 +0200 Subject: [PATCH] Strip whitespace from Nut "zero" serialno (#80141) --- homeassistant/components/nut/__init__.py | 2 +- tests/components/nut/fixtures/CP1500PFCLCD.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/nut/__init__.py b/homeassistant/components/nut/__init__.py index 27332e50b18..b4110736e55 100644 --- a/homeassistant/components/nut/__init__.py +++ b/homeassistant/components/nut/__init__.py @@ -148,7 +148,7 @@ def _serial_from_status(status: dict[str, str]) -> str | None: """Find the best serialvalue from the status.""" serial = status.get("device.serial") or status.get("ups.serial") if serial and ( - serial.lower() in NUT_FAKE_SERIAL or serial.count("0") == len(serial) + serial.lower() in NUT_FAKE_SERIAL or serial.count("0") == len(serial.strip()) ): return None return serial diff --git a/tests/components/nut/fixtures/CP1500PFCLCD.json b/tests/components/nut/fixtures/CP1500PFCLCD.json index 3a42a01b054..f3121b147ac 100644 --- a/tests/components/nut/fixtures/CP1500PFCLCD.json +++ b/tests/components/nut/fixtures/CP1500PFCLCD.json @@ -5,7 +5,7 @@ "driver.parameter.pollfreq": "30", "ups.beeper.status": "disabled", "input.voltage.nominal": "120", - "device.serial": "000000000000", + "device.serial": "000000000000 ", "ups.timer.shutdown": "-60", "input.voltage": "122.0", "ups.status": "OL",