Hello @LeiChat Can you remind me how much flexibility you have in defining the Emoncms URL and API used to post the data in the HA integration? If you use /input/post?fulljson= instead of ?json= or data=, this should fix this issue.
This issue which I’ve only recently appreciated is due to the way the white spaces are treated in the decoding of json data using the non “fulljson” options.
Basically if you use fulljson:
{"P1":100, "P2":200}
results in two inputs “P1” and “P2” as you would expect.
But if you use data= or json=, these use the json-like decoder which can decode strings that look like this:
P1:100,P2:200
but if the data is actually json as above, with that white space after the comma, the json like decoder first removes the brackets and double quotes leaving:
P1:100, P2:200
and then it splits by comma and colon leaving: “P1” and “ P2” (notice that leading space).
On emoncms.org I have modified the code to trim all input names to remove any leading spaces and at the same time I removed all existing leading spaces from configured inputs so that I didn’t break existing configurations.
I haven’t pushed this change to the main emoncms branch yet as it’s not as easy to manage the migration process in a way that would not break existing configurations with leading white spaces. Perhaps I should make that change anyway, the number of systems likely affected by this is relatively small and it would be good to have a more robust and consistent behaviour.
The easy fix in the mean time is to use the “fulljson” parameter in the the API call.