Search in sources :

Example 46 with RawType

use of org.openhab.core.library.types.RawType in project openhab-addons by openhab.

the class KodiConnection method downloadImage.

@Nullable
private RawType downloadImage(String url) {
    logger.debug("Trying to download the content of URL '{}'", url);
    RawType downloadedImage = HttpUtil.downloadImage(url);
    if (downloadedImage == null) {
        logger.debug("Failed to download the content of URL '{}'", url);
    }
    return downloadedImage;
}
Also used : RawType(org.openhab.core.library.types.RawType) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 47 with RawType

use of org.openhab.core.library.types.RawType in project openhab-addons by openhab.

the class IpCameraHandler method processSnapshot.

public void processSnapshot(byte[] incommingSnapshot) {
    lockCurrentSnapshot.lock();
    try {
        currentSnapshot = incommingSnapshot;
        if (cameraConfig.getGifPreroll() > 0) {
            fifoSnapshotBuffer.add(incommingSnapshot);
            if (fifoSnapshotBuffer.size() > (cameraConfig.getGifPreroll() + gifRecordTime)) {
                fifoSnapshotBuffer.removeFirst();
            }
        }
    } finally {
        lockCurrentSnapshot.unlock();
        currentSnapshotTime = Instant.now();
    }
    if (updateImageChannel) {
        updateState(CHANNEL_IMAGE, new RawType(incommingSnapshot, "image/jpeg"));
    } else if (firstMotionAlarm || motionAlarmUpdateSnapshot) {
        updateState(CHANNEL_IMAGE, new RawType(incommingSnapshot, "image/jpeg"));
        firstMotionAlarm = motionAlarmUpdateSnapshot = false;
    } else if (firstAudioAlarm || audioAlarmUpdateSnapshot) {
        updateState(CHANNEL_IMAGE, new RawType(incommingSnapshot, "image/jpeg"));
        firstAudioAlarm = audioAlarmUpdateSnapshot = false;
    }
}
Also used : RawType(org.openhab.core.library.types.RawType)

Example 48 with RawType

use of org.openhab.core.library.types.RawType in project addons by smarthomej.

the class ImageItemConverter method process.

@Override
public void process(@Nullable ContentWrapper content) {
    if (content == null) {
        updateState.accept(UnDefType.UNDEF);
        return;
    }
    String mediaType = content.getMediaType();
    updateState.accept(new RawType(content.getRawContent(), mediaType != null ? mediaType : RawType.DEFAULT_MIME_TYPE));
}
Also used : RawType(org.openhab.core.library.types.RawType)

Aggregations

RawType (org.openhab.core.library.types.RawType)48 IOException (java.io.IOException)12 Nullable (org.eclipse.jdt.annotation.Nullable)9 State (org.openhab.core.types.State)8 DoorbirdImage (org.openhab.binding.doorbird.internal.api.DoorbirdImage)7 BufferedImage (java.awt.image.BufferedImage)5 Test (org.junit.jupiter.api.Test)5 DecimalType (org.openhab.core.library.types.DecimalType)4 StringType (org.openhab.core.library.types.StringType)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 File (java.io.File)3 ContentResponse (org.eclipse.jetty.client.api.ContentResponse)3 FileNotFoundException (java.io.FileNotFoundException)2 FileOutputStream (java.io.FileOutputStream)2 ExecutionException (java.util.concurrent.ExecutionException)2 TimeoutException (java.util.concurrent.TimeoutException)2 Request (org.eclipse.jetty.client.api.Request)2 ImageItem (org.openhab.core.library.items.ImageItem)2 DateTimeType (org.openhab.core.library.types.DateTimeType)2