less annoying ha connection state

This commit is contained in:
ari committed 2022-08-25 12:27:14 -04:00
1 parent 15dfa25e34
commit e2d4022bde
6 files changed
+34 -14

No files matched your search

@@ -264,7 +264,7 @@ export const AutomationManager: FC<AutomationManagerProps> = ({
}
);
}
// refreshAutomations();
refreshAutomations();
}}
onAutomationUpdate={(auto) =>
wrapApiPromise(
-6
View File
@@ -58,12 +58,6 @@ export const InternalPage: FC<{
if (snackbarKeyHAConKey.current) {
snackbar.closeSnackbar(snackbarKeyHAConKey.current);
}
snackbarKeyHAConKey.current = snackbar.enqueueSnackbar(
`Connected to HA!`,
{
variant: "success",
}
);
}
}, [conn, snackbar]);
+16 -1
View File
@@ -1,6 +1,21 @@
.version-box {
position: absolute;
bottom: 0;
bottom: -0.5em;
right: 0;
font-size: 0.5em;
}
.version-box #circle {
color: var(--mui-primary-main);
height: 1em;
width: 1em;
}
.version-box #circle.error {
color: var(--mui-error-main);
}
.version-box #circle.loaded {
color: var(--mui-success-light);
}
+12 -4
View File
@@ -1,9 +1,17 @@
import "./index.css";
import { FC } from "react";
import { useHAConnection } from "haService/connection";
export const VersionBox: FC = () => {
const version = process.env.REACT_APP_BUILD_VERSION ?? "n/a";
return <div className="version-box">
version: {version}
const ha = useHAConnection();
const version = process.env.REACT_APP_BUILD_VERSION ?? "n/a";
return (
<div className="version-box">
version: {version} / HA Connection{" "}
<span id="circle" className={ha.status}>
🟢
</span>
</div>
}
);
};
+4 -1
View File
@@ -229,6 +229,9 @@ export const useHA = () => {
callService,
callHA,
deviceExtras: getDeviceExtraWsCalls(callHA),
reloadAutomations: () => callService("automation", "reload"),
reloadAutomations: () =>
conn.status === "loaded"
? callService("automation", "reload")
: Promise.resolve(),
};
};
+1 -1
View File
@@ -8,7 +8,7 @@ export const AutomationRoute: FC<{ api: ApiService }> = ({ api }) => {
return (
<AutomationManager
api={api}
refreshAutomations={() => ha.callService("automation", "reload")}
refreshAutomations={() => ha.reloadAutomations()}
triggerAutomation={(entity_id) =>
ha.callService(
"automation",