forked from home-assistant/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request home-assistant#627 from rmkraus/update_notify
Updater component
- Loading branch information
Showing
5 changed files
with
97 additions
and
52 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
""" DO NOT MODIFY. Auto-generated by build_frontend script """ | ||
VERSION = "44fc40d6c32d1f5ff94c590d17f9cc2e" | ||
VERSION = "b75e3c9ebd3de2dae0912a89499127a9" |
82 changes: 35 additions & 47 deletions
82
homeassistant/components/frontend/www_static/frontend.html
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
homeassistant/components/frontend/www_static/home-assistant-polymer
Submodule home-assistant-polymer
updated
from f2d9a4 to 99af26
6 changes: 3 additions & 3 deletions
6
homeassistant/components/frontend/www_static/webcomponents-lite.min.js
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
""" | ||
homeassistant.components.sensor.updater | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
Sensor that checks for available updates. | ||
For more details about this platform, please refer to the documentation at | ||
at https://home-assistant.io/components/sensor.updater/ | ||
""" | ||
import logging | ||
|
||
import requests | ||
|
||
from homeassistant.const import __version__ as CURRENT_VERSION | ||
from homeassistant.const import ATTR_FRIENDLY_NAME | ||
from homeassistant.helpers import event | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
PYPI_URL = 'https://pypi.python.org/pypi/homeassistant/json' | ||
DEPENDENCIES = [] | ||
DOMAIN = 'updater' | ||
ENTITY_ID = 'updater.updater' | ||
|
||
|
||
def setup(hass, config): | ||
''' setup the updater component ''' | ||
|
||
def check_newest_version(_=None): | ||
''' check if a new version is available and report if one is ''' | ||
newest = get_newest_version() | ||
|
||
if newest != CURRENT_VERSION and newest is not None: | ||
hass.states.set( | ||
ENTITY_ID, newest, {ATTR_FRIENDLY_NAME: 'Update Available'}) | ||
|
||
event.track_time_change(hass, check_newest_version, | ||
hour=[0, 12], minute=0, second=0) | ||
|
||
check_newest_version() | ||
|
||
return True | ||
|
||
|
||
def get_newest_version(): | ||
''' Get the newest HA version form PyPI ''' | ||
try: | ||
req = requests.get(PYPI_URL) | ||
|
||
return req.json()['info']['version'] | ||
except requests.RequestException: | ||
_LOGGER.exception('Could not contact PyPI to check for updates') | ||
return | ||
except ValueError: | ||
_LOGGER.exception('Received invalid response from PyPI') | ||
return | ||
except KeyError: | ||
_LOGGER.exception('Response from PyPI did not include version') | ||
return |