initial v2 list

This commit is contained in:
ari committed 2022-07-27 19:27:30 -04:00
1 parent dfcbe9e76a
commit f20eb271d9
23 files changed
+1379 -54

No files matched your search

+58
View File
@@ -0,0 +1,58 @@
import { createHAEntitiesState } from "./HAEntities";
import { EntitySource } from "./types";
import { HassEntities } from "home-assistant-js-websocket";
export type MockHAEntitiesProps =
| {
loading: true;
}
| {
loading: false;
entities: HassEntities;
entitySource: Record<string, EntitySource>;
};
export const useMockHAEntities = (args: MockHAEntitiesProps) => {
if (args.loading) {
return createHAEntitiesState(
{
additional: {},
ready: false,
collection: {
state: {},
refresh: () => new Promise(() => {}),
subscribe: () => () => {},
},
},
{
additional: {},
ready: false,
collection: {
state: {},
refresh: () => new Promise(() => {}),
subscribe: () => () => {},
},
}
);
} else {
return createHAEntitiesState(
{
additional: {},
ready: true,
collection: {
state: args.entities,
refresh: () => new Promise(() => {}),
subscribe: () => () => {},
},
},
{
additional: {},
ready: true,
collection: {
state: args.entitySource,
refresh: () => new Promise(() => {}),
subscribe: () => () => {},
},
}
);
}
};