diff --git a/.gitmodules b/.gitmodules index ca0b1f024b8..174bba680f0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,9 +10,6 @@ [submodule "homeassistant/external/noop"] path = homeassistant/external/noop url = https://github.com/balloob/noop.git -[submodule "homeassistant/components/frontend/www_static/polymer/home-assistant-js"] - path = homeassistant/components/frontend/www_static/polymer/home-assistant-js - url = https://github.com/balloob/home-assistant-js.git [submodule "homeassistant/external/vera"] path = homeassistant/external/vera url = https://github.com/jamespcole/home-assistant-vera-api.git @@ -22,3 +19,6 @@ [submodule "homeassistant/external/pymysensors"] path = homeassistant/external/pymysensors url = https://github.com/theolind/pymysensors +[submodule "homeassistant/components/frontend/www_static/home-assistant-polymer"] + path = homeassistant/components/frontend/www_static/home-assistant-polymer + url = https://github.com/balloob/home-assistant-polymer.git diff --git a/homeassistant/__main__.py b/homeassistant/__main__.py index 6f937d6916e..2514b35587f 100644 --- a/homeassistant/__main__.py +++ b/homeassistant/__main__.py @@ -5,6 +5,7 @@ import sys import os import argparse import subprocess +import importlib DEPENDENCIES = ['requests>=2.0', 'pyyaml>=3.11', 'pytz>=2015.2'] IS_VIRTUAL = (getattr(sys, 'base_prefix', sys.prefix) != sys.prefix or @@ -20,6 +21,16 @@ def validate_python(): sys.exit() +def ensure_pip(): + """ Validate pip is installed so we can install packages on demand. """ + if importlib.find_loader('pip') is None: + print("Your Python installation did not bundle 'pip'") + print("Home Assistant requires 'pip' to be installed.") + print("Please install pip: " + "https://pip.pypa.io/en/latest/installing.html") + sys.exit() + + # Copy of homeassistant.util.package because we can't import yet def install_package(package): """Install a package on PyPi. Accepts pip compatible package strings. @@ -35,6 +46,8 @@ def install_package(package): def validate_dependencies(): """ Validate all dependencies that HA uses. """ + ensure_pip() + print("Validating dependencies...") import_fail = False @@ -123,6 +136,9 @@ def main(): validate_python() validate_dependencies() + # Windows needs this to pick up new modules + importlib.invalidate_caches() + bootstrap = ensure_path_and_load_bootstrap() validate_git_submodules() @@ -133,11 +149,10 @@ def main(): config_path = ensure_config_path(config_dir) if args.demo_mode: - from homeassistant.components import http, demo + from homeassistant.components import frontend, demo - # Demo mode only requires http and demo components. hass = bootstrap.from_config_dict({ - http.DOMAIN: {}, + frontend.DOMAIN: {}, demo.DOMAIN: {} }) else: diff --git a/homeassistant/components/frontend/__init__.py b/homeassistant/components/frontend/__init__.py index 2892e278c5c..902b14e38b3 100644 --- a/homeassistant/components/frontend/__init__.py +++ b/homeassistant/components/frontend/__init__.py @@ -55,7 +55,7 @@ def _handle_get_root(handler, path_match, data): handler.end_headers() if handler.server.development: - app_url = "polymer/home-assistant.html" + app_url = "home-assistant-polymer/src/home-assistant.html" else: app_url = "frontend-{}.html".format(version.VERSION) diff --git a/homeassistant/components/frontend/version.py b/homeassistant/components/frontend/version.py index 0c1938ae74d..4a67ed0fc0e 100644 --- a/homeassistant/components/frontend/version.py +++ b/homeassistant/components/frontend/version.py @@ -1,2 +1,2 @@ """ DO NOT MODIFY. Auto-generated by build_frontend script """ -VERSION = "85f0078ea394a12dd95395799e345c83" +VERSION = "4f94fd4404583fbf27cc899c024d26ff" diff --git a/homeassistant/components/frontend/www_static/frontend.html b/homeassistant/components/frontend/www_static/frontend.html index 1c0506bd83c..023347483cb 100644 --- a/homeassistant/components/frontend/www_static/frontend.html +++ b/homeassistant/components/frontend/www_static/frontend.html @@ -1,5964 +1,6 @@ - - - - - - - - - - - - - - - - - - - + @-webkit-keyframes ha-spin { + 0% { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + 100% { + -webkit-transform: rotate(359deg); + transform: rotate(359deg); + } + } + @keyframes ha-spin { + 0% { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + 100% { + -webkit-transform: rotate(359deg); + transform: rotate(359deg); + } + } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + } \ No newline at end of file diff --git a/homeassistant/components/frontend/www_static/home-assistant-polymer b/homeassistant/components/frontend/www_static/home-assistant-polymer new file mode 160000 index 00000000000..576c04efb49 --- /dev/null +++ b/homeassistant/components/frontend/www_static/home-assistant-polymer @@ -0,0 +1 @@ +Subproject commit 576c04efb49a8a5f7f35734458ffc93f874dd68d diff --git a/homeassistant/components/frontend/www_static/polymer/bower.json b/homeassistant/components/frontend/www_static/polymer/bower.json deleted file mode 100644 index 093fed11a46..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/bower.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "name": "Home Assistant", - "version": "0.1.0", - "authors": [ - "Paulus Schoutsen " - ], - "main": "splash-login.html", - "license": "MIT", - "private": true, - "ignore": [ - "bower_components" - ], - "devDependencies": { - "polymer": "Polymer/polymer#^1.0.0", - "webcomponentsjs": "Polymer/webcomponentsjs#^0.7", - "paper-header-panel": "PolymerElements/paper-header-panel#^1.0.0", - "paper-toolbar": "PolymerElements/paper-toolbar#^1.0.0", - "paper-menu": "PolymerElements/paper-menu#^1.0.0", - "iron-input": "PolymerElements/iron-input#^1.0.0", - "iron-icons": "PolymerElements/iron-icons#^1.0.0", - "iron-image": "PolymerElements/iron-image#^1.0.0", - "paper-toast": "PolymerElements/paper-toast#^1.0.0", - "paper-dialog": "PolymerElements/paper-dialog#^1.0.0", - "paper-dialog-scrollable": "polymerelements/paper-dialog-scrollable#^1.0.0", - "paper-spinner": "PolymerElements/paper-spinner#^1.0.0", - "paper-button": "PolymerElements/paper-button#^1.0.0", - "paper-input": "PolymerElements/paper-input#^1.0.0", - "paper-toggle-button": "PolymerElements/paper-toggle-button#^1.0.0", - "paper-icon-button": "PolymerElements/paper-icon-button#^1.0.0", - "paper-item": "PolymerElements/paper-item#^1.0.0", - "paper-slider": "PolymerElements/paper-slider#^1.0.0", - "paper-checkbox": "PolymerElements/paper-checkbox#^1.0.0", - "paper-drawer-panel": "PolymerElements/paper-drawer-panel#^1.0.0", - "paper-scroll-header-panel": "polymerelements/paper-scroll-header-panel#^1.0.0", - "google-apis": "GoogleWebComponents/google-apis#0.8-preview", - "moment": "^2.10.3", - "layout": "Polymer/layout", - "paper-styles": "polymerelements/paper-styles#^1.0.0", - "lodash": "~3.9.3", - "pikaday": "~1.3.2" - }, - "resolutions": { - "polymer": "^1.0.0", - "webcomponentsjs": "^0.7.0" - } -} diff --git a/homeassistant/components/frontend/www_static/polymer/cards/state-card-configurator.html b/homeassistant/components/frontend/www_static/polymer/cards/state-card-configurator.html deleted file mode 100644 index 6a25d41f945..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/cards/state-card-configurator.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/cards/state-card-content.html b/homeassistant/components/frontend/www_static/polymer/cards/state-card-content.html deleted file mode 100644 index e5b929b0804..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/cards/state-card-content.html +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/cards/state-card-display.html b/homeassistant/components/frontend/www_static/polymer/cards/state-card-display.html deleted file mode 100755 index a40979dcb66..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/cards/state-card-display.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/cards/state-card-media_player.html b/homeassistant/components/frontend/www_static/polymer/cards/state-card-media_player.html deleted file mode 100644 index ab26365c298..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/cards/state-card-media_player.html +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/cards/state-card-scene.html b/homeassistant/components/frontend/www_static/polymer/cards/state-card-scene.html deleted file mode 100644 index cf7cc9a0c08..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/cards/state-card-scene.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/homeassistant/components/frontend/www_static/polymer/cards/state-card-thermostat.html b/homeassistant/components/frontend/www_static/polymer/cards/state-card-thermostat.html deleted file mode 100644 index a86ad51f446..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/cards/state-card-thermostat.html +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/cards/state-card-toggle.html b/homeassistant/components/frontend/www_static/polymer/cards/state-card-toggle.html deleted file mode 100755 index 51bbcc6fb6e..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/cards/state-card-toggle.html +++ /dev/null @@ -1,95 +0,0 @@ - - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/cards/state-card.html b/homeassistant/components/frontend/www_static/polymer/cards/state-card.html deleted file mode 100644 index 6a21706da74..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/cards/state-card.html +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/components/display-time.html b/homeassistant/components/frontend/www_static/polymer/components/display-time.html deleted file mode 100644 index f6908c8a7ff..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/components/display-time.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/components/domain-icon.html b/homeassistant/components/frontend/www_static/polymer/components/domain-icon.html deleted file mode 100644 index d9fe55538d4..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/components/domain-icon.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/components/entity-list.html b/homeassistant/components/frontend/www_static/polymer/components/entity-list.html deleted file mode 100644 index 8312e0bff09..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/components/entity-list.html +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/components/events-list.html b/homeassistant/components/frontend/www_static/polymer/components/events-list.html deleted file mode 100644 index 5c37d32ecc9..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/components/events-list.html +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/components/ha-color-picker.html b/homeassistant/components/frontend/www_static/polymer/components/ha-color-picker.html deleted file mode 100644 index 46ced3ddf64..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/components/ha-color-picker.html +++ /dev/null @@ -1,169 +0,0 @@ - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/components/ha-logbook.html b/homeassistant/components/frontend/www_static/polymer/components/ha-logbook.html deleted file mode 100644 index a2f2fb00d9b..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/components/ha-logbook.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/components/ha-sidebar.html b/homeassistant/components/frontend/www_static/polymer/components/ha-sidebar.html deleted file mode 100644 index 8746ee126c8..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/components/ha-sidebar.html +++ /dev/null @@ -1,247 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/components/ha-voice-command-progress.html b/homeassistant/components/frontend/www_static/polymer/components/ha-voice-command-progress.html deleted file mode 100644 index 44d29a0151c..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/components/ha-voice-command-progress.html +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/components/loading-box.html b/homeassistant/components/frontend/www_static/polymer/components/loading-box.html deleted file mode 100644 index c78fd91122c..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/components/loading-box.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/components/logbook-entry.html b/homeassistant/components/frontend/www_static/polymer/components/logbook-entry.html deleted file mode 100644 index 3575d6b5d94..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/components/logbook-entry.html +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/components/relative-ha-datetime.html b/homeassistant/components/frontend/www_static/polymer/components/relative-ha-datetime.html deleted file mode 100644 index 2017dd874f6..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/components/relative-ha-datetime.html +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/components/services-list.html b/homeassistant/components/frontend/www_static/polymer/components/services-list.html deleted file mode 100644 index 146703f1042..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/components/services-list.html +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/components/state-badge.html b/homeassistant/components/frontend/www_static/polymer/components/state-badge.html deleted file mode 100644 index 7b015b20786..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/components/state-badge.html +++ /dev/null @@ -1,105 +0,0 @@ - - - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/components/state-cards.html b/homeassistant/components/frontend/www_static/polymer/components/state-cards.html deleted file mode 100755 index 5eabf370e01..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/components/state-cards.html +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/components/state-history-chart-line.html b/homeassistant/components/frontend/www_static/polymer/components/state-history-chart-line.html deleted file mode 100644 index a45d6b3c3ec..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/components/state-history-chart-line.html +++ /dev/null @@ -1,198 +0,0 @@ - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/components/state-history-chart-timeline.html b/homeassistant/components/frontend/www_static/polymer/components/state-history-chart-timeline.html deleted file mode 100644 index 6e45cd264ed..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/components/state-history-chart-timeline.html +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/components/state-history-charts.html b/homeassistant/components/frontend/www_static/polymer/components/state-history-charts.html deleted file mode 100644 index 17a93fcabc1..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/components/state-history-charts.html +++ /dev/null @@ -1,158 +0,0 @@ - - - - - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/components/state-info.html b/homeassistant/components/frontend/www_static/polymer/components/state-info.html deleted file mode 100755 index 50b10fa91a9..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/components/state-info.html +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/components/stream-status.html b/homeassistant/components/frontend/www_static/polymer/components/stream-status.html deleted file mode 100644 index 47118ed9f9a..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/components/stream-status.html +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/dialogs/more-info-dialog.html b/homeassistant/components/frontend/www_static/polymer/dialogs/more-info-dialog.html deleted file mode 100644 index 6a1ac77133d..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/dialogs/more-info-dialog.html +++ /dev/null @@ -1,151 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/home-assistant-js b/homeassistant/components/frontend/www_static/polymer/home-assistant-js deleted file mode 160000 index 94d8682c1e7..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/home-assistant-js +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 94d8682c1e7679ae744e8419896d5d7b0bdd16cc diff --git a/homeassistant/components/frontend/www_static/polymer/home-assistant.html b/homeassistant/components/frontend/www_static/polymer/home-assistant.html deleted file mode 100644 index 8c4ed824cdd..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/home-assistant.html +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/html-minifier.conf b/homeassistant/components/frontend/www_static/polymer/html-minifier.conf deleted file mode 100644 index 2e6dbb9538b..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/html-minifier.conf +++ /dev/null @@ -1,11 +0,0 @@ -{ - "removeComments": true, - "removeCommentsFromCDATA": true, - "removeCDATASectionsFromCDATA": true, - "collapseWhitespace": true, - "collapseBooleanAttributes": true, - "removeScriptTypeAttributes": true, - "removeStyleLinkTypeAttributes": true, - "minifyJS": true, - "minifyCSS": true -} diff --git a/homeassistant/components/frontend/www_static/polymer/layouts/home-assistant-main.html b/homeassistant/components/frontend/www_static/polymer/layouts/home-assistant-main.html deleted file mode 100644 index a1e6fe9b2f5..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/layouts/home-assistant-main.html +++ /dev/null @@ -1,131 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/layouts/login-form.html b/homeassistant/components/frontend/www_static/polymer/layouts/login-form.html deleted file mode 100644 index 43b1e97590c..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/layouts/login-form.html +++ /dev/null @@ -1,160 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/layouts/partial-base.html b/homeassistant/components/frontend/www_static/polymer/layouts/partial-base.html deleted file mode 100644 index 3e1e5cc57fc..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/layouts/partial-base.html +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/layouts/partial-dev-call-service.html b/homeassistant/components/frontend/www_static/polymer/layouts/partial-dev-call-service.html deleted file mode 100644 index f3ae78d3953..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/layouts/partial-dev-call-service.html +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/layouts/partial-dev-fire-event.html b/homeassistant/components/frontend/www_static/polymer/layouts/partial-dev-fire-event.html deleted file mode 100644 index 57cc3ef5da4..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/layouts/partial-dev-fire-event.html +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/layouts/partial-dev-set-state.html b/homeassistant/components/frontend/www_static/polymer/layouts/partial-dev-set-state.html deleted file mode 100644 index 6771bbdb1ba..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/layouts/partial-dev-set-state.html +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/layouts/partial-history.html b/homeassistant/components/frontend/www_static/polymer/layouts/partial-history.html deleted file mode 100644 index 9abc0ad096c..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/layouts/partial-history.html +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/homeassistant/components/frontend/www_static/polymer/layouts/partial-logbook.html b/homeassistant/components/frontend/www_static/polymer/layouts/partial-logbook.html deleted file mode 100644 index a6fc0f615d8..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/layouts/partial-logbook.html +++ /dev/null @@ -1,119 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/layouts/partial-states.html b/homeassistant/components/frontend/www_static/polymer/layouts/partial-states.html deleted file mode 100644 index ed40a218a89..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/layouts/partial-states.html +++ /dev/null @@ -1,185 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/managers/notification-manager.html b/homeassistant/components/frontend/www_static/polymer/managers/notification-manager.html deleted file mode 100644 index 0d38e087ebd..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/managers/notification-manager.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/managers/preferences-manager.html b/homeassistant/components/frontend/www_static/polymer/managers/preferences-manager.html deleted file mode 100644 index a70f8070d69..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/managers/preferences-manager.html +++ /dev/null @@ -1,40 +0,0 @@ - - - diff --git a/homeassistant/components/frontend/www_static/polymer/more-infos/more-info-camera.html b/homeassistant/components/frontend/www_static/polymer/more-infos/more-info-camera.html deleted file mode 100644 index 92d5f1b509d..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/more-infos/more-info-camera.html +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/more-infos/more-info-configurator.html b/homeassistant/components/frontend/www_static/polymer/more-infos/more-info-configurator.html deleted file mode 100644 index 3309ff91cd9..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/more-infos/more-info-configurator.html +++ /dev/null @@ -1,125 +0,0 @@ - - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/more-infos/more-info-content.html b/homeassistant/components/frontend/www_static/polymer/more-infos/more-info-content.html deleted file mode 100644 index 1c5919e281c..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/more-infos/more-info-content.html +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/more-infos/more-info-default.html b/homeassistant/components/frontend/www_static/polymer/more-infos/more-info-default.html deleted file mode 100644 index a1b2cde666d..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/more-infos/more-info-default.html +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/more-infos/more-info-group.html b/homeassistant/components/frontend/www_static/polymer/more-infos/more-info-group.html deleted file mode 100644 index 29b0445de2b..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/more-infos/more-info-group.html +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/more-infos/more-info-light.html b/homeassistant/components/frontend/www_static/polymer/more-infos/more-info-light.html deleted file mode 100644 index 702eb5fd354..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/more-infos/more-info-light.html +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/more-infos/more-info-media_player.html b/homeassistant/components/frontend/www_static/polymer/more-infos/more-info-media_player.html deleted file mode 100644 index 1553ee5f1b1..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/more-infos/more-info-media_player.html +++ /dev/null @@ -1,210 +0,0 @@ - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/more-infos/more-info-script.html b/homeassistant/components/frontend/www_static/polymer/more-infos/more-info-script.html deleted file mode 100644 index bebe8753290..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/more-infos/more-info-script.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/more-infos/more-info-sun.html b/homeassistant/components/frontend/www_static/polymer/more-infos/more-info-sun.html deleted file mode 100644 index bc1f7211469..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/more-infos/more-info-sun.html +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/more-infos/more-info-thermostat.html b/homeassistant/components/frontend/www_static/polymer/more-infos/more-info-thermostat.html deleted file mode 100644 index 444935e2c83..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/more-infos/more-info-thermostat.html +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/resources/home-assistant-icons.html b/homeassistant/components/frontend/www_static/polymer/resources/home-assistant-icons.html deleted file mode 100644 index 3ab36597214..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/resources/home-assistant-icons.html +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/resources/home-assistant-js.html b/homeassistant/components/frontend/www_static/polymer/resources/home-assistant-js.html deleted file mode 100644 index d63ab0333cf..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/resources/home-assistant-js.html +++ /dev/null @@ -1,54 +0,0 @@ - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/resources/home-assistant-style.html b/homeassistant/components/frontend/www_static/polymer/resources/home-assistant-style.html deleted file mode 100644 index 473e3445d64..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/resources/home-assistant-style.html +++ /dev/null @@ -1,46 +0,0 @@ - - - diff --git a/homeassistant/components/frontend/www_static/polymer/resources/lodash.html b/homeassistant/components/frontend/www_static/polymer/resources/lodash.html deleted file mode 100644 index 54a43c19590..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/resources/lodash.html +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/homeassistant/components/frontend/www_static/polymer/resources/moment-js.html b/homeassistant/components/frontend/www_static/polymer/resources/moment-js.html deleted file mode 100644 index 30b71031163..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/resources/moment-js.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - diff --git a/homeassistant/components/frontend/www_static/polymer/resources/pikaday-js.html b/homeassistant/components/frontend/www_static/polymer/resources/pikaday-js.html deleted file mode 100644 index b8ca382dba0..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/resources/pikaday-js.html +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/homeassistant/components/frontend/www_static/polymer/resources/store-listener-behavior.html b/homeassistant/components/frontend/www_static/polymer/resources/store-listener-behavior.html deleted file mode 100644 index 7ad23230a4e..00000000000 --- a/homeassistant/components/frontend/www_static/polymer/resources/store-listener-behavior.html +++ /dev/null @@ -1,42 +0,0 @@ - diff --git a/homeassistant/components/frontend/www_static/version.py b/homeassistant/components/frontend/www_static/version.py new file mode 100644 index 00000000000..0f9641f054b --- /dev/null +++ b/homeassistant/components/frontend/www_static/version.py @@ -0,0 +1,2 @@ +""" DO NOT MODIFY. Auto-generated by build_frontend script """ +VERSION = "" diff --git a/homeassistant/components/sun.py b/homeassistant/components/sun.py index b1d1d755348..fd2cfa46b72 100644 --- a/homeassistant/components/sun.py +++ b/homeassistant/components/sun.py @@ -22,21 +22,18 @@ The sun event need to have the type 'sun', which service to call, which event import logging from datetime import timedelta -try: - import ephem -except ImportError: - # Will be fixed during setup - ephem = None - +import homeassistant.util as util import homeassistant.util.dt as dt_util from homeassistant.helpers.entity import Entity from homeassistant.components.scheduler import ServiceEventListener DEPENDENCIES = [] -REQUIREMENTS = ['pyephem>=3.7'] +REQUIREMENTS = ['astral>=0.8.1'] DOMAIN = "sun" ENTITY_ID = "sun.sun" +CONF_ELEVATION = 'elevation' + STATE_ABOVE_HORIZON = "above_horizon" STATE_BELOW_HORIZON = "below_horizon" @@ -99,24 +96,43 @@ def next_rising_utc(hass, entity_id=None): def setup(hass, config): """ Tracks the state of the sun. """ - logger = logging.getLogger(__name__) - - global ephem # pylint: disable=invalid-name - if ephem is None: - import ephem as ephem_ - ephem = ephem_ - if None in (hass.config.latitude, hass.config.longitude): - logger.error("Latitude or longitude not set in Home Assistant config") + _LOGGER.error("Latitude or longitude not set in Home Assistant config") return False - try: - sun = Sun(hass, str(hass.config.latitude), str(hass.config.longitude)) - except ValueError: - # Raised when invalid latitude or longitude is given to Observer - logger.exception("Invalid value for latitude or longitude") + latitude = util.convert(hass.config.latitude, float) + longitude = util.convert(hass.config.longitude, float) + errors = [] + + if latitude is None: + errors.append('Latitude needs to be a decimal value') + elif -90 > latitude < 90: + errors.append('Latitude needs to be -90 .. 90') + + if longitude is None: + errors.append('Longitude needs to be a decimal value') + elif -180 > longitude < 180: + errors.append('Longitude needs to be -180 .. 180') + + if errors: + _LOGGER.error('Invalid configuration received: %s', ", ".join(errors)) return False + platform_config = config.get(DOMAIN, {}) + + elevation = platform_config.get(CONF_ELEVATION) + + from astral import Location, GoogleGeocoder + + location = Location(('', '', latitude, longitude, hass.config.time_zone, + elevation or 0)) + + if elevation is None: + google = GoogleGeocoder() + google._get_elevation(location) # pylint: disable=protected-access + _LOGGER.info('Retrieved elevation from Google: %s', location.elevation) + + sun = Sun(hass, location) sun.point_in_time_listener(dt_util.utcnow()) return True @@ -127,14 +143,9 @@ class Sun(Entity): entity_id = ENTITY_ID - def __init__(self, hass, latitude, longitude): + def __init__(self, hass, location): self.hass = hass - self.observer = ephem.Observer() - # pylint: disable=assigning-non-slot - self.observer.lat = latitude - # pylint: disable=assigning-non-slot - self.observer.long = longitude - + self.location = location self._state = self.next_rising = self.next_setting = None @property @@ -167,17 +178,24 @@ class Sun(Entity): def update_as_of(self, utc_point_in_time): """ Calculate sun state at a point in UTC time. """ - sun = ephem.Sun() # pylint: disable=no-member + mod = -1 + while True: + next_rising_dt = self.location.sunrise( + utc_point_in_time + timedelta(days=mod), local=False) + if next_rising_dt > utc_point_in_time: + break + mod += 1 - # pylint: disable=assigning-non-slot - self.observer.date = ephem.date(utc_point_in_time) + mod = -1 + while True: + next_setting_dt = (self.location.sunset( + utc_point_in_time + timedelta(days=mod), local=False)) + if next_setting_dt > utc_point_in_time: + break + mod += 1 - self.next_rising = self.observer.next_rising( - sun, - start=utc_point_in_time).datetime().replace(tzinfo=dt_util.UTC) - self.next_setting = self.observer.next_setting( - sun, - start=utc_point_in_time).datetime().replace(tzinfo=dt_util.UTC) + self.next_rising = next_rising_dt + self.next_setting = next_setting_dt def point_in_time_listener(self, now): """ Called when the state of the sun has changed. """ diff --git a/requirements.txt b/requirements.txt index 83780721c2c..c7a569fad33 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,7 @@ pytz>=2015.2 zeroconf>=0.16.0 # Sun (sun) -pyephem>=3.7 +astral>=0.8.1 # Philips Hue library (lights.hue) phue>=0.8 diff --git a/scripts/build_frontend b/scripts/build_frontend index 2bf80d28541..9554e82256d 100755 --- a/scripts/build_frontend +++ b/scripts/build_frontend @@ -1,29 +1,19 @@ # Builds the frontend for production -# Call 'build_frontend demo' to build a demo frontend. # If current pwd is scripts, go 1 up. if [ ${PWD##*/} == "scripts" ]; then cd .. fi -scripts/build_js $1 +cd homeassistant/components/frontend/www_static/home-assistant-polymer +npm install +npm run frontend_prod -# To build the frontend, you need node, bower, vulcanize and html-minifier -# npm install -g bower vulcanize html-minifier - -# Install dependencies -cd homeassistant/components/frontend/www_static/polymer -bower install -cd .. -cp polymer/bower_components/webcomponentsjs/webcomponents-lite.min.js . - -vulcanize --inline-css --inline-scripts --strip-comments polymer/home-assistant.html > frontend.html - -# html-minifier crashes on frontend, minimize kills the CSS -# html-minifier --config-file polymer/html-minifier.conf -o frontend.html frontend.html +cp bower_components/webcomponentsjs/webcomponents-lite.min.js .. +cp build/frontend.html .. # Generate the MD5 hash of the new frontend -cd .. +cd ../.. echo '""" DO NOT MODIFY. Auto-generated by build_frontend script """' > version.py if [ $(command -v md5) ]; then echo 'VERSION = "'`md5 -q www_static/frontend.html`'"' >> version.py diff --git a/scripts/build_js b/scripts/build_js deleted file mode 100755 index a75b48f9bf9..00000000000 --- a/scripts/build_js +++ /dev/null @@ -1,17 +0,0 @@ -# Builds the JS for production - -# If current pwd is scripts, go 1 up. -if [ ${PWD##*/} == "scripts" ]; then - cd .. -fi - -cd homeassistant/components/frontend/www_static/polymer/home-assistant-js - -npm install - -if [ "$1" = "demo" ]; then - echo "Building a demo mode build!" - npm run demo -else - npm run prod -fi diff --git a/scripts/dev_js b/scripts/dev_js deleted file mode 100755 index a62f0d85ef3..00000000000 --- a/scripts/dev_js +++ /dev/null @@ -1,11 +0,0 @@ -# Builds the JS for developing, rebuilds when files change - -# If current pwd is scripts, go 1 up. -if [ ${PWD##*/} == "scripts" ]; then - cd .. -fi - -cd homeassistant/components/frontend/www_static/polymer/home-assistant-js - -npm install -npm run dev diff --git a/scripts/homeassistant.daemon b/scripts/homeassistant.daemon index 4c504557dec..bef4cd90f4a 100755 --- a/scripts/homeassistant.daemon +++ b/scripts/homeassistant.daemon @@ -12,7 +12,7 @@ # Created with: https://gist.github.com/naholyr/4275302#file-new-service-sh # # Installation: -# 1) Populate RUNAS and RUNDIR folders +# 1) Populate RUNAS and RUNDIR variables # 2) Create Log -- sudo touch /var/log/homeassistant.log # 3) Set Log Ownership -- sudo chown USER:GROUP /var/log/homeassistant.log # 4) Create PID File -- sudo touch /var/run/homeassistant.pid @@ -29,7 +29,7 @@ # If you are not, the SCRIPT variable must be modified to point to the correct # Python environment. -SCRIPT="./bin/python -m homeassistant" +SCRIPT="source bin/activate; ./bin/python -m homeassistant" RUNAS= RUNDIR= PIDFILE=/var/run/homeassistant.pid diff --git a/tests/test_component_device_sun_light_trigger.py b/tests/test_component_device_sun_light_trigger.py index 7a05f63099f..05452a830ec 100644 --- a/tests/test_component_device_sun_light_trigger.py +++ b/tests/test_component_device_sun_light_trigger.py @@ -67,7 +67,7 @@ class TestDeviceSunLightTrigger(unittest.TestCase): light.DOMAIN: {CONF_PLATFORM: 'test'} }) - sun.setup(self.hass, {}) + sun.setup(self.hass, {sun.DOMAIN: {sun.CONF_ELEVATION: 0}}) def tearDown(self): # pylint: disable=invalid-name """ Stop down stuff we started. """ diff --git a/tests/test_component_sun.py b/tests/test_component_sun.py index aec97ede6a8..705caadcd3a 100644 --- a/tests/test_component_sun.py +++ b/tests/test_component_sun.py @@ -8,7 +8,7 @@ Tests Sun component. import unittest from datetime import timedelta -import ephem +from astral import Astral import homeassistant as ha import homeassistant.util.dt as dt_util @@ -34,29 +34,35 @@ class TestSun(unittest.TestCase): def test_setting_rising(self): """ Test retrieving sun setting and rising. """ + latitude = 32.87336 + longitude = 117.22743 + # Compare it with the real data - self.hass.config.latitude = '32.87336' - self.hass.config.longitude = '117.22743' - sun.setup(self.hass, None) - - observer = ephem.Observer() - observer.lat = '32.87336' # pylint: disable=assigning-non-slot - observer.long = '117.22743' # pylint: disable=assigning-non-slot + self.hass.config.latitude = latitude + self.hass.config.longitude = longitude + sun.setup(self.hass, {sun.DOMAIN: {sun.CONF_ELEVATION: 0}}) + astral = Astral() utc_now = dt_util.utcnow() - body_sun = ephem.Sun() # pylint: disable=no-member - next_rising_dt = observer.next_rising( - body_sun, start=utc_now).datetime().replace(tzinfo=dt_util.UTC) - next_setting_dt = observer.next_setting( - body_sun, start=utc_now).datetime().replace(tzinfo=dt_util.UTC) - # Home Assistant strips out microseconds - # strip it out of the datetime objects - next_rising_dt = dt_util.strip_microseconds(next_rising_dt) - next_setting_dt = dt_util.strip_microseconds(next_setting_dt) + mod = -1 + while True: + next_rising = (astral.sunrise_utc(utc_now + + timedelta(days=mod), latitude, longitude)) + if next_rising > utc_now: + break + mod += 1 - self.assertEqual(next_rising_dt, sun.next_rising_utc(self.hass)) - self.assertEqual(next_setting_dt, sun.next_setting_utc(self.hass)) + mod = -1 + while True: + next_setting = (astral.sunset_utc(utc_now + + timedelta(days=mod), latitude, longitude)) + if next_setting > utc_now: + break + mod += 1 + + self.assertEqual(next_rising, sun.next_rising_utc(self.hass)) + self.assertEqual(next_setting, sun.next_setting_utc(self.hass)) # Point it at a state without the proper attributes self.hass.states.set(sun.ENTITY_ID, sun.STATE_ABOVE_HORIZON) @@ -71,7 +77,7 @@ class TestSun(unittest.TestCase): """ Test if the state changes at next setting/rising. """ self.hass.config.latitude = '32.87336' self.hass.config.longitude = '117.22743' - sun.setup(self.hass, None) + sun.setup(self.hass, {}) if sun.is_on(self.hass): test_state = sun.STATE_BELOW_HORIZON