Skip to content

Commit

Permalink
Fix bravia?
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonsm committed Jun 28, 2024
1 parent f068b90 commit 5659773
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions custom_components/zhibravia/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ async def async_setup(hass, config):


async def bravia_get_mac(hass, host, pin):
from homeassistant.components.braviatv.const import LEGACY_CLIENT_ID, NICKNAME_PREFIX, ATTR_MAC
from bravia_tv import BraviaRC
device = BraviaRC(host)
await hass.async_add_executor_job(device.connect, pin, LEGACY_CLIENT_ID, NICKNAME_PREFIX)
if not await hass.async_add_executor_job(device.is_connected):
return None

info = await hass.async_add_executor_job(device.get_system_info)
from aiohttp import CookieJar
from pybravia import BraviaClient
from homeassistant.components.braviatv.const import ATTR_MAC
from homeassistant.helpers.aiohttp_client import async_create_clientsession
session = async_create_clientsession(hass, cookie_jar=CookieJar(unsafe=True, quote_cookie=False),)
client = BraviaClient(host=host, session=session)
await client.connect(psk=pin)
await client.set_wol_mode(True)
info = await client.get_system_info()
# info = await hass.async_add_executor_job(client.get_system_info)
if not info:
return None
return info[ATTR_MAC]

0 comments on commit 5659773

Please sign in to comment.