trigger icon indicating copy to clipboard operation
trigger copied to clipboard

QR code generation: skip fields with default values

Open stokito opened this issue 4 weeks ago • 4 comments

Currently the QR code contains:

{"port": 22, "timeout": 5000, "require_wifi": false}

This fields can be omitted for the default values. It would be great to have same for the boolean fields but they still are added even when have the false value.

stokito avatar Dec 13 '25 18:12 stokito

I do not see that a port == 0 will be omited from the QR code: https://github.com/mwarning/trigger/blob/master/app/src/main/kotlin/app/trigger/QRShowActivity.kt#L52

But I haev not tested it yet - tomorrow.

mwarning avatar Dec 13 '25 21:12 mwarning

To remove Boolean that are false and integers that are 0 would rely on that those are always defaults. D different trigger versions might have different defaults. Without a good reason I would keep them.

mwarning avatar Dec 14 '25 18:12 mwarning

The timeout change is fine.

mwarning avatar Dec 14 '25 18:12 mwarning

Yes, for now all Door siblings (Nuki, SSH, HTTPS and MQTT) have bool fields defaults to false and int fields defaults to 0 except of the app_id=2342 but it's unlikely that someone will have the app_id=0. This is a good convention to follow anyway.

stokito avatar Dec 14 '25 20:12 stokito

It is a good convention to keep defaults to false and 0. But there is no guarantee. Unless there is a very good reason, I would like to keep all configuration arguments explicit.

If defaults are changed, then we end up with bug tickets. This should never happen.

mwarning avatar Dec 15 '25 06:12 mwarning

there is no guarantee

yeah, still if you know this then it's kind of safe. Anyway, this is minor issue so I'll close the PR

stokito avatar Dec 15 '25 07:12 stokito

sorry I had to veto against the approach. I had a very similar idea back then. But then decided to play it safe.

mwarning avatar Dec 15 '25 08:12 mwarning