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