2013-12-11 08:07:30 +00:00
|
|
|
"""
|
|
|
|
homeassistant.components.browser
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Provides functionality to launch a webbrowser on the host machine.
|
|
|
|
"""
|
|
|
|
|
2014-01-05 01:55:05 +00:00
|
|
|
DOMAIN = "browser"
|
2014-08-13 12:28:45 +00:00
|
|
|
DEPENDENCIES = []
|
2013-12-11 08:07:30 +00:00
|
|
|
|
|
|
|
SERVICE_BROWSE_URL = "browse_url"
|
|
|
|
|
|
|
|
|
2014-08-13 12:28:45 +00:00
|
|
|
def setup(hass, config):
|
2013-12-11 08:07:30 +00:00
|
|
|
""" Listen for browse_url events and open
|
|
|
|
the url in the default webbrowser. """
|
|
|
|
|
|
|
|
import webbrowser
|
|
|
|
|
2014-04-24 07:40:45 +00:00
|
|
|
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')))
|
2013-12-11 08:07:30 +00:00
|
|
|
|
|
|
|
return True
|