Skip to content

Conversation

3735943886
Copy link
Contributor

This Pull Request enhances the @mqtt_trigger to fully support the MQTT retain flag, passing it as a keyword argument to decorated functions. This allows pyscript automations to differentiate between new and retained messages, enabling more advanced logic.

Adds the `retain` flag to `TRIGGER_KWARGS` in pyscript's `eval.py` to prevent a TypeError with mqtt_trigger.
Updates the message handler in `mqtt.py` to include the `retain` flag in its processed arguments.
@craigbarratt
Copy link
Member

Thanks for the PR. Can you update the docs too please?

Updates the documentation to include the 'retain' flag.
@3735943886
Copy link
Contributor Author

Thanks for the PR. Can you update the docs too please?

Absolutely! I've updated the docs.
While I was working on it, I noticed a small inconsistency: the descriptions for qos and payload_obj ended with a period, but the others didn't. I've gone ahead and made a small style change to add periods to the remaining descriptions, making the entire section more uniform.

@craigbarratt craigbarratt merged commit 4acb52e into custom-components:master Sep 9, 2025
6 checks passed
@craigbarratt
Copy link
Member

Thanks for the PR!

@3735943886 3735943886 deleted the add_retain_flag_to_mqtt_trigger branch September 9, 2025 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants