-
Notifications
You must be signed in to change notification settings - Fork 77
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
dbus-mqtt: send null instead of empty array for dbus-invalid #936
Comments
yes, values do become undefined / null whatever when not known. On the dbus we do use a empty array for that. If there are better implementations for json please let us know. |
Hi @jhofstee , thanks or the reply :) Completely understand the problem - you don't HAVE a value, so how do you communicate that to the consumer? First, just to reiterate the problem I hit. In a typed language binding situation, I'm expecting a numeric value. Now, under this set of conditions the type of the value suddenly changes from numeric to a list type (or array, or collection, whatever you want to call it). So the question then for me is: what is the "right" thing to do? The options I can think of, in order or least to most surprising is:
The above options should not break de-serialization, but would still express the current situation. 0 (zero) MIGHT be misleading if a consumer is not looking at more topics. There is a nice StackOverflow post here on the topic. It would be great if any other MQTT consumers / integrators could also throw in some opinions :) |
If there is no value then my vote would be for it to be null. |
I would be happy with The good:
The bad:
|
Hi all, rather old open issue; sorry for that. I checked with several developers (VRM, VictronConnect) and they see no immediate issue with changing this. And agree that its technically better. We’ll still take this slowly, since changing this needs testing on various apps where we use this data; I know at least three:
and then there is
And then there are customer implementations to consider. lots of work and care for this seemingly small change. so; lets see! At least you know where aware of this. |
Thank you @mpvader - quality takes time :) |
@demaniak do you get Also interesting, are there topics that already do say I ask, because I can't reproduce it (meaning I get |
@wiebeytec , let me try and answer :) do you get { "value": [] } on other topics as well?Off the cuff, I can not say. My integration does not subscribe to ALL available topics - I have only noticed this particular situation for the Also interesting, are there topics that already do say {"value":null}?Again, I'm unfortunately not sure - I have not looked closely at this code for a while - it is working and doing what I want, so further changes have been slow :) I'm pretty sure I see some empty string values (i..e "", not The code has always been pretty defensive regarding If you think it can help, I can maybe add some checking and logging for null values, and make sure what I'm seeing. BUT, I will also just mention that I can't really logically see that
The only why I could understand a Maybe I ask, because I can't reproduce it (meaning I get null on invalid values). This means you may have found another bug.Well.. maybe let me try and be more specific about the state I observe this in. So when the On the VRM this can be seen as the Ac Loads value being displayed as Maybe also just worth checking current Venus versions we are talking about? |
Hey @demaniak thank you for the details. Wiebe and myself discussed this just now, here is the result:
I'll close this issue; to keep it central. Thanks! |
I updated to version 2.85 today.
All went well, and my MQTT integration seemed happy.
Then tonight we got hit with mains outage again (or as it is colloquially know, "load shedding").
And things went a bit weird.
For topic
N/xxxxxxxxxxxx/system/0/Ac/ConsumptionOnInput/L1/Power
, a payload like{"value": 555}
is typically expected.However, what was actually received, was
{"value": []}
.So fair enough, mains are dead, so no reading - but switching from a numeric type to a list type is a bit drastic, don't you agree?
I believe in earlier versions I would get a good solid 0 (zero) there instead, which is perfectly acceptable.
Once mains power was restored, I received the expected payload again.
The text was updated successfully, but these errors were encountered: