UNPKG

@hakit/core

Version:

A collection of React hooks and helpers for Home Assistant to easily communicate with the Home Assistant WebSocket API.

32 lines (31 loc) 1.16 kB
import { timeCacheEntityPromiseFunc as i } from "./time-cache-entity-promise.js"; const n = (t, e) => t.sendMessagePromise({ type: "auth/sign_path", path: e }), o = (t, e, a) => `${t}&width=${e}&height=${a}`, u = (t) => `/api/camera_proxy_stream/${t.entity_id}?token=${t.attributes.access_token}`, d = async (t, e, a, r) => { const s = await i("_cameraTmbUrl", 9e3, m, t, e); return o(s, a, r); }, m = async (t, e) => { const { path: a } = await n(t, `/api/camera_proxy/${e}`); return a; }, _ = async (t, e, a) => { const r = { type: "camera/stream", entity_id: e }; a && (r.format = a); const { url: s } = await t.sendMessagePromise(r); return s; }, p = (t, e) => t.sendMessagePromise({ type: "camera/get_prefs", entity_id: e }), c = "media-source://camera/", g = (t) => t.startsWith(c), y = (t) => t.substring(c.length); export { o as cameraUrlWithWidthHeight, u as computeMJPEGStreamUrl, p as fetchCameraPrefs, _ as fetchStreamUrl, m as fetchThumbnailUrl, d as fetchThumbnailUrlWithCache, y as getEntityIdFromCameraMediaSource, n as getSignedPath, g as isCameraMediaSource }; //# sourceMappingURL=camera.js.map