From 3fe17fc4d2cbbb5953d69f4fe863651f0042d233 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Wed, 7 Oct 2026 06:45:50 +0200 Subject: [PATCH] Pass the Freebox home node firmware version as a string (#184577) --- homeassistant/components/freebox/entity.py | 4 +++- .../components/freebox/test_binary_sensor.py | 20 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/freebox/entity.py b/homeassistant/components/freebox/entity.py index ddc694014e9e..af6110d846c1 100644 --- a/homeassistant/components/freebox/entity.py +++ b/homeassistant/components/freebox/entity.py @@ -36,7 +36,9 @@ class FreeboxHomeEntity(Entity): self._attr_unique_id += "-" + sub_node["name"].strip() self._available = True - self._firmware = node["props"].get("FwVersion") + # The Freebox reports the firmware version of home nodes as a number + firmware = node["props"].get("FwVersion") + self._firmware = str(firmware) if firmware is not None else None self._manufacturer = "Freebox SAS" self._model = CATEGORY_TO_MODEL.get(node["category"]) diff --git a/tests/components/freebox/test_binary_sensor.py b/tests/components/freebox/test_binary_sensor.py index 593b3cd9c287..1b66870d0647 100644 --- a/tests/components/freebox/test_binary_sensor.py +++ b/tests/components/freebox/test_binary_sensor.py @@ -11,8 +11,10 @@ from homeassistant.components.binary_sensor import ( BinarySensorDeviceClass, ) from homeassistant.components.freebox import SCAN_INTERVAL +from homeassistant.components.freebox.const import DOMAIN from homeassistant.const import ATTR_DEVICE_CLASS from homeassistant.core import HomeAssistant +from homeassistant.helpers import device_registry as dr from .common import setup_platform from .const import DATA_HOME_PIR_GET_VALUE, DATA_STORAGE_GET_RAIDS @@ -89,3 +91,21 @@ async def test_home( assert hass.states.get("binary_sensor.detecteur_cover").state == "on" assert hass.states.get("binary_sensor.ouverture_porte").state == "off" assert hass.states.get("binary_sensor.ouverture_porte_cover").state == "on" + + +@pytest.mark.usefixtures("router") +async def test_home_node_firmware_version( + hass: HomeAssistant, + caplog: pytest.LogCaptureFixture, + device_registry: dr.DeviceRegistry, +) -> None: + """Test the firmware version of a home node is passed as a string.""" + entry = await setup_platform(hass, BINARY_SENSOR_DOMAIN) + + # The PIR detector from the fixture reports its firmware version as a number + device = device_registry.async_get_device_by_identifier( + (DOMAIN, 26), entry.entry_id + ) + assert device is not None + assert device.sw_version == "29871925" + assert "non-string value" not in caplog.text