Created
September 4, 2020 02:33
-
-
Save raspberrypisig/da9f88874734cb081334fae8fdee0a28 to your computer and use it in GitHub Desktop.
customcomponent-explorer_media
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Example of a custom component exposing a service.""" | |
import asyncio | |
import logging | |
from homeassistant.core import callback | |
# The domain of your component. Should be equal to the name of your component. | |
DOMAIN = "explorer_media" | |
_LOGGER = logging.getLogger(__name__) | |
@asyncio.coroutine | |
def async_setup(hass, config): | |
async def my_service(call): | |
"""My first service.""" | |
_LOGGER.debug('Boo') | |
await hass.services.async_call('media_player','play_media', {'entity_id': 'media_player.rumpus_room_speaker','media_content_id': 'http://192.168.20.99:8002/test/topsecret/orinoco.mp3', 'media_content_type': 'music'}) | |
# Register our service with Home Assistant. | |
hass.services.async_register(DOMAIN, 'first', my_service) | |
"""Setup our skeleton component.""" | |
# States are in the format DOMAIN.OBJECT_ID. | |
hass.states.async_set('explorer_media.status', 'Works!') | |
# Return boolean to indicate that initialization was successfully. | |
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"domain": "explorer_media", | |
"name": "WWW Network Media Explorer", | |
"documentation": "https://example.com", | |
"dependencies": ["media_player"], | |
"codeowners": [], | |
"requirements": [] | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
first: | |
description: First Service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment