UNPKG

@hakit/core

Version:

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

3 lines (2 loc) 1.09 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./time-cache-entity-promise.js"),s=(e,t)=>e.sendMessagePromise({type:"auth/sign_path",path:t}),c=(e,t,a)=>`${e}&width=${t}&height=${a}`,h=e=>`/api/camera_proxy_stream/${e.entity_id}?token=${e.attributes.access_token}`,u=async(e,t,a,r)=>{const i=await o.timeCacheEntityPromiseFunc("_cameraTmbUrl",9e3,n,e,t);return c(i,a,r)},n=async(e,t)=>{const{path:a}=await s(e,`/api/camera_proxy/${t}`);return a},d=async(e,t,a)=>{const r={type:"camera/stream",entity_id:t};a&&(r.format=a);const{url:i}=await e.sendMessagePromise(r);return i},l=(e,t)=>e.sendMessagePromise({type:"camera/get_prefs",entity_id:t}),m="media-source://camera/",g=e=>e.startsWith(m),y=e=>e.substring(m.length);exports.cameraUrlWithWidthHeight=c;exports.computeMJPEGStreamUrl=h;exports.fetchCameraPrefs=l;exports.fetchStreamUrl=d;exports.fetchThumbnailUrl=n;exports.fetchThumbnailUrlWithCache=u;exports.getEntityIdFromCameraMediaSource=y;exports.getSignedPath=s;exports.isCameraMediaSource=g; //# sourceMappingURL=camera.js.map