UPNP sharp tv entity Id already exists

Hi all,

Hoping to get some help/advise

I have a sharp tv which gets automatically detected by UPNP/DLNA-DMR when started, however it works the first time I restart my homeassistant without any issues.

BUT then if I switch off my tv, let it change to unavailable in homeassistant then switch my tv back on, it never works again just stays as unavailable?

I have checked the logs and it seems to show that the entity id already exists so I understand why It won’t add another entity but don’t understand why it won’t change the status of existing entity?

The other problem I have is I can’t setup manual DLNA-dmr in my config.xml file because from what I have checked/found out using a upnp client on my laptop,
every time the tv turns on, the upnp port changes? So I can’t set a static xml config in config.xml?

Is the anything I can do to fix this issue or am I stuck?

2020-03-15 22:59:08 INFO (MainThread) [homeassistant.components.discovery] Found new service: dlna_dmr {'host': '192.168.23.242', 'port': 54388, 'ssdp_description': 'http://192.168.23.242:54388/aw', 'name': 'MySharpTV', 'model_name': 'MStarDMR', 'model_number': '0.0', 'serial': '000000', 'manufacturer': 'MStar', 'udn': 'uuid:305208a4-1dd2-11b2-9607-702ed9393890', 'upnp_device_type': 'urn:schemas-upnp-org:device:MediaRenderer:1'}
2020-03-15 22:59:08 INFO (MainThread) [homeassistant.components.media_player] Setting up media_player.dlna_dmr
2020-03-15 22:59:08 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 425, in _async_add_entity
    raise HomeAssistantError(msg)
homeassistant.exceptions.HomeAssistantError: Entity id already exists: media_player.mysharptv. Platform dlna_dmr does not generate unique IDs

setup a static IP for the device. The IP should not change, if it is, it’s your router. Unless the mac is dynamically changing.

Is the IP changing for this too? Are you hardcoding this device or is it discovered. I can’t tell based on your phrase ‘automatically detected’.

hi,
thanks for the suggestion
but ive already tried setting static ip address on the tv but same issue,
the TV is being detected by the discovery module itself and setting up an entity when homeassistant automatically starts up, but then once the tv is switched off and then switched back on, its found again by discovery but fails to change the existing entity and just decides to create a new one but thats not possible because one already exists?

START UP BIT:

2020-03-15 22:00:54 INFO (MainThread) [homeassistant.components.discovery] Found new service: dlna_dmr {'host': '192.168.23.242', 'port': 53972, 'ssdp_description': 'http://192.168.23.242:53972/aw', 'name': 'MySharpTV', 'model_name': 'MStarDMR', 'model_number': '0.0', 'serial': '000000', 'manufacturer': 'MStar', 'udn': 'uuid:305208a4-1dd2-11b2-9607-702ed9393890', 'upnp_device_type': 'urn:schemas-upnp-org:device:MediaRenderer:1'}
2020-03-15 22:00:54 INFO (SyncWorker_16) [homeassistant.loader] Loaded dlna_dmr from homeassistant.components.dlna_dmr
2020-03-15 22:00:55 INFO (MainThread) [homeassistant.components.media_player] Setting up media_player.dlna_dmr
2020-03-15 22:00:55 INFO (MainThread) [homeassistant.components.dlna_dmr.media_player] UPNP/DLNA event handler listening, url: http://192.168.23.117:8301/notify
2020-03-15 22:00:55 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new media_player.dlna_dmr entity: media_player.mysharptv

AFTER TV IS SWITCHED OFF FOR PERIOD OF TIME THEN SWITCHED BACK ON:

2020-03-15 22:59:08 INFO (MainThread) [homeassistant.components.discovery] Found new service: dlna_dmr {'host': '192.168.23.242', 'port': 54388, 'ssdp_description': 'http://192.168.23.242:54388/aw', 'name': 'MySharpTV', 'model_name': 'MStarDMR', 'model_number': '0.0', 'serial': '000000', 'manufacturer': 'MStar', 'udn': 'uuid:305208a4-1dd2-11b2-9607-702ed9393890', 'upnp_device_type': 'urn:schemas-upnp-org:device:MediaRenderer:1'}
2020-03-15 22:59:08 INFO (MainThread) [homeassistant.components.media_player] Setting up media_player.dlna_dmr
2020-03-15 22:59:08 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 425, in _async_add_entity
    raise HomeAssistantError(msg)
homeassistant.exceptions.HomeAssistantError: Entity id already exists: media_player.mysharptv. Platform dlna_dmr does not generate unique IDs

Setup a static IP and manually configure it instead of discovery and you should be good.

EDIT: To clarify, discovery is your problem.

BUT the UPNP port from the TV where the XML is located seems to change every time i switch the TV off and on, so how can i set it as static???

first start up - http://192.168.23.242:53972/aw
second start up - http://192.168.23.242:54388/aw

You need to make that a static IP. There’s no way that the device is doing that. Your network is. So when turned on, make it static on your router/gateway. The only way that won’t work is if the mac address is changing.

EDIT: Nevermind I just saw the port changing

So, that’s a stupid design. Go into your TV settings and see if you can assign a static port.

again… the tv is already set as a static ip as explained!
i have tried BOTH doing a DHCP static from router and physically setting a static ip on the TV, but same results, every time i switch the tv off and then back on, the ssdp_description has a different port number and never the same?

EDIT: the is no option in the tv to change any ports, and i have checked latest firmware on the tv too

Read my edit

read my edit sorry

Well then, I guess you should write up a issue against the component’s discovery. Because without a static port, you’re kinda screwed.

Is there a way to turn off UPNP on your tv? Maybe if you turn that off other options appear?

i am going to check when i get home, thank you for your help tho!

Forgive the long delay,
I have checked every option I could find on the tv but no luck,
No option to switch ports or even switch off UPNP or dlna,
I will however when I get chance move the tv downstairs next to my router and try using a network cable and see if it makes any difference in case it’s just the built in WiFi that’s maybe the issue?
But still strange how every time I switch it off and in the port number changes and this causes home-assistant to think it’s a new tv even tho the device name hasn’t changed?
The tv model if anybody is interested is Sharp LC-32FI5342KF

seems like you need to write up an issue against the platform.

already done :slight_smile: https://github.com/home-assistant/core/issues/32893

Ok so moved tv downstairs, plugged in cable and it’s still the same issue

Detected ok on first start up of home assistant but then after turn off and back on, get the entity id already exists and the upnp port on the tv has changed to another port, very strange…