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

Simplify mqttjson dict format #522

Closed
wlcrs opened this issue Feb 13, 2022 · 4 comments
Closed

Simplify mqttjson dict format #522

wlcrs opened this issue Feb 13, 2022 · 4 comments
Labels

Comments

@wlcrs
Copy link

wlcrs commented Feb 13, 2022

Description

I'm using the new mqqtjson option to integrate ebusd in to Home Assistant.

I'm however a bit surprised by how fields which contain multiple values are handled. I would propose to simplify how you return these fields, and remove those unnecessary {"name": ,"value":}.

In case of naming conflicts, you could suffix the index?

So instead of:

{
     "0": {"name": "temp1", "value": 53.0},
     "1": {"name": "temp1", "value": 51.0},
     "2": {"name": "temp2", "value": null},
     "3": {"name": "temp1", "value": null},
     "4": {"name": "temp1", "value": 48.0},
     "5": {"name": "pumpstate", "value": "off"}
}

Return this:

{
     "temp1_0": 53.0,
     "temp1_1": 51.0,
     "temp2": null,
     "temp1_3": null,
     "temp1_4:" null,
     "pumpstate": "off",
}
@john30
Copy link
Owner

john30 commented Feb 13, 2022

the numbers are used because the names are not unique. so the right thing to do would be to correct the message definition to have unique fields names, then the numeric index is replaced by the name.

@Nico184
Copy link

Nico184 commented Feb 25, 2022

Hello,
I tried to add the field namens in configuration files, but it did not work as expected, as I described here #255 of the configuration rep. Did I something wrong?

@john30
Copy link
Owner

john30 commented Feb 26, 2022

with --mqttjson=short (commit 1798007) it is now possible to remove the extra object from the payload

@john30
Copy link
Owner

john30 commented Nov 13, 2022

completed

@john30 john30 closed this as completed Nov 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants