-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Convert auth to TS * Lint * Update HA-JS-WS to 3.2.0 * Migrate ws collections to TS * Upgrade to latest HAWS * Bump HAWS * Lint * Add types to WS calls
- Loading branch information
Showing
14 changed files
with
182 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { createCollection, Connection } from "home-assistant-js-websocket"; | ||
import { Panels } from "../types"; | ||
|
||
export const subscribePanels = ( | ||
conn: Connection, | ||
onChange: (panels: Panels) => void | ||
) => | ||
createCollection<Panels>( | ||
"_pnl", | ||
() => conn.sendMessagePromise({ type: "get_panels" }), | ||
undefined, | ||
conn, | ||
onChange | ||
); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { createCollection, Connection } from "home-assistant-js-websocket"; | ||
import { Themes } from "../types"; | ||
|
||
const fetchThemes = (conn) => | ||
conn.sendMessagePromise({ | ||
type: "frontend/get_themes", | ||
}); | ||
|
||
const subscribeUpdates = (conn, store) => | ||
conn.subscribeEvents( | ||
(event) => store.setState(event.data, true), | ||
"themes_updated" | ||
); | ||
|
||
export const subscribeThemes = ( | ||
conn: Connection, | ||
onChange: (themes: Themes) => void | ||
) => | ||
createCollection<Themes>( | ||
"_thm", | ||
fetchThemes, | ||
subscribeUpdates, | ||
conn, | ||
onChange | ||
); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { | ||
createCollection, | ||
getUser, | ||
Connection, | ||
} from "home-assistant-js-websocket"; | ||
import { User } from "../types"; | ||
|
||
export const subscribeUser = ( | ||
conn: Connection, | ||
onChange: (user: User) => void | ||
) => | ||
createCollection<User>( | ||
"_usr", | ||
// the getUser command is mistyped in current verrsion of HAWS. | ||
// Fixed in 3.2.5 | ||
() => (getUser(conn) as unknown) as Promise<User>, | ||
undefined, | ||
conn, | ||
onChange | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.