Closed wouterbouvy closed 3 years ago
@wouterbouvy I missed your pull request completly. But I agree, the JSON generator creates JSON array object in MQTT that is not needed. I have been working on my OTGW firmware (other repo) and already fixed the JSON there. I even consider removing the JSON completly for MQTT. The code is more complicated then needed. I will check out your pull request.
Just checked in Auto-Discovery feature for MQTT. Removed the array in JSON generator. The auto-discovery feature should remove backward breaking change problem, as the configuration is automatic. On initial use this could need some rework, untested at this point.
Merge your suggestion manually. If auto-discovery feature works properly, we can even futher simplify the MQTT messages. As the JSON is actually not really needed (matter of taste I guess).
@wouterbouvy just to let you know, the active branch is the esp32 port. It's also backward compatible with the esp8266. So you can start to use this version. I need to clean out my branching soon, and merge back into the master codebase.
@wouterbouvy you liked clean messages... what about my last update then. No more JSON in MQTT, and it just works with you HomeAssistant setup, due to Auto-Discovery backward compatibility is assured. Let me know what you think about this change? Did you ever use the JSON from MQTT?
Will check your code later, and since I only have 1 DSMR logger for production use, will need to figure out a way to test. I actually do use the JSON formatting to have other Tasmota based devices subscribe to the power delivered/returned topics and switch loads according to power usage. See: https://tasmota.github.io/docs/Subscribe-%26-Unsubscribe/
@wouterbouvy as I understand the documentation. If the MQTT topic is just a value, you do simply not define a key. And it thus should work without JSON. The key is only needed if you have a JSON message.
Please let me know if that works for you.
Not picked up by original maintainer since it will break existing configurations. I like cleaner code MQTT messages though. No need to put responses in an array since only one value is expected
Before: Topic: DSMR-API/power_delivered "{"power_delivered": [{"value": 1.674, "unit": "kW"}}"]
After: Topic: DSMR-API/power_delivered "{"power_delivered": {"value": 1.674, "unit": "kW"}}"