Skip to content

New Share your ideas with the AWTRIX community. Keep your creations together in your account.

Sign in

Report content

Tell us about content that is unlawful or breaks the rules. You do not need an account. Add your email address if you would like to hear the outcome.

Reporting Solar Energy Production (NG) by reedy
Comment by AlxBcr

## Suggestion: Use the AWTRIX NG `mqtt_prefix` entity instead of `device_topic` I found an issue with the MQTT topic lookup in this blueprint. The current version searches the selected AWTRIX device for an entity containing `device_topic`: ```jinja {{ states((device_entities(device_id) | select('search', 'device_topic') | list)[0]) }} ``` Current AWTRIX NG Home Assistant discovery provides an entity named `mqtt_prefix` instead, for example: ```text sensor.awtrix_kitchen_mqtt_prefix ``` If no legacy `device_topic` entity exists, the resulting list is empty and the automation fails every minute with: ```text UndefinedError: list object has no element 0 ``` The official AWTRIX NG documentation also recommends resolving the device prefix through the `mqtt_prefix` entity: https://blueforcer.github.io/awtrix-ng/guides/home-assistant/#from-a-picked-device-to-its-topic ### Suggested change Replace the existing `devices_topics` variable with this guarded lookup: ```yaml devices_topics: >- {%- set ns = namespace(devices=[]) %} {%- for device_id in device_ids %} {%- set prefix_entities = device_entities(device_id) | select('search', 'mqtt_prefix') | list %} {%- if prefix_entities %} {%- set prefix = states(prefix_entities[0]) | trim %} {%- if prefix not in ['', 'unknown', 'unavailable', 'none'] %} {%- set ns.devices = ns.devices + [prefix ~ '/cmd/apps/pushed/solar_power'] %} {%- endif %} {%- endif %} {%- endfor %} {{ ns.devices }} ``` This preserves support for selecting multiple AWTRIX devices and prevents invalid MQTT publications when a device or its prefix sensor is temporarily unavailable. I tested this change with AWTRIX NG firmware 1.1.0. After reloading the Home Assistant automations, the automation completed successfully and published the expected payload to: ```text awtrix_d12f50/cmd/apps/pushed/solar_power ``` The previous `list object has no element 0` error no longer occurs.

What is wrong?

Include the exact link if the content is not already shown above, and explain why it is unlawful or breaks the rules. Please avoid sharing unnecessary personal details.

Your contact details — optional

We consider anonymous reports too. A complete notice of unlawful content under Article 16 DSA normally includes your name and e-mail address; the exception for child sexual abuse offences applies. Without contact details, we cannot send you the outcome. Reports are normally kept for three years; the privacy policy explains retention and any documented extension.

How we handle reports is described in the terms of service.