Skip to content

Add Milesight WS303 mini leak detection sensor - #38

Merged
brocaar merged 2 commits into
chirpstack:masterfrom
AkashM707:add-milesight-ws303
Aug 27, 2026
Merged

Add Milesight WS303 mini leak detection sensor#38
brocaar merged 2 commits into
chirpstack:masterfrom
AkashM707:add-milesight-ws303

Conversation

@AkashM707

Copy link
Copy Markdown
Contributor

Adds the Milesight WS303 mini leak detection sensor, firmware 1.5, reusing the existing Milesight 1.0.3 profiles for AS923, AU915, EU868 and US915.

The codec is Milesight's published decoder and encoder for this product, combined into a single file.

One thing worth flagging for review: both halves define a getValue helper with opposite semantics — the decoder maps a numeric key to a label, the encoder maps a label back to its key. Concatenating them unchanged lets the encoder's definition win through function hoisting, and every decode then returns "unknown". The encoder's helper is renamed to getEncodeValue here; no other changes to Milesight's code.

Tests cover battery, leakage status (normal / leak), device status, and downlink encoding for reboot and report interval.

Adds the WS303 with AS923, AU915, EU868 and US915 profiles, reusing the
existing Milesight 1.0.3 profiles.

The codec is Milesight's published decoder and encoder for this product,
combined into a single file. Both halves define a getValue helper with
opposite semantics — the decoder maps a numeric key to a label, the encoder
maps a label back to its key — so the encoder's has been renamed to
getEncodeValue. Concatenating them unchanged lets the encoder's definition
win through hoisting, and every decode returns "unknown".

Decode and encode tests cover battery, leakage status, device status,
reboot and report interval.
@brocaar

brocaar commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

@AkashM707 the tests are failing. I believe it is related to these lines:

function Buffer(size) {
  this.buffer = new Array(size);
  this.offset = 0;

  for (var i = 0; i < size; i++) {
    this.buffer[i] = 0;
  }
}

I did a test and replacing these lines with:

class Buffer {
  constructor(size) {
    this.buffer = new Array(size).fill(0);
    this.offset = 0;
  }
}

solved the issue. Could you update this in your pull-request?

@brocaar found this was causing the test suite to fail and confirmed a
class-based Buffer resolves it.
@brocaar
brocaar merged commit 7fb494c into chirpstack:master Aug 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants