Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion homeassistant/components/braviatv/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"domain": "braviatv",
"name": "Sony Bravia TV",
"documentation": "https://www.home-assistant.io/integrations/braviatv",
"requirements": ["bravia-tv==1.0.1", "getmac==0.8.1"],
"requirements": ["bravia-tv==1.0.1"],
"dependencies": ["configurator"],
"codeowners": ["@robbiet480"]
}
21 changes: 7 additions & 14 deletions homeassistant/components/braviatv/media_player.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
"""Support for interface with a Sony Bravia TV."""
import ipaddress
import logging

from bravia_tv import BraviaRC
from getmac import get_mac_address
import voluptuous as vol

from homeassistant.components.media_player import PLATFORM_SCHEMA, MediaPlayerDevice
Expand All @@ -22,6 +20,7 @@
)
from homeassistant.const import CONF_HOST, CONF_NAME, STATE_OFF, STATE_ON
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.device_registry import format_mac
from homeassistant.util.json import load_json, save_json

BRAVIA_CONFIG_FILE = "bravia.conf"
Expand Down Expand Up @@ -94,30 +93,24 @@ def setup_bravia(config, pin, hass, add_entities):
request_configuration(config, hass, add_entities)
return

try:
if ipaddress.ip_address(host).version == 6:
mode = "ip6"
else:
mode = "ip"
except ValueError:
mode = "hostname"
mac = get_mac_address(**{mode: host})

# If we came here and configuring this host, mark as done
if host in _CONFIGURING:
request_id = _CONFIGURING.pop(host)
configurator = hass.components.configurator
configurator.request_done(request_id)
_LOGGER.info("Discovery configuration done")

braviarc = BraviaRC(host)
braviarc.connect(pin, CLIENTID_PREFIX, NICKNAME)
system_info = braviarc.get_system_info()
Comment thread
springstan marked this conversation as resolved.
Outdated
mac = format_mac(system_info["macAddr"])
unique_id = system_info["cid"].lower()

# Save config
save_json(
hass.config.path(BRAVIA_CONFIG_FILE),
{host: {"pin": pin, "host": host, "mac": mac}},
)
braviarc = BraviaRC(host, mac)
braviarc.connect(pin, CLIENTID_PREFIX, NICKNAME)
unique_id = braviarc.get_system_info()["cid"].lower()

add_entities([BraviaTVDevice(braviarc, name, pin, unique_id)])

Expand Down
1 change: 0 additions & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,6 @@ georss_ign_sismologia_client==0.2
# homeassistant.components.qld_bushfire
georss_qld_bushfire_alert_client==0.3

# homeassistant.components.braviatv
# homeassistant.components.huawei_lte
# homeassistant.components.kef
# homeassistant.components.minecraft_server
Expand Down
1 change: 0 additions & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ georss_ign_sismologia_client==0.2
# homeassistant.components.qld_bushfire
georss_qld_bushfire_alert_client==0.3

# homeassistant.components.braviatv
# homeassistant.components.huawei_lte
# homeassistant.components.kef
# homeassistant.components.minecraft_server
Expand Down