Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[netatmo] Give access to video only when video is available #12698

Merged
merged 1 commit into from
May 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.netatmo.internal.api.data.ModuleType;
import org.openhab.binding.netatmo.internal.api.data.NetatmoConstants.VideoStatus;
import org.openhab.binding.netatmo.internal.api.dto.Event;
import org.openhab.binding.netatmo.internal.api.dto.HomeEvent;
import org.openhab.binding.netatmo.internal.api.dto.NAObject;
Expand Down Expand Up @@ -98,17 +99,17 @@ public void setNewData(@Nullable NAObject data) {
case CHANNEL_EVENT_VIDEO_STATUS:
return homeEvent.getVideoId() != null ? toStringType(homeEvent.getVideoStatus()) : UnDefType.NULL;
case CHANNEL_EVENT_VIDEO_LOCAL_URL:
return getStreamURL(true, homeEvent.getVideoId());
return getStreamURL(true, homeEvent.getVideoId(), homeEvent.getVideoStatus());
case CHANNEL_EVENT_VIDEO_VPN_URL:
return getStreamURL(false, homeEvent.getVideoId());
return getStreamURL(false, homeEvent.getVideoId(), homeEvent.getVideoStatus());
}
}
return null;
}

private State getStreamURL(boolean local, @Nullable String videoId) {
private State getStreamURL(boolean local, @Nullable String videoId, VideoStatus videoStatus) {
String url = local ? localUrl : vpnUrl;
if ((local && !isLocal) || url == null || videoId == null) {
if ((local && !isLocal) || url == null || videoId == null || videoStatus != VideoStatus.AVAILABLE) {
return UnDefType.NULL;
}
return toStringType("%s/vod/%s/index.m3u8", url, videoId);
Expand Down