Image

homey.image

An image, which can be used as token values in the flow editor, device album art, or camera images. An image must be registered, and the contents will be retrieved when needed.

This class must not be initialized by the developer, but retrieved by calling ManagerImages.create_image().

Ancestors

  • homey.client.serializer.Serializable
  • abc.ABC

Methods

get_stream

async def get_stream(self) ‑> StreamReturn

Get a stream containing the image data.

Raises

HomeyError
Raised if the image is not registered.

pipe

async def pipe(self,
streamWritable)
‑> ImageStreamMetadata

Pipe the image data into the stream.

Returns

The metadata of the image file.

Raises

HomeyError
Raised if the image is not registered.
ValueError
Raised if the stream is not writable.

set_path

def set_path(self, path: str) ‑> None

Set the image file path.

Args

NameTypeDescription
path str A relative path to the image, e.g. /userdata/kitten.jpg

set_stream

def set_stream(self, source: Callable[[BytesIO], Coroutine[Any, Any, None]]) ‑> None

Set a function that writes the image data to streams if requested. This is mostly useful for external image sources.

Args

NameTypeDescription
source Callable[[BytesIO], Coroutine[Any, Any, None]] A callback that receives the stream to write to.

set_url

def set_url(self, url: str) ‑> None

Set the image file URL. This URL must be publicly accessible.

Args

NameTypeDescription
url str An absolute URL of the image file, starting with https://

Raises

ValueError
Raised if the url is not a valid HTTPS url.

unregister

async def unregister(self) ‑> None

Unregister the image.

Raises

NotRegistered
Raised if the image is not registered.

update

async def update(self) ‑> None

Notify users that the image contents have been updated.

Raises

NotRegistered
Raised if the image is not registered.

ImageStreamMetadata

class ImageStreamMetadata

Metadata for an image stream. The content_length is not required if it can be inferred.

Ancestors

  • builtins.dict

Instance variables

filename

var filename : str

The filename of the image file.

contentType

var contentType : str

The MIME type of the image file.

contentLength

var contentLength : int

The size of the image file in bytes.

Writable

class Writable(buffer: BytesIO)

Instance variables

buffer

var buffer : _io.BytesIO

done

var done : _asyncio.Future

StreamReturn

class StreamReturn

Ancestors

  • builtins.dict

Instance variables

data

var dataWritable

meta

var metaImageStreamMetadata