Overview

The EnerTalk Installer is an install library that provides developers with full functionality to install enertalk devices.

This library can be installed and used like other cordova plugins. I will explain details in How to install.

Input

In order to succeed in the installation, you need to provide information on the user’s installation environment. Below is list and explanation.

EnerTalk Installer takes exactly two inputs options and onClose.
The options option is an object, key and value pair, which contains the informations necessary to install the device.

The onClose option is a method to close the installer on the user application.

The options object

Field Type Description
userId string, number (required) Device holder’s unique Id
siteId number (required) Id of a site.
accessToken string (required) AccessToken to request the API used by the installer.
clientId string (required) To verify who requested installation
country string (required) Site location, one of ‘KR’, ‘US’ or ‘JP’
installPurpose number (required) Device use purpose. Choose one of 1, 2 or 3. Each number represents, Consumption(1) / Appliance(2) / Generation(3)
installType number (required) The type of distribution box, which the device will be installed. Choose one of 1, 2, 3, 4 or 5. Each number represents, Single phase 2 wires(1) / Single phase 3 wires(2) / Poly phase 3 wires(3) / Poly phase 4 wires(4) / Multi channel(5)
registrationId string (required) An uuid to authenticate the device with the Encored server.
ctCapacity number (required) CT capacity amount. Choose one of 50, 100, 200, 300, 600. Each number represents, 50A, 100A, 200A, 300A, 600A. This option is not required if one of the option replace or wifiConnectOnly is true.
dataPeriod number (required) The number of seconds that the device sends data to the Encored server. Choose one of 1, 60, 300, 900. Each value represents, from 1 second to 900 seconds.
dataCount number Number of Hz. Choose one of 1, 10, 15. If the option dataPeriod of value is 1, then this option will be required
deviceId string Id of the installing device. This option is required if one of the option replace or wifiConnectOnly is true.
deviceName string Name of the installing device, default serial number.
registrationUrl string The registering API endpoint, Encored’s API endpoint will be used if you do not provide any registrationUrl.
replace boolean Set true, if you want to replace your device with the other device.
wifiConnectOnly boolean Set true, if you want to reconnect your device with the wifi.

NOTE
* You cannot set both replace and wifiConnectOnly to true
* You can only set dataCount to 10/15hz iff installPurpose is Consumption and dataPeriod is 1 second.
* If dataPeriod is greater than 1 second, you can only set dataCount to 1hz.
* If you choose concumption as your installPurpose, then you should not let user choose multiChannel for installType.

The onClose method

This is the method provided by the developer who builds the application using this library.

<enertalk-installer options="installOptions" on-close=“closeInstaller(apple)"></enertalk-installer>

$scope.closeInstaller = function(state) {
         $log.info('Closed!');
};

How to install

Prerequisite

Cordova plugins needs to be installed in the application.

cordova-plugin-geolocation 2.4.0
cordova-spinning-dialog 1.3.1
cordova-plugin-network-information 1.2.1
cordova-plugin-settings 1.0.1
ionic-plugin-keyboard 2.2.1
cordova-plugin-device 1.1.3
cordova-plugin-android-permissions 0.10.0
cordova-plugin-request-location-accuracy 1.0.3

Add the following to your bower.json file.

dependencies
{
  “enertalk_installer": “https://x-oauthbasic:5f2623717025bfabe50c01ec646cf12d241f4ed1@github.com/EncoredTech/enertalk_installer.git"
}

then

bower install enertalk_installer

Examples

The following is sample code. You can test this code on your application.

html file

<!DOCTYPE html>
<html>
  <head>
    <title>EnerTalk Installer</title>

    <!-- Import EnerTalk Installer dependencies -->
    <link href="lib/ng-enertalk-installer/build/css/main.css" rel="stylesheet">
    <script src="lib/ng-enertalk-installer/build/js/main.js"></script>
  </head>
  <body ng-app="exampleApp" ng-controller="ExampleCtrl">
    <button ng-click="openInstaller()">Open Installer</button>

    <script src="./example.js"></script>
  </body>
</html>

<script id="installer.html" type="text/ng-template">
  <ion-modal-view>
    <ion-content>
      <enertalk-installer
        options="options"
        on-close="closeModal()"
      ></enertalk-installer>
    </ion-content>
  </ion-modal-view>
</script>

JS file

angular.module('exampleApp')
  .controller('ExampleCtrl', function ($ionicModal) {

    $scope.openInstaller = function () {
      $ionicModal.fromTemplateUrl('installer.html', {
       scope: $scope,
       animation: 'slide-in-up'
     }).then(function(modal) {
       $scope.modal = modal;

       $scope.options = {
         clientId: 'yourAPIKey',
         userId: 'yourUserId',
         siteId: 'yourSiteId',
         deviceId: 'yourDeviceId',
         deviceName: 'yourDeviceName',
         registrationId: 'yourRegId',
         country: 'KR',
         installPurpose: 1,
         installType: 4,
         ctCapacity: 300,
         dataPeriod: 1,
         dataCount: 15,
         replace: false,
         wifiConnectOnly: false,
         registrationUrl: 'endpointOfAPIServer'
       };

       $scope.closeModal = function() {
         $scope.modal.hide();
       };

       $scope.$on('$destroy', function() {
         $scope.modal.remove();
       });

       $scope.modal.show();
     });
    };
  });

bower.json

{
  "name": "example",
  "dependencies": {
    “enertalk_installer": “https://x-oauthbasic:5f2623717025bfabe50c01ec646cf12d241f4ed1@github.com/EncoredTech/enertalk_installer.git"
  }
}