From 3f0fbdde581d80f685bc570355d89b23c46e4683 Mon Sep 17 00:00:00 2001 From: gruijter Date: Tue, 28 Nov 2023 16:56:43 +0100 Subject: [PATCH] v2.8.1 Removed SO timeout in test. Added retrieval of Water logs (BE only). Documentation update BE electricity meter. --- .gitignore | 50 +------ .npmignore | 4 +- README.md | 9 +- changelog.txt | 1 + docs/Youless.html | 214 ++++++++++++++++++++++++++- docs/global.html | 358 +++++++++++++++++++++++++++++++++++++++++++++- docs/index.html | 13 +- package.json | 2 +- test/_test.js | 17 ++- youless.js | 70 ++++++++- 10 files changed, 664 insertions(+), 74 deletions(-) diff --git a/.gitignore b/.gitignore index ddef37b..a214031 100644 --- a/.gitignore +++ b/.gitignore @@ -1,50 +1,4 @@ -ssdp.js -crc16*.* +zzz* +.vscode/ -# Windows image file caches -Thumbs.db -ehthumbs.db -# Folder config file -Desktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msm -*.msp - -# Windows shortcuts -*.lnk - -# ========================= -# Operating System Files -# ========================= - -# OSX -# ========================= - -.DS_Store -.AppleDouble -.LSOverride - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk diff --git a/.npmignore b/.npmignore index 3879028..8ac69ae 100644 --- a/.npmignore +++ b/.npmignore @@ -1,4 +1,4 @@ docs/ .vscode/ -ssdp.js -crc16*.* +zzz* + diff --git a/README.md b/README.md index 8c1079a..70e2a45 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,15 @@ * device information, including firmware version * live energy readings of analogue and digital meters * live energy and gas readings of P1 smart meters (LS120 only) +* live water readings of P1 smart meters (LS120 with Belgium meters only) * live readings of the S0 input (LS120 only) * live readings of the optical sensor * live P1 tariff, power, voltage, current readings per phase (LS120 only) * raw P1 data (Experimental and unstable!) * historic logs of power -* historic log of gas (LS120 only) -* historic log of S0 (LS120 only) +* historic logs of gas (LS120 only) +* historic logs of S0 (LS120 only) +* historic logs of water (LS120 only) #### set: @@ -21,6 +23,7 @@ * power counter value * S0 pulses per KwH value (LS120 only) * S0 counter value (LS120 only) +* S0 counter timeout (LS120 only) * optical sensor luminance @@ -32,7 +35,7 @@ ### Note: -This package has been developed and tested with the Enelogic (-EL) firmware and PVOutput (-PO) firmware ^1.4.4. +This package has been developed and tested with the Enelogic (-EL) firmware and PVOutput (-PO) firmware ^1.6.0. Other firmware versions (-EO, and -PO below 1.4.4) might not be fully supported, especially for the function getAdvancedStatus(). ### Install: diff --git a/changelog.txt b/changelog.txt index 5c3e3d5..e5600df 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,4 @@ +2.8.1 - 28-11-2023 Removed SO timeout in test. Added retrieval of Water logs (BE only). Documentation update BE electricity meter. 2.8.0 - 27-11-2023 Added S0 timeout setting (LS120 fw ^1.6.0). Documentation update BE water meter. (LS120 fw ^1.6.0) 2.7.1 - 31-05-2023 Fix for P1 data LS120 fw ^1.6.0 2.7.0 - 23-06-2022 Added P1Status method (3 phase P1 information, only for LS120 fw ^1.5.0) diff --git a/docs/Youless.html b/docs/Youless.html index 2c84283..4c3a1b3 100644 --- a/docs/Youless.html +++ b/docs/Youless.html @@ -26,7 +26,7 @@
@@ -1663,6 +1663,216 @@
Returns:
+

(async) getWaterlog(resolutionopt, periodopt) → {Promise.<waterLog>}

+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+

Get historic water usage data. Note: Only available for LS120 and with Belgian meters.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDefaultDescription
resolution + + +string + + + + + + <optional>
+ + + + + +
+ + 'Days' + +

The interval of logdata in: T(enminutes), H(ours) or D(ays)

period + + +number + + + + + + <optional>
+ + + + + +
+ + this month + +

The period that can be selected for historic data depends on the selected resolution:

+
    +
  • Tenminutes: period 1 (this day) - 30 (30 days ago)
  • +
  • Hours: period 1 (this day) - 70 (70 days ago)
  • +
  • Days: period 1 (January) - 12 (December)
  • +
