Support !secret in JSON constructed with ArduinoJson syntax
#3442
-
Component namejson Link to component documentation on our websitehttps://esphome.io/components/json/ Describe the enhancementCurrently there are two ways of defining JSON as defined in: https://esphome.io/components/http_request/#examples on_...:
- http_request.post:
url: https://esphome.io
json:
key: !lambda |-
return id(my_sensor).state;
greeting: "Hello World"
# Will send:
# {"key": "42.0", "greeting": "Hello World"}And using ArduinoJson syntaxt which supports almost everything including nested JSON: on_...:
- http_request.post:
url: https://esphome.io
json: |-
root["sensor"] = "gps";
root["time"] = 1351824120;
root["nest"][0]["apple"] = "good";
# Will send:
# {"sensor":"gps","time":1351824120,"nest":[{"apple":"good"}]}But the problem is, the 2nd syntax doesn't support using Use casesAllow sending HTTP request using values stored in secrets. Anything else?A workaround that I tried is using globals, but it doesn't really work when putting such as |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
|
🏷️ I've automatically added the |
Beta Was this translation helpful? Give feedback.
-
|
I think that isn't possible. Use a substitution to pull in the secret, then use that in your json. |
Beta Was this translation helpful? Give feedback.
Also, I think you misunderstood the workaround.