diff --git a/src/lib/shared/hooks/interfaces/useILightingScenes.ts b/src/lib/shared/hooks/interfaces/useILightingScenes.ts new file mode 100644 index 0000000..40cf13e --- /dev/null +++ b/src/lib/shared/hooks/interfaces/useILightingScenes.ts @@ -0,0 +1,21 @@ +import { useGetDevice } from 'src/lib/store'; +import { LightingState } from 'src/lib/types'; +import { useWebsocketContext } from 'src/lib/utils/useWebsocketContext'; + +export function useILightingScenes(key: string): ILightingScenesReturn | undefined { + const { sendMessage } = useWebsocketContext(); + const device = useGetDevice(key); + + if (!device) return undefined; + + const setScene = (scene: string) => { + sendMessage(`/device/${key}/scene`, scene); + }; + + return { lightingState: device, selectScene: setScene }; +} + +export interface ILightingScenesReturn { + lightingState: LightingState; + selectScene: (scene: string) => void; +} \ No newline at end of file