core: KEF LS50 entity duplicated upon HASS start if the speakers device is offline
The problem
Every time I restart Home Assistant the entity for KEF LS50 speakers gets duplicated if the speakers are turned off at the moment. It works fine if the speakers are on. This is the very first edition of KEF LS50 Wireless that does not support wake-up over ethernet.
What is version of Home Assistant Core has the issue?
core-2021.3.3
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Core
Integration causing the issue
KEF
Link to integration documentation on our website
https://www.home-assistant.io/integrations/kef/
Example YAML snippet
media_player:
- platform: kef
host: 10.0.1.32
type: LSX
name: kef_bedroom
- platform: kef
host: 10.0.1.33
type: LS50
name: kef_living_room
supports_on: false
Anything in the logs that might be useful for us?
No response
In case if the speakers are off (offline) after HASS restart I get two entities media_player.kef_living_room
and media_player.kef_living_room_2
. I also have KEF LSX and those work just fine, I assume that’s because they are always online.

About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 20 (14 by maintainers)
Commits related to this issue
- use IP as unique_id, fixes #47678 The MAC address isn't available when the speaker is offline, which results in two different entities, one with a `unique_id` set to the MAC address and the other set... — committed to basnijholt/home-assistant by basnijholt 3 years ago
- use IP as unique_id, fixes #47678 The MAC address isn't available when the speaker is offline, which results in two different entities, one with a `unique_id` set to the MAC address and the other set... — committed to basnijholt/home-assistant by basnijholt 3 years ago
This is still an issue, just didn’t have the time to investigate yet.
I did also notice this myself now actually.
@mark007 I think the fix was merged and I confirmed at my setup that the duplicated entity is not being created anymore if you restart Home Assistant while KEF speakers are offline. I am at Home Assistant 2021.10.4.
I believe this is because of https://github.com/home-assistant/core/blob/f17a5f0db93d696442d9144e9064089d37e088db/homeassistant/components/kef/media_player.py#L124-L141
where we use the MAC address as
unique_id
. When the speaker is offline, the mac address will return as None.I am testing using the IP as
unique_id
instead locally. If this works well, then I will create a PR that should finally fix this issue.