Skip to content

Commit

Permalink
Use format_mac correctly for acaia (#132062)
Browse files Browse the repository at this point in the history
  • Loading branch information
zweckj authored and frenck committed Dec 2, 2024
1 parent 1e5a592 commit c3c5009
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
10 changes: 5 additions & 5 deletions homeassistant/components/acaia/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async def async_step_user(
errors: dict[str, str] = {}

if user_input is not None:
mac = format_mac(user_input[CONF_ADDRESS])
mac = user_input[CONF_ADDRESS]
try:
is_new_style_scale = await is_new_scale(mac)
except AcaiaDeviceNotFound:
Expand All @@ -53,12 +53,12 @@ async def async_step_user(
except AcaiaUnknownDevice:
return self.async_abort(reason="unsupported_device")
else:
await self.async_set_unique_id(mac)
await self.async_set_unique_id(format_mac(mac))
self._abort_if_unique_id_configured()

if not errors:
return self.async_create_entry(
title=self._discovered_devices[user_input[CONF_ADDRESS]],
title=self._discovered_devices[mac],
data={
CONF_ADDRESS: mac,
CONF_IS_NEW_STYLE_SCALE: is_new_style_scale,
Expand Down Expand Up @@ -99,10 +99,10 @@ async def async_step_bluetooth(
) -> ConfigFlowResult:
"""Handle a discovered Bluetooth device."""

self._discovered[CONF_ADDRESS] = mac = format_mac(discovery_info.address)
self._discovered[CONF_ADDRESS] = discovery_info.address
self._discovered[CONF_NAME] = discovery_info.name

await self.async_set_unique_id(mac)
await self.async_set_unique_id(format_mac(discovery_info.address))
self._abort_if_unique_id_configured()

try:
Expand Down
7 changes: 4 additions & 3 deletions homeassistant/components/acaia/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from dataclasses import dataclass

from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.device_registry import DeviceInfo, format_mac
from homeassistant.helpers.entity import EntityDescription
from homeassistant.helpers.update_coordinator import CoordinatorEntity

Expand All @@ -25,10 +25,11 @@ def __init__(
super().__init__(coordinator)
self.entity_description = entity_description
self._scale = coordinator.scale
self._attr_unique_id = f"{self._scale.mac}_{entity_description.key}"
formatted_mac = format_mac(self._scale.mac)
self._attr_unique_id = f"{formatted_mac}_{entity_description.key}"

self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, self._scale.mac)},
identifiers={(DOMAIN, formatted_mac)},
manufacturer="Acaia",
model=self._scale.model,
suggested_area="Kitchen",
Expand Down

0 comments on commit c3c5009

Please sign in to comment.