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