Fix recording timezone issue.

This commit is contained in:
Dermot Duffy
2024-08-26 13:10:19 -07:00
parent 2412cc5ac8
commit 09a15ab785
2 changed files with 14 additions and 4 deletions
+8 -2
View File
@@ -36,7 +36,10 @@ export const getRecordingsSummary = async (
type: 'frigate/recordings/summary',
instance_id: clientID,
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,
// See: https://github.com/colinhacks/zod/pull/1752
@@ -148,7 +151,10 @@ export const getEventSummary = async (
{
type: 'frigate/events/summary',
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,
);
@@ -34,6 +34,8 @@ describe('frigate requests', () => {
day: new Date(),
};
const hass = createHASS();
hass.config.time_zone = 'Europe/Dublin';
vi.mocked(homeAssistantWSRequest).mockResolvedValue(recordingSummary);
expect(await getRecordingsSummary(hass, 'clientID', 'camera.office')).toBe(
recordingSummary,
@@ -45,7 +47,7 @@ describe('frigate requests', () => {
type: 'frigate/recordings/summary',
instance_id: 'clientID',
camera: 'camera.office',
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
timezone: 'Europe/Dublin',
}),
true,
);
@@ -179,6 +181,8 @@ describe('frigate requests', () => {
},
];
const hass = createHASS();
hass.config.time_zone = 'Europe/Dublin';
vi.mocked(homeAssistantWSRequest).mockResolvedValue(eventSummary);
expect(await getEventSummary(hass, 'clientID')).toBe(eventSummary);
expect(homeAssistantWSRequest).toBeCalledWith(
@@ -187,7 +191,7 @@ describe('frigate requests', () => {
expect.objectContaining({
type: 'frigate/events/summary',
instance_id: 'clientID',
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
timezone: 'Europe/Dublin',
}),
true,
);