Skip to content

Commit 4f378db

Browse files
authored
Merge pull request #117 from home-assistant/add-state-to-hass-config
2 parents b9fa5c1 + ef670b2 commit 4f378db

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

lib/config.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function processComponentLoaded(
1717
if (state === undefined) return null;
1818

1919
return {
20-
components: state.components.concat(event.data.component)
20+
components: state.components.concat(event.data.component),
2121
};
2222
}
2323

@@ -29,10 +29,10 @@ const subscribeUpdates = (conn: Connection, store: Store<HassConfig>) =>
2929
"component_loaded"
3030
),
3131
conn.subscribeEvents(
32-
() => fetchConfig(conn).then(config => store.setState(config, true)),
32+
() => fetchConfig(conn).then((config) => store.setState(config, true)),
3333
"core_config_updated"
34-
)
35-
]).then(unsubs => () => unsubs.forEach(unsub => unsub()));
34+
),
35+
]).then((unsubs) => () => unsubs.forEach((unsub) => unsub()));
3636

3737
const configColl = (conn: Connection) =>
3838
getCollection(conn, "_cnf", fetchConfig, subscribeUpdates);
@@ -41,3 +41,9 @@ export const subscribeConfig = (
4141
conn: Connection,
4242
onChange: (state: HassConfig) => void
4343
): UnsubscribeFunc => configColl(conn).subscribe(onChange);
44+
45+
export const STATE_NOT_RUNNING = "NOT_RUNNING";
46+
export const STATE_STARTING = "STARTING";
47+
export const STATE_RUNNING = "RUNNING";
48+
export const STATE_STOPPING = "STOPPING";
49+
export const STATE_FINAL_WRITE = "FINAL_WRITE";

lib/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export type HassConfig = {
5858
version: string;
5959
config_source: string;
6060
safe_mode: boolean;
61+
state: "NOT_RUNNING" | "STARTING" | "RUNNING" | "STOPPING" | "FINAL_WRITE";
6162
external_url: string | null;
6263
internal_url: string | null;
6364
};

0 commit comments

Comments
 (0)