diff --git a/api/src/controllers/recognize.controller.js b/api/src/controllers/recognize.controller.js index 9f47a20f..0caf7684 100644 --- a/api/src/controllers/recognize.controller.js +++ b/api/src/controllers/recognize.controller.js @@ -79,7 +79,7 @@ module.exports.start = async (req, res) => { } if (event.type === 'frigate') { - process.env.FRIGATE_LAST_EVENT = time.utc(); + process.env.FRIGATE_LAST_EVENT = JSON.stringify({ time: time.utc(), camera }); const check = await frigate.checks({ ...event, PROCESSING, diff --git a/api/src/controllers/status.controller.js b/api/src/controllers/status.controller.js index 516f3bc3..5fcdfea9 100644 --- a/api/src/controllers/status.controller.js +++ b/api/src/controllers/status.controller.js @@ -1,4 +1,5 @@ const axios = require('axios'); +const { tryParseJSON } = require('../util/validators.util'); const { connected } = require('../util/mqtt.util'); const { auth, jwt } = require('../util/auth.util'); const { BAD_REQUEST } = require('../constants/http-status'); @@ -18,10 +19,16 @@ module.exports.auth = (req, res) => { module.exports.frigate = async (req, res) => { if (!FRIGATE.URL) return res.status(BAD_REQUEST).error('Frigate URL not configured'); + + const { time, camera } = tryParseJSON(process.env.FRIGATE_LAST_EVENT) || { + time: null, + camera: null, + }; + const { data: version } = await axios({ method: 'get', url: `${FRIGATE.URL}/api/version`, }); - res.send({ version, last: process.env.FRIGATE_LAST_EVENT || null }); + res.send({ version, last: { time, camera } }); }; diff --git a/frontend/src/views/Config.vue b/frontend/src/views/Config.vue index d53cfc88..dc965460 100644 --- a/frontend/src/views/Config.vue +++ b/frontend/src/views/Config.vue @@ -382,8 +382,11 @@ export default { await Sleep(1000); const { data } = await ApiService.get('status/frigate'); this.frigate.status = 200; - this.frigate.tooltip = data.version; - if (data.last) this.frigate.tooltip = `${this.frigate.tooltip} | Last Event: ${Time.ago(data.last)}`; + this.frigate.tooltip = `Version: ${data.version}`; + const { last } = data; + if (last.time && last.camera) { + this.frigate.tooltip += `\nLast Event: ${Time.ago(last.time)} (${last.camera})`; + } } catch (error) { const status = error.response && error.response.status ? error.response.status : 500; this.frigate.tooltip = null;