core/homeassistant/components/browser.py

27 lines
637 B
Python
Raw Normal View History

"""
homeassistant.components.browser
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Provides functionality to launch a webbrowser on the host machine.
"""
DOMAIN = "browser"
DEPENDENCIES = []
SERVICE_BROWSE_URL = "browse_url"
def setup(hass, config):
""" Listen for browse_url events and open
the url in the default webbrowser. """
import webbrowser
hass.services.register(DOMAIN, SERVICE_BROWSE_URL,
lambda service:
webbrowser.open(
2014-11-08 21:57:08 +00:00
service.data.get(
'url', 'https://www.google.com')))
return True