[
  {
    "path": ".github/workflows/hacs.yml",
    "content": "name: HACS validation\n\non:\n  push:\n  pull_request:\n\njobs:\n  hacs:\n    runs-on: \"ubuntu-latest\"\n    steps:\n      - uses: \"actions/checkout@v2\"\n      - uses: \"hacs/action@main\"\n        with: { category: \"integration\", ignore: \"brands\" }\n  hassfest:\n    runs-on: \"ubuntu-latest\"\n    steps:\n      - uses: \"actions/checkout@v3\"\n      - uses: \"home-assistant/actions/hassfest@master\"\n"
  },
  {
    "path": ".gitignore",
    "content": "__pycache__/\n.idea/\n.homeassistant/\n"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2020 AlexxIT\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# DashCast for Home Assistant\n\n[![hacs_badge](https://img.shields.io/badge/HACS-Custom-orange.svg)](https://github.com/custom-components/hacs)\n\nThis [Home Assistant](https://www.home-assistant.io/) service allows you to cast a website to a Google [Chromecast](https://en.wikipedia.org/wiki/Chromecast).\n\n**PS.** All thanks to [@stestagg](https://github.com/stestagg), developer of [DashCast](https://stestagg.github.io/dashcast/) app for Google Chromecast.\n\n## Installation\n\n**Method 1.** [HACS](https://hacs.xyz/) custom repo:\n\n> HACS > Integrations > 3 dots (upper top corner) > Custom repositories > URL: `AlexxIT/DashCast`, Category: Integration > Add > wait > DashCast > Install\n\n**Method 2.** Manually copy `dash_cast` folder from [latest release](https://github.com/AlexxIT/DashCast/releases/latest) to `/config/custom_components` folder.\n\n## Configuration\n\n**Method 1.** GUI:\n\n> Configuration > Integrations > Add Integration > **DashCast**\n\nIf the integration is not in the list, you need to clear the browser cache.\n\n**Method 2.** YAML:\n\n```yaml\ndash_cast:\n```\n\n## Usage\n\nNew service `dash_cast.load_url`:\n\n```yaml\nservice: dash_cast.load_url\ndata:\n  entity_id: media_player.hall_tv\n  url: https://www.home-assistant.io/\n  force: true  # use this option if iframe blocking is enabled on the site\n  reload_seconds: 60  # reload page every X seconds\n```\n"
  },
  {
    "path": "custom_components/dash_cast/__init__.py",
    "content": "import voluptuous as vol\nfrom homeassistant.config_entries import ConfigEntry\nfrom homeassistant.const import ATTR_ENTITY_ID\nfrom homeassistant.core import ServiceCall, HomeAssistant\nfrom homeassistant.helpers import config_validation as cv\nfrom homeassistant.helpers.entity_component import DATA_INSTANCES\nfrom pychromecast import Chromecast\nfrom pychromecast.controllers.dashcast import DashCastController\n\nDOMAIN = \"dash_cast\"\n\nLOAD_URL_SCHEMA = cv.make_entity_service_schema(\n    {\n        vol.Required(\"url\"): cv.string,\n        vol.Optional(\"force\", default=False): cv.boolean,\n        vol.Optional(\"reload_seconds\", default=0): cv.positive_int,\n    }\n)\n\n\nasync def async_setup(hass: HomeAssistant, config: dict) -> bool:\n    dashs = {}\n\n    async def play_media(call: ServiceCall):\n        kwargs = dict(call.data)\n        entity_ids = kwargs.pop(ATTR_ENTITY_ID)\n\n        for entity in hass.data[DATA_INSTANCES][\"media_player\"].entities:\n            if entity.entity_id not in entity_ids:\n                continue\n\n            dash: DashCastController = dashs.get(entity.entity_id)\n            if not dash:\n                chromecast: Chromecast = getattr(entity, \"_chromecast\")\n                if chromecast:\n                    dashs[entity.entity_id] = dash = DashCastController()\n                    chromecast.register_handler(dash)\n                else:\n                    return\n\n            dash.load_url(**kwargs)\n\n    hass.services.async_register(DOMAIN, \"load_url\", play_media, LOAD_URL_SCHEMA)\n\n    return True\n\n\nasync def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:\n    return True\n"
  },
  {
    "path": "custom_components/dash_cast/config_flow.py",
    "content": "from homeassistant.config_entries import ConfigFlow\n\nfrom . import DOMAIN\n\n\nclass ConfigFlowHandler(ConfigFlow, domain=DOMAIN):\n    async def async_step_import(self, user_input=None):\n        return await self.async_step_user()\n\n    async def async_step_user(self, user_input=None):\n        if self._async_current_entries():\n            return self.async_abort(reason=\"single_instance_allowed\")\n        return self.async_create_entry(title=\"DashCast\", data={})\n"
  },
  {
    "path": "custom_components/dash_cast/manifest.json",
    "content": "{\n  \"domain\": \"dash_cast\",\n  \"name\": \"DashCast\",\n  \"codeowners\": [\n    \"@AlexxIT\"\n  ],\n  \"config_flow\": true,\n  \"dependencies\": [\n    \"cast\"\n  ],\n  \"documentation\": \"https://github.com/AlexxIT/DashCast\",\n  \"iot_class\": \"calculated\",\n  \"issue_tracker\": \"https://github.com/AlexxIT/DashCast/issues\",\n  \"requirements\": [],\n  \"version\": \"1.1.1\"\n}\n"
  },
  {
    "path": "custom_components/dash_cast/services.yaml",
    "content": "load_url:\n  fields:\n    entity_id:\n      required: true\n      selector:\n        entity:\n          integration: cast\n          domain: media_player\n    url:\n      example: https://www.home-assistant.io/\n      required: true\n      selector:\n        text:\n    force:\n      default: false\n      selector:\n        boolean:\n    reload_seconds:\n      default: 0\n      selector:\n        number:\n          min: 0\n          max: 10000\n"
  },
  {
    "path": "custom_components/dash_cast/translations/en.json",
    "content": "{\n  \"services\": {\n    \"load_url\": {\n      \"name\": \"DashCast\",\n      \"description\": \"Send websites to Chromecasts\",\n      \"fields\": {\n        \"entity_id\": {\n          \"name\": \"Entity\",\n          \"description\": \"Media player from Google Cast integration\"\n        },\n        \"url\": {\n          \"name\": \"URL\",\n          \"description\": \"Webpage URL\"\n        },\n        \"force\": {\n          \"name\": \"Force\",\n          \"description\": \"Use this option if iframe blocking is enabled on the site\"\n        },\n        \"reload_seconds\": {\n          \"name\": \"Reload seconds\",\n          \"description\": \"Reload page every X seconds\"\n        }\n      }\n    }\n  }\n}"
  },
  {
    "path": "hacs.json",
    "content": "{\n    \"name\": \"DashCast\",\n    \"render_readme\": true,\n    \"homeassistant\": \"2023.2.0\"\n}"
  }
]