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) ‑> StreamReturnGet a stream containing the image data.
Raises
HomeyError- Raised if the image is not registered.
pipe
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.
set_path
def set_path(self, path: str) ‑> NoneSet the image file path.
Args
| Name | Type | Description |
|---|---|---|
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]]) ‑> NoneSet a function that writes the image data to streams if requested. This is mostly useful for external image sources.
Args
| Name | Type | Description |
|---|---|---|
source |
Callable[[BytesIO], Coroutine[Any, Any, None]] | A callback that receives the stream to write to. |
set_url
def set_url(self, url: str) ‑> NoneSet the image file URL. This URL must be publicly accessible.
Args
| Name | Type | Description |
|---|---|---|
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) ‑> NoneUnregister the image.
Raises
NotRegistered- Raised if the image is not registered.
update
async def update(self) ‑> NoneNotify users that the image contents have been updated.
Raises
NotRegistered- Raised if the image is not registered.
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 : strThe filename of the image file.
contentType
var contentType : strThe MIME type of the image file.
contentLength
var contentLength : intThe size of the image file in bytes.
Writable
Instance variables
buffer
var buffer : _io.BytesIOdone
var done : _asyncio.FutureStreamReturn
Ancestors
- builtins.dict