GithubHelp home page GithubHelp logo

iobroker-community-adapters / iobroker.legrand-ecocompteur Goto Github PK

View Code? Open in Web Editor NEW
1.0 4.0 2.0 623 KB

ioBroker adapter for the Legrand Ecocompteur module (aka. Legrand Measurement Concentrator EMDX³ 412000).

License: MIT License

HTML 11.42% CSS 0.49% JavaScript 88.09%
iobroker-adapter power-monitoring energy-monitoring legrand

iobroker.legrand-ecocompteur's Introduction

Logo

ioBroker.legrand-ecocompteur

NPM version Downloads Number of Installations (latest) Number of Installations (stable)

NPM

legrand-ecocompteur adapter for ioBroker

Adapter for the Legrand Ecocompteur module (aka. Legrand Measurement Concentrator EMDX³ 412000).

This is a power measurement device with it's own web interface. The adapter utilises that web interface by:

  • Polling for instantaneous power readings (read in a JSON response).
  • Polling the device's index page to read the TIC interface. TIC stands for Télé-Information Client which is a French construct. This value is generally read from a utility billing meter connected to the Ecocompteur.

These objects are created for each of the 5 circuits the Ecocompteur reads plus overall total:

  • Instantaneous power (in Watts).
  • Total cumulated energy measured while the adapter was running (in kWh).

A further object is created to store the TIC interface value.

Note the Ecocompteur's Fragile IP Stack

Through testing it has been noted that the Ecocompteur has a rather fragile IP stack. Sometimes the stack can 'hang' and stop responding to requests, although in the author's experience, that was tracked to non-RFC compliant requests coming from another home automation device.

Nevertheless, it would be prudent to mitigate for this risk by placing the device behind a simple Nginx micro-caching reverse proxy. Example Nginx configuration for an Ecocompteur at http://192.168.0.10/ (hence set BaseURL settings for this adapter to http://<Nginx address>:8080/le/):

proxy_cache_path /tmp/cache keys_zone=cache:32k levels=1 inactive=10s max_size=256k;

server {
    listen 8080;

    proxy_cache cache;
    proxy_cache_valid 200 1s;
    location /le/ {
        proxy_pass http://192.168.0.10/;
    }
}

Configuration

The following configuration is required:

  • Base URL of device.
  • JSON polling interval (in seconds).
  • Index polling interval (in seconds).
  • Validation: maximum circuit reading (in Watts).

Changelog

1.0.0

  • (Robin Rainton) Stable release.

0.0.6

  • (Robin Rainton) Change IP address setting to base URL. Settings will need to be updated.
  • (Robin Rainton) Fixed timeout handling. Parse readings from index HTML. Refactor to use more promises & single interval timer.

0.0.4

  • (Robin Rainton) Added reading validation filter.

0.0.3

  • (Robin Rainton) initial clean release.

License

MIT License

Copyright (c) 2020 Robin Rainton [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

iobroker.legrand-ecocompteur's People

Contributors

apollon77 avatar dependabot[bot] avatar mcm1957 avatar raintonr avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

iobroker.legrand-ecocompteur's Issues

Catch request timeout correctly

2022-03-26 00:55:38.865  - ^[[31merror^[[39m: legrand-ecocompteur.0 (27403) Request timeout!
2022-03-26 00:55:38.872  - ^[[31merror^[[39m: legrand-ecocompteur.0 (27403) Request error: timeout
2022-03-26 00:55:38.878  - ^[[31merror^[[39m: legrand-ecocompteur.0 (27403) Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch().
2022-03-26 00:55:38.879  - ^[[31merror^[[39m: legrand-ecocompteur.0 (27403) unhandled promise rejection: undefined
2022-03-26 00:55:38.882  - ^[[32minfo^[[39m: legrand-ecocompteur.0 (27403) cleaned everything up...
2022-03-26 00:55:38.888  - ^[[31merror^[[39m: legrand-ecocompteur.0 (27403) Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch().
2022-03-26 00:55:38.889  - ^[[31merror^[[39m: legrand-ecocompteur.0 (27403) unhandled promise rejection: Invalid argument: "timer". Expected an instance of SetIntervalAsyncTimer.
2022-03-26 00:55:38.890  - ^[[31merror^[[39m: legrand-ecocompteur.0 (27403) SetIntervalAsyncError: Invalid argument: "timer". Expected an instance of SetIntervalAsyncTimer.
    at validateTimer (/opt/iobroker/node_modules/set-interval-async/dynamic/index.js:61:11)
    at /opt/iobroker/node_modules/set-interval-async/dynamic/index.js:81:5
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/opt/iobroker/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
    at _next (/opt/iobroker/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
    at /opt/iobroker/node_modules/@babel/runtime/helpers/asyncToGenerator.js:32:7
    at new Promise (<anonymous>)
    at /opt/iobroker/node_modules/@babel/runtime/helpers/asyncToGenerator.js:21:12
    at _clearIntervalAsync (/opt/iobroker/node_modules/set-interval-async/dynamic/index.js:98:30)
    at clearIntervalAsync (/opt/iobroker/node_modules/set-interval-async/dynamic/index.js:76:30)
2022-03-26 00:55:38.892  - ^[[31merror^[[39m: legrand-ecocompteur.0 (27403) Invalid argument: "timer". Expected an instance of SetIntervalAsyncTimer.
2022-03-26 00:55:39.389  - ^[[32minfo^[[39m: legrand-ecocompteur.0 (27403) terminating
2022-03-26 00:55:39.393  - ^[[33mwarn^[[39m: legrand-ecocompteur.0 (27403) Terminated (UNCAUGHT_EXCEPTION): Without reason

Refactor to use setIntervalAsync & only one timer

This seems to be a safer idea as setIntervalAsync guarantees that the function will never execute more than once at the same time.

Moreover, would also be safer to load the HTML or JSON page on each interval. If #9 is implemented will allow page loads to interleave.

Pass New error in req.destroy on('timeout')

on('timeout') assumes on('error') will be called directly after. This is true, but only if the request has not been accepted. If the called server accepts a request but does not finish sending a response, on('timeout') is called but throws no further error when calling req.destroy().

This should simply be changed to req.destroy(new Error('timeout'));

Reading validation (filter crazy high looking readings)

Checking readings for a circuit recorded into Influx I see...

name: power
time                 circuit device function room src uuid value
----                 ------- ------ -------- ---- --- ---- -----
2020-05-12T02:08:21Z Kitchen                      iob      93
2020-05-12T02:08:23Z Kitchen                      iob      92
2020-05-12T02:08:44Z Kitchen                      iob      0
2020-05-12T02:13:44Z Kitchen                      iob      0
2020-05-12T02:18:44Z Kitchen                      iob      0
2020-05-12T02:23:18Z Kitchen                      iob      181172
2020-05-12T02:23:28Z Kitchen                      iob      0
2020-05-12T02:28:28Z Kitchen                      iob      0

That reading of 181172 is clearly rubbish but by recording it this messes up the kWh reading for that circuit (and total). Readings that are clearly bogus should be ignored.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.