diff --git a/api/.vulture_whitelist b/api/.vulture_whitelist index d30f803..569702b 100644 --- a/api/.vulture_whitelist +++ b/api/.vulture_whitelist @@ -10,14 +10,21 @@ read_ping # unused function (src/api/routes/ping.py:10) websocket_endpoint # unused function (src/api/routes/socket.py:13) params # unused variable (src/api/types.py:16) total_items # unused variable (src/api/types.py:17) +alias # unused variable (src/automations/types.py:36) +description # unused variable (src/automations/types.py:37) trigger_variables # unused variable (src/automations/types.py:38) +mode # unused variable (src/automations/types.py:39) trigger # unused variable (src/automations/types.py:40) condition # unused variable (src/automations/types.py:41) action # unused variable (src/automations/types.py:42) _.to_json # unused method (src/automations/types.py:70) +error_name # unused variable (src/errors.py:22) +error_message # unused variable (src/errors.py:23) +error_traceback # unused variable (src/errors.py:24) +original_error # unused variable (src/errors.py:25) _.automation_tags # unused property (src/hass_config/loader.py:28) json_dumps # unused function (src/json_serializer.py:5) -theme # unused variable (src/user_profile.py:9) -lang # unused variable (src/user_profile.py:10) +theme # unused variable (src/user_profile.py:10) +lang # unused variable (src/user_profile.py:11) SecretValue # unused class (src/yaml_serializer/__init__.py:48) EnvVar # unused class (src/yaml_serializer/__init__.py:186) diff --git a/api/src/automations/db.py b/api/src/automations/db.py index c2705d7..d62d6be 100644 --- a/api/src/automations/db.py +++ b/api/src/automations/db.py @@ -1,44 +1,12 @@ -import base64 -import json from typing import Iterable from src.logger import get_logger -from .errors import ( - DBNoAutomationFound, - RepeatedAutomationId, -) +from .errors import DBNoAutomationFound, RepeatedAutomationId from .types import ExtenededAutomation logger = get_logger(__file__) -automations_tbl = "autos" - - -def encode_auto(auto: ExtenededAutomation) -> str: - return base64.b64encode( - json.dumps(auto.to_primitive(include_tags=True)).encode("utf-8") - ).decode("utf-8") - - -def encode_obj(auto: dict | list) -> str: - return base64.b64encode(json.dumps(auto).encode("utf-8")).decode("utf-8") - - -def decode_auto( - auto_str: str, source_file: str, source_file_type: str, configuration_key: str -) -> ExtenededAutomation: - return ExtenededAutomation( - source_file=source_file, - source_file_type=source_file_type, - configuration_key=decode_obj(configuration_key), # type: ignore - **decode_obj(auto_str), - ) - - -def decode_obj(obj_str: str) -> dict | list: - return json.loads(base64.b64decode(obj_str.encode("utf-8")).decode("utf-8")) - class AutomationDBConnection: def __init__(self) -> None: diff --git a/api/src/automations/manager.py b/api/src/automations/manager.py index a56da58..9f04ced 100644 --- a/api/src/automations/manager.py +++ b/api/src/automations/manager.py @@ -1,5 +1,3 @@ -from pathlib import Path -from tempfile import mktemp from typing import Optional, Union from src.errors import ErrorSet, FormattedError