mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +00:00
Add Bluetooth connection to LaMetric (#147342)
This commit is contained in:
parent
fc91047d8d
commit
512449a76d
@ -3,6 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.helpers.device_registry import (
|
||||
CONNECTION_BLUETOOTH,
|
||||
CONNECTION_NETWORK_MAC,
|
||||
DeviceInfo,
|
||||
format_mac,
|
||||
@ -21,10 +22,13 @@ class LaMetricEntity(CoordinatorEntity[LaMetricDataUpdateCoordinator]):
|
||||
def __init__(self, coordinator: LaMetricDataUpdateCoordinator) -> None:
|
||||
"""Initialize the LaMetric entity."""
|
||||
super().__init__(coordinator=coordinator)
|
||||
connections = {(CONNECTION_NETWORK_MAC, format_mac(coordinator.data.wifi.mac))}
|
||||
if coordinator.data.bluetooth is not None:
|
||||
connections.add(
|
||||
(CONNECTION_BLUETOOTH, format_mac(coordinator.data.bluetooth.address))
|
||||
)
|
||||
self._attr_device_info = DeviceInfo(
|
||||
connections={
|
||||
(CONNECTION_NETWORK_MAC, format_mac(coordinator.data.wifi.mac))
|
||||
},
|
||||
connections=connections,
|
||||
identifiers={(DOMAIN, coordinator.data.serial_number)},
|
||||
manufacturer="LaMetric Inc.",
|
||||
model_id=coordinator.data.model,
|
||||
|
@ -12,7 +12,7 @@
|
||||
},
|
||||
"bluetooth": {
|
||||
"active": false,
|
||||
"address": "AA:BB:CC:DD:EE:FF",
|
||||
"address": "AA:BB:CC:DD:EE:EE",
|
||||
"available": true,
|
||||
"discoverable": true,
|
||||
"low_energy": {
|
||||
|
@ -15,7 +15,7 @@
|
||||
}),
|
||||
'bluetooth': dict({
|
||||
'active': False,
|
||||
'address': 'AA:BB:CC:DD:EE:FF',
|
||||
'address': 'AA:BB:CC:DD:EE:EE',
|
||||
'available': True,
|
||||
'discoverable': True,
|
||||
'name': '**REDACTED**',
|
||||
|
@ -44,7 +44,8 @@ async def test_button_app_next(
|
||||
assert device_entry
|
||||
assert device_entry.configuration_url == "https://127.0.0.1/"
|
||||
assert device_entry.connections == {
|
||||
(dr.CONNECTION_NETWORK_MAC, "aa:bb:cc:dd:ee:ff")
|
||||
(dr.CONNECTION_NETWORK_MAC, "aa:bb:cc:dd:ee:ff"),
|
||||
(dr.CONNECTION_BLUETOOTH, "aa:bb:cc:dd:ee:ee"),
|
||||
}
|
||||
assert device_entry.entry_type is None
|
||||
assert device_entry.identifiers == {(DOMAIN, "SA110405124500W00BS9")}
|
||||
@ -91,7 +92,8 @@ async def test_button_app_previous(
|
||||
assert device_entry
|
||||
assert device_entry.configuration_url == "https://127.0.0.1/"
|
||||
assert device_entry.connections == {
|
||||
(dr.CONNECTION_NETWORK_MAC, "aa:bb:cc:dd:ee:ff")
|
||||
(dr.CONNECTION_NETWORK_MAC, "aa:bb:cc:dd:ee:ff"),
|
||||
(dr.CONNECTION_BLUETOOTH, "aa:bb:cc:dd:ee:ee"),
|
||||
}
|
||||
assert device_entry.entry_type is None
|
||||
assert device_entry.identifiers == {(DOMAIN, "SA110405124500W00BS9")}
|
||||
@ -139,7 +141,8 @@ async def test_button_dismiss_current_notification(
|
||||
assert device_entry
|
||||
assert device_entry.configuration_url == "https://127.0.0.1/"
|
||||
assert device_entry.connections == {
|
||||
(dr.CONNECTION_NETWORK_MAC, "aa:bb:cc:dd:ee:ff")
|
||||
(dr.CONNECTION_NETWORK_MAC, "aa:bb:cc:dd:ee:ff"),
|
||||
(dr.CONNECTION_BLUETOOTH, "aa:bb:cc:dd:ee:ee"),
|
||||
}
|
||||
assert device_entry.entry_type is None
|
||||
assert device_entry.identifiers == {(DOMAIN, "SA110405124500W00BS9")}
|
||||
@ -187,7 +190,8 @@ async def test_button_dismiss_all_notifications(
|
||||
assert device_entry
|
||||
assert device_entry.configuration_url == "https://127.0.0.1/"
|
||||
assert device_entry.connections == {
|
||||
(dr.CONNECTION_NETWORK_MAC, "aa:bb:cc:dd:ee:ff")
|
||||
(dr.CONNECTION_NETWORK_MAC, "aa:bb:cc:dd:ee:ff"),
|
||||
(dr.CONNECTION_BLUETOOTH, "aa:bb:cc:dd:ee:ee"),
|
||||
}
|
||||
assert device_entry.entry_type is None
|
||||
assert device_entry.identifiers == {(DOMAIN, "SA110405124500W00BS9")}
|
||||
|
@ -56,7 +56,10 @@ async def test_brightness(
|
||||
device = device_registry.async_get(entry.device_id)
|
||||
assert device
|
||||
assert device.configuration_url == "https://127.0.0.1/"
|
||||
assert device.connections == {(dr.CONNECTION_NETWORK_MAC, "aa:bb:cc:dd:ee:ff")}
|
||||
assert device.connections == {
|
||||
(dr.CONNECTION_NETWORK_MAC, "aa:bb:cc:dd:ee:ff"),
|
||||
(dr.CONNECTION_BLUETOOTH, "aa:bb:cc:dd:ee:ee"),
|
||||
}
|
||||
assert device.entry_type is None
|
||||
assert device.hw_version is None
|
||||
assert device.identifiers == {(DOMAIN, "SA110405124500W00BS9")}
|
||||
@ -105,7 +108,10 @@ async def test_volume(
|
||||
device = device_registry.async_get(entry.device_id)
|
||||
assert device
|
||||
assert device.configuration_url == "https://127.0.0.1/"
|
||||
assert device.connections == {(dr.CONNECTION_NETWORK_MAC, "aa:bb:cc:dd:ee:ff")}
|
||||
assert device.connections == {
|
||||
(dr.CONNECTION_NETWORK_MAC, "aa:bb:cc:dd:ee:ff"),
|
||||
(dr.CONNECTION_BLUETOOTH, "aa:bb:cc:dd:ee:ee"),
|
||||
}
|
||||
assert device.entry_type is None
|
||||
assert device.hw_version is None
|
||||
assert device.identifiers == {(DOMAIN, "SA110405124500W00BS9")}
|
||||
|
@ -49,7 +49,10 @@ async def test_brightness_mode(
|
||||
device = device_registry.async_get(entry.device_id)
|
||||
assert device
|
||||
assert device.configuration_url == "https://127.0.0.1/"
|
||||
assert device.connections == {(dr.CONNECTION_NETWORK_MAC, "aa:bb:cc:dd:ee:ff")}
|
||||
assert device.connections == {
|
||||
(dr.CONNECTION_NETWORK_MAC, "aa:bb:cc:dd:ee:ff"),
|
||||
(dr.CONNECTION_BLUETOOTH, "aa:bb:cc:dd:ee:ee"),
|
||||
}
|
||||
assert device.entry_type is None
|
||||
assert device.hw_version is None
|
||||
assert device.identifiers == {(DOMAIN, "SA110405124500W00BS9")}
|
||||
|
@ -42,7 +42,10 @@ async def test_wifi_signal(
|
||||
device = device_registry.async_get(entry.device_id)
|
||||
assert device
|
||||
assert device.configuration_url == "https://127.0.0.1/"
|
||||
assert device.connections == {(dr.CONNECTION_NETWORK_MAC, "aa:bb:cc:dd:ee:ff")}
|
||||
assert device.connections == {
|
||||
(dr.CONNECTION_NETWORK_MAC, "aa:bb:cc:dd:ee:ff"),
|
||||
(dr.CONNECTION_BLUETOOTH, "aa:bb:cc:dd:ee:ee"),
|
||||
}
|
||||
assert device.entry_type is None
|
||||
assert device.hw_version is None
|
||||
assert device.identifiers == {(DOMAIN, "SA110405124500W00BS9")}
|
||||
|
@ -51,7 +51,10 @@ async def test_bluetooth(
|
||||
device = device_registry.async_get(entry.device_id)
|
||||
assert device
|
||||
assert device.configuration_url == "https://127.0.0.1/"
|
||||
assert device.connections == {(dr.CONNECTION_NETWORK_MAC, "aa:bb:cc:dd:ee:ff")}
|
||||
assert device.connections == {
|
||||
(dr.CONNECTION_NETWORK_MAC, "aa:bb:cc:dd:ee:ff"),
|
||||
(dr.CONNECTION_BLUETOOTH, "aa:bb:cc:dd:ee:ee"),
|
||||
}
|
||||
assert device.entry_type is None
|
||||
assert device.hw_version is None
|
||||
assert device.identifiers == {(DOMAIN, "SA110405124500W00BS9")}
|
||||
|
Loading…
x
Reference in New Issue
Block a user