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

How to select field with reserved characters? #32

Open
halmartin opened this issue Dec 2, 2023 · 0 comments
Open

How to select field with reserved characters? #32

halmartin opened this issue Dec 2, 2023 · 0 comments

Comments

@halmartin
Copy link

halmartin commented Dec 2, 2023

Hello, thank you for this useful project, I have been using it for many years to read sensor data from Tasmota and Espurna sensors.

I have the following problem: I have a tasmota device which sends a sensor reading with a field that contains the reserved character .:

2023-12-02 13:20:52,756 DEBUG: mqtt_on_message tele/tasmota/tasmota_16268C/SENSOR b'{"Time":"2023-12-02T14:20:52","VINDRIKTNING":{"PM2.5":5}}'
2023-12-02 13:20:52,757 WARNING: different number of fields
2023-12-02 13:20:52,758 WARNING: empty fields

I am interested in transporting the value of field PM2.5 to influxdb, my config.yaml is the following:

  - measurement: pmtwodotfive
    topic: tele/tasmota/+/SENSOR
    fields:
      value: $.payload.VINDRIKTNING.'PM2.5'
    tags:           
      id: $.topic[2]

How should I properly declare the path of .payload.VINDRIKTNING.PM2.5? The above configuration is not working for me.

If I am understanding the documentation of jsonpath-ng correctly, single or double quotes should be sufficient to select a field with special characters:

Syntax Meaning
fieldname the field fieldname (from the “current” object)
"fieldname" same as above, for allowing special characters in the fieldname
'fieldname' ditto
@halmartin halmartin changed the title How to properly escape reserved characters in field name? How to select field with reserved characters? Dec 2, 2023
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

No branches or pull requests

1 participant