mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-12-19 19:06:16 +01:00
Add ability to restart
This commit is contained in:
parent
3d28d8cee2
commit
a2d5754e4b
@ -72,13 +72,14 @@ export function MqttProvider({
|
||||
return <Mqtt.Provider value={{ state, ws: wsRef.current }}>{children}</Mqtt.Provider>;
|
||||
}
|
||||
|
||||
export function useMqtt(watchTopic, publishTopic) {
|
||||
export function useMqtt(watchTopic, publishTopic, defaultValue = null) {
|
||||
const { state, ws } = useContext(Mqtt);
|
||||
|
||||
const value = state[watchTopic] || { payload: null };
|
||||
const value = state[watchTopic] || { payload: defaultValue };
|
||||
|
||||
const send = useCallback(
|
||||
(payload) => {
|
||||
payload = payload || defaultValue;
|
||||
ws.send(
|
||||
JSON.stringify({
|
||||
topic: publishTopic || watchTopic,
|
||||
@ -118,3 +119,12 @@ export function useSnapshotsState(camera) {
|
||||
} = useMqtt(`${camera}/snapshots/state`, `${camera}/snapshots/set`);
|
||||
return { payload, send, connected };
|
||||
}
|
||||
|
||||
export function useRestart() {
|
||||
const {
|
||||
value: { payload },
|
||||
send,
|
||||
connected,
|
||||
} = useMqtt(``, `restart`, "container");
|
||||
return { send, connected };
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user