Add in Alexa Last used Sensor. #768

This commit is contained in:
ccostan
2020-06-07 14:29:26 -04:00
parent f9094e57d4
commit 93c5bb6837
34 changed files with 441 additions and 233 deletions

View File

@@ -1,6 +1,7 @@
"""Return repository information if any."""
import json
from aiogithubapi import AIOGitHubAPIException, GitHub
from custom_components.hacs.globals import get_hacs
from custom_components.hacs.handler.template import render_template
from custom_components.hacs.hacsbase.exceptions import HacsException
@@ -63,6 +64,28 @@ async def get_releases(repository, prerelease=False, returnlimit=5):
raise HacsException(exception)
def get_frontend_version():
"""get the frontend version from the manifest."""
manifest = read_hacs_manifest()
frontend = 0
for requirement in manifest.get("requirements", []):
if requirement.startswith("hacs_frontend"):
frontend = requirement.split("==")[1]
break
return frontend
def read_hacs_manifest():
"""Reads the HACS manifest file and returns the contents."""
hacs = get_hacs()
content = {}
with open(
f"{hacs.system.config_path}/custom_components/hacs/manifest.json"
) as manifest:
content = json.loads(manifest.read())
return content
async def get_integration_manifest(repository):
"""Return the integration manifest."""
if repository.data.content_in_root:

View File

@@ -1,7 +1,6 @@
"""Install helper for repositories."""
import os
import tempfile
from custom_components.hacs.globals import get_hacs
from custom_components.hacs.hacsbase.exceptions import HacsException
from custom_components.hacs.hacsbase.backup import Backup, BackupNetDaemon
from custom_components.hacs.helpers.download import download_content
@@ -74,42 +73,6 @@ async def install_repository(repository):
else:
repository.data.installed_version = version
await reload_after_install(repository)
installation_complete(repository)
async def reload_after_install(repository):
"""Reload action after installation success."""
if repository.data.category == "integration":
if repository.data.config_flow:
if repository.data.full_name != "hacs/integration":
await repository.reload_custom_components()
repository.pending_restart = True
elif repository.data.category == "theme":
try:
await repository.hacs.hass.services.async_call(
"frontend", "reload_themes", {}
)
except Exception: # pylint: disable=broad-except
pass
elif repository.data.category == "netdaemon":
try:
await repository.hacs.hass.services.async_call(
"hassio", "addon_restart", {"addon": "c6a2317c_netdaemon"}
)
except Exception: # pylint: disable=broad-except
pass
def installation_complete(repository):
"""Action to run when the installation is complete."""
hacs = get_hacs()
hacs.hass.bus.async_fire(
"hacs/repository",
{"id": 1337, "action": "install", "repository": repository.data.full_name},
)
def version_to_install(repository):
"""Determine which version to isntall."""

View File

@@ -5,7 +5,6 @@ from custom_components.hacs.hacsbase.exceptions import (
HacsException,
HacsExpectedException,
)
from queueman import concurrent
# @concurrent(15, 5)
@@ -27,7 +26,7 @@ async def register_repository(full_name, category, check=True, ref=None, action=
repository = RERPOSITORY_CLASSES[category](full_name)
if check:
try:
await repository.registration(ref)
await repository.async_registration(ref)
if hacs.system.status.new:
repository.data.new = False
if repository.validate.errors: