Skip to content

Commit

Permalink
I use hostnames on my network, this makes ssdp work (#45)
Browse files Browse the repository at this point in the history
Co-authored-by: Anthony Nash <anthonynash@server.home>
  • Loading branch information
nashant and Anthony Nash authored Jul 29, 2020
1 parent b4fcd1e commit 672a6ad
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions custom_components/samsungtv_encrypted/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import wakeonlan
import subprocess
import urllib.request
import ipaddress

from .PySmartCrypto.pysmartcrypto import PySmartCrypto
from bs4 import BeautifulSoup
Expand Down Expand Up @@ -146,9 +147,12 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
_LOGGER.warning("Cannot determine device")
return

try:
ipaddress.ip_address(host)
except:
host = socket.gethostbyname(host)
# Only add a device once, so discovered devices do not override manual config.
ip_addr = socket.gethostbyname(host)
if ip_addr not in known_devices:
if host not in known_devices:
# known_devices.add(ip_addr)
add_entities([SamsungTVDevice(host, port, name, timeout, mac, uuid, token, sessionid, key_power_off, turn_on_action)])
_LOGGER.info("Samsung TV %s:%d added as '%s'", host, port, name)
Expand Down

0 comments on commit 672a6ad

Please sign in to comment.