+ + + + + + + + + + + + + + +
Returns:
+ + + + +
+
+ Type +
+
+ +Promise.<waterLog> + + +
+
+ + + + + + + + +

(async) login(optionsopt) → {Promise.<Youless.loggedIn>}

@@ -3059,7 +3269,7 @@
Returns:

- Documentation generated by JSDoc 3.6.6 on Mon Nov 27 2023 19:02:12 GMT+0100 (Midden-Europese standaardtijd) using the docdash theme. + Documentation generated by JSDoc 3.6.6 on Tue Nov 28 2023 16:37:16 GMT+0100 (Midden-Europese standaardtijd) using the docdash theme.
diff --git a/docs/global.html b/docs/global.html index ee8e6e9..065a0ab 100644 --- a/docs/global.html +++ b/docs/global.html @@ -26,7 +26,7 @@
@@ -1601,6 +1601,8 @@
Properties:
Type + Attributes + @@ -1613,7 +1615,7 @@
Properties:
- ver + tr @@ -1626,17 +1628,23 @@
Properties:
+ + + + + + -

P1 interface version e.g. 50

+

Active tariff. 1 = high, 2 = low

- tr + pa @@ -1649,10 +1657,80 @@
Properties:
+ + + <optional>
+ + + + + -

Active tariff. 1 = high, 2 = low

+

power peak 15 minutes (Watt, BE only), e.g. 120

+ + + + + + + pp + + + + + +number + + + + + + + + + <optional>
+ + + + + + + + +

power peak month (Watt, BE only), e.g. 1280

+ + + + + + + pts + + + + + +number + + + + + + + + + <optional>
+ + + + + + + + +

date and time of peak (yyMMddhhmm, BE only), e.g. 2311181715

@@ -1672,6 +1750,12 @@
Properties:
+ + + + + + @@ -1695,6 +1779,12 @@
Properties:
+ + + + + + @@ -1718,6 +1808,12 @@
Properties:
+ + + + + + @@ -1741,6 +1837,12 @@
Properties:
+ + + + + + @@ -1764,6 +1866,12 @@
Properties:
+ + + + + + @@ -1787,6 +1895,12 @@
Properties:
+ + + + + + @@ -1810,6 +1924,12 @@
Properties:
+ + + + + + @@ -1833,6 +1953,12 @@
Properties:
+ + + + + + @@ -1856,6 +1982,12 @@
Properties:
+ + + + + + @@ -1879,6 +2011,12 @@
Properties:
+ + + + + + @@ -1907,7 +2045,7 @@
Properties:
Example
// P1Status information
-{ ver: 50, tr: 2, i1: 5.000, i2: 0.000, i3: 0.000, v1: 238.400, v2: 0.000, v3: 0.000, l1:-1129, l2: 0, l3: 0, tm: 1543065737 }
+{ tr: 2, i1: 5.000, i2: 0.000, i3: 0.000, v1: 238.400, v2: 0.000, v3: 0.000, l1:-1129, l2: 0, l3: 0, tm: 1543065737 } @@ -2725,6 +2863,212 @@
Example
+ +

waterLog

+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
Properties:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
un + + +string + + + +

the unit of the data 'm3' or 'L' (liter)

tm + + +string + + + +

the date/time of the first log entry. e.g. '2018-11-01T00:00:00'

dt + + +number + + + +

the entry interval delta in seconds. e.g. 86400 (= 1 day)

val + + +Array.string + + + +

an array containing the log entries. Closing entry is always null

+ + + + + + +
+

contains historic water usage data

