[netatmo] Give access to video only when video is available (#12698)
Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
parent
f6ab246a41
commit
4e56b9b734
@ -20,6 +20,7 @@ import java.time.ZonedDateTime;
|
|||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
import org.openhab.binding.netatmo.internal.api.data.ModuleType;
|
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.Event;
|
||||||
import org.openhab.binding.netatmo.internal.api.dto.HomeEvent;
|
import org.openhab.binding.netatmo.internal.api.dto.HomeEvent;
|
||||||
import org.openhab.binding.netatmo.internal.api.dto.NAObject;
|
import org.openhab.binding.netatmo.internal.api.dto.NAObject;
|
||||||
@ -98,17 +99,17 @@ public class EventChannelHelper extends ChannelHelper {
|
|||||||
case CHANNEL_EVENT_VIDEO_STATUS:
|
case CHANNEL_EVENT_VIDEO_STATUS:
|
||||||
return homeEvent.getVideoId() != null ? toStringType(homeEvent.getVideoStatus()) : UnDefType.NULL;
|
return homeEvent.getVideoId() != null ? toStringType(homeEvent.getVideoStatus()) : UnDefType.NULL;
|
||||||
case CHANNEL_EVENT_VIDEO_LOCAL_URL:
|
case CHANNEL_EVENT_VIDEO_LOCAL_URL:
|
||||||
return getStreamURL(true, homeEvent.getVideoId());
|
return getStreamURL(true, homeEvent.getVideoId(), homeEvent.getVideoStatus());
|
||||||
case CHANNEL_EVENT_VIDEO_VPN_URL:
|
case CHANNEL_EVENT_VIDEO_VPN_URL:
|
||||||
return getStreamURL(false, homeEvent.getVideoId());
|
return getStreamURL(false, homeEvent.getVideoId(), homeEvent.getVideoStatus());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
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;
|
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 UnDefType.NULL;
|
||||||
}
|
}
|
||||||
return toStringType("%s/vod/%s/index.m3u8", url, videoId);
|
return toStringType("%s/vod/%s/index.m3u8", url, videoId);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user