From 04b0de6f886e7884725aadc9ddeba5386d0375d0 Mon Sep 17 00:00:00 2001 From: Sam Stenvall Date: Mon, 14 Aug 2023 20:16:18 +0300 Subject: [PATCH] Query the device address when started with slave address 0 --- CHANGELOG.md | 1 + app/modbus.mjs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c79bae5..f6233e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * Add missing error handling to the `/summary` route, change HTTP error responses to return JSON * Add `-v` option which enables debug logging * Start using ESLint, add `no-console` rule to enforce use of logger instances +* Include the unit's Modbus address in the device information ## 2.3.2 diff --git a/app/modbus.mjs b/app/modbus.mjs index f12ebe5..25178c2 100644 --- a/app/modbus.mjs +++ b/app/modbus.mjs @@ -289,6 +289,12 @@ export const getDeviceInformation = async (modbusClient) => { 'modelName': createModelNameString(deviceInformation), } + result = await mutex.runExclusive(async () => tryReadHoldingRegisters(modbusClient, 640, 1)) + deviceInformation = { + ...deviceInformation, + 'modbusAddress': result.data[0], + } + return deviceInformation }