0.1.0 • Published 3 years ago

@smtmt2021/enlite v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

License: MIT Node.js CI

Enlite for smart meter

+-------------------------------------------+
|                 Your Apps                 |
+-------------------------------------------+
|               >>> Enlite <<<              |
+-------------------------------------------+
|           WSUN Adaptor Interface          |
+-------------------------------------------+
|                          |  UDP  |  PANA  |
|        WSUN Adaptor      | IPv6 / 6LoWPAN |
|                          |  IEEE802.15.4  |
+-------------------------------------------+
                       :
+-------------------------------------------+
|         A smart meter of your home        |
+-------------------------------------------+

Usage

  • Here is a very brief code:
import { EnliteGetInstance, SmartElectricEnergyMeter, CLASS } from 'enlite';
// write your own app
class MySmartMeter extends SmartElectricEnergyMeter {
  startPolling() {
    this.timer = setInterval(async () => {
      const watt = await this.getInstantaneousElectricEnergey();
      console.log(`${watt}W`);
    }, 60 * 1000);
  }
}
// get a framework which is provided by this project
const enlite = EnliteGetInstance();
// register the app you wrote above
enlite.addDeviceClass(CLASS.LOW_VOLTAGE_SMART_ELECTRIC_ENERGY_METER, MySmartMeter);
// prepare code to activate measuring
enlite.once('device-created', device => {
  // start polling to get a current value of your smart meter
  device.startPolling();
});
// let's go
enlite.open();

Test

  • npm test
  • then, open ./coverage/lcov-report/index.html to see the coverage.

Debug

  • Specify following environment variables (e.g. export DEBUG=enlite/enlite) to display debug information;
File or moduleEnvironment variable
src/enlite-impl.tsenlite/enlite
src/nodeprofile.tsenlite/nodeprofile
src/controller.tsenlite/controller
src/device.tsenlite/device
src/node.tsenlite/node
wsun-adaptorwsun/adaptor, wsun/socket

License

  • MIT license
  • Copyright (c) 2021 KINOSHITA minoru, All Rights Reserved.