Correct mqtt image docs and move example (#28494)

* Correct mqtt image docs and move example

* Tiny tweak

---------

Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com>
This commit is contained in:
Jan Bouwhuis 2023-08-08 08:56:02 +02:00 committed by GitHub
parent a0922fae84
commit 9ef33fb7f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,14 +25,8 @@ To enable this image in your installation, add the following to your `configurat
```yaml ```yaml
# Example configuration.yaml entry # Example configuration.yaml entry
mqtt: mqtt:
image: - image:
- topic: zanzito/shared_locations/my-device url_topic: mynas/status/url
```
The sample configuration above can be tested by publishing an image to the topic from the console:
```shell
mosquitto_pub -h <mqtt_broker> -t zanzito/shared_locations/my-device -f <image_filename.jpg>
``` ```
{% configuration %} {% configuration %}
@ -73,7 +67,7 @@ availability_topic:
required: false required: false
type: string type: string
content_type: content_type:
description: The content type of and image data message received on `image_topic`. This option cannot be used with the `from_url_topic` because the content type is derived when downloading the image. description: The content type of and image data message received on `image_topic`. This option cannot be used with the `url_topic` because the content type is derived when downloading the image.
required: false required: false
type: string type: string
default: image/jpeg default: image/jpeg
@ -180,7 +174,7 @@ url_topic:
type: string type: string
{% endconfiguration %} {% endconfiguration %}
### Example receiving images from from a URL ### Example receiving images from a URL
Add the configuration below to your `configuration.yaml`. Add the configuration below to your `configuration.yaml`.
@ -195,8 +189,30 @@ mosquitto_pub -h <mqtt_broker> -t mynas/status/url -m "https://design.home-assis
```yaml ```yaml
# Example configuration.yaml entry # Example configuration.yaml entry
mqtt: mqtt:
image: - image:
- from_url_topic: mynas/status/url url_topic: mynas/status/url
```
{% endraw %}
### Example receiving images from a file
Add the configuration below to your `configuration.yaml`.
To test it, publish an image URL to the topic from the console:
```shell
mosquitto_pub -h <mqtt_broker> -t mynas/status/file -f <logo.png>
```
{% raw %}
```yaml
# Example configuration.yaml entry
mqtt:
- image:
image_topic: mynas/status/file
content_type: image/png
``` ```
{% endraw %} {% endraw %}