Skip to content

Commit

Permalink
Fix entity_id param parsing #25
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Dec 8, 2024
1 parent 997831a commit cf85305
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions custom_components/dash_cast/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import voluptuous as vol
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.core import ServiceCall, HomeAssistant
Expand All @@ -8,19 +9,21 @@

DOMAIN = "dash_cast"

CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN)
LOAD_URL_SCHEMA = cv.make_entity_service_schema(
{
vol.Required("url"): cv.string,
vol.Optional("force", default=False): cv.boolean,
vol.Optional("reload_seconds", default=0): cv.positive_int,
}
)


async def async_setup(hass: HomeAssistant, config: dict) -> bool:
dashs = {}

async def play_media(call: ServiceCall):
entity_ids = call.data.get(ATTR_ENTITY_ID)
kwargs = {
k: v
for k, v in call.data.items()
if k in ("url", "force", "reload_seconds")
}
kwargs = dict(call.data)
entity_ids = kwargs.pop(ATTR_ENTITY_ID)

for entity in hass.data[DATA_INSTANCES]["media_player"].entities:
if entity.entity_id not in entity_ids:
Expand All @@ -37,7 +40,7 @@ async def play_media(call: ServiceCall):

dash.load_url(**kwargs)

hass.services.async_register(DOMAIN, "load_url", play_media)
hass.services.async_register(DOMAIN, "load_url", play_media, LOAD_URL_SCHEMA)

return True

Expand Down

0 comments on commit cf85305

Please sign in to comment.