-
Notifications
You must be signed in to change notification settings - Fork 255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MQTT Payload Template Not Rendering in Button Call-Service #907
Comments
Create a script or automation for the tap action trigger... like action: script.turn_on |
Hello, we tried to solve the issue. This is what we did: Modify the handleAction function to render Jinja2 templates in MQTT publish payloads before sending the action. This addresses the issue where template variables in Lovelace button tap_actions for MQTT publish were not being rendered. You can review changes in this commit: endic-sam928281@ac824aa. Caution Disclaimer: The concept of solution was created by AI and you should never copy paste this code before you check the correctness of generated code. Solution might not be complete, you should use this code as an inspiration only. Latta AI seeks to solve problems in open source projects as part of its mission to support developers around the world. Learn more about our mission at https://latta.ai/ourmission . If you no longer want Latta AI to attempt solving issues on your repository, you can block this account. |
That's great - thank you very much! When would this be published into an
updated version of the card?
…On Mon, Feb 3, 2025 at 2:59 PM endic-sam928281 ***@***.***> wrote:
Hello, we tried to solve the issue.
This is what we did:
Modify the handleAction function to render Jinja2 templates in MQTT
publish payloads before sending the action. This addresses the issue where
template variables in Lovelace button tap_actions for MQTT publish were not
being rendered.
You can review changes in this commit: ***@***.***
<endic-sam928281@ac824aa>
.
Caution
Disclaimer: The concept of solution was created by AI and you should never
copy paste this code before you check the correctness of generated code.
Solution might not be complete, you should use this code as an inspiration
only.
------------------------------
Latta AI seeks to solve problems in open source projects as part of its
mission to support developers around the world. Learn more about our
mission at https://latta.ai/ourmission . If you no longer want Latta AI
to attempt solving issues on your repository, you can block this account.
—
Reply to this email directly, view it on GitHub
<#907 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABCJNAKDB34JDDMQSGHIW7L2N7DDXAVCNFSM6AAAAABWM5B2VCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMMZRHE2DOMBTGU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
After the deprecation of payload_data for MQTT, we were instructed to use payload exclusively for static and template-based payloads. While testing MQTT messages with template data in Developer Tools, everything works correctly. However, when using a Lovelace button (via a tap_action calling mqtt.publish) that includes a template variable in the payload, the variable is not rendered and the literal template string is passed through instead. For example:
tap_action:
action: call-service
service: mqtt.publish
service_data:
payload: {{ states("input_boolean.studio_mode_chill") }}
topic: eventghost
will just render as:
{{ states("input_boolean.studio_mode_chill") }}
Is there a way to move the jinja2 rendering over to the payload key now that everything has been switched over?
The text was updated successfully, but these errors were encountered: