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