Fix recording timezone issue.
This commit is contained in:
@@ -36,7 +36,10 @@ export const getRecordingsSummary = async (
|
|||||||
type: 'frigate/recordings/summary',
|
type: 'frigate/recordings/summary',
|
||||||
instance_id: clientID,
|
instance_id: clientID,
|
||||||
camera: camera_name,
|
camera: camera_name,
|
||||||
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
||||||
|
// Ask for the summary relative to HA timezone
|
||||||
|
// See: https://github.com/dermotduffy/frigate-hass-card/issues/1267
|
||||||
|
timezone: hass.config.time_zone,
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
// See: https://github.com/colinhacks/zod/pull/1752
|
// See: https://github.com/colinhacks/zod/pull/1752
|
||||||
@@ -148,7 +151,10 @@ export const getEventSummary = async (
|
|||||||
{
|
{
|
||||||
type: 'frigate/events/summary',
|
type: 'frigate/events/summary',
|
||||||
instance_id: clientID,
|
instance_id: clientID,
|
||||||
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
||||||
|
// Ask for the summary relative to HA timezone
|
||||||
|
// See: https://github.com/dermotduffy/frigate-hass-card/issues/1267
|
||||||
|
timezone: hass.config.time_zone,
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ describe('frigate requests', () => {
|
|||||||
day: new Date(),
|
day: new Date(),
|
||||||
};
|
};
|
||||||
const hass = createHASS();
|
const hass = createHASS();
|
||||||
|
hass.config.time_zone = 'Europe/Dublin';
|
||||||
|
|
||||||
vi.mocked(homeAssistantWSRequest).mockResolvedValue(recordingSummary);
|
vi.mocked(homeAssistantWSRequest).mockResolvedValue(recordingSummary);
|
||||||
expect(await getRecordingsSummary(hass, 'clientID', 'camera.office')).toBe(
|
expect(await getRecordingsSummary(hass, 'clientID', 'camera.office')).toBe(
|
||||||
recordingSummary,
|
recordingSummary,
|
||||||
@@ -45,7 +47,7 @@ describe('frigate requests', () => {
|
|||||||
type: 'frigate/recordings/summary',
|
type: 'frigate/recordings/summary',
|
||||||
instance_id: 'clientID',
|
instance_id: 'clientID',
|
||||||
camera: 'camera.office',
|
camera: 'camera.office',
|
||||||
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
timezone: 'Europe/Dublin',
|
||||||
}),
|
}),
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
@@ -179,6 +181,8 @@ describe('frigate requests', () => {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
const hass = createHASS();
|
const hass = createHASS();
|
||||||
|
hass.config.time_zone = 'Europe/Dublin';
|
||||||
|
|
||||||
vi.mocked(homeAssistantWSRequest).mockResolvedValue(eventSummary);
|
vi.mocked(homeAssistantWSRequest).mockResolvedValue(eventSummary);
|
||||||
expect(await getEventSummary(hass, 'clientID')).toBe(eventSummary);
|
expect(await getEventSummary(hass, 'clientID')).toBe(eventSummary);
|
||||||
expect(homeAssistantWSRequest).toBeCalledWith(
|
expect(homeAssistantWSRequest).toBeCalledWith(
|
||||||
@@ -187,7 +191,7 @@ describe('frigate requests', () => {
|
|||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
type: 'frigate/events/summary',
|
type: 'frigate/events/summary',
|
||||||
instance_id: 'clientID',
|
instance_id: 'clientID',
|
||||||
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
timezone: 'Europe/Dublin',
|
||||||
}),
|
}),
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user