+
+ + + + + + + +
Example
+ +
// daily water usage in the month November
+{
+  un: 'm3',
+  tm: '2023-11-01T00:00:00',
+  dt: 86400,
+  val: [
+    ' 0,160', ' 0,450', ' 0,100',
+    ' 0,550', ' 0,290', ' 0,210',
+    ' 0,190', ' 0,170', ' 0,200',
+    ' 0,220', ' 0,220', ' 0,170',
+    ' 0,110', ' 0,140', ' 0,150',
+    ' 0,200', ' 0,240', ' 0,240',
+    ' 0,160', ' 0,140', ' 0,270',
+    ' 0,110', ' 0,330', ' 0,130',
+    ' 0,000', ' 0,030', ' 0,150',
+    null
+  ]
+}
+/*
+more detailed information on:
+
+Youless: http://wiki.td-er.nl/index.php?title=YouLess
+DSMR: http://domoticx.com/p1-poort-slimme-meter-hardware/:
+ + + + @@ -2742,7 +3086,7 @@
Example

- Documentation generated by JSDoc 3.6.6 on Mon Nov 27 2023 19:02:12 GMT+0100 (Midden-Europese standaardtijd) using the docdash theme. + Documentation generated by JSDoc 3.6.6 on Tue Nov 28 2023 16:37:16 GMT+0100 (Midden-Europese standaardtijd) using the docdash theme.
diff --git a/docs/index.html b/docs/index.html index 04606b9..5a840be 100644 --- a/docs/index.html +++ b/docs/index.html @@ -26,7 +26,7 @@
@@ -57,13 +57,15 @@

get:

  • device information, including firmware version
  • live energy readings of analogue and digital meters
  • live energy and gas readings of P1 smart meters (LS120 only)
  • +
  • live water readings of P1 smart meters (LS120 with Belgium meters only)
  • live readings of the S0 input (LS120 only)
  • live readings of the optical sensor
  • live P1 tariff, power, voltage, current readings per phase (LS120 only)
  • raw P1 data (Experimental and unstable!)
  • historic logs of power
  • -
  • historic log of gas (LS120 only)
  • -
  • historic log of S0 (LS120 only)
  • +
  • historic logs of gas (LS120 only)
  • +
  • historic logs of S0 (LS120 only)
  • +
  • historic logs of water (LS120 only)
  • set:

      @@ -72,6 +74,7 @@

      set:

    • power counter value
    • S0 pulses per KwH value (LS120 only)
    • S0 counter value (LS120 only)
    • +
    • S0 counter timeout (LS120 only)
    • optical sensor luminance

    do:

    @@ -82,7 +85,7 @@

    do:

  • reboot the device (LS120 only)
  • Note:

    -

    This package has been developed and tested with the Enelogic (-EL) firmware and PVOutput (-PO) firmware ^1.4.4. +

    This package has been developed and tested with the Enelogic (-EL) firmware and PVOutput (-PO) firmware ^1.6.0. Other firmware versions (-EO, and -PO below 1.4.4) might not be fully supported, especially for the function getAdvancedStatus().

    Install:

    If you don't have Node installed yet, get it from: Nodejs.org.

    @@ -126,7 +129,7 @@

    Detailed documentation:


    - Documentation generated by JSDoc 3.6.6 on Mon Nov 27 2023 19:02:12 GMT+0100 (Midden-Europese standaardtijd) using the docdash theme. + Documentation generated by JSDoc 3.6.6 on Tue Nov 28 2023 16:37:16 GMT+0100 (Midden-Europese standaardtijd) using the docdash theme.
    diff --git a/package.json b/package.json index 9126e15..200b69d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "youless", - "version": "2.8.0", + "version": "2.8.1", "description": "Node package to interface with Youless energy monitor devices (LS110 and LS120)", "main": "youless.js", "scripts": { diff --git a/test/_test.js b/test/_test.js index ce2159e..9542c67 100644 --- a/test/_test.js +++ b/test/_test.js @@ -138,7 +138,16 @@ async function doTest() { .catch((error) => logError(error)); log.push(`t = ${(Date.now() - t0) / 1000}`); - // get S0 log of the present month + // get water log of the present month + log.push('trying to get historic water log of present month (LS120 in BE only)'); + await youless.getWaterlog() + .then((waterLog) => { + log.push(waterLog); + }) + .catch((error) => logError(error)); + log.push(`t = ${(Date.now() - t0) / 1000}`); + + // get raw P1 status log.push('trying to get the raw P1 status'); await youless.getRawP1Status({ noCheck: true }) .then((rawP1Status) => { @@ -174,9 +183,9 @@ async function doTest() { // .catch((error) => logError(error)); // set the S0 pulses timeout - log.push('trying to set the S0 timeout (LS120 only)'); - await youless.setS0Timeout(5) - .catch((error) => logError(error)); + // log.push('trying to set the S0 timeout (LS120 only)'); + // await youless.setS0Timeout(5) + // .catch((error) => logError(error)); // // set the Power counter value (in KwH) NOTE: also resets powerPulses to 1000 // await youless.setPowerCounter(12345) diff --git a/youless.js b/youless.js index 6416d69..8a27b60 100644 --- a/youless.js +++ b/youless.js @@ -37,6 +37,7 @@ const rebootPath = '/S?rb='; const discoverPath = '/d'; const advancedStatusPath = '/e'; const gasLogPath = '/W'; // add range w/d/m, selection, and json format. e.g. ?d=70&f=j +const waterLogPath = '/K'; // add range w/d/m, selection, and json format. e.g. ?d=70&f=j // Only available for LS120 fw>-1.4: const setS0PulsesPath = '/M?s='; // add pulses per kWh, e.g. /M?&s=1000 @@ -488,6 +489,44 @@ class Youless { } } + /** + * Get historic water usage data. Note: Only available for LS120 and with Belgian meters. + * @param {string} [resolution = 'Days'] - The interval of logdata in: T(enminutes), H(ours) or D(ays) + * @param {number} [period = this month] - The period that can be selected for historic data depends on the selected resolution: + * - Tenminutes: period 1 (this day) - 30 (30 days ago) + * - Hours: period 1 (this day) - 70 (70 days ago) + * - Days: period 1 (January) - 12 (December) + * @returns {Promise} + */ + async getWaterlog(resolution, period) { + try { + const res = resolution || 'd'; // defaults to days + const now = new Date(); + const thisMonth = now.getMonth() + 1; + const per = Number(period) || thisMonth; // defaults to this month + let range; + switch (res[0].toLowerCase()) { + case 't': + range = 'w'; + break; + case 'h': + range = 'd'; + break; + case 'd': + range = 'm'; + break; + default: + throw Error('The resolution can only be T(enminutes), H(ours) or D(ays)'); + } + const getWaterlogPath = `${waterLogPath}?${range}=${per}&f=j`; + const result = await this._makeRequest(getWaterlogPath); + const gasLog = JSON.parse(result.body); + return Promise.resolve(gasLog); + } catch (error) { + return Promise.reject(error); + } + } + /** * Set meter type to D(igital) or A(nalog). * @param {string} value - The meter type A(analog) or D(igital). @@ -858,8 +897,10 @@ p2: 9942.712, n1: 1570.936, n2: 4250.937, gas: 6192.638, gts: 1811241400, gtm: 1 /** * @typedef P1Status * @description P1Status is an object containing P1 version, tariff and current/voltage/power information per phase. -* @property {number} ver P1 interface version e.g. 50 * @property {number} tr Active tariff. 1 = high, 2 = low +* @property {number} [pa] power peak 15 minutes (Watt, BE only), e.g. 120 +* @property {number} [pp] power peak month (Watt, BE only), e.g. 1280 +* @property {number} [pts] date and time of peak (yyMMddhhmm, BE only), e.g. 2311181715 * @property {number} i1 phase 1 current (Ampere), e.g. 5.000 * @property {number} i2 phase 2 current (Ampere), e.g. 5.000 * @property {number} i3 phase 3 current (Ampere), e.g. 5.000 @@ -871,7 +912,7 @@ p2: 9942.712, n1: 1570.936, n2: 4250.937, gas: 6192.638, gts: 1811241400, gtm: 1 * @property {number} l3 phase 3 power (Watt), e.g. 1129 * @property {number} tm time of retrieving info. unix-time-format. e.g. 1542575626 * @example // P1Status information -{ ver: 50, tr: 2, i1: 5.000, i2: 0.000, i3: 0.000, v1: 238.400, v2: 0.000, v3: 0.000, l1:-1129, l2: 0, l3: 0, tm: 1543065737 } +{ tr: 2, i1: 5.000, i2: 0.000, i3: 0.000, v1: 238.400, v2: 0.000, v3: 0.000, l1:-1129, l2: 0, l3: 0, tm: 1543065737 } */ /** @@ -990,6 +1031,31 @@ p2: 9942.712, n1: 1570.936, n2: 4250.937, gas: 6192.638, gts: 1811241400, gtm: 1 } */ +/** +* @typedef waterLog +* @description contains historic water usage data +* @property {string} un - the unit of the data 'm3' or 'L' (liter) +* @property {string} tm - the date/time of the first log entry. e.g. '2018-11-01T00:00:00' +* @property {number} dt - the entry interval delta in seconds. e.g. 86400 (= 1 day) +* @property {Array.string} val - an array containing the log entries. Closing entry is always null +* @example // daily water usage in the month November +{ + un: 'm3', + tm: '2023-11-01T00:00:00', + dt: 86400, + val: [ + ' 0,160', ' 0,450', ' 0,100', + ' 0,550', ' 0,290', ' 0,210', + ' 0,190', ' 0,170', ' 0,200', + ' 0,220', ' 0,220', ' 0,170', + ' 0,110', ' 0,140', ' 0,150', + ' 0,200', ' 0,240', ' 0,240', + ' 0,160', ' 0,140', ' 0,270', + ' 0,110', ' 0,330', ' 0,130', + ' 0,000', ' 0,030', ' 0,150', + null + ] +} /* more detailed information on: