Skip to content

Fix WS90 Victron flow: relay device lookup and decimal scaling - #235

Merged
orlin369 merged 1 commit into
ALLTERCO:mainfrom
drHouse-gif:fix/ws90-victron-bthome-decode
Nov 4, 2026
Merged

orlin369 merged 1 commit into
ALLTERCO:mainfrom
drHouse-gif:fix/ws90-victron-bthome-decode

Conversation

@drHouse-gif

@drHouse-gif drHouse-gif commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

weather-env/ws90-shelly-to-victron.nodered.json never published anything. Two defects, both in the Freshest gateway + BTHome decode + merge function node.

1. devices is an array, not a MAC-keyed map (blocker)

BLE.CloudRelay.ListInfos answers like this:

{"ts":1793815328,"offset":0,"count":1,"total":1,
 "devices":[{"c0:2c:ed:21:72:1e":{"name":null,"model":0,
   "sdata":{"fcd2":"QAChBQAAACAARAAARDwARgBenBg="},"mdata":{},"last_seen":1793815327}}]}

The flow treated devices as a map keyed by MAC:

const devices = body && body.devices ? body.devices : {};
Object.keys(devices).some(function (mac) {
    if (String(mac).toLowerCase() === WS90_MAC) { ... }
});

Object.keys() over that array yields ["0"], so the comparison was "0" === "c0:2c:ed:...". It never matched, the function returned null, and nothing reached the Victron. Running the published function verbatim against a live gateway response:

Shelly returns devices as: ARRAY
Object.keys(devices) = ["0"]
ws90_decode result: null          <-- nothing downstream
same function, devices passed as a map: {"packet_id":161,"temperature":7.2,...}

Fixed by flattening the array into the map the rest of the function already expects. Both response shapes are now handled, so this stays correct if the RPC ever returns a map.

2. Decimal scaling by multiplication put floating-point artifacts on the dbus

The decoder scaled with * 0.1, * 0.01 and * 0.001. None of those are exactly representable as doubles, so:

71   * 0.1   = 7.1000000000000005     71   / 10   = 7.1
1148 * 0.1   = 114.80000000000001     1148 / 10   = 114.8

Those values went straight onto com.victronenergy.temperature/101 and showed up in the GUI. Brute-forcing every integer a 16-bit field can hold, 40874 of 196608 scaled values stringify differently between multiplication and division; division is exact for 10, 100 and 1000. Replaced throughout the decoder, which also cleans up dew_point, capacitor_voltage, wind_speed, wind_gust, uv_index, wind_direction, illuminance and precipitation.

Verification

Hardware: Venus OS Large, @victronenergy/node-red-contrib-victron 1.7.29, Ecowitt WS90 relayed by a Shelly Plug S Gen3 on firmware 2.1.1.

The patched flow decodes both of the WS90's alternating advertisements and merges them:

after packet 1: {"battery":100,"pressure":963.1,"dew_point":4.84,"capacitor_voltage":3,
                 "humidity":85,"temperature":7.2,"precipitation":114.8,...}
after packet 2: {... ,"illuminance":0,"rain":false,"wind_speed":0,"wind_gust":0.5,
                 "uv_index":0,"wind_direction":310}

temperature device -> {"Temperature":7.2,"Humidity":85,"Pressure":963.1}
meteo device       -> {"WindSpeed":0,"WindDirection":310}

Read back from the GX, matching the gateway's decoded packet in the same minute:

com.victronenergy.temperature/101  /Temperature 7.1  /Humidity 86  /Pressure 963.1
com.victronenergy.meteo/101        /WindSpeed 0.5    /WindDirection 49

The two-gateway path was exercised with a second Shelly that has BLE relay enabled but is out of range of the station: that branch returns null and the freshest-source selection picks the gateway that can see it.

Notes

  • The JSON is written back with the repository's existing formatting (4-space indent, non-ASCII characters left literal, no trailing newline), so the diff is one line.
  • No change to examples-manifest.json: it indexes .shelly.js only.
  • Not addressed here, flagged for a maintainer's call: the flow has no staleness handling. If the station or the gateway dies, the virtual devices keep serving the last reading indefinitely, and com.victronenergy.temperature exposes no /Connected path to signal otherwise. /Status stays at 0 ("Ok") because dbus-victron-virtual sets it once at registration and the flow never writes it.

BLE.CloudRelay.ListInfos returns devices as an array of single-key
objects keyed by MAC, not as a MAC-keyed map. The flow's lookup ran
Object.keys() over that array, so it compared "0" against the
configured MAC, never matched, and the flow published nothing.

The BTHome decoder also scaled by multiplying with 0.1, 0.01 and
0.001, none of which are exactly representable as doubles, so values
reached the Victron dbus as 7.1000000000000005 degC and
114.80000000000001 mm. Dividing by 10, 100 and 1000 is exact.

Verified end to end: Venus OS Large with node-red-contrib-victron
1.7.29, an Ecowitt WS90 relayed by a Shelly Plug S Gen3, values
landing on com.victronenergy.temperature/101 and
com.victronenergy.meteo/101.
@drHouse-gif
drHouse-gif force-pushed the fix/ws90-victron-bthome-decode branch from 9001f02 to 039bc2e Compare November 4, 2026 18:34
@orlin369
orlin369 merged commit 69e06a0 into ALLTERCO:main Nov 4, 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