Open Lightning1984 opened 2 years ago
What did you to to figure out that the output json is truncated? As far as I know: If you put the output to an 14-Byte text variable, it'll be tuncated after 14 byte but if you directly forward it into an other logic module, it should be processed completely.
Hi,
I'm feeding the json data directly into JSON-Parser(11087). In the logic editor I used the worksheet monitoring function to debug the module. Initially as mentioned the Output "nrg / json" was completely empty, then I tried to insert self._set_output_value(self.PIN_O_NRG_JSON, str(nrg_json)), the output did now show values but was truncated in the worksheet monitor in the ouput as well as in the input of the JSON Parser module, but showed more than 14 Byte. Additionally the JSON parser module did not successfully parse any data even if I used a key which i could see in the truncated data.
I assumed that it was due to the truncated output, so split the data into 3 separate fields. But the JSON-Parser still wasn't working. I noticed that instead of double quotes (") single quotes (') where put out which is not according to JSON specification. (e.g. {'V L1': 230.0})
Only after replacing the string with the json.dumps function in the output it started to work.
self._set_output_value(self.PIN_O_NRG_JSON_POWERFACTOR, json.dumps(nrg_json_powerfactor))
What i did not test anymore is if the truncated output would be processed correctly internally using the json.dumps() function instead of the str() function.
regards
Hi @En3rGy,
I imported release 0.5 but that seemingly did not have JSON output for the "nrg" field enabled yet as mentioned here: https://github.com/En3rGy/14105_go-eCharger/issues/4 So i downloaded and built the latest source version from github.
The JSON field was available in the Logic Module but was not populated with any data. When looking at the code I found that the function to set the output field was not there:
https://github.com/En3rGy/14105_go-eCharger/blob/fc0a7686283346316d0f60d2cac5f919dcfb0abf/src/14105_go-eCharger%20(14105).py#L247-L254
after line 253 one would need self._set_output_value(self.PIN_O_NRG_JSON, json.dumps(nrg_json))
Unfortunately it looks like the string fields are limited in length in the Module so the data gets cut short. To overcome this issue I split the field into 3 individual Fields: https://github.com/En3rGy/14105_go-eCharger/compare/main...Lightning1984:patch-1?expand=1
Now the data is correctly exported in JSON format and can be further evaluated with e.g. the JSON Parser.
regards