mirror of
https://github.com/CCOSTAN/Home-AssistantConfig.git
synced 2025-09-14 23:55:18 +00:00
Add in Alexa Last used Sensor. #768
This commit is contained in:
@@ -50,20 +50,6 @@ class HacsAppdaemon(HacsRepository):
|
||||
self.logger.error(error)
|
||||
return self.validate.success
|
||||
|
||||
async def registration(self, ref=None):
|
||||
"""Registration."""
|
||||
if ref is not None:
|
||||
self.ref = ref
|
||||
self.force_branch = True
|
||||
if not await self.validate_repository():
|
||||
return False
|
||||
|
||||
# Run common registration steps.
|
||||
await self.common_registration()
|
||||
|
||||
# Set local path
|
||||
self.content.path.local = self.localpath
|
||||
|
||||
async def update_repository(self, ignore_issues=False):
|
||||
"""Update."""
|
||||
await self.common_update(ignore_issues)
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Class for integrations in HACS."""
|
||||
# pylint: disable=attribute-defined-outside-init
|
||||
from integrationhelper import Logger
|
||||
|
||||
from homeassistant.loader import async_get_custom_components
|
||||
@@ -6,7 +7,6 @@ from homeassistant.loader import async_get_custom_components
|
||||
from custom_components.hacs.hacsbase.exceptions import HacsException
|
||||
from custom_components.hacs.helpers.filters import get_first_directory_in_directory
|
||||
from custom_components.hacs.helpers.information import get_integration_manifest
|
||||
from custom_components.hacs.helpers.action import run_action_checks
|
||||
from custom_components.hacs.repositories.repository import HacsRepository
|
||||
|
||||
|
||||
@@ -27,6 +27,16 @@ class HacsIntegration(HacsRepository):
|
||||
"""Return localpath."""
|
||||
return f"{self.hacs.system.config_path}/custom_components/{self.data.domain}"
|
||||
|
||||
async def async_post_installation(self):
|
||||
"""Run post installation steps."""
|
||||
if self.data.config_flow:
|
||||
if self.data.full_name != "hacs/integration":
|
||||
await self.reload_custom_components()
|
||||
if self.data.first_install:
|
||||
self.pending_restart = False
|
||||
return
|
||||
self.pending_restart = True
|
||||
|
||||
async def validate_repository(self):
|
||||
"""Validate."""
|
||||
await self.common_validate()
|
||||
@@ -50,9 +60,6 @@ class HacsIntegration(HacsRepository):
|
||||
raise HacsException(exception)
|
||||
self.logger.error(exception)
|
||||
|
||||
if self.hacs.action:
|
||||
await run_action_checks(self)
|
||||
|
||||
# Handle potential errors
|
||||
if self.validate.errors:
|
||||
for error in self.validate.errors:
|
||||
@@ -60,20 +67,6 @@ class HacsIntegration(HacsRepository):
|
||||
self.logger.error(error)
|
||||
return self.validate.success
|
||||
|
||||
async def registration(self, ref=None):
|
||||
"""Registration."""
|
||||
if ref is not None:
|
||||
self.ref = ref
|
||||
self.force_branch = True
|
||||
if not await self.validate_repository():
|
||||
return False
|
||||
|
||||
# Run common registration steps.
|
||||
await self.common_registration()
|
||||
|
||||
# Set local path
|
||||
self.content.path.local = self.localpath
|
||||
|
||||
async def update_repository(self, ignore_issues=False):
|
||||
"""Update."""
|
||||
await self.common_update(ignore_issues)
|
||||
@@ -98,3 +91,4 @@ class HacsIntegration(HacsRepository):
|
||||
self.logger.info("Reloading custom_component cache")
|
||||
del self.hacs.hass.data["custom_components"]
|
||||
await async_get_custom_components(self.hacs.hass)
|
||||
self.logger.info("Custom_component cache reloaded")
|
||||
|
@@ -58,20 +58,6 @@ class HacsNetdaemon(HacsRepository):
|
||||
self.logger.error(error)
|
||||
return self.validate.success
|
||||
|
||||
async def registration(self, ref=None):
|
||||
"""Registration."""
|
||||
if ref is not None:
|
||||
self.ref = ref
|
||||
self.force_branch = True
|
||||
if not await self.validate_repository():
|
||||
return False
|
||||
|
||||
# Run common registration steps.
|
||||
await self.common_registration()
|
||||
|
||||
# Set local path
|
||||
self.content.path.local = self.localpath
|
||||
|
||||
async def update_repository(self, ignore_issues=False):
|
||||
"""Update."""
|
||||
await self.common_update(ignore_issues)
|
||||
@@ -89,3 +75,12 @@ class HacsNetdaemon(HacsRepository):
|
||||
|
||||
# Set local path
|
||||
self.content.path.local = self.localpath
|
||||
|
||||
async def async_post_installation(self):
|
||||
"""Run post installation steps."""
|
||||
try:
|
||||
await self.hacs.hass.services.async_call(
|
||||
"hassio", "addon_restart", {"addon": "c6a2317c_netdaemon"}
|
||||
)
|
||||
except Exception: # pylint: disable=broad-except
|
||||
pass
|
||||
|
@@ -2,10 +2,9 @@
|
||||
import json
|
||||
from integrationhelper import Logger
|
||||
|
||||
from .repository import HacsRepository
|
||||
from ..hacsbase.exceptions import HacsException
|
||||
|
||||
from custom_components.hacs.hacsbase.exceptions import HacsException
|
||||
from custom_components.hacs.helpers.information import find_file_name
|
||||
from custom_components.hacs.repositories.repository import HacsRepository
|
||||
|
||||
|
||||
class HacsPlugin(HacsRepository):
|
||||
@@ -18,11 +17,14 @@ class HacsPlugin(HacsRepository):
|
||||
self.data.file_name = None
|
||||
self.data.category = "plugin"
|
||||
self.information.javascript_type = None
|
||||
self.content.path.local = (
|
||||
f"{self.hacs.system.config_path}/www/community/{full_name.split('/')[-1]}"
|
||||
)
|
||||
self.content.path.local = self.localpath
|
||||
self.logger = Logger(f"hacs.repository.{self.data.category}.{full_name}")
|
||||
|
||||
@property
|
||||
def localpath(self):
|
||||
"""Return localpath."""
|
||||
return f"{self.hacs.system.config_path}/www/community/{self.data.full_name.split('/')[-1]}"
|
||||
|
||||
async def validate_repository(self):
|
||||
"""Validate."""
|
||||
# Run common validation steps.
|
||||
@@ -46,17 +48,6 @@ class HacsPlugin(HacsRepository):
|
||||
self.logger.error(error)
|
||||
return self.validate.success
|
||||
|
||||
async def registration(self, ref=None):
|
||||
"""Registration."""
|
||||
if ref is not None:
|
||||
self.ref = ref
|
||||
self.force_branch = True
|
||||
if not await self.validate_repository():
|
||||
return False
|
||||
|
||||
# Run common registration steps.
|
||||
await self.common_registration()
|
||||
|
||||
async def update_repository(self, ignore_issues=False):
|
||||
"""Update."""
|
||||
await self.common_update(ignore_issues)
|
||||
@@ -65,7 +56,9 @@ class HacsPlugin(HacsRepository):
|
||||
find_file_name(self)
|
||||
|
||||
if self.content.path.remote is None:
|
||||
self.validate.errors.append("Repostitory structure not compliant")
|
||||
self.validate.errors.append(
|
||||
f"Repostitory structure for {self.ref.replace('tags/','')} is not compliant"
|
||||
)
|
||||
|
||||
if self.content.path.remote == "release":
|
||||
self.content.single = True
|
||||
|
@@ -17,10 +17,15 @@ class HacsPythonScript(HacsRepository):
|
||||
self.data.full_name = full_name
|
||||
self.data.category = "python_script"
|
||||
self.content.path.remote = "python_scripts"
|
||||
self.content.path.local = f"{self.hacs.system.config_path}/python_scripts"
|
||||
self.content.path.local = self.localpath
|
||||
self.content.single = True
|
||||
self.logger = Logger(f"hacs.repository.{self.data.category}.{full_name}")
|
||||
|
||||
@property
|
||||
def localpath(self):
|
||||
"""Return localpath."""
|
||||
return f"{self.hacs.system.config_path}/python_scripts"
|
||||
|
||||
async def validate_repository(self):
|
||||
"""Validate."""
|
||||
# Run common validation steps.
|
||||
@@ -49,17 +54,8 @@ class HacsPythonScript(HacsRepository):
|
||||
self.logger.error(error)
|
||||
return self.validate.success
|
||||
|
||||
async def registration(self, ref=None):
|
||||
async def async_post_registration(self):
|
||||
"""Registration."""
|
||||
if ref is not None:
|
||||
self.ref = ref
|
||||
self.force_branch = True
|
||||
if not await self.validate_repository():
|
||||
return False
|
||||
|
||||
# Run common registration steps.
|
||||
await self.common_registration()
|
||||
|
||||
# Set name
|
||||
find_file_name(self)
|
||||
|
||||
|
@@ -15,3 +15,7 @@ class RemovedRepository:
|
||||
for key in data:
|
||||
if key in self.__dict__:
|
||||
setattr(self, key, data[key])
|
||||
|
||||
def to_json(self):
|
||||
"""Return a JSON representation of the data."""
|
||||
return self.__dict__
|
||||
|
@@ -9,9 +9,9 @@ from aiogithubapi import AIOGitHubAPIException
|
||||
from .manifest import HacsManifest
|
||||
from ..helpers.misc import get_repository_name
|
||||
from ..handler.download import async_download_file, async_save_file
|
||||
from ..helpers.misc import version_left_higher_then_right
|
||||
from ..helpers.install import install_repository, version_to_install
|
||||
from ..helpers.install import version_to_install
|
||||
|
||||
from custom_components.hacs.repositories.helpers import RepositoryHelpers
|
||||
from custom_components.hacs.hacsbase.exceptions import HacsException
|
||||
from custom_components.hacs.store import async_remove_store
|
||||
from custom_components.hacs.globals import get_hacs
|
||||
@@ -98,7 +98,7 @@ class RepositoryContent:
|
||||
single = False
|
||||
|
||||
|
||||
class HacsRepository:
|
||||
class HacsRepository(RepositoryHelpers):
|
||||
"""HacsRepository."""
|
||||
|
||||
def __init__(self):
|
||||
@@ -122,49 +122,6 @@ class HacsRepository:
|
||||
self.treefiles = []
|
||||
self.ref = None
|
||||
|
||||
@property
|
||||
def pending_upgrade(self):
|
||||
"""Return pending upgrade."""
|
||||
if not self.can_install:
|
||||
return False
|
||||
if self.data.installed:
|
||||
if self.data.selected_tag is not None:
|
||||
if self.data.selected_tag == self.data.default_branch:
|
||||
if self.data.installed_commit != self.data.last_commit:
|
||||
return True
|
||||
return False
|
||||
if self.display_installed_version != self.display_available_version:
|
||||
return True
|
||||
return False
|
||||
|
||||
@property
|
||||
def custom(self):
|
||||
"""Return flag if the repository is custom."""
|
||||
if self.data.full_name.split("/")[0] in ["custom-components", "custom-cards"]:
|
||||
return False
|
||||
if str(self.data.id) in [str(x) for x in self.hacs.common.default]:
|
||||
return False
|
||||
if self.data.full_name == "hacs/integration":
|
||||
return False
|
||||
return True
|
||||
|
||||
@property
|
||||
def can_install(self):
|
||||
"""Return bool if repository can be installed."""
|
||||
target = None
|
||||
if self.data.homeassistant is not None:
|
||||
target = self.data.homeassistant
|
||||
if self.data.homeassistant is not None:
|
||||
target = self.data.homeassistant
|
||||
|
||||
if target is not None:
|
||||
if self.data.releases:
|
||||
if not version_left_higher_then_right(
|
||||
self.hacs.system.ha_version, target
|
||||
):
|
||||
return False
|
||||
return True
|
||||
|
||||
@property
|
||||
def display_name(self):
|
||||
"""Return display name."""
|
||||
@@ -288,10 +245,6 @@ class HacsRepository:
|
||||
# Update "info.md"
|
||||
self.information.additional_info = await get_info_md_content(self)
|
||||
|
||||
async def install(self):
|
||||
"""Common installation steps of the repository."""
|
||||
await install_repository(self)
|
||||
|
||||
async def download_zip(self, validate):
|
||||
"""Download ZIP archive from repository release."""
|
||||
try:
|
||||
@@ -353,6 +306,8 @@ class HacsRepository:
|
||||
json.loads(manifest.content)
|
||||
)
|
||||
self.data.update_data(json.loads(manifest.content))
|
||||
if self.hacs.action:
|
||||
self.logger.info(json.loads(manifest.content))
|
||||
except (AIOGitHubAPIException, Exception) as exception: # Gotta Catch 'Em All
|
||||
if self.hacs.action:
|
||||
raise HacsException(f"hacs.json file is not valid ({exception}).")
|
||||
|
@@ -14,10 +14,23 @@ class HacsTheme(HacsRepository):
|
||||
self.data.full_name = full_name
|
||||
self.data.category = "theme"
|
||||
self.content.path.remote = "themes"
|
||||
self.content.path.local = f"{self.hacs.system.config_path}/themes/"
|
||||
self.content.path.local = self.localpath
|
||||
self.content.single = False
|
||||
self.logger = Logger(f"hacs.repository.{self.data.category}.{full_name}")
|
||||
|
||||
@property
|
||||
def localpath(self):
|
||||
"""Return localpath."""
|
||||
return f"{self.hacs.system.config_path}/themes/{self.data.file_name.replace('.yaml', '')}"
|
||||
|
||||
async def async_post_installation(self):
|
||||
"""Run post installation steps."""
|
||||
try:
|
||||
await self.hacs.hass.services.async_call("frontend", "reload_themes", {})
|
||||
self.logger.info("Themes reloaded")
|
||||
except Exception: # pylint: disable=broad-except
|
||||
pass
|
||||
|
||||
async def validate_repository(self):
|
||||
"""Validate."""
|
||||
# Run common validation steps.
|
||||
@@ -44,20 +57,11 @@ class HacsTheme(HacsRepository):
|
||||
self.logger.error(error)
|
||||
return self.validate.success
|
||||
|
||||
async def registration(self, ref=None):
|
||||
async def async_post_registration(self):
|
||||
"""Registration."""
|
||||
if ref is not None:
|
||||
self.ref = ref
|
||||
self.force_branch = True
|
||||
if not await self.validate_repository():
|
||||
return False
|
||||
|
||||
# Run common registration steps.
|
||||
await self.common_registration()
|
||||
|
||||
# Set name
|
||||
find_file_name(self)
|
||||
self.content.path.local = f"{self.hacs.system.config_path}/themes/{self.data.file_name.replace('.yaml', '')}"
|
||||
self.content.path.local = self.localpath
|
||||
|
||||
async def update_repository(self, ignore_issues=False):
|
||||
"""Update."""
|
||||
@@ -69,4 +73,4 @@ class HacsTheme(HacsRepository):
|
||||
|
||||
# Update name
|
||||
find_file_name(self)
|
||||
self.content.path.local = f"{self.hacs.system.config_path}/themes/{self.data.file_name.replace('.yaml', '')}"
|
||||
self.content.path.local = self.localpath
|
||||
|
Reference in New Issue
Block a user