Add Bluetooth connection to Melnor devices (#173669)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
jasonjhofmann
2026-06-13 20:27:19 +02:00
committed by GitHub
co-authored by Claude Opus 4.8
parent 88f1cb55d4
commit 34d175e452
3 changed files with 75 additions and 1 deletions
+2 -1
View File
@@ -6,7 +6,7 @@ from melnor_bluetooth.device import Device, Valve
from homeassistant.components.number import EntityDescription
from homeassistant.core import callback
from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.device_registry import CONNECTION_BLUETOOTH, DeviceInfo
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from .const import DOMAIN
@@ -30,6 +30,7 @@ class MelnorBluetoothEntity(CoordinatorEntity[MelnorDataUpdateCoordinator]):
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, self._device.mac)},
connections={(CONNECTION_BLUETOOTH, self._device.mac)},
manufacturer="Melnor",
model=self._device.model,
name=self._device.name,
@@ -0,0 +1,36 @@
# serializer version: 1
# name: test_device_registry
DeviceRegistryEntrySnapshot({
'area_id': None,
'config_entries': <ANY>,
'config_entries_subentries': <ANY>,
'configuration_url': None,
'connections': set({
tuple(
'bluetooth',
'FAKE-ADDRESS-1',
),
}),
'disabled_by': None,
'entry_type': None,
'hw_version': None,
'id': <ANY>,
'identifiers': set({
tuple(
'melnor',
'FAKE-ADDRESS-1',
),
}),
'labels': set({
}),
'manufacturer': 'Melnor',
'model': 'test_model',
'model_id': None,
'name': 'test_melnor',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'sw_version': None,
'via_device_id': None,
})
# ---
+37
View File
@@ -0,0 +1,37 @@
"""Test the Melnor integration setup."""
from syrupy.assertion import SnapshotAssertion
from homeassistant.components.melnor.const import DOMAIN
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr
from .conftest import (
FAKE_ADDRESS_1,
mock_config_entry,
patch_async_ble_device_from_address,
patch_async_register_callback,
patch_melnor_device,
)
async def test_device_registry(
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
snapshot: SnapshotAssertion,
) -> None:
"""Test the device registry entry, including the Bluetooth connection."""
entry = mock_config_entry(hass)
with (
patch_async_ble_device_from_address(),
patch_melnor_device(),
patch_async_register_callback(),
):
assert await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
device_entry = device_registry.async_get_device(
identifiers={(DOMAIN, FAKE_ADDRESS_1)}
)
assert device_entry == snapshot