Module homey.image
Classes
class 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
async def get_stream(self) ‑> StreamReturn-
Get a stream containing the image data.
Raises
HomeyError- Raised if the image is not registered.
async def pipe(self,
stream: Writable) ‑> 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.
def set_path(self, path: str) ‑> None-
Set the image file path.
Args
path- A relative path to the image, e.g.
/userdata/kitten.jpg
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
source- A callback that receives the stream to write to.
def set_url(self, url: str) ‑> None-
Set the image file URL. This URL must be publicly accessible.
Args
url- An absolute URL of the image file, starting with
https://
Raises
ValueError- Raised if the url is not a valid HTTPS url.
async def unregister(self) ‑> None-
Unregister the image.
Raises
NotRegistered- Raised if the image is not registered.
async def update(self) ‑> None-
Notify users that the image contents have been updated.
Raises
NotRegistered- Raised if the image is not registered.
class ImageStreamMetadata-
Metadata for an image stream. The content_length is not required if it can be inferred.
Ancestors
- builtins.dict
Instance variables
var filename : str-
The filename of the image file.
var content_type : str-
The MIME type of the image file.
var content_length : int-
The size of the image file in bytes.
class Writable (buffer: BytesIO)-
Instance variables
var buffer : _io.BytesIOvar done : _asyncio.Future
class StreamReturn-
Ancestors
- builtins.dict
Instance variables
var data : Writablevar meta : ImageStreamMetadata