From baaf1a39c5887543cd8874d4560d3f26ab619aa4 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Tue, 20 Jun 2023 12:59:57 +0200 Subject: [PATCH] Document image entity (#1802) Co-authored-by: Franck Nijhof --- docs/core/entity/image.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 docs/core/entity/image.md diff --git a/docs/core/entity/image.md b/docs/core/entity/image.md new file mode 100644 index 00000000..e6d107fd --- /dev/null +++ b/docs/core/entity/image.md @@ -0,0 +1,36 @@ +--- +title: Image Entity +sidebar_label: Image +--- + +An image entity can display a static image. Derive a platform entity from [`homeassistant.components.image.ImageEntity`](https://github.com/home-assistant/core/blob/dev/homeassistant/components/image/__init__.py). + +The image entity is a greatly simplified version of the [`camera`](/docs/core/entity/camera) entity, and only supports serving a static image. + +To make frontend refetch the image, bump the `image_last_updated` property. +## Properties + +:::tip +Properties should always only return information from memory and not do I/O (like network requests). Implement `update()` or `async_update()` to fetch data. +::: + +| Name | Type | Default | Description | +| ------------------------ | ----- | ------- | ---------------------------------------------------------------------------------------------------------------------------------- | +| image_last_updated | datetime | `None` | Timestamp of when the image was last updated. Used to determine `state`. | + +## Methods + +### Image + +Return bytes of the image. + +```python +class MyImage(ImageEntity): + # Implement one of these methods. + + def image(self) -> bytes | None: + """Return bytes of image.""" + + async def async_image(self) -> bytes | None: + """Return bytes of image.""" +```