mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
PyChromecast properly integrated now.
This commit is contained in:
parent
9cfcf43202
commit
df53b05423
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[submodule "homeassistant/packages/pychromecast"]
|
||||||
|
path = homeassistant/packages/pychromecast
|
||||||
|
url = https://github.com/balloob/pychromecast.git
|
@ -14,7 +14,7 @@ Installation instructions
|
|||||||
-------------------------
|
-------------------------
|
||||||
|
|
||||||
* install python modules [python-dateutil](http://labix.org/python-dateutil), [PyEphem](http://rhodesmill.org/pyephem/), [Requests](http://python-requests.org) and [PHue](https://github.com/studioimaginaire/phue): `pip install python-dateutil pyephem requests phue`
|
* install python modules [python-dateutil](http://labix.org/python-dateutil), [PyEphem](http://rhodesmill.org/pyephem/), [Requests](http://python-requests.org) and [PHue](https://github.com/studioimaginaire/phue): `pip install python-dateutil pyephem requests phue`
|
||||||
* Clone the repository `git clone https://github.com/balloob/home-assistant.git`.
|
* Clone the repository and pull in the submodules `git clone --recursive https://github.com/balloob/home-assistant.git`
|
||||||
* Copy home-assistant.conf.default to home-assistant.conf and adjust the config values to match your setup.
|
* Copy home-assistant.conf.default to home-assistant.conf and adjust the config values to match your setup.
|
||||||
* For Tomato you will have to not only setup your host, username and password but also a http_id. The http_id can be retrieved by going to the admin console of your router, view the source of any of the pages and search for `http_id`.
|
* For Tomato you will have to not only setup your host, username and password but also a http_id. The http_id can be retrieved by going to the admin console of your router, view the source of any of the pages and search for `http_id`.
|
||||||
* Setup PHue by running `python -m phue --host HUE_BRIDGE_IP_ADDRESS` from the commandline.
|
* Setup PHue by running `python -m phue --host HUE_BRIDGE_IP_ADDRESS` from the commandline.
|
||||||
|
@ -16,6 +16,8 @@ import dateutil.parser
|
|||||||
from phue import Bridge
|
from phue import Bridge
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
from .packages.pychromecast import pychromecast
|
||||||
|
|
||||||
from . import track_state_change
|
from . import track_state_change
|
||||||
from .util import sanitize_filename
|
from .util import sanitize_filename
|
||||||
from .observers import (STATE_CATEGORY_SUN, SUN_STATE_BELOW_HORIZON, SUN_STATE_ABOVE_HORIZON,
|
from .observers import (STATE_CATEGORY_SUN, SUN_STATE_BELOW_HORIZON, SUN_STATE_ABOVE_HORIZON,
|
||||||
@ -28,7 +30,7 @@ HUE_MAX_TRANSITION_TIME = 9000
|
|||||||
|
|
||||||
EVENT_DOWNLOAD_FILE = "download_file"
|
EVENT_DOWNLOAD_FILE = "download_file"
|
||||||
EVENT_BROWSE_URL = "browse_url"
|
EVENT_BROWSE_URL = "browse_url"
|
||||||
|
EVENT_CHROMECAST_YOUTUBE_VIDEO = "chromecast.play_youtube_video"
|
||||||
EVENT_TURN_LIGHT_ON = "turn_light_on"
|
EVENT_TURN_LIGHT_ON = "turn_light_on"
|
||||||
EVENT_TURN_LIGHT_OFF = "turn_light_off"
|
EVENT_TURN_LIGHT_OFF = "turn_light_off"
|
||||||
|
|
||||||
@ -244,3 +246,9 @@ def setup_file_downloader(eventbus, download_path):
|
|||||||
def setup_webbrowser(eventbus):
|
def setup_webbrowser(eventbus):
|
||||||
""" Listen for browse_url events and opens the url in the default webbrowser. """
|
""" Listen for browse_url events and opens the url in the default webbrowser. """
|
||||||
eventbus.listen(EVENT_BROWSE_URL, lambda event: webbrowser.open(event.data['url']))
|
eventbus.listen(EVENT_BROWSE_URL, lambda event: webbrowser.open(event.data['url']))
|
||||||
|
|
||||||
|
def setup_chromecast(eventbus, host):
|
||||||
|
""" Listen for chromecast events. """
|
||||||
|
eventbus.listen("start_fireplace", lambda event: pychromecast.play_youtube_video(host, "eyU3bRy2x44"))
|
||||||
|
eventbus.listen("start_epic_sax", lambda event: pychromecast.play_youtube_video(host, "kxopViU98Xo"))
|
||||||
|
eventbus.listen(EVENT_CHROMECAST_YOUTUBE_VIDEO, lambda event: pychromecast.play_youtube_video(host, event.data['video']))
|
||||||
|
0
homeassistant/packages/__init__.py
Normal file
0
homeassistant/packages/__init__.py
Normal file
1
homeassistant/packages/pychromecast
Submodule
1
homeassistant/packages/pychromecast
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 6b8999574c8f70cb28686ef8d19f1e4bf0c8c056
|
25
start.py
25
start.py
@ -1,13 +1,13 @@
|
|||||||
|
#!/usr/bin/python2
|
||||||
|
""" Starts home assistant with all possible functionality. """
|
||||||
|
|
||||||
from ConfigParser import SafeConfigParser
|
from ConfigParser import SafeConfigParser
|
||||||
|
|
||||||
from homeassistant import StateMachine, EventBus, start_home_assistant
|
from homeassistant import StateMachine, EventBus, start_home_assistant
|
||||||
|
|
||||||
from homeassistant import observers
|
from homeassistant import observers
|
||||||
from homeassistant import actors
|
from homeassistant import actors
|
||||||
from homeassistant.httpinterface import HTTPInterface
|
from homeassistant.httpinterface import HTTPInterface
|
||||||
|
|
||||||
from lib.pychromecast import play_youtube_video
|
|
||||||
|
|
||||||
# Read config
|
# Read config
|
||||||
config = SafeConfigParser()
|
config = SafeConfigParser()
|
||||||
config.read("home-assistant.conf")
|
config.read("home-assistant.conf")
|
||||||
@ -17,21 +17,22 @@ eventbus = EventBus()
|
|||||||
statemachine = StateMachine(eventbus)
|
statemachine = StateMachine(eventbus)
|
||||||
|
|
||||||
# Init observers
|
# Init observers
|
||||||
tomato = observers.TomatoDeviceScanner(config.get('tomato','host'), config.get('tomato','username'),
|
tomato = observers.TomatoDeviceScanner(config.get('tomato','host'),
|
||||||
config.get('tomato','password'), config.get('tomato','http_id'))
|
config.get('tomato','username'),
|
||||||
|
config.get('tomato','password'),
|
||||||
|
config.get('tomato','http_id'))
|
||||||
|
|
||||||
devicetracker = observers.DeviceTracker(eventbus, statemachine, tomato)
|
devicetracker = observers.DeviceTracker(eventbus, statemachine, tomato)
|
||||||
|
|
||||||
observers.track_sun(eventbus, statemachine, config.get("common","latitude"), config.get("common","longitude"))
|
observers.track_sun(eventbus, statemachine,
|
||||||
|
config.get("common","latitude"),
|
||||||
|
config.get("common","longitude"))
|
||||||
|
|
||||||
# Init actors
|
# Init actors
|
||||||
actors.LightTrigger(eventbus, statemachine, devicetracker, actors.HueLightControl())
|
actors.LightTrigger(eventbus, statemachine,
|
||||||
|
devicetracker, actors.HueLightControl())
|
||||||
# If a chromecast is specified, add some chromecast specific event triggers
|
|
||||||
if config.has_option("chromecast", "host"):
|
|
||||||
eventbus.listen("start_fireplace", lambda event: play_youtube_video(config.get("chromecast","host"), "eyU3bRy2x44"))
|
|
||||||
eventbus.listen("start_epic_sax", lambda event: play_youtube_video(config.get("chromecast","host"), "kxopViU98Xo"))
|
|
||||||
|
|
||||||
|
actors.setup_chromecast(eventbus, config.get("chromecast", "host"))
|
||||||
actors.setup_file_downloader(eventbus, "downloads")
|
actors.setup_file_downloader(eventbus, "downloads")
|
||||||
actors.setup_webbrowser(eventbus)
|
actors.setup_webbrowser(eventbus)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user