Skip to content
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

add support for plain text in payload (i.e. no JSON) #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jpmens
Copy link
Contributor

@jpmens jpmens commented Oct 1, 2023

this permits something like condition: event.payload == 'hello' for an MQTT publish with a payload consisting of the word "hello"

mosquitto_pub -t anomaly-data-out -m hello

  this permits something like
  `condition: event.payload == 'hello'` for an MQTT publish with
  a payload consisting of the word "hello"
@jpmens
Copy link
Contributor Author

jpmens commented Oct 1, 2023

Rulebook fragment:

    - name: Say hello
      condition: event.payload == 'hello'
      action:
        run_module:
           name: debug
           module_args:
              msg: "Hello there from MQTT!"

jpmens added a commit to jpmens/kubealex.eda that referenced this pull request Oct 1, 2023
This appears to address kubealex#3 in as much as it works and the warning I
reported there is silenced. Note that this patch contains the PR I
submitted in kubealex#4.
	closes kubealex#3
@kubealex
Copy link
Owner

kubealex commented Oct 3, 2023

thank you @jpmens for the suggestion!

i have a couple of concerns about this:

  • Are you aware of a use case where a plain text payload could make sense? (it would require per-string parsing)
  • Couldn't this open up to potential errors for malformed json payload?

For the second one, my biggest fear is that if for any reason the source generates a malformed json payload, it would still be accepted as plaintext, increasing the debug time.

Let me know what you think :)

@jpmens
Copy link
Contributor Author

jpmens commented Oct 4, 2023

I don't disagree that this opens the case for JSON not being parsed properly, but on the flip side, debugging that can be just as hard as having an incorrect element in the published JSON. :)

There have been several IoT devices which post plain text payloads, and adding support for plain text arguably makes it simpler for people to test.

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