From 9efbcb2f82cf6e65b56672a90fdab48bdcbc35f3 Mon Sep 17 00:00:00 2001 From: Jordan Harvey Date: Thu, 16 Oct 2025 07:46:29 +0100 Subject: [PATCH] Add model information for probe_plus devices (#154262) --- homeassistant/components/probe_plus/__init__.py | 8 +++++++- homeassistant/components/probe_plus/config_flow.py | 5 +++-- homeassistant/components/probe_plus/entity.py | 2 ++ tests/components/probe_plus/test_config_flow.py | 8 +++----- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/probe_plus/__init__.py b/homeassistant/components/probe_plus/__init__.py index be1faf4a297d..0d29fb86b59d 100644 --- a/homeassistant/components/probe_plus/__init__.py +++ b/homeassistant/components/probe_plus/__init__.py @@ -2,7 +2,7 @@ from __future__ import annotations -from homeassistant.const import Platform +from homeassistant.const import CONF_MODEL, Platform from homeassistant.core import HomeAssistant from .coordinator import ProbePlusConfigEntry, ProbePlusDataUpdateCoordinator @@ -12,6 +12,12 @@ PLATFORMS: list[Platform] = [Platform.SENSOR] async def async_setup_entry(hass: HomeAssistant, entry: ProbePlusConfigEntry) -> bool: """Set up Probe Plus from a config entry.""" + # Perform a migration to ensure the model is added to the config entry schema. + if CONF_MODEL not in entry.data: + # The config entry adds the model number of the device to the start of its title + hass.config_entries.async_update_entry( + entry, data={**entry.data, CONF_MODEL: entry.title.split(" ")[0]} + ) coordinator = ProbePlusDataUpdateCoordinator(hass, entry) await coordinator.async_config_entry_first_refresh() entry.runtime_data = coordinator diff --git a/homeassistant/components/probe_plus/config_flow.py b/homeassistant/components/probe_plus/config_flow.py index 1e9a858e9fca..cb87c348cd44 100644 --- a/homeassistant/components/probe_plus/config_flow.py +++ b/homeassistant/components/probe_plus/config_flow.py @@ -13,7 +13,7 @@ from homeassistant.components.bluetooth import ( async_discovered_service_info, ) from homeassistant.config_entries import ConfigFlow, ConfigFlowResult -from homeassistant.const import CONF_ADDRESS +from homeassistant.const import CONF_ADDRESS, CONF_MODEL from .const import DOMAIN @@ -73,6 +73,7 @@ class ProbeConfigFlow(ConfigFlow, domain=DOMAIN): title=discovery.title, data={ CONF_ADDRESS: discovery.discovery_info.address, + CONF_MODEL: discovery.discovery_info.name, }, ) self._set_confirm_only() @@ -95,7 +96,7 @@ class ProbeConfigFlow(ConfigFlow, domain=DOMAIN): discovery = self._discovered_devices[address] return self.async_create_entry( title=discovery.title, - data=user_input, + data={**user_input, CONF_MODEL: discovery.discovery_info.name}, ) current_addresses = self._async_current_ids() diff --git a/homeassistant/components/probe_plus/entity.py b/homeassistant/components/probe_plus/entity.py index c2c53f5bca4d..a2c3c543d472 100644 --- a/homeassistant/components/probe_plus/entity.py +++ b/homeassistant/components/probe_plus/entity.py @@ -4,6 +4,7 @@ from dataclasses import dataclass from pyprobeplus import ProbePlusDevice +from homeassistant.const import CONF_MODEL from homeassistant.helpers.device_registry import ( CONNECTION_BLUETOOTH, DeviceInfo, @@ -40,6 +41,7 @@ class ProbePlusEntity(CoordinatorEntity[ProbePlusDataUpdateCoordinator]): name=coordinator.device.name, manufacturer="Probe Plus", suggested_area="Kitchen", + model=coordinator.config_entry.data.get(CONF_MODEL), connections={(CONNECTION_BLUETOOTH, coordinator.device.mac)}, ) diff --git a/tests/components/probe_plus/test_config_flow.py b/tests/components/probe_plus/test_config_flow.py index 1d2481443116..cae87f4b9e5a 100644 --- a/tests/components/probe_plus/test_config_flow.py +++ b/tests/components/probe_plus/test_config_flow.py @@ -7,7 +7,7 @@ import pytest from homeassistant.components.probe_plus.const import DOMAIN from homeassistant.config_entries import SOURCE_BLUETOOTH, SOURCE_USER -from homeassistant.const import CONF_ADDRESS +from homeassistant.const import CONF_ADDRESS, CONF_MODEL from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType from homeassistant.helpers.service_info.bluetooth import BluetoothServiceInfo @@ -57,7 +57,7 @@ async def test_user_config_flow_creates_entry( assert result["type"] is FlowResultType.CREATE_ENTRY assert result["result"].unique_id == "aa:bb:cc:dd:ee:ff" assert result["title"] == "FM210 aa:bb:cc:dd:ee:ff" - assert result["data"] == {CONF_ADDRESS: "aa:bb:cc:dd:ee:ff"} + assert result["data"] == {CONF_ADDRESS: "aa:bb:cc:dd:ee:ff", CONF_MODEL: "FM210"} async def test_user_flow_already_configured( @@ -97,9 +97,7 @@ async def test_bluetooth_discovery( assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == "FM210 aa:bb:cc:dd:ee:ff" assert result["result"].unique_id == "aa:bb:cc:dd:ee:ff" - assert result["data"] == { - CONF_ADDRESS: service_info.address, - } + assert result["data"] == {CONF_ADDRESS: service_info.address, CONF_MODEL: "FM210"} async def test_already_configured_bluetooth_discovery(