Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7020c6aee9 | ||
|
|
41dc77ff4f | ||
|
|
c5cf8edfd6 | ||
|
|
2dca59fa3f | ||
|
|
df95265af0 | ||
|
|
78057939da | ||
|
|
a4a607768a | ||
|
|
a9b2bdb775 | ||
|
|
eee37346ab | ||
|
|
6ee7ce8f70 | ||
|
|
2dfbc31b5d |
No files matched your search
@@ -1,5 +1,9 @@
|
||||
# Changelog 
|
||||
|
||||
## [0.7.4] Bugfixes
|
||||
|
||||
- Backend now correctly returns unset alias + description
|
||||
|
||||
## [0.7.1] Bugfixes + Italian!
|
||||
|
||||
- Added support for automations that do not have an `id`
|
||||
|
||||
@@ -17,6 +17,10 @@ class FailedDeletion(AutomationLoaderException):
|
||||
pass
|
||||
|
||||
|
||||
class InvalidPackage(AutomationLoaderException):
|
||||
pass
|
||||
|
||||
|
||||
class DBError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
from itertools import chain
|
||||
from pathlib import Path
|
||||
from typing import Any, Iterator, Tuple, Union
|
||||
|
||||
@@ -16,7 +15,7 @@ from src.yaml_serializer import (
|
||||
)
|
||||
|
||||
from ..hass_config.loader import HassConfig
|
||||
from .errors import InvalidAutomationFile
|
||||
from .errors import InvalidAutomationFile, InvalidPackage
|
||||
from .tags import TagManager
|
||||
from .types import (
|
||||
AutomationExtractedIter,
|
||||
@@ -46,7 +45,9 @@ def load_and_iter_automations(
|
||||
elif isinstance(ref, InlineAutomation):
|
||||
yield from load_automation_inline_ref(hass_config.root_path, tag_manager, ref)
|
||||
else:
|
||||
raise AssertionError(f"ref has an invalid type of {type(ref)} = {ref}")
|
||||
raise logger.error(
|
||||
AssertionError(f"ref has an invalid type of {type(ref)} = {ref}")
|
||||
)
|
||||
except InvalidAutomationFile as e:
|
||||
logger.error(e)
|
||||
|
||||
@@ -56,12 +57,17 @@ def extract_automation_refs(
|
||||
) -> AutomationExtractedIter:
|
||||
found = False
|
||||
|
||||
for ref in chain(
|
||||
extract_automation_root_refs(hass_config), extract_automation_package_refs(hass_config)
|
||||
):
|
||||
for ref in extract_automation_root_refs(hass_config):
|
||||
found = True
|
||||
yield ref
|
||||
|
||||
try:
|
||||
for ref in extract_automation_package_refs(hass_config):
|
||||
found = True
|
||||
yield ref
|
||||
except InvalidPackage as err:
|
||||
logger.fatal(err)
|
||||
|
||||
if not found:
|
||||
yield IncludedAutoamtion([""], IncludedYaml(hass_config.root_path / "automations.yaml"))
|
||||
|
||||
@@ -80,7 +86,7 @@ def extract_automation_root_refs(
|
||||
source_file=hass_config.get_configuration_path(),
|
||||
)
|
||||
else:
|
||||
logger.warning(f"found an invalid type in {key}!")
|
||||
logger.error(f"found an invalid type in {key}!")
|
||||
|
||||
|
||||
def extract_automation_package_refs(hass_config: HassConfig) -> AutomationExtractedIter:
|
||||
@@ -93,7 +99,7 @@ def extract_automation_package_refs(hass_config: HassConfig) -> AutomationExtrac
|
||||
packages,
|
||||
)
|
||||
elif isinstance(packages_config, IncludedYamlDirList):
|
||||
raise AssertionError("cannot configure packages with 'included_dir_list' directive")
|
||||
raise InvalidPackage("cannot configure packages with 'included_dir_list' directive")
|
||||
elif isinstance(packages_config, IncludedYamlDirNamed):
|
||||
packages = packages_config.to_normalized_json(use_path_as_keys=True)
|
||||
for package_path, package in packages.items():
|
||||
@@ -109,7 +115,7 @@ def extract_automation_package_refs(hass_config: HassConfig) -> AutomationExtrac
|
||||
package_set,
|
||||
) in iter(packages_config):
|
||||
if not isinstance(package_set, dict):
|
||||
raise AssertionError(
|
||||
raise InvalidPackage(
|
||||
f"expected {pacakge_set_path} to be a dictionary but got {type(package_set)}"
|
||||
)
|
||||
yield from extract_automation_inline_package_refs(
|
||||
@@ -124,7 +130,7 @@ def extract_automation_package_refs(hass_config: HassConfig) -> AutomationExtrac
|
||||
packages_config,
|
||||
)
|
||||
else:
|
||||
raise AssertionError("configurations.homeassistant.packages must be a dictionary!")
|
||||
raise InvalidPackage("configurations.homeassistant.packages must be a dictionary!")
|
||||
|
||||
|
||||
def extract_automation_inline_package_refs(
|
||||
@@ -134,44 +140,48 @@ def extract_automation_inline_package_refs(
|
||||
ignore_package_name=False,
|
||||
) -> AutomationExtractedIter:
|
||||
for package_name, package_data in packages_config.items():
|
||||
if isinstance(package_data, IncludedYaml):
|
||||
package_mapping = package_data.to_normalized_json()
|
||||
yield from extract_automation_from_package(
|
||||
package_data=package_mapping,
|
||||
package_name=package_name,
|
||||
source_file=source_file,
|
||||
prefix_config_keys=prefix_config_keys,
|
||||
ignore_package_name=ignore_package_name,
|
||||
)
|
||||
elif isinstance(package_data, IncludedYamlDirList):
|
||||
raise NotImplementedError(package_data)
|
||||
elif isinstance(package_data, IncludedYamlDirNamed):
|
||||
for package_key_path in package_data.to_normalized_json(True).keys():
|
||||
if package_key_path.stem == "automation":
|
||||
yield IncludedAutoamtion(
|
||||
configuration_key=[package_name], ref=IncludedYaml(package_key_path)
|
||||
)
|
||||
elif isinstance(package_data, IncludedYamlDirMergedNamed):
|
||||
for data_path, data_set in iter(package_data):
|
||||
logger.info(f"Loading package={package_name}:{type(package_data)} from {package_data}")
|
||||
try:
|
||||
if isinstance(package_data, IncludedYaml):
|
||||
package_mapping = package_data.to_normalized_json()
|
||||
yield from extract_automation_from_package(
|
||||
package_data=package_mapping,
|
||||
package_name=package_name,
|
||||
package_data=data_set,
|
||||
source_file=data_path,
|
||||
prefix_config_keys=[],
|
||||
ignore_package_name=True,
|
||||
source_file=source_file,
|
||||
prefix_config_keys=prefix_config_keys,
|
||||
ignore_package_name=ignore_package_name,
|
||||
)
|
||||
elif isinstance(package_data, dict):
|
||||
yield from extract_automation_from_package(
|
||||
package_data=package_data,
|
||||
package_name=package_name,
|
||||
source_file=source_file,
|
||||
prefix_config_keys=prefix_config_keys,
|
||||
ignore_package_name=ignore_package_name,
|
||||
)
|
||||
else:
|
||||
raise AssertionError(
|
||||
f"configurations.homeassistant.packages[{package_name}] must be a dictionary!"
|
||||
)
|
||||
elif isinstance(package_data, IncludedYamlDirList):
|
||||
raise NotImplementedError(package_data)
|
||||
elif isinstance(package_data, IncludedYamlDirNamed):
|
||||
for package_key_path in package_data.to_normalized_json(True).keys():
|
||||
if package_key_path.stem == "automation":
|
||||
yield IncludedAutoamtion(
|
||||
configuration_key=[package_name], ref=IncludedYaml(package_key_path)
|
||||
)
|
||||
elif isinstance(package_data, IncludedYamlDirMergedNamed):
|
||||
for data_path, data_set in iter(package_data):
|
||||
yield from extract_automation_from_package(
|
||||
package_name=package_name,
|
||||
package_data=data_set,
|
||||
source_file=data_path,
|
||||
prefix_config_keys=[],
|
||||
ignore_package_name=True,
|
||||
)
|
||||
elif isinstance(package_data, dict):
|
||||
yield from extract_automation_from_package(
|
||||
package_data=package_data,
|
||||
package_name=package_name,
|
||||
source_file=source_file,
|
||||
prefix_config_keys=prefix_config_keys,
|
||||
ignore_package_name=ignore_package_name,
|
||||
)
|
||||
elif package_data is not None:
|
||||
raise InvalidPackage(
|
||||
f"configurations.homeassistant.packages.{package_name} must be a dictionary but got {type(package_data)}!"
|
||||
)
|
||||
except InvalidPackage as err:
|
||||
logger.error(err)
|
||||
|
||||
|
||||
def extract_automation_from_package(
|
||||
|
||||
@@ -1,21 +1,28 @@
|
||||
from pathlib import Path
|
||||
from typing import Iterator, NamedTuple, Tuple, Union
|
||||
from typing import Iterator, NamedTuple, Tuple
|
||||
|
||||
from yaml.nodes import Node
|
||||
|
||||
from src.logger import get_logger
|
||||
|
||||
from .manager import YamlManager
|
||||
|
||||
dump_yaml = YamlManager.dump_yaml
|
||||
load_yaml = YamlManager.load_yaml
|
||||
|
||||
logger = get_logger(__file__)
|
||||
|
||||
|
||||
def load_dir_yaml(folder_or_file: Path) -> Iterator[Tuple[Path, dict | list]]:
|
||||
if folder_or_file.is_dir():
|
||||
for file in folder_or_file.iterdir():
|
||||
yield from load_dir_yaml(file)
|
||||
else:
|
||||
with folder_or_file.open("r") as fp:
|
||||
yield folder_or_file, load_yaml(fp, root_path=folder_or_file.parent)
|
||||
if folder_or_file.suffix.lower() == ".yaml":
|
||||
with folder_or_file.open("r") as fp:
|
||||
yield folder_or_file, load_yaml(fp, root_path=folder_or_file.parent)
|
||||
else:
|
||||
logger.info(f"Ignoring the file {folder_or_file}")
|
||||
|
||||
|
||||
@YamlManager.as_constructor("!include")
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
# all the packages!
|
||||
|
||||
This is really cool :)
|
||||
|
||||
- A list item!
|
||||
|
||||
<<more thisngs!>>
|
||||
@@ -0,0 +1,7 @@
|
||||
# all the packages!
|
||||
|
||||
This is really cool :)
|
||||
|
||||
- A list item!
|
||||
|
||||
<<more thisngs!>>
|
||||
@@ -0,0 +1,7 @@
|
||||
# all the packages!
|
||||
|
||||
This is really cool :)
|
||||
|
||||
- A list item!
|
||||
|
||||
<<more thisngs!>>
|
||||
@@ -0,0 +1,7 @@
|
||||
# all the packages!
|
||||
|
||||
This is really cool :)
|
||||
|
||||
- A list item!
|
||||
|
||||
<<more thisngs!>>
|
||||
@@ -0,0 +1,21 @@
|
||||
- alias: UI 1
|
||||
description: Example
|
||||
mode: single
|
||||
trigger:
|
||||
- platform: homeassistant
|
||||
event: start
|
||||
condition: []
|
||||
action:
|
||||
- service: counter.increment
|
||||
data: {}
|
||||
target:
|
||||
entity_id: counter.up_times
|
||||
- alias: UI 2
|
||||
description: ""
|
||||
trigger:
|
||||
- platform: sun
|
||||
event: sunrise
|
||||
offset: 0
|
||||
condition: []
|
||||
action: []
|
||||
mode: single
|
||||
@@ -0,0 +1,2 @@
|
||||
homeassistant:
|
||||
packages: !include_dir_named integrations
|
||||
Whitespace-only changes.
@@ -0,0 +1 @@
|
||||
automation: !include ../automations.yaml
|
||||
@@ -0,0 +1 @@
|
||||
media_player: !include_dir_list ../entities/media_players
|
||||
@@ -0,0 +1,21 @@
|
||||
- alias: UI 1
|
||||
description: Example
|
||||
mode: single
|
||||
trigger:
|
||||
- platform: homeassistant
|
||||
event: start
|
||||
condition: []
|
||||
action:
|
||||
- service: counter.increment
|
||||
data: {}
|
||||
target:
|
||||
entity_id: counter.up_times
|
||||
- alias: UI 2
|
||||
description: ""
|
||||
trigger:
|
||||
- platform: sun
|
||||
event: sunrise
|
||||
offset: 0
|
||||
condition: []
|
||||
action: []
|
||||
mode: single
|
||||
@@ -0,0 +1,2 @@
|
||||
homeassistant:
|
||||
packages: !include_dir_named integrations
|
||||
@@ -0,0 +1 @@
|
||||
automation: !include ../automations.yaml
|
||||
@@ -0,0 +1 @@
|
||||
# media_player: !include_dir_list ../entities/media_players
|
||||
@@ -0,0 +1,21 @@
|
||||
- alias: UI 1
|
||||
description: Example
|
||||
mode: single
|
||||
trigger:
|
||||
- platform: homeassistant
|
||||
event: start
|
||||
condition: []
|
||||
action:
|
||||
- service: counter.increment
|
||||
data: {}
|
||||
target:
|
||||
entity_id: counter.up_times
|
||||
- alias: UI 2
|
||||
description: ""
|
||||
trigger:
|
||||
- platform: sun
|
||||
event: sunrise
|
||||
offset: 0
|
||||
condition: []
|
||||
action: []
|
||||
mode: single
|
||||
@@ -0,0 +1,2 @@
|
||||
homeassistant:
|
||||
packages: !include_dir_named integrations
|
||||
@@ -0,0 +1 @@
|
||||
automation: !include ../automations.yaml
|
||||
@@ -0,0 +1 @@
|
||||
media_player:
|
||||
@@ -0,0 +1,21 @@
|
||||
- alias: UI 1
|
||||
description: Example
|
||||
mode: single
|
||||
trigger:
|
||||
- platform: homeassistant
|
||||
event: start
|
||||
condition: []
|
||||
action:
|
||||
- service: counter.increment
|
||||
data: {}
|
||||
target:
|
||||
entity_id: counter.up_times
|
||||
- alias: UI 2
|
||||
description: ""
|
||||
trigger:
|
||||
- platform: sun
|
||||
event: sunrise
|
||||
offset: 0
|
||||
condition: []
|
||||
action: []
|
||||
mode: single
|
||||
@@ -0,0 +1,2 @@
|
||||
homeassistant:
|
||||
packages: !include_dir_named integrations
|
||||
@@ -0,0 +1 @@
|
||||
- platform: media
|
||||
@@ -0,0 +1 @@
|
||||
automation: !include ../automations.yaml
|
||||
@@ -0,0 +1,16 @@
|
||||
- platform: ping
|
||||
host: 192.168.0.119
|
||||
name: "Ping Pc Tv"
|
||||
scan_interval: 10
|
||||
- platform: ping
|
||||
host: 192.168.0.181
|
||||
name: "Ping Living Room Tv"
|
||||
scan_interval: 10
|
||||
- platform: ping
|
||||
host: 192.168.0.100
|
||||
name: "Ping Printer"
|
||||
scan_interval: 15
|
||||
- platform: ping
|
||||
host: 192.168.0.177
|
||||
name: "Ping Broadlink"
|
||||
scan_interval: 15
|
||||
@@ -0,0 +1 @@
|
||||
media_player: !include_dir_list ../entities/media_players
|
||||
@@ -22,6 +22,10 @@ from tests.utils import (
|
||||
HA_CONFIG11_EXAMPLE,
|
||||
HA_CONFIG12_EXAMPLE,
|
||||
HA_CONFIG13_EXAMPLE,
|
||||
HA_CONFIG14_EXAMPLE,
|
||||
HA_CONFIG15_EXAMPLE,
|
||||
HA_CONFIG16_EXAMPLE,
|
||||
HA_CONFIG17_EXAMPLE,
|
||||
HA_CONFIG_EXAMPLE,
|
||||
)
|
||||
|
||||
@@ -162,6 +166,10 @@ class loader_tests(TestCase):
|
||||
(HA_CONFIG11_EXAMPLE, 3),
|
||||
(HA_CONFIG12_EXAMPLE, 4),
|
||||
(HA_CONFIG13_EXAMPLE, 4),
|
||||
(HA_CONFIG14_EXAMPLE, 1),
|
||||
(HA_CONFIG15_EXAMPLE, 1),
|
||||
(HA_CONFIG16_EXAMPLE, 1),
|
||||
(HA_CONFIG17_EXAMPLE, 1),
|
||||
]:
|
||||
with self.subTest(config_name=ha_path.name, expected=expected):
|
||||
hass_config = HassConfig(ha_path)
|
||||
|
||||
@@ -23,6 +23,10 @@ HA_CONFIG10_EXAMPLE = SAMPLES_FOLDER / "config-10"
|
||||
HA_CONFIG11_EXAMPLE = SAMPLES_FOLDER / "config-11"
|
||||
HA_CONFIG12_EXAMPLE = SAMPLES_FOLDER / "config-12"
|
||||
HA_CONFIG13_EXAMPLE = SAMPLES_FOLDER / "config-13"
|
||||
HA_CONFIG14_EXAMPLE = SAMPLES_FOLDER / "config-14"
|
||||
HA_CONFIG15_EXAMPLE = SAMPLES_FOLDER / "config-15"
|
||||
HA_CONFIG16_EXAMPLE = SAMPLES_FOLDER / "config-16"
|
||||
HA_CONFIG17_EXAMPLE = SAMPLES_FOLDER / "config-17"
|
||||
|
||||
|
||||
def get_example_automation_loader(
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
name: Shortumation
|
||||
version: v0.7.1
|
||||
version: v0.7.4
|
||||
slug: shortumation
|
||||
image: "asosnovsky/shortumation-{arch}"
|
||||
url: "https://github.com/asosnovsky/Shortumation"
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import "./App.css";
|
||||
import { Routes, Route, BrowserRouter } from "react-router-dom";
|
||||
import { AutomationRoute } from "routes/automation";
|
||||
import { useConnectedApiService } from "apiService";
|
||||
import { useConnectedApiService } from "services/api";
|
||||
import { ErrorBoundary } from "components/ErrorBoundary";
|
||||
import { CookiesProvider } from "react-cookie";
|
||||
import { Page } from "components/Page";
|
||||
|
||||
@@ -10,7 +10,7 @@ import { AddIcon, TrashIcon } from "components/Icons";
|
||||
import InputAutoText from "components/Inputs/InputAutoText";
|
||||
import { TagDB } from "components/AutomationManager/TagDB";
|
||||
import { ButtonIcon } from "components/Icons/ButtonIcons";
|
||||
import { useLang } from "lang";
|
||||
import { useLang } from "services/lang";
|
||||
|
||||
export interface AutoInfoBoxProps {
|
||||
metadata: AutomationMetadata & Partial<AutomationShortumationMetadata>;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import "./index.css";
|
||||
|
||||
import { AutomationNode, AutomationNodeMapping } from "types/automations";
|
||||
import { useHA } from "haService";
|
||||
import { useHA } from "services/ha";
|
||||
import { CollectionNodeElement } from "components/DAGGraph/nodes/CollectionNode/CollectionNodeElement";
|
||||
import { getDescriptionFromAutomationNode } from "utils/formatting";
|
||||
import { Size } from "components/DAGGraph/elements/types";
|
||||
|
||||
@@ -31,7 +31,7 @@ import { MiniFailure } from "types/validators/helper";
|
||||
|
||||
import { AutoInfoBox } from "./AutoInfoBox";
|
||||
import { useAutomatioEditorState, EditorData } from "./state";
|
||||
import { useLang } from "lang";
|
||||
import { useLang } from "services/lang";
|
||||
import { useSnackbar } from "notistack";
|
||||
import { Alert } from "@mui/material";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HassEntities } from "home-assistant-js-websocket";
|
||||
import { LangStore, useLang } from "lang";
|
||||
import { LangStore, useLang } from "services/lang";
|
||||
import { useEffect, useState } from "react";
|
||||
import { AutomationData, BareAutomationData } from "types/automations";
|
||||
import { defaultAutomation } from "utils/defaults";
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
} from "./state";
|
||||
import Alert from "@mui/material/Alert";
|
||||
import { useConfirm } from "material-ui-confirm";
|
||||
import { useLang } from "lang";
|
||||
import { useLang } from "services/lang";
|
||||
|
||||
export type AutomationManagerLoadedProps = UseAutomationManagerStateArgs & {
|
||||
onAutomationDelete: (aid: string, eid: string) => void;
|
||||
|
||||
@@ -7,7 +7,7 @@ import { useAutomationDB } from "./automationDB";
|
||||
import { useConfirm } from "material-ui-confirm";
|
||||
import { AutomationManagerAutoUpdatable } from "../types";
|
||||
import { useSnackbar } from "notistack";
|
||||
import { useLang } from "lang";
|
||||
import { useLang } from "services/lang";
|
||||
|
||||
export type UseAutomationManagerStateArgs = {
|
||||
configAutomations: AutomationData[];
|
||||
|
||||
@@ -12,7 +12,7 @@ import { Button } from "components/Inputs/Buttons/Button";
|
||||
import InputAutoText from "components/Inputs/InputAutoText";
|
||||
|
||||
import { TagDB } from "../TagDB";
|
||||
import { useLang } from "lang";
|
||||
import { useLang } from "services/lang";
|
||||
|
||||
export type TagsProps = {
|
||||
automationId: string;
|
||||
|
||||
@@ -18,7 +18,7 @@ import { ButtonIcon } from "components/Icons/ButtonIcons";
|
||||
import { AutomationManagerAuto } from "../types";
|
||||
import { Tags } from "./Tags";
|
||||
import { TagDB } from "../TagDB";
|
||||
import { useLang } from "lang";
|
||||
import { useLang } from "services/lang";
|
||||
|
||||
export type MetadataBoxProps = AutomationManagerAuto & {
|
||||
onDelete: () => void;
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
} from "../types";
|
||||
import { Button } from "components/Inputs/Buttons/Button";
|
||||
import { ButtonIcon } from "components/Icons/ButtonIcons";
|
||||
import { useLang } from "lang";
|
||||
import { useLang } from "services/lang";
|
||||
|
||||
export type AutomationManagerSidebarProps = {
|
||||
tagsDB: TagDB;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { makeStory } from "devUtils";
|
||||
import { useMockApiService } from "apiService";
|
||||
import { useMockApiService } from "services/api";
|
||||
import { AutomationManager } from ".";
|
||||
import {
|
||||
MockHAEntitiesProps,
|
||||
useMockHAEntities,
|
||||
} from "haService/HAEntities.mock";
|
||||
} from "services/ha/HAEntities.mock";
|
||||
import { AutomationData } from "types/automations";
|
||||
import { createMockAuto } from "utils/mocks";
|
||||
import { useState } from "react";
|
||||
|
||||
@@ -4,8 +4,8 @@ import { FC, useEffect, useRef, useState } from "react";
|
||||
import LinearProgress from "@mui/material/LinearProgress";
|
||||
import Skeleton from "@mui/material/Skeleton";
|
||||
|
||||
import { ApiService } from "apiService/core";
|
||||
import { HAEntitiesState } from "haService/HAEntities";
|
||||
import { ApiService } from "services/api/core";
|
||||
import { HAEntitiesState } from "services/ha/HAEntities";
|
||||
import { AutomationManagerLoaded } from "./Loaded";
|
||||
import { Alert } from "@mui/material";
|
||||
import { useSnackbar } from "notistack";
|
||||
@@ -14,8 +14,8 @@ import { getFailures } from "types/validators/helper";
|
||||
import * as av from "types/validators/autmation";
|
||||
import { useConfirm } from "material-ui-confirm";
|
||||
import InputYaml from "components/Inputs/Base/InputYaml";
|
||||
import { APIResponse } from "apiService/types";
|
||||
import { useLang } from "lang";
|
||||
import { APIResponse } from "services/api/types";
|
||||
import { useLang } from "services/lang";
|
||||
|
||||
export type AutomationManagerProps = {
|
||||
onAutomationStateChange: (eid: string, on: boolean) => Promise<any>;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import Alert from "@mui/material/Alert";
|
||||
import Skeleton from "@mui/material/Skeleton";
|
||||
import { ApiService } from "apiService/core";
|
||||
import { UserProfile } from "apiService/types";
|
||||
import { ApiService } from "services/api/core";
|
||||
import { UserProfile } from "services/api/types";
|
||||
import { InputList } from "components/Inputs/InputList";
|
||||
import { useLang } from "lang";
|
||||
import { useLang } from "services/lang";
|
||||
import { FC, useState } from "react";
|
||||
import LinearProgress from "@mui/material/LinearProgress";
|
||||
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
import "./index.css";
|
||||
import { FC, useState } from "react";
|
||||
import { useHAConnection } from "haService/connection";
|
||||
import { useHAConnection } from "services/ha/connection";
|
||||
import { Button } from "components/Inputs/Buttons/Button";
|
||||
import SettingsSuggestOutlinedIcon from "@mui/icons-material/SettingsSuggestOutlined";
|
||||
import { useLang } from "lang";
|
||||
import { useLang } from "services/lang";
|
||||
import { Modal } from "components/Modal";
|
||||
import { UserProfileEditor, UserProfileProps } from "./UserProfile";
|
||||
import { useVersioner } from "services/versioner";
|
||||
|
||||
export type BottomBarProps = UserProfileProps;
|
||||
export const BottomBar: FC<BottomBarProps> = ({ api }) => {
|
||||
const lang = useLang();
|
||||
const ha = useHAConnection();
|
||||
const version = process.env.REACT_APP_BUILD_VERSION ?? "n/a";
|
||||
const versionMgr = useVersioner();
|
||||
const [isOpen, setOpen] = useState(false);
|
||||
|
||||
return (
|
||||
@@ -31,7 +32,7 @@ export const BottomBar: FC<BottomBarProps> = ({ api }) => {
|
||||
🟢
|
||||
</b>
|
||||
</span>
|
||||
<span>version: {version}</span>
|
||||
<span>version: {versionMgr.current}</span>
|
||||
<Button className="settings" onClick={() => setOpen(!isOpen)}>
|
||||
<SettingsSuggestOutlinedIcon />
|
||||
{lang.get("USER_PRERENCES")}
|
||||
|
||||
@@ -6,13 +6,13 @@ import { FC, useState } from "react";
|
||||
import { AutomationCondition } from "types/automations/conditions";
|
||||
import { getSubTypeList } from "utils/automations";
|
||||
import { getConditionDefaultValues } from "utils/defaults";
|
||||
import { useHA } from "haService";
|
||||
import { useHA } from "services/ha";
|
||||
import InputYaml from "components/Inputs/Base/InputYaml";
|
||||
import { getViewer } from "./viewRender";
|
||||
import { getEditor } from "./editorRender";
|
||||
import useWindowSize from "utils/useWindowSize";
|
||||
import { ConditionNodeSettings } from "./ConditionNodeSettings";
|
||||
import { useLang } from "lang";
|
||||
import { useLang } from "services/lang";
|
||||
|
||||
export type ConditionNodeBaseProps = {
|
||||
condition: AutomationCondition;
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
import { genUpdateMethods } from "./nestedUpdater";
|
||||
import { InputTime } from "components/Inputs/Base/InputTime";
|
||||
import InputYaml from "components/Inputs/Base/InputYaml";
|
||||
import { HAService } from "haService";
|
||||
import { HAService } from "services/ha";
|
||||
import { DeviceEditor } from "components/DeviceEditor";
|
||||
import { ButtonIcon } from "components/Icons/ButtonIcons";
|
||||
import AddIcon from "@mui/icons-material/Add";
|
||||
@@ -31,7 +31,7 @@ import { prettyName } from "utils/formatting";
|
||||
import { InputList } from "components/Inputs/InputList";
|
||||
import { Button } from "components/Inputs/Buttons/Button";
|
||||
import { RemoveCircle } from "@mui/icons-material";
|
||||
import { LangStore } from "lang";
|
||||
import { LangStore } from "services/lang";
|
||||
|
||||
interface Editor<C extends AutomationCondition>
|
||||
extends FC<{
|
||||
|
||||
@@ -3,7 +3,7 @@ import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { Page } from "components/Page";
|
||||
import { DAGGraphBoard } from "components/DAGGraph/board";
|
||||
import { useAutomationNodes } from "./index";
|
||||
import { useHA } from "haService";
|
||||
import { useHA } from "services/ha";
|
||||
import { AutomationActionData } from "types/automations";
|
||||
import { createUpdaterFromAutomationData } from "../updater";
|
||||
import { ModalState } from "../board/types";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { FC, useState, ReactNode } from "react";
|
||||
import { AutomationSequenceNode } from "types/automations";
|
||||
import { useHA } from "haService";
|
||||
import { useHA } from "services/ha";
|
||||
import { ModalState } from "./board/types";
|
||||
import { createUpdater } from "./updater";
|
||||
import { useAutomationNodes } from "./elements";
|
||||
|
||||
@@ -13,7 +13,7 @@ import { prettyName } from "utils/formatting";
|
||||
import DeleteForeverIcon from "@mui/icons-material/DeleteForever";
|
||||
import { useConfirm } from "material-ui-confirm";
|
||||
import { useSnackbar } from "notistack";
|
||||
import { useLang } from "lang";
|
||||
import { useLang } from "services/lang";
|
||||
|
||||
export const CollectionNodeElement: FC<PropsWithChildren<CollectionNodeProps>> =
|
||||
({
|
||||
|
||||
@@ -16,7 +16,7 @@ import InputBoolean from "components/Inputs/Base/InputBoolean";
|
||||
import { SpeedDial } from "components/SpeedDial";
|
||||
import { SequenceNodeElementProps } from "./types";
|
||||
import { useSequenceNodeColor } from "./util";
|
||||
import { useLang } from "lang";
|
||||
import { useLang } from "services/lang";
|
||||
|
||||
export const SequenceNodeElement: FC<
|
||||
PropsWithChildren<SequenceNodeElementProps>
|
||||
|
||||
@@ -6,9 +6,9 @@ import { InputDevice } from "components/Inputs/AutoComplete/InputDevice";
|
||||
import { InputDeviceCapabilties } from "components/Inputs/AutoComplete/InputDeviceCapabilties";
|
||||
import { InputEntity } from "components/Inputs/AutoComplete/InputEntities";
|
||||
import { cleanUpUndefined } from "utils/helpers";
|
||||
import { DeviceBaseType, DeviceTypeCapability } from "haService/types";
|
||||
import { DeviceBaseType, DeviceTypeCapability } from "services/ha/types";
|
||||
import { AutomationDeviceState } from "types/automations/common";
|
||||
import { useLang } from "lang";
|
||||
import { useLang } from "services/lang";
|
||||
|
||||
export type DeviceEditorProps<DBT extends DeviceBaseType> = {
|
||||
type: "action" | "condition" | "trigger";
|
||||
|
||||
@@ -2,7 +2,7 @@ import "./ButtonIcons.css";
|
||||
import Tooltip from "@mui/material/Tooltip";
|
||||
import { FC, ReactNode } from "react";
|
||||
import IconButton, { IconButtonTypeMap } from "@mui/material/IconButton";
|
||||
import { useLang } from "lang";
|
||||
import { useLang } from "services/lang";
|
||||
|
||||
export type ButtonIconProps = {
|
||||
icon: ReactNode;
|
||||
|
||||
@@ -3,8 +3,8 @@ import {
|
||||
InputAutoComplete,
|
||||
InputAutoCompletePropsBase,
|
||||
} from "./InputAutoComplete";
|
||||
import { useHAAreas } from "haService/AreaRegistry";
|
||||
import { useLang } from "lang";
|
||||
import { useHAAreas } from "services/ha/AreaRegistry";
|
||||
import { useLang } from "services/lang";
|
||||
|
||||
export type InputAreaProps = InputAutoCompletePropsBase & {
|
||||
restrictToDomain?: string[];
|
||||
|
||||
@@ -7,7 +7,7 @@ import Popper from "@mui/material/Popper";
|
||||
import { SearchItem } from "./extras";
|
||||
import { ReactNode } from "react";
|
||||
import { prettyName } from "utils/formatting";
|
||||
import { useLang } from "lang";
|
||||
import { useLang } from "services/lang";
|
||||
|
||||
export type BaseOption<T = {}> = {
|
||||
id: string;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { FC } from "react";
|
||||
import { useHADeviceRegistry } from "haService";
|
||||
import { useLang } from "lang";
|
||||
import { useHADeviceRegistry } from "services/ha";
|
||||
import { useLang } from "services/lang";
|
||||
import {
|
||||
InputAutoComplete,
|
||||
InputAutoCompletePropsBase,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import "./InputDeviceCapabilties.css";
|
||||
import { HaFormSchema } from "haService/types";
|
||||
import { HaFormSchema } from "services/ha/types";
|
||||
import { useSnackbar } from "notistack";
|
||||
import { useRef } from "react";
|
||||
import { prettyName } from "utils/formatting";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { FC } from "react";
|
||||
import { useHAEntities } from "haService/HAEntities";
|
||||
import { useHAEntities } from "services/ha/HAEntities";
|
||||
import {
|
||||
InputAutoComplete,
|
||||
InputAutoCompletePropsBase,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { FC } from "react";
|
||||
import { useHAServices } from "haService";
|
||||
import { useHAServices } from "services/ha";
|
||||
import {
|
||||
InputAutoComplete,
|
||||
InputAutoCompletePropsBase,
|
||||
} from "./InputAutoComplete";
|
||||
import { prettyName } from "utils/formatting";
|
||||
import { useLang } from "lang";
|
||||
import { useLang } from "services/lang";
|
||||
|
||||
export type InputServiceProps = InputAutoCompletePropsBase & {
|
||||
multiple?: false;
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
} from "utils/time";
|
||||
import { InputEntity } from "./InputEntities";
|
||||
import { InputTime } from "components/Inputs/Base/InputTime";
|
||||
import { useLang } from "lang";
|
||||
import { useLang } from "services/lang";
|
||||
|
||||
export type InputTimeEntityProps = {
|
||||
value: string;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import React, { ReactNode, useState } from "react";
|
||||
import { useToolTip } from "tooltip/context";
|
||||
import { ReactNode, useState } from "react";
|
||||
import TextField from "@mui/material/TextField";
|
||||
|
||||
export interface Props {
|
||||
@@ -22,19 +21,16 @@ export default function InputText({
|
||||
label,
|
||||
title,
|
||||
helperText,
|
||||
textBoxFor,
|
||||
value = "",
|
||||
onChange,
|
||||
endAdornment,
|
||||
onEnter = () => {},
|
||||
additionalTooltipFilters = {},
|
||||
multiline = false,
|
||||
maxRows = 4,
|
||||
className,
|
||||
placeholder,
|
||||
required,
|
||||
}: Props) {
|
||||
const tooltip = useToolTip();
|
||||
const [isFocused, setIsFocused] = useState(false);
|
||||
return (
|
||||
<TextField
|
||||
@@ -68,17 +64,6 @@ export default function InputText({
|
||||
}}
|
||||
onFocus={(e) => {
|
||||
setIsFocused(true);
|
||||
if (textBoxFor) {
|
||||
tooltip.setFocus(
|
||||
e.target.getBoundingClientRect(),
|
||||
{
|
||||
searchObject: textBoxFor,
|
||||
searchText: value,
|
||||
filterObjects: additionalTooltipFilters,
|
||||
},
|
||||
onChange
|
||||
);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
} from "utils/time";
|
||||
import { prettyName } from "utils/formatting";
|
||||
import { ButtonIcon } from "components/Icons/ButtonIcons";
|
||||
import { useLang } from "lang";
|
||||
import { useLang } from "services/lang";
|
||||
|
||||
// constants
|
||||
const fields: Array<keyof AutomationTimeObject> = [
|
||||
|
||||
@@ -9,7 +9,7 @@ import FormHelperText from "@mui/material/FormHelperText";
|
||||
import InputAdornment from "@mui/material/InputAdornment";
|
||||
import { Save } from "@mui/icons-material";
|
||||
import { ButtonIcon } from "components/Icons/ButtonIcons";
|
||||
import { useLang } from "lang";
|
||||
import { useLang } from "services/lang";
|
||||
|
||||
export interface Props<T extends {}> {
|
||||
label: string;
|
||||
|
||||
@@ -7,7 +7,7 @@ import FormControl from "@mui/material/FormControl";
|
||||
import Select from "@mui/material/Select";
|
||||
import { prettyName } from "utils/formatting";
|
||||
import { ReactNode } from "react";
|
||||
import { useLang } from "lang";
|
||||
import { useLang } from "services/lang";
|
||||
|
||||
export type Props<T extends string | Object> = {
|
||||
current?: T;
|
||||
|
||||
@@ -5,7 +5,7 @@ import Autocomplete from "@mui/material/Autocomplete";
|
||||
import TextField from "@mui/material/TextField";
|
||||
import Checkbox from "@mui/material/Checkbox";
|
||||
import { useSnackbar } from "notistack";
|
||||
import { useLang } from "lang";
|
||||
import { useLang } from "services/lang";
|
||||
|
||||
export interface Props<T extends string> {
|
||||
label: string;
|
||||
|
||||
@@ -5,7 +5,7 @@ import CheckCircleOutlineOutlinedIcon from "@mui/icons-material/CheckCircleOutli
|
||||
import ModeEditOutlineOutlinedIcon from "@mui/icons-material/ModeEditOutlineOutlined";
|
||||
import TextField from "@mui/material/TextField";
|
||||
import Tooltip from "@mui/material/Tooltip";
|
||||
import { useLang } from "lang";
|
||||
import { useLang } from "services/lang";
|
||||
|
||||
export type InputTextViewProps = {
|
||||
className?: string;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { HAService } from "haService";
|
||||
import { HAEntitiesState } from "haService/HAEntities";
|
||||
import { LangStore } from "lang";
|
||||
import { HAService } from "services/ha";
|
||||
import { HAEntitiesState } from "services/ha/HAEntities";
|
||||
import { LangStore } from "services/lang";
|
||||
import { FC } from "react";
|
||||
import { AutomationAction } from "types/automations/actions";
|
||||
import { AutomationCondition } from "types/automations/conditions";
|
||||
|
||||
@@ -15,7 +15,7 @@ import { Button } from "components/Inputs/Buttons/Button";
|
||||
import { useState } from "react";
|
||||
import AddIcon from "@mui/icons-material/Add";
|
||||
import { InputTimeEntity } from "components/Inputs/AutoComplete/InputTimeEntity";
|
||||
import { useLang } from "lang";
|
||||
import { useLang } from "services/lang";
|
||||
|
||||
export const TriggerTime: OptionManager<AutomationTriggerTime> = {
|
||||
defaultState: () => ({
|
||||
|
||||
@@ -10,10 +10,10 @@ import {
|
||||
import InputYaml from "components/Inputs/Base/InputYaml";
|
||||
import InputText from "components/Inputs/Base/InputText";
|
||||
import { getDescriptionFromAutomationNode } from "utils/formatting";
|
||||
import { useHA } from "haService";
|
||||
import { useHA } from "services/ha";
|
||||
import { Generic } from "./Generic";
|
||||
import { getNodeTypeAndValidate } from "utils/automations";
|
||||
import { useLang } from "lang";
|
||||
import { useLang } from "services/lang";
|
||||
|
||||
type UseState = <S>(s: S) => [S, Dispatch<SetStateAction<S>>];
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { Button } from "components/Inputs/Buttons/Button";
|
||||
import InputBoolean from "components/Inputs/Base/InputBoolean";
|
||||
import { useConfirm } from "material-ui-confirm";
|
||||
import { getNodeSubTypeDescription } from "./utils";
|
||||
import { useLang } from "lang";
|
||||
import { useLang } from "services/lang";
|
||||
|
||||
export interface NodeEditorProps {
|
||||
node: AutomationNode;
|
||||
|
||||
@@ -10,23 +10,28 @@ import {
|
||||
import { BottomBar } from "components/BottomBar";
|
||||
import { SnackbarKey, SnackbarProvider, useSnackbar } from "notistack";
|
||||
import Button from "@mui/material/Button";
|
||||
import { useHAConnection } from "haService/connection";
|
||||
import { useHAConnection } from "services/ha/connection";
|
||||
import { ConfirmProvider } from "material-ui-confirm";
|
||||
import { Color } from "@mui/material";
|
||||
import { Color, Skeleton, Theme } from "@mui/material";
|
||||
import useWindowSize from "utils/useWindowSize";
|
||||
import { ApiService } from "apiService/core";
|
||||
import { ApiStateProvider, useMockApiService } from "apiService";
|
||||
import { ApiService } from "services/api/core";
|
||||
import { ApiStateProvider, useMockApiService } from "services/api";
|
||||
import { LangProvider, LangStore, useLang } from "services/lang";
|
||||
|
||||
export type PageProps = PropsWithChildren<{
|
||||
api: ApiService;
|
||||
}>;
|
||||
|
||||
export const InternalPage: FC<PageProps> = ({ children, api }) => {
|
||||
export const BareInternalPage: FC<
|
||||
PageProps & {
|
||||
isMobile: boolean;
|
||||
theme: Theme;
|
||||
lang: LangStore;
|
||||
}
|
||||
> = ({ children, api, isMobile, theme, lang }) => {
|
||||
const conn = useHAConnection();
|
||||
const theme = useTheme();
|
||||
const snackbar = useSnackbar();
|
||||
const snackbarKeyHAConKey = useRef<SnackbarKey | null>(null);
|
||||
const { isMobile } = useWindowSize();
|
||||
|
||||
useEffect(() => {
|
||||
if (conn.status === "error") {
|
||||
@@ -46,12 +51,6 @@ export const InternalPage: FC<PageProps> = ({ children, api }) => {
|
||||
if (snackbarKeyHAConKey.current) {
|
||||
snackbar.closeSnackbar(snackbarKeyHAConKey.current);
|
||||
}
|
||||
snackbarKeyHAConKey.current = snackbar.enqueueSnackbar(
|
||||
`Connecting to websocket...`,
|
||||
{
|
||||
variant: "info",
|
||||
}
|
||||
);
|
||||
} else if (conn.status === "loaded") {
|
||||
if (snackbarKeyHAConKey.current) {
|
||||
snackbar.closeSnackbar(snackbarKeyHAConKey.current);
|
||||
@@ -60,15 +59,38 @@ export const InternalPage: FC<PageProps> = ({ children, api }) => {
|
||||
}, [conn, snackbar]);
|
||||
|
||||
return (
|
||||
<main className={["page", "column", isMobile ? "mobile" : ""].join(" ")}>
|
||||
<div className="page-contents column">{children}</div>
|
||||
<BottomBar api={api} />
|
||||
<style>
|
||||
{`:root {
|
||||
${convertPaletteToCss(theme.palette)}
|
||||
}`}
|
||||
</style>
|
||||
</main>
|
||||
<ConfirmProvider
|
||||
defaultOptions={{
|
||||
cancellationText: lang.get("CLOSE"),
|
||||
confirmationText: lang.get("CONFIRM"),
|
||||
}}
|
||||
>
|
||||
<main className={["page", "column", isMobile ? "mobile" : ""].join(" ")}>
|
||||
<div className="page-contents column">{children}</div>
|
||||
<BottomBar api={api} />
|
||||
<style>
|
||||
{`:root {
|
||||
${convertPaletteToCss(theme.palette)}
|
||||
}`}
|
||||
</style>
|
||||
</main>
|
||||
</ConfirmProvider>
|
||||
);
|
||||
};
|
||||
|
||||
export const InternalPage: FC<PageProps> = ({ children, api }) => {
|
||||
const theme = useTheme();
|
||||
const { isMobile } = useWindowSize();
|
||||
const lang = useLang();
|
||||
|
||||
if (!lang.ready) {
|
||||
return <Skeleton />;
|
||||
}
|
||||
|
||||
return (
|
||||
<BareInternalPage api={api} isMobile={isMobile} theme={theme} lang={lang}>
|
||||
{children}
|
||||
</BareInternalPage>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -85,24 +107,22 @@ export const Page: FC<PageProps> = (props) => {
|
||||
|
||||
return (
|
||||
<ThemeProvider theme={theme}>
|
||||
<ConfirmProvider>
|
||||
<SnackbarProvider
|
||||
anchorOrigin={{
|
||||
vertical: "bottom",
|
||||
horizontal: "center",
|
||||
}}
|
||||
ref={notistackRef}
|
||||
action={(key) => (
|
||||
<Button onClick={onClickDismiss(key)}>Dismiss</Button>
|
||||
)}
|
||||
dense
|
||||
preventDuplicate
|
||||
>
|
||||
<ApiStateProvider value={props.api.state}>
|
||||
<SnackbarProvider
|
||||
anchorOrigin={{
|
||||
vertical: "bottom",
|
||||
horizontal: "center",
|
||||
}}
|
||||
ref={notistackRef}
|
||||
action={(key) => <Button onClick={onClickDismiss(key)}>Dismiss</Button>}
|
||||
dense
|
||||
preventDuplicate
|
||||
>
|
||||
<ApiStateProvider value={props.api.state}>
|
||||
<LangProvider>
|
||||
<InternalPage {...props} />
|
||||
</ApiStateProvider>
|
||||
</SnackbarProvider>
|
||||
</ConfirmProvider>
|
||||
</LangProvider>
|
||||
</ApiStateProvider>
|
||||
</SnackbarProvider>
|
||||
</ThemeProvider>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
} from "components/Inputs/AutoComplete/InputAutoComplete";
|
||||
import { prettyName } from "utils/formatting";
|
||||
import InputBoolean from "components/Inputs/Base/InputBoolean";
|
||||
import { SelectorNumber, SelectorText } from "haService/fieldTypes";
|
||||
import { SelectorNumber, SelectorText } from "services/ha/fieldTypes";
|
||||
import InputYaml from "components/Inputs/Base/InputYaml";
|
||||
import { useSnackbar } from "notistack";
|
||||
import { InputEntity } from "components/Inputs/AutoComplete/InputEntities";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import "./ServiceEditorTarget.css";
|
||||
import { InputDevice } from "components/Inputs/AutoComplete/InputDevice";
|
||||
import { InputEntity } from "components/Inputs/AutoComplete/InputEntities";
|
||||
import { Targets } from "haService/fieldTypes";
|
||||
import { Targets } from "services/ha/fieldTypes";
|
||||
import { FC } from "react";
|
||||
import { InputArea } from "components/Inputs/AutoComplete/InputArea";
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { useState } from "react";
|
||||
import { ServiceEditor } from ".";
|
||||
import { TypedHassService } from "haService/fieldTypes";
|
||||
import { TypedHassService } from "services/ha/fieldTypes";
|
||||
import InputYaml from "components/Inputs/Base/InputYaml";
|
||||
|
||||
import { makeStory } from "devUtils";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import "./index.css";
|
||||
|
||||
import { cleanUpUndefined } from "utils/helpers";
|
||||
import { TypedHassService } from "haService/fieldTypes";
|
||||
import { TypedHassService } from "services/ha/fieldTypes";
|
||||
import { FC, useState } from "react";
|
||||
import {
|
||||
ServiceEditorOption,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { BaseOption } from "components/Inputs/AutoComplete/InputAutoComplete";
|
||||
import { FieldData, TypedHassService } from "haService/fieldTypes";
|
||||
import { FieldData, TypedHassService } from "services/ha/fieldTypes";
|
||||
import { prettyName } from "utils/formatting";
|
||||
|
||||
export type ServiceEditorData = {
|
||||
|
||||
@@ -2,8 +2,8 @@ import "styles/root.css";
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { Page } from "components/Page";
|
||||
import { ComponentProps, JSXElementConstructor } from "react";
|
||||
import { ApiService } from "apiService/core";
|
||||
import { useConnectedApiService, useMockApiService } from "apiService";
|
||||
import { ApiService } from "services/api/core";
|
||||
import { useConnectedApiService, useMockApiService } from "services/api";
|
||||
|
||||
export type MakeStoryArgs<
|
||||
T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useConnectedApiService } from "apiService";
|
||||
import { useConnectedApiService } from "services/api";
|
||||
import { makeStory } from "devUtils";
|
||||
import { AutomationRoute } from "./automation";
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ApiService } from "apiService/core";
|
||||
import { ApiService } from "services/api/core";
|
||||
import { FC } from "react";
|
||||
import { useHA } from "haService";
|
||||
import { useHA } from "services/ha";
|
||||
import { AutomationManager } from "components/AutomationManager";
|
||||
|
||||
export const AutomationRoute: FC<{ api: ApiService }> = ({ api }) => {
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,6 +1,6 @@
|
||||
import { useAutoMockAPI } from "./mock";
|
||||
import { makeAutomationAPI } from "./automations";
|
||||
import { createMockAuto } from "../utils/mocks";
|
||||
import { createMockAuto } from "utils/mocks";
|
||||
import { AutomationData } from "types/automations";
|
||||
|
||||
const fakeUseRef = (a: any) => ({ current: a });
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -21,10 +21,11 @@ export type APIResponse<D> =
|
||||
};
|
||||
export type Waitable<D> =
|
||||
| { ready: undefined }
|
||||
| ({ ready: true } & APIResponse<D>)
|
||||
| ({ ready: true } & D)
|
||||
| {
|
||||
ready: false;
|
||||
};
|
||||
export type ApiWaitable<D> = Waitable<APIResponse<D>>;
|
||||
export interface ListData<D> {
|
||||
params: ListParams;
|
||||
totalItems: number;
|
||||
@@ -32,8 +33,8 @@ export interface ListData<D> {
|
||||
}
|
||||
|
||||
export interface ApiState {
|
||||
automations: Waitable<ListData<AutomationData>>;
|
||||
userProfile: Waitable<UserProfile>;
|
||||
automations: ApiWaitable<ListData<AutomationData>>;
|
||||
userProfile: ApiWaitable<UserProfile>;
|
||||
}
|
||||
|
||||
export type UserProfile = {
|
||||
@@ -2,7 +2,7 @@ import { useState } from "react";
|
||||
import { ApiState } from "./types";
|
||||
import { AutomationAPI } from "./automations";
|
||||
import { UserProfileAPI } from "./profile";
|
||||
import { UserProfile } from "apiService/types";
|
||||
import { UserProfile } from "services/api/types";
|
||||
|
||||
export const useDefaultApiState = () =>
|
||||
useState<ApiState>({
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -1,6 +1,6 @@
|
||||
import React, { FC, useEffect, useState } from "react";
|
||||
import { makeStory } from "devUtils";
|
||||
import { useHA } from "haService";
|
||||
import { useHA } from "services/ha";
|
||||
import InputYaml from "components/Inputs/Base/InputYaml";
|
||||
import { InputList } from "components/Inputs/InputList";
|
||||
import { Button } from "components/Inputs/Buttons/Button";
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
ERR_INVALID_HTTPS_TO_HTTP,
|
||||
createConnection as _createConnection,
|
||||
} from "home-assistant-js-websocket";
|
||||
import { wsURL } from "apiService";
|
||||
import { wsURL } from "services/api";
|
||||
|
||||
export type HAConnection =
|
||||
| {
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { FC } from "react";
|
||||
import { useHADeviceRegistry } from "haService";
|
||||
import { useHADeviceRegistry } from "services/ha";
|
||||
import InputYaml from "components/Inputs/Base/InputYaml";
|
||||
import { makeStory } from "devUtils";
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import React, { FC, useState } from "react";
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { MockPage } from "components/Page";
|
||||
import { useHAEntities } from "haService/HAEntities";
|
||||
import { useHAEntities } from "services/ha/HAEntities";
|
||||
|
||||
const Test: FC<{ onRender: () => void }> = ({ onRender }) => {
|
||||
const [searchTerm, setSearch] = useState("");
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { FC } from "react";
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { MockPage } from "components/Page";
|
||||
import { useHAEntityRegistry } from "haService";
|
||||
import { useHAEntityRegistry } from "services/ha";
|
||||
|
||||
const Test: FC<{ onRender: () => void }> = ({ onRender }) => {
|
||||
const conn = useHAEntityRegistry();
|
||||
File renamed without changes.
File renamed without changes.
@@ -12,7 +12,7 @@ import { TypedHassService } from "./fieldTypes";
|
||||
import { Option } from "components/Inputs/AutoComplete/InputAutoComplete";
|
||||
import { getDeviceExtraWsCalls } from "./extras";
|
||||
import { useHAEntities } from "./HAEntities";
|
||||
import { useLang } from "lang";
|
||||
import { useLang } from "services/lang";
|
||||
|
||||
export type ServiceOption = Option<{
|
||||
domain: string;
|
||||
Loaded 100 of 111 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user