Skip to content

Commit

Permalink
[netatmo] Give access to video only when video is available (#12698)
Browse files Browse the repository at this point in the history
Signed-off-by: Laurent Garnier <lg.hc@free.fr>
  • Loading branch information
lolodomo authored May 7, 2022
1 parent f6ab246 commit 4e56b9b
Showing 1 changed file with 5 additions and 4 deletions.
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

0 comments on commit 4e56b9b

Please sign in to comment.