1
mirror of https://github.com/home-assistant/core synced 2024-07-18 12:02:20 +02:00

Fix config entry reference for Home Assistant Cast user (#49729)

* Fix config entry reference for Home Assistant Cast user

* Simplify config_entry lookup
This commit is contained in:
Erik Montnemery 2021-04-27 11:20:10 +02:00 committed by GitHub
parent b00ccf98f0
commit 96e7ae94f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -53,7 +53,7 @@ from homeassistant.const import (
STATE_PLAYING,
)
from homeassistant.core import HomeAssistant, callback
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.network import NoURLAvailableError, get_url
import homeassistant.util.dt as dt_util
@ -463,8 +463,9 @@ class CastDevice(MediaPlayerEntity):
# Create a signed path.
if media_id[0] == "/":
# Sign URL with Home Assistant Cast User
config_entries = self.hass.config_entries.async_entries(CAST_DOMAIN)
user_id = config_entries[0].data["user_id"]
config_entry_id = self.registry_entry.config_entry_id
config_entry = self.hass.config_entries.async_get_entry(config_entry_id)
user_id = config_entry.data["user_id"]
user = await self.hass.auth.async_get_user(user_id)
if user.refresh_tokens:
refresh_token: RefreshToken = list(user.refresh_tokens.values())[0]