elad-bar / ha-shinobi

Shinobi Video custom component for HA
53 stars 5 forks source link

Timezone ignoreg #47

Closed ronluna closed 1 year ago

ronluna commented 1 year ago

Seems like shinobi records the videos in GMT time no matter what the timezone is set in Shinobi or Home assistant the videos in the Media navigation are shown in gmt time causing the incorrect folder position (events happening today showing in tomorrow's folder and so on) is it possible for the the add-on to capture the timzezone of the shinobi server or at least use the home assistant time zone ?

elad-bar commented 1 year ago

Issue is related to the code in Shinobi, need to fix it over there and already have an open issue in that repo for it, will share it later

skvalex commented 1 year ago

@elad-bar I created merge request on gitlab over this issue that fixes it. Please take a look at it.

elad-bar commented 1 year ago

Will look at it, tried to work on it as part of v3 release but couldn't reproduce the issue, Both Shinobi and HA defined on the same time zone, time presented in HA is the actual video time, How do you define the time zone in shinobi / homr assistant? I would like to create an exact same local environment to make sure that by playing with time zone in each of them nothing got effected

skvalex commented 1 year ago

@elad-bar you probably can't reproduce it, because you have some images generated for a video. See libs/videoBrowser.js in Shinobi code:

videoItems.forEach(v => {
            const imagesOfVideo = imageItems.filter(i => i.time >= v.time && i.time <= v.end);

            if (imagesOfVideo.length > 0) {
                const chosenImage = imagesOfVideo[0];

                v.time = getISODateTime(v.time);
                v.filename = chosenImage.filename;

                delete v.end;
            }
        });

If no images exist for a video, then the time not being changed by getISODateTime and stays in UTC causing the issue.

elad-bar commented 1 year ago

Looked at it, makes sense, most probably didn't experience it because i'm generating images in 1 minute interval

elad-bar commented 1 year ago

Thanks for finding and fixing it

skvalex commented 1 year ago

I think this issue can be closed since the fix was merged