NAV
Command Line Ruby Python PHP Perl Java NodeJS Javascript

Introduction

Welcome to the EKM METERING API!

We at EKM see easy access to your data, and the scalable systems behind the EKM Push, as crucial to moving our products into the future. To that end, we do what is unheard of in our industry, we give you your data for FREE.

The EKM API is organized around Representational State Transfer, or REST. You can use our Application Programming Interface, or API, to access EKM API endpoints, which can get you information on various EKM Push meter/ioStack data and utilize it in your own application, database, billing system, or building automation system.

We have language bindings in Shell (cURL), Ruby, Python, PHP, Perl, Java, Javascript and Nodejs! You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right.

Our API is designed to have predictable, resource-oriented URLs and to use HTTP response codes to indicate API errors. We use built-in HTTP features, like HTTP authentication and HTTP verbs, which can be understood by off-the-shelf HTTP clients, and we support cross-origin resource sharing to allow you to interact securely with our API from a client-side web application (though you should remember that you should never expose your secret EKM Push API key in any public website’s client-side code). JSON will be returned in all responses from the API, including errors (though if you’re using API bindings, we will convert the response to the appropriate language-specific object).

Authentication

To authorize, make sure to use your personal EKM Push account key.

The examples in this API documentation use the demo key of MTAxMDoyMDIw. Please make sure you remove this key and place your personal key in the https address if you are trying to access the meters in your account.

With shell, you can just pass the correct address with each request
curl -s "URL Here"
Authorization: "EKM Push Key"
# Ruby Version: 3.1.2

# Load required modules
require 'net/http'
require 'json'
require 'uri'

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call

def call_api(api_path)
  uri = URI.parse("URL Here#{api_path}")
  response = Net::HTTP.get_response(uri)
  puts response.uri
  JSON.parse(response.body)
end

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
# URI only NOT URL - Do not include for example https://summary.ekmpush.com
api_object = call_api('URI Here')

# This just displays the object but you can use what ever
# code you would like to work with the object here
require 'pp'
pp api_object

'''
Python version: 3.9.12
'''

# Required Python Modules
import urllib.request
import urllib.error
import urllib.parse
import json
import pprint

# This function accesses the api_request URL and converts
# the contents to a usable Python object and returns it
def call_api ( api_request ):
    '''
    Make http request
    '''
    response = urllib.request.urlopen(api_request)
    response = response.read()
    json_object = json.loads(response.decode())
    return json_object

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
api_object = call_api("URL Here")

# This just displays the object but you can use what ever
# code you would like to work with the object here
pprint.pprint(api_object)

<?php
// PHP 8.0.17 (cli)

// Call the callApi function to create a usable
// object named $apiObject from the API request URL.
// Put the API request URL in the call
$apiObject=callApi('URL Here');

// This just displays the object but you can use what ever
// code you would like to work with the object here
var_dump($apiObject);

// This function accesses the apiRequest URL and converts
// the contents to a usable PHP object and returns it
function callApi ($apiRequest='') {

        $json=@file_get_contents($apiRequest);
        $jsonObject=json_decode($json);
        return ($jsonObject);

}
?>    
#!/usr/bin/perl
# Perl version: v5.34
# CPAN.pm version 2.2
# Perl Modules Version:
# JSON: 4.05
# LWP::Protocol::https: 6.10
# LWP::Simple: 6.62
#
# OS Prerequisites
# UBUNTU
# apt install cpanminus
#
# Install Perl Modules
#       cpan LWP::Simple
#       cpan LWP::Protocol::https
#       cpan JSON

# Required Perl Modules
use strict;
use warnings;
use LWP::Simple;
use JSON;
use Data::Dumper;

# This function accesses the api_request URL and converts
# the contents to a usable Perl object and returns it
sub call_api {
    my $api_request = shift;
    my $json_text   = get($api_request);
    my $json_object = JSON->new->utf8->decode($json_text);
    return $json_object;
}

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
my $api_object = call_api('URL Here');

# This just displays the object but you can use what ever
# code you would like to work with the object here
print Dumper($api_object);    ## no critic (InputOutput::RequireCheckedSyscalls)

/*
 openjdk version "17.0.2" 2022-01-18

 Download the correct org.json jar version for your
 needs from: https://mvnrepository.com/artifact/org.json/json

 This example uses version 20220320 accessible here:
 https://repo1.maven.org/maven2/org/json/json/20220320/json-20220320.jar

 Instructions to run this program

 1. Put this code in a file named EKM.java
 2. Copy the downloaded org.json jar and EKM.java to the same directory
 3. Compile
  javac -cp .:./json-20220320.jar ./EKM.java
 4. Run
  java -cp .:./json-20220320.jar EKM
*/

//Import required classes
import java.net.*;
import java.io.*;
import org.json.*;

@java.lang.SuppressWarnings({"java:S106", "java:S112", "java:S125"})

public class EKM {
    public static JSONObject callApi(String apiRequest) throws Exception {

        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object

        URL url = new URL(apiRequest);
        URLConnection connection = url.openConnection();
        BufferedReader in = new BufferedReader(
                                               new InputStreamReader(
                                                                     connection.getInputStream()));

        StringBuilder response = new StringBuilder();
        String inputLine;

        while ((inputLine = in.readLine()) != null)
            response.append(inputLine);

        in.close();

        return new JSONObject(response.toString());
    }

    public static void main(String[] args) throws Exception {
        /*
         Call callApi to create a usable
         object named apiObject from the API request URL.
         Put the API request URL in the call
         */
        JSONObject apiObject = EKM.callApi("URL Here");

        /*
         You can access any part of the apiObject using code like this:
         JSONArray  readData = apiObject.getJSONObject("readmeter").getJSONArray("ReadSet").
         getJSONObject(0).getJSONArray("ReadData");
        */

        // This just outputs the whole apiObject
        System.out.println(apiObject.toString(4));
    }
}
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">

// The example function is called from the 
// body tag when the page loads
function example(){

// Call the callApi function to create a usable
// object named apiObject from the API request URL.
// Put the API request URL in the call
callApi('URL Here',function(apiObject){

       // This just displays the object in the result div
       // you can use what ever code you would like to work 
       // with the object here
       document.getElementById("result").innerHTML = "<pre>"+JSON.stringify(apiObject, null, 4)+"</pre>";
       });

};

// This code accesses the apiRequest URL and converts
// the contents to a usable JSON object named apiObject
function callApi(apiRequest,callback) {
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
      if (xhttp.readyState == 4 && xhttp.status == 200) {
        var jsonObject = JSON.parse(xhttp.responseText);
        callback(jsonObject);
      }
    };
    xhttp.open("GET", apiRequest, true);
    xhttp.send();
}
</script>

</head>
  <body onload="example()">
    <div id="result"/>
  </body>
</html>
/*
* Requirements
* NodeJS: v16.14.2
* Axios:  0.27.2
*/

// Load modules
const axios = require('axios');

const apiClient = axios.create({
  baseURL: 'URL Here',
  timeout: 1000 * 15,
})

// This code accesses the apiRequest query and
// logs the response data or the error
;(async () => {
  try {
    const res = await apiClient.get('URI Here');
    const apiResData = res.data;

    console.log(JSON.stringify(apiResData, null, 2));
  } catch (error) {
    console.error(error.message);
  }
})();

Make sure to replace the sample key: MTAxMDoyMDIw, with your API key in the https address.

EKM uses API keys to allow access to the API. You authenticate to the EKM API by providing one of your unique API keys in each request. Each Push account holder is provided with an EKM Push User Key, which provides access to all meters in their account. This key carries lots of privileges so we encourage you to keep it secret. In addition to this master key, additional keys are also provided to give access to each meter/ioStack individually, and keys can be created to provide access to sub groups of meters/ioStacks upon request. These secondary keys can be used to share single meters/ioStacks, or a subset of meters/ioStacks, without sharing access to all meters/ioStacks in an account. For example, if you are a landlord with multiple rentals and meters/ioStacks, you could share specific meter/ioStack keys with each of your tenants, so that they could have access to only the data that pertains to their usage.

Authentication to the API occurs via HTTP Basic Auth. Provide your API key as the basic authorized username. You do not need to provide a password. You must authenticate for all requests.

The EKM Push API expects the API key to be included in all requests to the server. The key is included in the URL in the following way:

Authorization: key=MTAxMDoyMDIw

Realtime API

Click here to go to Realtime Documentation

If you are developing your own app, cloud-to-cloud solution, billing system, or other SAS solution, our Real-Time API allows you to easily access your EKM Push data in any format that you need. Below you will find descriptions regarding how to access the data, and about the filters you can apply so the data comes to you in a format that is easily digested and inserted into your software solution.

The real-time API provides the 1,000 latest meter readings for each of your meters/IOStack devices. If your device is being read once per minute, the data will be made available once per minute, per device. Whether you have one device or 10,000 devices, this is the easiest and most scalable way to access your data.

The EKM Dash, EKM Widget, encompass.io, wattvision.com, pvoutput.org, the other solutions in our Push App Store, as well as other customers that have their own custom solutions, all use this API to access their data. We use the same API as you and do not give ourselves any special permissions, we see what you see, which forces us to make the API as great as possible for everyone. We have even given you code examples that can be copy and pasted into your own software language to make the data access that much easier.

Use the API definition, metered values definition, code snippet suggestion, and guide to get you on your way to developing your next killer app. If you create something great, let us know; we’re open to adding all useful apps into the Push App Store.

We also have a Realtime API Request Builder Tool found here:

Realtime API Builder

Account API

Click here to go to Account API Documentation

This API provides information for accounts and devices owned by the account.

Get information for the specified target, which can be account, gateway, meter or ioStack.

You could make API request with the EKM Push Key that is your own Authorization Key that you received for your Push Account, or instead the EKM Push Key you could use Gateway Key for more restricted access. Be aware that if you use the Gateway Key, you will only receive information regards to that gateway.

Gateway Settings API

This API is used to send commands and settings to devices connected to a Push3 gateway as well as the gateway device itself.

The EKM Push Key is your own Authorization Key that you received for your Push Account. In the following examples of this API document, we will be using the following key MTAxMDoyMDIw in all of our HTTPS calls. You will need to change the example key MTAxMDoyMDIw with your own private key to access the meters you have associated with your account. Also, you could use the Gateway Key instead of the EKM Push Key for more restricted access.

In case of an error (response code 400), the response JSON will contain an error attribute with a string value describing the error.

The response from this endpoint does not tell you if the command was received by the gateway device or if it was successfully executed, only that the command was sent to the gateway device. The command message is sent to the gateway device via an HTTP push stream that the gateway polls for incoming commands. The gateway then responds by sending a JSON message via a separate response push stream.

The response from the sendCommand endpoint gives enough information to poll the push stream for a response message from the Push3 gateway device handling the command. The stream is accessible using a WebSocket or an HTTP stream connection.

The settings you can change are things like CT Ratio, Meter Time, Reset Max Demand, Set Demand Period, Change Meter Number (NOT recommended), Change Password (Super NOT recommended), Set Time of Use, etc.

All Gateway Settings API requests require an API bearer token to prove that the client is authorized to make the request.

API Token Required

The Gateway Settings API section requires an API token to authorize the request.

An API token can be created here: Create API Token

HTTPS Request

curl -i -X POST 'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw' -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk" --data-raw '{"command": "SetRelay", "params": {"duration": 1, "meter_password": "00000000", "relay": "Relay_1", "status": "close"}, "target": "meter", "target_id": "000350000900"}'
# Ruby Version: 3.1.2

# Load required modules
require 'net/http'
require 'json'
require 'uri'

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call

def call_api(api_path, data)
    req_header = {        
        'Content-Type' => 'application/json',
        'Accept' => 'application/json',
        'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk'
      }

    uri = URI.parse("https://api.ekmpush.com#{api_path}")

    # Create the HTTP objects
    https = Net::HTTP.new(uri.host, uri.port)
    https.use_ssl = true
    request = Net::HTTP::Post.new(uri.request_uri, req_header)
    request.body = data

    # Send the request
    response = https.request(request)
    JSON.parse(response.body)
rescue => e
    puts "failed #{e}"
end

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
# URI only NOT URL - Do not include https://api.ekmpush.com
req_data = '{
    "command": "SetRelay",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "relay": "Relay_1",
        "status": "close",
        "duration": 1,
        "meter_password": "00000000"
        }
    }'
api_object = call_api('/sendCommand?key=MTAxMDoyMDIw', req_data)

# This just displays the object but you can use what ever
# code you would like to work with the object here
require 'pp'
puts "Response JSON Object:"
pp api_object

'''
Python version: 3.9.12
'''

# Required Python Modules
import urllib.request
import urllib.error
import urllib.parse
import json
import pprint

# This function accesses the api_request URL and converts
# the contents to a usable Python object and returns it
def call_api ( api_request, data ):
    '''Make http request'''
    headers = {
        "Accept": "application/json",
        "Content-Type": "application/json",
        "Authorization": "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk"
    }
    req = urllib.request.Request(api_request, headers=headers)
    jsondata = json.dumps(data)
    json_bytes = jsondata.encode('utf-8')   # Needs to be bytes
    response = urllib.request.urlopen(req, json_bytes)
    response = response.read()
    json_object = json.loads(response.decode())
    return json_object

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call

# Request JSON Object
req_json = {
    "command": "SetRelay",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "relay": "Relay_1",
        "status": "close",
        "duration": 1,
        "meter_password": "00000000"
        }
    }

api_object = call_api("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw", req_json)

# This just displays the object but you can use what ever
# code you would like to work with the object here
print("Response JSON Object:")
pprint.pprint(api_object)

<?php
// PHP 8.0.17 (cli)

$postData = '{
    "command": "SetRelay",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "relay": "Relay_1",
        "status": "close",
        "duration": 1,
        "meter_password": "00000000"
        }
    }';

// Call the callApi function to create a usable
// object named $apiObject from the API request URL.
// Put the API request URL in the call
$apiObject=callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', $postData);

// This just displays the object but you can use what ever
// code you would like to work with the object here
var_dump($apiObject);

// This function accesses the apiRequest URL and converts
// the contents to a usable PHP object and returns it
function callApi($apiRequest='', $postData='')
{
    $opts = array('http' =>
        array(
            'method'  => 'POST',
            'header'  => "Content-Type: application/json\r\n".
            "Accept: application/json\r\n".
            "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk\r\n",
            'content' => $postData
        )
    );

    $context = stream_context_create($opts);
    $json = file_get_contents($apiRequest, false, $context);
    $jsonObject = json_decode($json, true);
    return ($jsonObject);
}

#!/usr/bin/perl
# Perl version: v5.34
# CPAN.pm version 2.2
# Perl Modules Version:
# JSON: 4.05
# LWP::Protocol::https: 6.10
# LWP::UserAgent: 6.43
#
# OS Prerequisites
# UBUNTU
# apt install cpanminus
#
# Install Perl Modules
#       cpan LWP::UserAgent
#       cpan LWP::Protocol::https
#       cpan JSON

# Required Perl Modules
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use Data::Dumper;

# This function accesses the api_request URL and converts
# the contents to a usable Perl object and returns it
sub call_api {
    my $req_json = {
        'command'   => 'SetRelay',
        'target'    => 'meter',
        'target_id' => '000350000900',
        'params'    => {
            'relay'          => 'Relay_1',
            'status'         => 'close',
            'duration'       => 1,
            'meter_password' => '00000000'
        }
    };
    my $api_request = shift;
    my $req         = HTTP::Request->new( 'POST', $api_request );
    $req->header( 'Content-Type' => 'application/json' );
    $req->header( 'Accept' => 'application/json' );
    $req->header( 'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk' );
    $req->content( encode_json $req_json );
    my $lwp         = LWP::UserAgent->new;
    my $res         = $lwp->request($req);
    my $content     = $res->decoded_content();
    my $json_object = JSON->new->utf8->decode($content);
    return $json_object;
}

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
my $api_object =
  call_api('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw');

# This just displays the object but you can use what ever
# code you would like to work with the object here
print
  "Response JSON Object:\n";  ## no critic (InputOutput::RequireCheckedSyscalls)
print Dumper($api_object);    ## no critic (InputOutput::RequireCheckedSyscalls)

/*
 openjdk version "17.0.2" 2022-01-18

 Download the correct org.json jar version for your
 needs from: https://mvnrepository.com/artifact/org.json/json

 This example uses version 20220320 accessible here:
 https://repo1.maven.org/maven2/org/json/json/20220320/json-20220320.jar

 Instructions to run this program

 1. Put this code in a file named EKM.java
 2. Copy the downloaded org.json jar and EKM.java to the same directory
 3. Compile
  javac -cp .:./json-20220320.jar ./EKM.java
 4. Run
  java -cp .:./json-20220320.jar EKM
*/

//Import required classes
import java.net.*;
import java.io.*;
import org.json.*;

@java.lang.SuppressWarnings({"java:S106", "java:S112", "java:S125"})

public class EKM {
    public static JSONObject callApi(String apiRequest) throws Exception {

        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object

        URL url = new URL(apiRequest);        
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty( "Content-type", "application/json");
        connection.setRequestProperty("Accept", "application/json");
        connection.setRequestProperty("Authorization", "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk");
        connection.setDoOutput(true);

        String reqData = "{\"command\": \"SetRelay\", \"target\": \"meter\", \"target_id\": \"000350000900\", \"params\": { \"relay\": \"Relay_1\", \"status\": \"close\", \"duration\": 1,\"meter_password\": \"00000000\"}}";
        try(OutputStream os = connection.getOutputStream()) {
            byte[] input = reqData.getBytes("utf-8");
            os.write(input, 0, input.length);           
        }

        try(BufferedReader br = new BufferedReader(
            new InputStreamReader(connection.getInputStream(), "utf-8"))) {
                StringBuilder response = new StringBuilder();
                String responseLine = null;
                while ((responseLine = br.readLine()) != null) {
                    response.append(responseLine.trim());
                }
                return new JSONObject(response.toString());
            }        
    }    

    public static void main(String[] args) throws Exception {
        /*
         Call callApiPost to create a usable
         object named apiObject from the API request URL.
         Put the API request URL in the call
         */
        JSONObject apiObject = EKM.callApi("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw");


        // This just displays the object but you can use what ever
        // code you would like to work with the object here
        System.out.println("Response JSON Object:");
        System.out.println(apiObject.toString(4));
        }
}

/*
* Requirements
* NodeJS: v16.14.2
* Axios:  0.27.2
*/

// Load modules
const axios = require('axios');

async function doRequest() {
    const params  = {
        "command": "SetRelay",
        "target": "meter",
        "target_id": "000350000900",
        "params": {
            "relay": "Relay_1",
            "status": "close",
            "duration": 1,
            "meter_password": "00000000"
            }
        }

    let res = await axios.post("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw", params,  {
        headers: {
          'Accept': 'application/json',
          // eslint-disable-next-line max-len
          'Authorization': 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk',
        }});

    let data = res.data;
    console.log("Response JSON Object: " + JSON.stringify(data, null, 2));    
}

doRequest();
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">

// The example function is called from the
// body tag when the page loads
function example(){

// Call the callApi function to create a usable
// object named apiObject from the API request URL.
// Put the API request URL in the call
callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', function(apiObject){

    // This just displays the object in the result div
    // you can use whatever code you would like to work
    // with the object here
    document.getElementById("result").innerHTML = "<pre>"+JSON.stringify(apiObject, null, 4)+"</pre>";    
    });

};

// This code accesses the apiRequest URL and converts
// the contents to a usable JSON object named apiObject
function callApi(apiRequest, callback) {
  const params  = {
        "command": "SetRelay",
        "target": "meter",
        "target_id": "000350000900",
        "params": {
            "relay": "Relay_1",
            "status": "close",
            "duration": 1,
            "meter_password": "00000000"
            }
      }
  var xhttp = new XMLHttpRequest();

  xhttp.onreadystatechange = function() {
    if (xhttp.readyState == 4 && xhttp.status == 200) {
      var jsonObject = JSON.parse(xhttp.responseText);
      callback(jsonObject);
    }
  };
  xhttp.open("POST", apiRequest, true);
  xhttp.setRequestHeader("Accept", "application/json");
  xhttp.setRequestHeader("Content-Type", "application/json");
  xhttp.setRequestHeader("Authorization", "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk");
  xhttp.send(JSON.stringify(params));
}
</script>

</head>
  <body onload="example()">
    <h1>Response JSON Object: </h1>
    <div id="result"> </div>
  </body>
</html>

The above example returns the following results:

{"response_channel_id": "response_NjUyNTqwNZI5dUU2N7F1MeFOmmxSElVadTm0", "response_channel_host": "appsrv.ekmmetering.com", "msg_id": "8fze16ce8d1b16ebb42e2c1d96d9f4c7"}
{"response_channel_id"=>"response_NjUyNTqwNZI5dUU2N7F1MeFOmmxSElVadTm0",
 "response_channel_host"=>"appsrv.ekmmetering.com",
 "msg_id"=>"8fze16ce8d1b16ebb42e2c1d96d9f4c7"}
{'msg_id': '8fze16ce8d1b16ebb42e2c1d96d9f4c7',
 'response_channel_host': 'appsrv.ekmmetering.com',
 'response_channel_id': 'response_NjUyNTqwNZI5dUU2N7F1MeFOmmxSElVadTm0'}
array(3) {
  ["response_channel_id"]=>
  string(45) "response_NjUyNTqwNZI5dUU2N7F1MeFOmmxSElVadTm0"
  ["response_channel_host"]=>
  string(22) "appsrv.ekmmetering.com"
  ["msg_id"]=>
  string(32) "8fze16ce8d1b16ebb42e2c1d96d9f4c7"
}
$VAR1 = {
          'response_channel_id' => 'response_NjUyNTqwNZI5dUU2N7F1MeFOmmxSElVadTm0',
          'response_channel_host' => 'appsrv.ekmmetering.com',
          'msg_id' => '8fze16ce8d1b16ebb42e2c1d96d9f4c7'
        };
{
    "response_channel_id": "response_NjUyNTqwNZI5dUU2N7F1MeFOmmxSElVadTm0",
    "msg_id": "8fze16ce8d1b16ebb42e2c1d96d9f4c7",
    "response_channel_host": "appsrv.ekmmetering.com"
}
{
  "response_channel_id": "response_NjUyNTqwNZI5dUU2N7F1MeFOmmxSElVadTm0",
  "response_channel_host": "appsrv.ekmmetering.com",
  "msg_id": "8fze16ce8d1b16ebb42e2c1d96d9f4c7"
}
{
    "response_channel_id": "response_NjUyNTqwNZI5dUU2N7F1MeFOmmxSElVadTm0",
    "response_channel_host": "appsrv.ekmmetering.com",
    "msg_id": "8fze16ce8d1b16ebb42e2c1d96d9f4c7"
}

All HTTPS POST requests will begin with the following information in the https address:

https://api.ekmpush.com/sendCommand?

The information that you provide, such as your EKM Push Key (i.e. MTAxMDoyMDIw) will follow the beginning https address. This can optionally be specified in the POST body JSON.

Example below of what a typical https address will look like:

https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw

HTTPS ADDRESS DESCRIPTION
https://api.ekmpush.com/sendCommand Beginning of the https address.
key (string) – EKM Push Key or the Push3 Gateway Key. This can optionally be specified in the POST body JSON.

For Close Relay 1 for one second on meter 000350000900, we will pass the Request JSON Object:

{ "command": "SetRelay", "target": "meter", "target_id": "000350000900", "params": { "relay": "Relay_1", "status": "close", "duration": 1, "meter_password": "00000000" } }

PARAMETER DESCRIPTION
command (string) – the name of the command (i.e. “SetRelay”).
target (string) – the target device type (i.e. “meter”).
target_id (string) – the target id (i.e. a meter address).
client (string) – optional API client name. This should be relatively unique.
response_channel_id (string) – optional response channel id.
params (jsonobj) – the command parameters as a JSON object.

Additionally, you have to add in the request headers:

HEADERS DESCRIPTION
Accept Sets output type to JSON (i.e. application/json).
Authorization API Bearer Token to prove that the client is authorized to make the request (i.e. Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk)

After send the POST request, we will receive a Response JSON Object like:

{ "msg_id": "8fze16ce8d1b16ebb42e2c1d96d9f4c7", "response_channel_id": "response_NjUyNTqwNZI5dUU2N7F1MeFOmmxSElVadTm0", "response_channel_host": "appsrv.ekmmetering.com" }

PARAMETER DESCRIPTION
msg_id (string) – the message id used to identify the response message.
response_channel_id (string) – websocket/stream channel id for response message.
response_channel_host (string) – host of websocket/stream.

Retrieving the Command Response

# Add to the response_channel_id the .b20:
curl --no-buffer -s -v "https://appsrv.ekmmetering.com/sub/response_NjUyNTqwNZI5dUU2N7F1MeFOmmxSElVadTm0.b20"
# Ruby Version: 3.1.2

# Load required modules
require 'net/http'
require 'json'
require 'uri'

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call

def call_api(api_path)
    uri = URI.parse("https://appsrv.ekmmetering.com#{api_path}")

    # Create the HTTP objects
    https = Net::HTTP.new(uri.host, uri.port)
    https.use_ssl = true
    puts "\nRetrieving the Command Response, it will take some time ..."
    https.request_get(uri.path) do |resp|
        resp.read_body do |segment|
            puts segment
        end         
    end
rescue => e
    puts "failed #{e}"
end

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
# URI only NOT URL - Do not include https://api.ekmpush.com
api_object = call_api('/sub/response_NjUyNTqwNZI5dUU2N7F1MeFOmmxSElVadTm0')

'''
Python version: 3.9.12
'''

# Required Python Modules
import urllib.request
import urllib.error
import urllib.parse

import json
import pprint

# This function accesses the api_request URL and converts
# the contents to a usable Python object and returns it
def call_api ( api_request ):
    '''
        Get the server stream
    '''
    print("Retrieving the Command Response, it will take some time ...")
    response = urllib.request.urlopen(api_request)
    for line in response:
        print(line.decode('utf-8').rstrip())

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call

call_api("https://appsrv.ekmmetering.com"\
    "/sub/response_NjUyNTqwNZI5dUU2N7F1MeFOmmxSElVadTm0")

<?php
// PHP 8.0.17 (cli)

// Call the callApi function to create a usable
// object named $apiObject from the API request URL.
// Put the API request URL in the call
callApi('https://appsrv.ekmmetering.com/sub/response_NjUyNTqwNZI5dUU2N7F1MeFOmmxSElVadTm0');

// This function accesses the apiRequest URL and converts
// the contents to a usable PHP object and returns it
function callApi ($apiRequest='') {
    print "Retrieving the Command Response, it will take some time ...\n";
    echo file_get_contents($apiRequest);
}
?>
#!/usr/bin/perl
# Perl version: v5.34
# CPAN.pm version 2.2
# Perl Modules Version:
# JSON: 4.05
# LWP::Protocol::https: 6.10
# LWP::UserAgent: 6.43
#
# OS Prerequisites
# UBUNTU
# apt install cpanminus
#
# Install Perl Modules
#       cpan LWP::UserAgent
#       cpan LWP::Protocol::https
#       cpan JSON

# Required Perl Modules
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use Data::Dumper;

# This function accesses the api_request URL and converts
# the contents to a usable Perl object and returns it
sub call_api {
    my $api_request = shift;
    print "\nRetrieving the Command Response. "
      ;    ## no critic (InputOutput::RequireCheckedSyscalls)
    print "It will take some time ... \n"
      ;               ## no critic (InputOutput::RequireCheckedSyscalls)
                      # Making a new request with the channel_id
    my $ua       = LWP::UserAgent->new;
    my $req      = HTTP::Request->new();
    my $response = $ua->get($api_request);
    my $result   = $response->decoded_content();
    print $result;    ## no critic (InputOutput::RequireCheckedSyscalls)
}

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
my $api_object =
  call_api(
'https://appsrv.ekmmetering.com/sub/response_NjUyNTqwNZI5dUU2N7F1MeFOmmxSElVadTm0'
  );

/*
 openjdk version "17.0.2" 2022-01-18

 Download the correct org.json jar version for your
 needs from: https://mvnrepository.com/artifact/org.json/json

 This example uses version 20220320 accessible here:
 https://repo1.maven.org/maven2/org/json/json/20220320/json-20220320.jar

 Instructions to run this program

 1. Put this code in a file named EKM.java
 2. Copy the downloaded org.json jar and EKM.java to the same directory
 3. Compile
  javac -cp .:./json-20220320.jar ./EKM.java
 4. Run
  java -cp .:./json-20220320.jar EKM
*/

//Import required classes
import java.net.*;
import java.io.*;
import org.json.*;

@java.lang.SuppressWarnings({"java:S106", "java:S112", "java:S125"})

public class EKM {    
    public static JSONObject callApi(String apiRequest) throws Exception {
        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object
        URL url = new URL(apiRequest);
        System.out.println("Retrieving the Command Response. It will take some time ...");
        URLConnection yc = url.openConnection();
        BufferedReader in = new BufferedReader(new InputStreamReader(
                                    yc.getInputStream()));
        String inputLine;
        while ((inputLine = in.readLine()) != null) 
            System.out.println(inputLine);
        in.close();        
        return new JSONObject(inputLine.toString());
    }

    public static void main(String[] args) throws Exception {
        /*
         Call callApiPost to create a usable
         object named apiObject from the API request URL.
         Put the API request URL in the call
         */
        EKM.callApi("https://appsrv.ekmmetering.com/sub/response_NjUyNTqwNZI5dUU2N7F1MeFOmmxSElVadTm0");
        }
}

/*
* Requirements
* NodeJS: v16.14.2
* Axios:  0.27.2
* ws 8.8.1
*/

// Load modules
const axios = require('axios');

async function doRequest() {
    console.log("Retrieving the Command Response. It will take some time ...");
    let response = await axios.get("https://appsrv.ekmmetering.com/sub/response_NjUyNTqwNZI5dUU2N7F1MeFOmmxSElVadTm0", {
        responseType: 'stream'
    });
    const stream = response.data;
    stream.on('data', data => {
        console.log(data.toString());        
    });
    stream.on('end', () => {
        console.log("Stream done");
    });    
}

doRequest();
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">

// The example function is called from the
// body tag when the page loads
function example(){

  // Call the callApi function to create a usable
  // object named apiObject from the API request URL.
  // Put the API request URL in the call
  callApi('https://appsrv.ekmmetering.com/sub/response_NjUyNTqwNZI5dUU2N7F1MeFOmmxSElVadTm0', function(apiObject){

    // This just displays the object in the result div
    // you can use what ever code you would like to work
    // with the object here
    document.getElementById("result").innerHTML = "<pre>"+JSON.stringify(apiObject, null, 4)+"</pre>";
  });
};

// This code accesses the apiRequest URL and converts
// the contents to a usable JSON object named apiObject
function callApi(apiRequest, callback) {
  var xhttp = new XMLHttpRequest();

  xhttp.onreadystatechange = function() {
    if(xhttp.readyState > 2) {
      // process newData
      var jsonObject = JSON.parse(xhttp.responseText);
      callback(jsonObject);
    }    
  };
  xhttp.open("GET", apiRequest, true);
  xhttp.send();
}
</script>

</head>
  <body onload="example()">
    <h1>Retrieving the Command Response</h1>
    <h2>Run your request command and wait here for the response:</h2>
    <div id="result"> </div>
  </body>
</html>

Since commands can be sent to the same Push3 gateway device by more than one client asynchronously the order of response messages (or the time it takes to respond) is not guaranteed. It is necessary to poll an HTTP stream or websocket for messages and wait for the message that matches the message id returned by the sendCommand API.

Either an HTTP stream connection or a websocket can be used.

The response message stream URL is constructed as follows:

https://(response_channel_host)/sub/(response_channel_id)

The websocket address:

wss://(response_channel_host)/ws/(response_channel_id)

For our example, we will take the data in the response:

{ "msg_id": "8fze16ce8d1b16ebb42e2c1d96d9f4c7", "response_channel_id": "response_NjUyNTqwNZI5dUU2N7F1MeFOmmxSElVadTm0", "response_channel_host": "appsrv.ekmmetering.com" }

And make a new HTTP stream or a websocket connection:

https://appsrv.ekmmetering.com/sub/response_NjUyNTqwNZI5dUU2N7F1MeFOmmxSElVadTm0

{ "msg_id": "8fze16ce8d1b16ebb42e2c1d96d9f4c7", "timestamp": 1611374002.628128, "success": true, "error": null, "data": null }

Response JSON Object msg_id (string) – the message id used to identify the response message
timestamp (float) – epoch timestamp of when the gateway received the command
success (boolean) – true if the command succeeded, otherwise false
error (string) – an error message if the command failed, otherwise null
data (jsonobj) – a JSON object if the command has a return value, otherwise null

Set Meter Password

curl -i -X POST 'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw' -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk" --data-raw '{"command": "SetMeterPassword", "target": "meter", "target_id": "000350000900", "params": {"new_password": "01234567"}}'
# Ruby Version: 3.1.2

# Load required modules
require 'net/http'
require 'json'
require 'uri'

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call

def call_api(api_path, data)
  req_header = {        
    'Content-Type' => 'application/json',
    'Accept' => 'application/json',
    'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk'
  }
  uri = URI.parse("https://api.ekmpush.com#{api_path}")

  # Create the HTTP objects
  https = Net::HTTP.new(uri.host, uri.port)
  https.use_ssl = true
  request = Net::HTTP::Post.new(uri.request_uri, req_header)
  request.body = data

  # Send the request
  response = https.request(request)
  JSON.parse(response.body)
end

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
# URI only NOT URL - Do not include https://api.ekmpush.com
req_data = '{
  "target": "meter",
  "target_id": "000350000900",
  "command": "SetMeterPassword",
  "params": {
    "new_password": "01234567"
  }
}'

api_object = call_api('/sendCommand?key=MTAxMDoyMDIw', req_data)

# This just displays the object but you can use what ever
# code you would like to work with the object here
require 'pp'
pp api_object

'''
Python version: 3.9.12
'''

# Required Python Modules
import urllib.request
import urllib.error
import urllib.parse
import json
import pprint

# This function accesses the api_request URL and converts
# the contents to a usable Python object and returns it
def call_api ( api_request, data ):
    '''Make http request'''
    headers = {
        "Accept": "application/json",
        "Content-Type": "application/json",
        "Authorization": "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk"
    }
    req = urllib.request.Request(api_request, headers=headers)
    jsondata = json.dumps(data)
    json_bytes = jsondata.encode('utf-8')   # Needs to be bytes
    response = urllib.request.urlopen(req, json_bytes)
    response = response.read()
    json_object = json.loads(response.decode())
    return json_object

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call

# Request JSON Object
req_json = {
    "target": "meter",
    "target_id": "000350000900",
    "command": "SetMeterPassword",
    "params": {
        "new_password": "01234567"
    }
}

api_object = call_api("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw", req_json)

# This just displays the object but you can use what ever
# code you would like to work with the object here
pprint.pprint(api_object)

<?php
// PHP 8.0.17 (cli)

$postData = '{
    "target": "meter",
    "target_id": "000350000900",
    "command": "SetMeterPassword",
    "params": {
        "new_password": "01234567"
    }
  }';

// Call the callApi function to create a usable
// object named $apiObject from the API request URL.
// Put the API request URL in the call
$apiObject=callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', $postData);

// This just displays the object but you can use what ever
// code you would like to work with the object here
var_dump($apiObject);

// This function accesses the apiRequest URL and converts
// the contents to a usable PHP object and returns it
function callApi ($apiRequest='', $postData='') {
    $opts = array('http' =>
        array(
            'method'  => 'POST',
            'header'  => "Content-Type: application/json\r\n".
            "Accept: application/json\r\n".
            "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk\r\n",
            'content' => $postData
        )
    );
    $context = stream_context_create($opts);
    $json = file_get_contents($apiRequest, false, $context);
    $jsonObject = json_decode($json, true);
    return ($jsonObject);
}

#!/usr/bin/perl
# Perl version: v5.34
# CPAN.pm version 2.2
# Perl Modules Version:
# JSON: 4.05
# LWP::Protocol::https: 6.10
# LWP::UserAgent: 6.43
#
# OS Prerequisites
# UBUNTU
# apt install cpanminus
#
# Install Perl Modules
#       cpan LWP::UserAgent
#       cpan LWP::Protocol::https
#       cpan JSON

# Required Perl Modules
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use Data::Dumper;

# This function accesses the api_request URL and converts
# the contents to a usable Perl object and returns it
sub call_api {
    my $req_json = {
        'target'    => 'meter',
        'target_id' => '000350000900',
        'command'   => 'SetMeterPassword',
        'params'    => {
            'new_password' => '01234567'
        }
    };
    my $api_request = shift;
    my $req         = HTTP::Request->new( 'POST', $api_request );
    $req->header( 'Accept' => 'application/json' );
    $req->header( 'Content-Type' => 'application/json' );
    $req->header( 'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk' );
    $req->content( encode_json $req_json );
    my $lwp         = LWP::UserAgent->new;
    my $res         = $lwp->request($req);
    my $content     = $res->decoded_content();
    my $json_object = JSON->new->utf8->decode($content);
    return $json_object;
}

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
my $api_object =
  call_api('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw');

# This just displays the object but you can use what ever
# code you would like to work with the object here
print Dumper($api_object);    ## no critic (InputOutput::RequireCheckedSyscalls)


/*
 openjdk version "17.0.2" 2022-01-18

 Download the correct org.json jar version for your
 needs from: https://mvnrepository.com/artifact/org.json/json

 This example uses version 20220320 accessible here:
 https://repo1.maven.org/maven2/org/json/json/20220320/json-20220320.jar

 Instructions to run this program

 1. Put this code in a file named EKM.java
 2. Copy the downloaded org.json jar and EKM.java to the same directory
 3. Compile
  javac -cp .:./json-20220320.jar ./EKM.java
 4. Run
  java -cp .:./json-20220320.jar EKM
*/

//Import required classes
import java.net.*;
import java.io.*;
import org.json.*;

@java.lang.SuppressWarnings({"java:S106", "java:S112", "java:S125"})

public class EKM {
    public static JSONObject callApiPost(String apiRequest) throws Exception {

        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object

        URL url = new URL(apiRequest);        
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty( "Accept", "application/json");
        connection.setRequestProperty( "Content-type", "application/json");
        connection.setRequestProperty( "Authorization", "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk");
        connection.setDoOutput(true);

        String reqData = "{\"target\": \"meter\", \"target_id\": \"000350000900\", \"command\": \"SetMeterPassword\", \"params\": { \"new_password\": \"01234567\"}}";
        try(OutputStream os = connection.getOutputStream()) {
            byte[] input = reqData.getBytes("utf-8");
            os.write(input, 0, input.length);
        }

        try(BufferedReader br = new BufferedReader(
            new InputStreamReader(connection.getInputStream(), "utf-8"))) {
                StringBuilder response = new StringBuilder();
                String responseLine = null;
                while ((responseLine = br.readLine()) != null) {
                    response.append(responseLine.trim());
                }
                return new JSONObject(response.toString());
            }        
    }
    public static JSONObject callApi(String apiRequest) throws Exception {
        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object
        URL url = new URL(apiRequest);
        URLConnection yc = url.openConnection();
        BufferedReader in = new BufferedReader(new InputStreamReader(
                                    yc.getInputStream()));
        String inputLine;
        while ((inputLine = in.readLine()) != null) 
            System.out.println(inputLine);
        in.close();
        return new JSONObject(inputLine.toString());
    }

    public static void main(String[] args) throws Exception {
        /*
         Call callApiPost to create a usable
         object named apiObject from the API request URL.
         Put the API request URL in the call
         */
        JSONObject apiObject = EKM.callApiPost("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw");


        // This just displays the object but you can use what ever
        // code you would like to work with the object here
        System.out.println(apiObject.toString(4));
        }
}

/*
* Requirements
* NodeJS: v16.14.2
* Axios:  0.27.2
*/

// Load modules
const axios = require('axios');

// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
  try {
    const params  = {
        "target": "meter",
        "target_id": "000350000900",
        "command": "SetMeterPassword",
        "params": {
            "new_password": "01234567"
        }
    }

    const res = await axios.post(
        'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', params, {
          headers: {
            'Accept': 'application/json',
            // eslint-disable-next-line max-len
            'Authorization': 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk',
          }});
    const apiResData = res.data;    
    console.log(JSON.stringify(apiResData, null, 2));
  } catch (error) {
    console.error(error.message);
  }
})();

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">

// The example function is called from the
// body tag when the page loads
function example(){

// Call the callApi function to create a usable
// object named apiObject from the API request URL.
// Put the API request URL in the call
callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw',function(apiObject){

      // This just displays the object in the result div
      // you can use what ever code you would like to work
      // with the object here
      document.getElementById("result").innerHTML = "<pre>"+JSON.stringify(apiObject, null, 4)+"</pre>";
      });

};

// This code accesses the apiRequest URL and converts
// the contents to a usable JSON object named apiObject
function callApi(apiRequest,callback) {
    var xhttp = new XMLHttpRequest();
    const params  = {
          "target": "meter",
          "target_id": "000350000900",
          "command": "SetMeterPassword",
          "params": {
                "new_password": "01234567"
          }
    }

    xhttp.onreadystatechange = function() {
      if (xhttp.readyState == 4 && xhttp.status == 200) {
        var jsonObject = JSON.parse(xhttp.responseText);
        callback(jsonObject);
      }
    };
    xhttp.open("POST", apiRequest, true);
    xhttp.setRequestHeader("Accept", "application/json");
    xhttp.setRequestHeader("Content-Type", "application/json");
    xhttp.setRequestHeader("Authorization", "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk");
    xhttp.send(JSON.stringify(params));
}
</script>

</head>
  <body onload="example()">
    <div id="result"> </div>
  </body>
</html>

We do not recommend changing the default password. Do not use this function unless the risk of serial line hacking exceeds the risk of pwd loss. There is no recovery backdoor for your meter.

By default, the meter device password is ‘00000000’. If you would like to change it you have to set the command to SetMeterPassword and in the params add the parameter new_password with the numeric value.

In the example below the password being used is: ’01234567

{ "target": "meter", "target_id": "000350000900", "command": "SetMeterPassword" , "params": { "new_password": "01234567" } }


JSON PARAMETERS

PARAMETER Description
new_password (int) - the new meter password, must be numeric.

If you changed the meter password and you want to put the original password back:

{ "target": "meter", "target_id": "000350000900", "command": "SetMeterPassword" , "params": { "password": "01234567", "new_password": "00000000" } }

Set CT Ratio

curl -i -X POST 'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw' -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk" --data-raw '{"command": "CTRatioSet", "target": "meter", "target_id": "000350000900", "params": { "CT_Ratio": 200, "meter_password": "00000000"}}'
# Ruby Version: 3.1.2

# Load required modules
require 'net/http'
require 'json'
require 'uri'

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call

def call_api(api_path, data)
  req_header = {        
    'Content-Type' => 'application/json',
    'Accept' => 'application/json',
    'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk'
  }
  uri = URI.parse("https://api.ekmpush.com#{api_path}")

  # Create the HTTP objects
  https = Net::HTTP.new(uri.host, uri.port)
  https.use_ssl = true
  request = Net::HTTP::Post.new(uri.request_uri, req_header)
  request.body = data

  # Send the request
  response = https.request(request)
  JSON.parse(response.body)
end

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
# URI only NOT URL - Do not include https://api.ekmpush.com
req_data = '{
  "command": "CTRatioSet",
  "target": "meter",
  "target_id": "000350000900",
  "params": {
    "CT_Ratio": 200,
    "meter_password": "00000000"
  }
}'

api_object = call_api('/sendCommand?key=MTAxMDoyMDIw', req_data)

# This just displays the object but you can use what ever
# code you would like to work with the object here
require 'pp'
pp api_object

'''
Python version: 3.9.12
'''

# Required Python Modules
import urllib.request
import urllib.error
import urllib.parse
import json
import pprint

# This function accesses the api_request URL and converts
# the contents to a usable Python object and returns it
def call_api ( api_request, data ):
    '''Make http request'''
    headers = {
        "Accept": "application/json",
        "Content-Type": "application/json",
        "Authorization": "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk"
    }
    req = urllib.request.Request(api_request, headers=headers)
    jsondata = json.dumps(data)
    json_bytes = jsondata.encode('utf-8')   # Needs to be bytes
    response = urllib.request.urlopen(req, json_bytes)
    response = response.read()
    json_object = json.loads(response.decode())
    return json_object

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call

# Request JSON Object
req_json = {
    "command": "CTRatioSet",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "CT_Ratio": 200,
        "meter_password": "00000000"
    }
}

api_object = call_api("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw", req_json)

# This just displays the object but you can use what ever
# code you would like to work with the object here
pprint.pprint(api_object)

<?php
// PHP 8.0.17 (cli)

$postData = '{
    "command": "CTRatioSet",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "CT_Ratio": 200,
        "meter_password": "00000000"
    }
}';

// Call the callApi function to create a usable
// object named $apiObject from the API request URL.
// Put the API request URL in the call
$apiObject=callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', $postData);

// This just displays the object but you can use what ever
// code you would like to work with the object here
var_dump($apiObject);

// This function accesses the apiRequest URL and converts
// the contents to a usable PHP object and returns it
function callApi($apiRequest='', $postData='')
{
    $opts = array('http' =>
        array(
            'method'  => 'POST',
            'header'  => "Content-Type: application/json\r\n".
            "Accept: application/json\r\n".
            "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk\r\n",
            'content' => $postData
        )
    );
    $context = stream_context_create($opts);
    $json = file_get_contents($apiRequest, false, $context);
    $jsonObject = json_decode($json, true);
    return ($jsonObject);
}

#!/usr/bin/perl
# Perl version: v5.34
# CPAN.pm version 2.2
# Perl Modules Version:
# JSON: 4.05
# LWP::Protocol::https: 6.10
# LWP::UserAgent: 6.43
#
# OS Prerequisites
# UBUNTU
# apt install cpanminus
#
# Install Perl Modules
#       cpan LWP::UserAgent
#       cpan LWP::Protocol::https
#       cpan JSON

# Required Perl Modules
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use Data::Dumper;

# This function accesses the api_request URL and converts
# the contents to a usable Perl object and returns it
sub call_api {
    my $req_json = {
        'target'    => 'meter',
        'target_id' => '000350000900',
        'command'   => 'CTRatioSet',
        'params'    => {
            'CT_Ratio' => 200,
            'meter_password' => '00000000'
        }
    };
    my $api_request = shift;
    my $req         = HTTP::Request->new( 'POST', $api_request );
    $req->header( 'Accept' => 'application/json' );
    $req->header( 'Content-Type' => 'application/json' );
    $req->header( 'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk' );
    $req->content( encode_json $req_json );
    my $lwp         = LWP::UserAgent->new;
    my $res         = $lwp->request($req);
    my $content     = $res->decoded_content();
    my $json_object = JSON->new->utf8->decode($content);
    return $json_object;
}

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
my $api_object =
  call_api('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw');

# This just displays the object but you can use what ever
# code you would like to work with the object here
print Dumper($api_object);    ## no critic (InputOutput::RequireCheckedSyscalls)

/*
 openjdk version "17.0.2" 2022-01-18

 Download the correct org.json jar version for your
 needs from: https://mvnrepository.com/artifact/org.json/json

 This example uses version 20220320 accessible here:
 https://repo1.maven.org/maven2/org/json/json/20220320/json-20220320.jar

 Instructions to run this program

 1. Put this code in a file named EKM.java
 2. Copy the downloaded org.json jar and EKM.java to the same directory
 3. Compile
  javac -cp .:./json-20220320.jar ./EKM.java
 4. Run
  java -cp .:./json-20220320.jar EKM
*/

//Import required classes
import java.net.*;
import java.io.*;
import org.json.*;

@java.lang.SuppressWarnings({"java:S106", "java:S112", "java:S125"})

public class EKM {
    public static JSONObject callApiPost(String apiRequest) throws Exception {

        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object

        URL url = new URL(apiRequest);        
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty( "Content-type", "application/json");
        connection.setRequestProperty("Accept", "application/json");
        connection.setRequestProperty("Authorization", "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk");
        connection.setDoOutput(true);

        String reqData = "{\"target\": \"meter\", \"target_id\": \"000350000900\", \"command\": \"CTRatioSet\", \"params\": { \"CT_Ratio\": 200, \"meter_password\": \"00000000\"}}";
        try(OutputStream os = connection.getOutputStream()) {
            byte[] input = reqData.getBytes("utf-8");
            os.write(input, 0, input.length);           
        }

        try(BufferedReader br = new BufferedReader(
            new InputStreamReader(connection.getInputStream(), "utf-8"))) {
                StringBuilder response = new StringBuilder();
                String responseLine = null;
                while ((responseLine = br.readLine()) != null) {
                    response.append(responseLine.trim());
                }
                return new JSONObject(response.toString());
            }        
    }
    public static JSONObject callApi(String apiRequest) throws Exception {
        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object
        URL url = new URL(apiRequest);
        URLConnection yc = url.openConnection();
        BufferedReader in = new BufferedReader(new InputStreamReader(
                                    yc.getInputStream()));
        String inputLine;
        while ((inputLine = in.readLine()) != null) 
            System.out.println(inputLine);
        in.close();
        return new JSONObject(inputLine.toString());
    }

    public static void main(String[] args) throws Exception {
        /*
         Call callApiPost to create a usable
         object named apiObject from the API request URL.
         Put the API request URL in the call
         */
        JSONObject apiObject = EKM.callApiPost("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw");


        // This just displays the object but you can use what ever
        // code you would like to work with the object here
        System.out.println(apiObject.toString(4));
        }
}
/*
* Requirements
* NodeJS: v16.14.2
* Axios:  0.27.2
*/

// Load modules
const axios = require('axios');

// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
  try {
    const params  = {
        "target": "meter",
        "target_id": "000350000900",
        "command": "CTRatioSet",
        "params": {
          "CT_Ratio": 200,
          "meter_password": "00000000"
        }
    }

    const res = await axios.post(
        'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', params, {
          headers: {
            'Accept': 'application/json',
            // eslint-disable-next-line max-len
            'Authorization': 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk',
          }});
    const apiResData = res.data;    
    console.log(JSON.stringify(apiResData, null, 2));
  } catch (error) {
    console.error(error.message);
  }
})();

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">

// The example function is called from the
// body tag when the page loads
function example(){

// Call the callApi function to create a usable
// object named apiObject from the API request URL.
// Put the API request URL in the call
callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw',function(apiObject){

      // This just displays the object in the result div
      // you can use what ever code you would like to work
      // with the object here
      document.getElementById("result").innerHTML = "<pre>"+JSON.stringify(apiObject, null, 4)+"</pre>";
      });

};

// This code accesses the apiRequest URL and converts
// the contents to a usable JSON object named apiObject
function callApi(apiRequest,callback) {
    var xhttp = new XMLHttpRequest();
    const params  = {
      "command": "CTRatioSet",
      "target": "meter",
      "target_id": "000350000900",
      "params": {
        "CT_Ratio": 200,
        "meter_password": "00000000"    
      }
    }

    xhttp.onreadystatechange = function() {
      if (xhttp.readyState == 4 && xhttp.status == 200) {
        var jsonObject = JSON.parse(xhttp.responseText);
        callback(jsonObject);
      }
    };
    xhttp.open("POST", apiRequest, true);
    xhttp.setRequestHeader("Accept", "application/json");
    xhttp.setRequestHeader("Content-Type", "application/json");
    xhttp.setRequestHeader("Authorization", "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk");
    xhttp.send(JSON.stringify(params));
}
</script>

</head>
  <body onload="example()">
    <div id="result"> </div>
  </body>
</html>

Adjust if you are connecting different amperage rated current transformers (CTs) to the meter.

JSON Object to change CT Ratio should look like:

{ "target": "meter", "target_id": "000350000900", "command": "CTRatioSet" , "params": { "ct_ratio": 200, "meter_password": "00000000" } }

In the example above the ct_ratio is 200, which means 200A: 26.6 mA.

JSON PARAMETERS

PARAMETER DESCRIPTION
ct_ratio (int) - the new CT ratio value.

Possible values:

VALUE DESCRIPTION
100 100A: 26.6 mA
200 200A: 26.6 mA
400 400A: 26.6 mA
600 600A: 26.6 mA
800 800A: 26.6 mA
1500 1500A: 26.6 mA
3000 3000A: 26.6 mA
5000 5000A: 26.6 mA

Set Date and Time

curl -i -X POST 'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw' -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk" --data-raw '{"command": "setTime", "target": "meter", "target_id": "000350000900", "params": {"Year": 2022, "Month": 8, "Day": 2, "Hour": 13, "Minutes": 38, "Seconds": 1, "meter_password": "00000000"}}'
# Ruby Version: 3.1.2

# Load required modules
require 'net/http'
require 'json'
require 'uri'

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call

def call_api(api_path, data)
  req_header = {        
    'Content-Type' => 'application/json',
    'Accept' => 'application/json',
    'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk'
  }
  uri = URI.parse("https://api.ekmpush.com#{api_path}")

  # Create the HTTP objects
  https = Net::HTTP.new(uri.host, uri.port)
  https.use_ssl = true
  request = Net::HTTP::Post.new(uri.request_uri, req_header)
  request.body = data

  # Send the request
  response = https.request(request)
  JSON.parse(response.body)
end

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
# URI only NOT URL - Do not include https://api.ekmpush.com
req_data = '{
  "command": "setTime",
  "target": "meter",
  "target_id": "000350000900",
  "params": {
    "Year": 2022,
    "Month": 8,
    "Day": 2,
    "Hour": 13,
    "Minutes": 38,
    "Seconds": 1,
    "meter_password": "00000000"
  }
}'

api_object = call_api('/sendCommand?key=MTAxMDoyMDIw', req_data)

# This just displays the object but you can use what ever
# code you would like to work with the object here
require 'pp'
pp api_object

'''
Python version: 3.9.12
'''

# Required Python Modules
import urllib.request
import urllib.error
import urllib.parse
import json
import pprint

# This function accesses the api_request URL and converts
# the contents to a usable Python object and returns it
def call_api ( api_request, data ):
    '''Make http request'''
    headers = {
        "Accept": "application/json",
        "Content-Type": "application/json",
        "Authorization": "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk"
    }
    req = urllib.request.Request(api_request, headers=headers)
    jsondata = json.dumps(data)
    json_bytes = jsondata.encode('utf-8')   # Needs to be bytes
    response = urllib.request.urlopen(req, json_bytes)
    response = response.read()
    json_object = json.loads(response.decode())
    return json_object

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call

# Request JSON Object
req_json = {
    "command": "setTime",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "Year": 2022,
        "Month": 8,
        "Day": 2,
        "Hour": 13,
        "Minutes": 38,
        "Seconds": 1,
        "meter_password": "00000000"
    }
}

api_object = call_api("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw", req_json)

# This just displays the object but you can use what ever
# code you would like to work with the object here
pprint.pprint(api_object)

<?php
// PHP 8.0.17 (cli)

$postData = '{
    "command": "setTime",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "Year": 2022,
        "Month": 8,
        "Day": 2,
        "Hour": 13,
        "Minutes": 38,
        "Seconds": 1,
        "meter_password": "00000000"
    }
}';

// Call the callApi function to create a usable
// object named $apiObject from the API request URL.
// Put the API request URL in the call
$apiObject=callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', $postData);

// This just displays the object but you can use what ever
// code you would like to work with the object here
var_dump($apiObject);

// This function accesses the apiRequest URL and converts
// the contents to a usable PHP object and returns it
function callApi($apiRequest='', $postData='')
{
    $opts = array('http' =>
        array(
            'method'  => 'POST',
            'header'  => "Content-Type: application/json\r\n".
            "Accept: application/json\r\n".
            "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk\r\n",
            'content' => $postData
        )
    );
    $context = stream_context_create($opts);
    $json = file_get_contents($apiRequest, false, $context);
    $jsonObject = json_decode($json, true);
    return ($jsonObject);
}

#!/usr/bin/perl
# Perl version: v5.34
# CPAN.pm version 2.2
# Perl Modules Version:
# JSON: 4.05
# LWP::Protocol::https: 6.10
# LWP::UserAgent: 6.43
#
# OS Prerequisites
# UBUNTU
# apt install cpanminus
#
# Install Perl Modules
#       cpan LWP::UserAgent
#       cpan LWP::Protocol::https
#       cpan JSON

# Required Perl Modules
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use Data::Dumper;

# This function accesses the api_request URL and converts
# the contents to a usable Perl object and returns it
sub call_api {
    my $req_json = {
        'target'    => 'meter',
        'target_id' => '000350000900',
        'command'   => 'setTime',
        'params'    => {
            'Year'    => 2022,
            'Month'   => 8,
            'Day'     => 2,
            'Hour'    => 13,
            'Minutes' => 38,
            'Seconds' => 1,
            'meter_password' => '00000000'
        }
    };
    my $api_request = shift;
    my $req         = HTTP::Request->new( 'POST', $api_request );
    $req->header( 'Accept' => 'application/json' );
    $req->header( 'Content-Type' => 'application/json' );
    $req->header( 'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk' );
    $req->content( encode_json $req_json );
    my $lwp         = LWP::UserAgent->new;
    my $res         = $lwp->request($req);
    my $content     = $res->decoded_content();
    my $json_object = JSON->new->utf8->decode($content);
    return $json_object;
}

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
my $api_object =
  call_api('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw');

# This just displays the object but you can use what ever
# code you would like to work with the object here
print Dumper($api_object);    ## no critic (InputOutput::RequireCheckedSyscalls)

/*
 openjdk version "17.0.2" 2022-01-18

 Download the correct org.json jar version for your
 needs from: https://mvnrepository.com/artifact/org.json/json

 This example uses version 20220320 accessible here:
 https://repo1.maven.org/maven2/org/json/json/20220320/json-20220320.jar

 Instructions to run this program

 1. Put this code in a file named EKM.java
 2. Copy the downloaded org.json jar and EKM.java to the same directory
 3. Compile
  javac -cp .:./json-20220320.jar ./EKM.java
 4. Run
  java -cp .:./json-20220320.jar EKM
*/

//Import required classes
import java.net.*;
import java.io.*;
import org.json.*;

@java.lang.SuppressWarnings({"java:S106", "java:S112", "java:S125"})

public class EKM {
    public static JSONObject callApiPost(String apiRequest) throws Exception {

        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object

        URL url = new URL(apiRequest);        
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty( "Content-type", "application/json");
        connection.setRequestProperty("Accept", "application/json");
        connection.setRequestProperty("Authorization", "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk");
        connection.setDoOutput(true);

        String reqData = "{\"command\": \"setTime\", \"target\": \"meter\", \"target_id\": \"000350000900\", \"params\": {\"Year\": 2022, \"Month\": 8, \"Day\": 2, \"Hour\": 13, \"Minutes\": 38, \"Seconds\": 1, \"meter_password\": \"00000000\"}}";
        try(OutputStream os = connection.getOutputStream()) {
            byte[] input = reqData.getBytes("utf-8");
            os.write(input, 0, input.length);           
        }

        try(BufferedReader br = new BufferedReader(
            new InputStreamReader(connection.getInputStream(), "utf-8"))) {
                StringBuilder response = new StringBuilder();
                String responseLine = null;
                while ((responseLine = br.readLine()) != null) {
                    response.append(responseLine.trim());
                }
                return new JSONObject(response.toString());
            }        
    }
    public static JSONObject callApi(String apiRequest) throws Exception {
        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object
        URL url = new URL(apiRequest);
        URLConnection yc = url.openConnection();
        BufferedReader in = new BufferedReader(new InputStreamReader(
                                    yc.getInputStream()));
        String inputLine;
        while ((inputLine = in.readLine()) != null) 
            System.out.println(inputLine);
        in.close();
        return new JSONObject(inputLine.toString());
    }

    public static void main(String[] args) throws Exception {
        /*
         Call callApiPost to create a usable
         object named apiObject from the API request URL.
         Put the API request URL in the call
         */
        JSONObject apiObject = EKM.callApiPost("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw");


        // This just displays the object but you can use what ever
        // code you would like to work with the object here
        System.out.println(apiObject.toString(4));
        }
}
/*
* Requirements
* NodeJS: v16.14.2
* Axios:  0.27.2
*/

// Load modules
const axios = require('axios');

// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
  try {
    const params  = {
      "command": "setTime",
      "target": "meter",
      "target_id": "000350000900",
      "params": {
          "Year": 2022,
          "Month": 8,
          "Day": 2,
          "Hour": 13,
          "Minutes": 38,
          "Seconds": 1,
          "meter_password": "00000000"
      }
  }

    const res = await axios.post(
        'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', params, {
          headers: {
            'Accept': 'application/json',
            // eslint-disable-next-line max-len
            'Authorization': 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk',
          }});
    const apiResData = res.data;    
    console.log(JSON.stringify(apiResData, null, 2));
  } catch (error) {
    console.error(error.message);
  }
})();

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">

// The example function is called from the
// body tag when the page loads
function example(){

// Call the callApi function to create a usable
// object named apiObject from the API request URL.
// Put the API request URL in the call
callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw',function(apiObject){

      // This just displays the object in the result div
      // you can use what ever code you would like to work
      // with the object here
      document.getElementById("result").innerHTML = "<pre>"+JSON.stringify(apiObject, null, 4)+"</pre>";
      });

};

// This code accesses the apiRequest URL and converts
// the contents to a usable JSON object named apiObject
function callApi(apiRequest,callback) {
    var xhttp = new XMLHttpRequest();
    const params  = {
    "command": "setTime",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "Year": 2022,
        "Month": 8,
        "Day": 2,
        "Hour": 13,
        "Minutes": 38,
        "Seconds": 1,
        "meter_password": "00000000"
    }
  }

    xhttp.onreadystatechange = function() {
      if (xhttp.readyState == 4 && xhttp.status == 200) {
        var jsonObject = JSON.parse(xhttp.responseText);
        callback(jsonObject);
      }
    };
    xhttp.open("POST", apiRequest, true);
    xhttp.setRequestHeader("Accept", "application/json");
    xhttp.setRequestHeader("Content-Type", "application/json");
    xhttp.setRequestHeader("Authorization", "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk");
    xhttp.send(JSON.stringify(params));
}
</script>

</head>
  <body onload="example()">
    <div id="result"> </div>
  </body>
</html>

This endpoint lets you adjust the internal clock of the meter. The schedules are run on the meter, not in the gateway. So the meter needs to know the time.

To change the time and date the JSON Object should look like this:

{ "target": "meter", "target_id": "000350000900", "command": "setTime" , "params": { "Year": 2022, "Month": 8, "Day": 2, "Hour": 13, "Minutes": 38, "Seconds": 1, "meter_password": "00000000" } }

In the example above we are setting the date and time for the meter ‘000350000900’:

JSON PARAMETERS

PARAMETER DESCRIPTION
Year (int) - Indicates the year. Example: 2022, for the year 2022.
Month (int) - Indicates the month. Example: 8, for the month of August.
Day (int) - Indicates the day of the month. Example: 2, for the second day of the month.
Hour (int) - Indicates the hour. Example: 13, for 13 in the afternoon. (Military hour)
Minutes (int) - Indicates the minutes. Example: 38, for 38 minutes.
Seconds (int) - Indicates the seconds. Example: 01, for 1 second.

Set Max Demand Reset

curl -i -X POST 'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw' -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk" --data-raw '{"command": "MaxDemandResetInterval", "target": "meter", "target_id": "000350000900", "params": {"Interval": 3, "meter_password": "00000000"}}'
# Ruby Version: 3.1.2

# Load required modules
require 'net/http'
require 'json'
require 'uri'

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call

def call_api(api_path, data)
  req_header = {        
    'Content-Type' => 'application/json',
    'Accept' => 'application/json',
    'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk'
  }
  uri = URI.parse("https://api.ekmpush.com#{api_path}")

  # Create the HTTP objects
  https = Net::HTTP.new(uri.host, uri.port)
  https.use_ssl = true
  request = Net::HTTP::Post.new(uri.request_uri, req_header)
  request.body = data

  # Send the request
  response = https.request(request)
  JSON.parse(response.body)
end

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
# URI only NOT URL - Do not include https://api.ekmpush.com
req_data = '{
  "command": "MaxDemandResetInterval",
  "target": "meter",
  "target_id": "000350000900",
  "params": {
      "Interval": 3,
      "meter_password": "00000000"
    }
  }'

api_object = call_api('/sendCommand?key=MTAxMDoyMDIw', req_data)

# This just displays the object but you can use what ever
# code you would like to work with the object here
require 'pp'
pp api_object

'''
Python version: 3.9.12
'''

# Required Python Modules
import urllib.request
import urllib.error
import urllib.parse
import json
import pprint

# This function accesses the api_request URL and converts
# the contents to a usable Python object and returns it
def call_api ( api_request, data ):
    '''Make http request'''
    headers = {
        "Accept": "application/json",
        "Content-Type": "application/json",
        "Authorization": "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk"
    }
    req = urllib.request.Request(api_request, headers=headers)
    jsondata = json.dumps(data)
    json_bytes = jsondata.encode('utf-8')   # Needs to be bytes
    response = urllib.request.urlopen(req, json_bytes)
    response = response.read()
    json_object = json.loads(response.decode())
    return json_object

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call

# Request JSON Object
req_json = {
    "command": "MaxDemandResetInterval",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "Interval": 3,
        "meter_password": "00000000"
    }
}

api_object = call_api("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw", req_json)

# This just displays the object but you can use what ever
# code you would like to work with the object here
pprint.pprint(api_object)

<?php
// PHP 8.0.17 (cli)

$postData = '{
    "command": "MaxDemandResetInterval",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "Interval": 3,
        "meter_password": "00000000"
    }
}';

// Call the callApi function to create a usable
// object named $apiObject from the API request URL.
// Put the API request URL in the call
$apiObject=callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', $postData);

// This just displays the object but you can use what ever
// code you would like to work with the object here
var_dump($apiObject);

// This function accesses the apiRequest URL and converts
// the contents to a usable PHP object and returns it
function callApi($apiRequest='', $postData='')
{
    $opts = array('http' =>
        array(
            'method'  => 'POST',
            'header'  => "Content-Type: application/json\r\n".
            "Accept: application/json\r\n".
            "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk\r\n",
            'content' => $postData
        )
    );
    $context = stream_context_create($opts);
    $json = file_get_contents($apiRequest, false, $context);
    $jsonObject = json_decode($json, true);
    return ($jsonObject);
}

#!/usr/bin/perl
# Perl version: v5.34
# CPAN.pm version 2.2
# Perl Modules Version:
# JSON: 4.05
# LWP::Protocol::https: 6.10
# LWP::UserAgent: 6.43
#
# OS Prerequisites
# UBUNTU
# apt install cpanminus
#
# Install Perl Modules
#       cpan LWP::UserAgent
#       cpan LWP::Protocol::https
#       cpan JSON

# Required Perl Modules
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use Data::Dumper;

# This function accesses the api_request URL and converts
# the contents to a usable Perl object and returns it
sub call_api {
    my $req_json = {
        'target'    => 'meter',
        'target_id' => '000350000900',
        'command'   => 'MaxDemandResetInterval',
        'params'    => {
            'Interval'    => 3,
            'meter_password' => '00000000'
        }
    };
    my $api_request = shift;
    my $req         = HTTP::Request->new( 'POST', $api_request );
    $req->header( 'Accept' => 'application/json' );
    $req->header( 'Content-Type' => 'application/json' );
    $req->header( 'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk' );
    $req->content( encode_json $req_json );
    my $lwp         = LWP::UserAgent->new;
    my $res         = $lwp->request($req);
    my $content     = $res->decoded_content();
    my $json_object = JSON->new->utf8->decode($content);
    return $json_object;
}

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
my $api_object =
  call_api('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw');

# This just displays the object but you can use what ever
# code you would like to work with the object here
print Dumper($api_object);    ## no critic (InputOutput::RequireCheckedSyscalls)

/*
 openjdk version "17.0.2" 2022-01-18

 Download the correct org.json jar version for your
 needs from: https://mvnrepository.com/artifact/org.json/json

 This example uses version 20220320 accessible here:
 https://repo1.maven.org/maven2/org/json/json/20220320/json-20220320.jar

 Instructions to run this program

 1. Put this code in a file named EKM.java
 2. Copy the downloaded org.json jar and EKM.java to the same directory
 3. Compile
  javac -cp .:./json-20220320.jar ./EKM.java
 4. Run
  java -cp .:./json-20220320.jar EKM
*/

//Import required classes
import java.net.*;
import java.io.*;
import org.json.*;

@java.lang.SuppressWarnings({"java:S106", "java:S112", "java:S125"})

public class EKM {
    public static JSONObject callApiPost(String apiRequest) throws Exception {

        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object

        URL url = new URL(apiRequest);        
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty( "Accept", "application/json");
        connection.setRequestProperty( "Content-type", "application/json");
        connection.setRequestProperty( "Authorization", "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk");
        connection.setDoOutput(true);

        String reqData = "{\"command\": \"MaxDemandResetInterval\", \"target\": \"meter\", \"target_id\": \"000350000900\", \"params\": {\"Interval\": 3, \"meter_password\": \"00000000\"}}";
        try(OutputStream os = connection.getOutputStream()) {
            byte[] input = reqData.getBytes("utf-8");
            os.write(input, 0, input.length);           
        }

        try(BufferedReader br = new BufferedReader(
            new InputStreamReader(connection.getInputStream(), "utf-8"))) {
                StringBuilder response = new StringBuilder();
                String responseLine = null;
                while ((responseLine = br.readLine()) != null) {
                    response.append(responseLine.trim());
                }
                return new JSONObject(response.toString());
            }        
    }
    public static JSONObject callApi(String apiRequest) throws Exception {
        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object
        URL url = new URL(apiRequest);
        URLConnection yc = url.openConnection();
        BufferedReader in = new BufferedReader(new InputStreamReader(
                                    yc.getInputStream()));
        String inputLine;
        while ((inputLine = in.readLine()) != null) 
            System.out.println(inputLine);
        in.close();
        return new JSONObject(inputLine.toString());
    }

    public static void main(String[] args) throws Exception {
        /*
         Call callApiPost to create a usable
         object named apiObject from the API request URL.
         Put the API request URL in the call
         */
        JSONObject apiObject = EKM.callApiPost("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw");


        // This just displays the object but you can use what ever
        // code you would like to work with the object here
        System.out.println(apiObject.toString(4));
        }
}
/*
* Requirements
* NodeJS: v16.14.2
* Axios:  0.27.2
*/

// Load modules
const axios = require('axios');

// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
  try {
    const params  = {
      "command": "MaxDemandResetInterval",
      "target": "meter",
      "target_id": "000350000900",
      "params": {
          "Interval": 3,
          "meter_password": "00000000"
      }
  }  

    const res = await axios.post(
        'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', params, {
          headers: {
            'Accept': 'application/json',
            // eslint-disable-next-line max-len
            'Authorization': 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk',
          }});
    const apiResData = res.data;    
    console.log(JSON.stringify(apiResData, null, 2));
  } catch (error) {
    console.error(error.message);
  }
})();

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">

// The example function is called from the
// body tag when the page loads
function example(){

// Call the callApi function to create a usable
// object named apiObject from the API request URL.
// Put the API request URL in the call
callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw',function(apiObject){

      // This just displays the object in the result div
      // you can use what ever code you would like to work
      // with the object here
      document.getElementById("result").innerHTML = "<pre>"+JSON.stringify(apiObject, null, 4)+"</pre>";
      });

};

// This code accesses the apiRequest URL and converts
// the contents to a usable JSON object named apiObject
function callApi(apiRequest,callback) {
    var xhttp = new XMLHttpRequest();
    const params  = {
    "command": "MaxDemandResetInterval",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "Interval": 3,
        "meter_password": "00000000"
    }
  }

    xhttp.onreadystatechange = function() {
      if (xhttp.readyState == 4 && xhttp.status == 200) {
        var jsonObject = JSON.parse(xhttp.responseText);
        callback(jsonObject);
      }
    };
    xhttp.open("POST", apiRequest, true);
    xhttp.setRequestHeader("Accept", "application/json");
    xhttp.setRequestHeader("Content-Type", "application/json");
    xhttp.setRequestHeader("Authorization", "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk");
    xhttp.send(JSON.stringify(params));
}
</script>

</head>
  <body onload="example()">
    <div id="result"> </div>
  </body>
</html>

The Max Demand value is the Maximum Watts (average of the spike within the Max Demand Period) the meter has seen since the Max Demand was reset. You can work with it following the next instructions.

Gateway Set Max Demand Reset Interval

For v.4/5 meters you can have the demand value reset to 0 on a set schedule so that it starts over for each billing period.

If you would like to set a specific schedule interval you can add a JSON object like:

{ "target": "meter", "target_id": "000350000900", "command": "MaxDemandResetInterval" , "params": { "Interval": INTERVAL_VALUE, "meter_password": "00000000" } }

JSON PARAMETERS

PARAMETER DESCRIPTION
Interval (int) - Indicates the interval you want to use.

Values that you have to use:

VALUE DESCRIPTION
0 Off
1 Monthly
2 Weekly
3 Daily
4 Hourly


The INTERVAL_VALUE for a Daily schedule is 3. So, your JSON object should look like the following:

{ "target": "meter", "target_id": "000350000900", "command": "MaxDemandResetInterval", "params": { "Interval": 3, "meter_password": "00000000" } }

Gateway Set Max Demand Period

curl -i -X POST 'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw' -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk" --data-raw '{"command": "MaxDemandPeriodSet", "target": "meter", "target_id": "000350000900", "params": { "max_demand_period": 1, "meter_password": "00000000"}}'
# Ruby Version: 3.1.2

# Load required modules
require 'net/http'
require 'json'
require 'uri'

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call

def call_api(api_path, data)
  req_header = {        
    'Content-Type' => 'application/json',
    'Accept' => 'application/json',
    'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk'
  }
  uri = URI.parse("https://api.ekmpush.com#{api_path}")

  # Create the HTTP objects
  https = Net::HTTP.new(uri.host, uri.port)
  https.use_ssl = true
  request = Net::HTTP::Post.new(uri.request_uri, req_header)
  request.body = data

  # Send the request
  response = https.request(request)
  JSON.parse(response.body)
end

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
# URI only NOT URL - Do not include https://api.ekmpush.com
req_data = '{
  "command": "MaxDemandPeriodSet",
  "target": "meter",
  "target_id": "000350000900",
  "params": {
      "Max_Demand_Period": 1,
      "meter_password": "00000000"
  }
}'

api_object = call_api('/sendCommand?key=MTAxMDoyMDIw', req_data)

# This just displays the object but you can use what ever
# code you would like to work with the object here
require 'pp'
pp api_object

'''
Python version: 3.9.12
'''

# Required Python Modules
import urllib.request
import urllib.error
import urllib.parse
import json
import pprint

# This function accesses the api_request URL and converts
# the contents to a usable Python object and returns it
def call_api ( api_request, data ):
    '''Make http request'''
    headers = {
        "Accept": "application/json",
        "Content-Type": "application/json",
        "Authorization": "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk"
    }
    req = urllib.request.Request(api_request, headers=headers)
    jsondata = json.dumps(data)
    json_bytes = jsondata.encode('utf-8')   # Needs to be bytes
    response = urllib.request.urlopen(req, json_bytes)
    response = response.read()
    json_object = json.loads(response.decode())
    return json_object

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call

# Request JSON Object
req_json = {
    "command": "MaxDemandPeriodSet",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "Max_Demand_Period": 1,
        "meter_password": "00000000"
    }
}

api_object = call_api("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw", req_json)

# This just displays the object but you can use what ever
# code you would like to work with the object here
pprint.pprint(api_object)

<?php
// PHP 8.0.17 (cli)

$postData = '{
    "command": "MaxDemandPeriodSet",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "max_demand_period": 1,
        "meter_password": "00000000"
    }
}';

// Call the callApi function to create a usable
// object named $apiObject from the API request URL.
// Put the API request URL in the call
$apiObject=callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', $postData);

// This just displays the object but you can use what ever
// code you would like to work with the object here
var_dump($apiObject);

// This function accesses the apiRequest URL and converts
// the contents to a usable PHP object and returns it
function callApi($apiRequest='', $postData='')
{
    $opts = array('http' =>
        array(
            'method'  => 'POST',
            'header'  => "Content-Type: application/json\r\n".
            "Accept: application/json\r\n".
            "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk\r\n",
            'content' => $postData
        )
    );
    $context = stream_context_create($opts);
    $json = file_get_contents($apiRequest, false, $context);
    $jsonObject = json_decode($json, true);
    return ($jsonObject);
}

#!/usr/bin/perl
# Perl version: v5.34
# CPAN.pm version 2.2
# Perl Modules Version:
# JSON: 4.05
# LWP::Protocol::https: 6.10
# LWP::UserAgent: 6.43
#
# OS Prerequisites
# UBUNTU
# apt install cpanminus
#
# Install Perl Modules
#       cpan LWP::UserAgent
#       cpan LWP::Protocol::https
#       cpan JSON

# Required Perl Modules
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use Data::Dumper;

# This function accesses the api_request URL and converts
# the contents to a usable Perl object and returns it
sub call_api {
    my $req_json = {
        'target'    => 'meter',
        'target_id' => '000350000900',
        'command'   => 'MaxDemandPeriodSet',
        'params'    => {
            'max_demand_period' => 1,
            'meter_password'    => '00000000'
        }
    };
    my $api_request = shift;
    my $req         = HTTP::Request->new( 'POST', $api_request );
    $req->header( 'Accept' => 'application/json' );
    $req->header( 'Content-Type' => 'application/json' );
    $req->header( 'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk' );
    $req->content( encode_json $req_json );
    my $lwp         = LWP::UserAgent->new;
    my $res         = $lwp->request($req);
    my $content     = $res->decoded_content();
    my $json_object = JSON->new->utf8->decode($content);
    return $json_object;
}

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
my $api_object =
  call_api('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw');

# This just displays the object but you can use what ever
# code you would like to work with the object here
print Dumper($api_object);    ## no critic (InputOutput::RequireCheckedSyscalls)

/*
 openjdk version "17.0.2" 2022-01-18

 Download the correct org.json jar version for your
 needs from: https://mvnrepository.com/artifact/org.json/json

 This example uses version 20220320 accessible here:
 https://repo1.maven.org/maven2/org/json/json/20220320/json-20220320.jar

 Instructions to run this program

 1. Put this code in a file named EKM.java
 2. Copy the downloaded org.json jar and EKM.java to the same directory
 3. Compile
  javac -cp .:./json-20220320.jar ./EKM.java
 4. Run
  java -cp .:./json-20220320.jar EKM
*/

//Import required classes
import java.net.*;
import java.io.*;
import org.json.*;

@java.lang.SuppressWarnings({"java:S106", "java:S112", "java:S125"})

public class EKM {
    public static JSONObject callApiPost(String apiRequest) throws Exception {

        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object

        URL url = new URL(apiRequest);        
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty( "Accept", "application/json");
        connection.setRequestProperty( "Content-type", "application/json");
        connection.setRequestProperty( "Authorization", "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk");
        connection.setDoOutput(true);

        String reqData = "{\"command\": \"MaxDemandPeriodSet\", \"target\": \"meter\", \"target_id\": \"000350000900\", \"params\": {\"max_demand_period\": 1, \"meter_password\": \"00000000\"}}";
        try(OutputStream os = connection.getOutputStream()) {
            byte[] input = reqData.getBytes("utf-8");
            os.write(input, 0, input.length);           
        }

        try(BufferedReader br = new BufferedReader(
            new InputStreamReader(connection.getInputStream(), "utf-8"))) {
                StringBuilder response = new StringBuilder();
                String responseLine = null;
                while ((responseLine = br.readLine()) != null) {
                    response.append(responseLine.trim());
                }
                return new JSONObject(response.toString());
            }        
    }
    public static JSONObject callApi(String apiRequest) throws Exception {
        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object
        URL url = new URL(apiRequest);
        URLConnection yc = url.openConnection();
        BufferedReader in = new BufferedReader(new InputStreamReader(
                                    yc.getInputStream()));
        String inputLine;
        while ((inputLine = in.readLine()) != null) 
            System.out.println(inputLine);
        in.close();
        return new JSONObject(inputLine.toString());
    }

    public static void main(String[] args) throws Exception {
        /*
         Call callApiPost to create a usable
         object named apiObject from the API request URL.
         Put the API request URL in the call
         */
        JSONObject apiObject = EKM.callApiPost("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw");


        // This just displays the object but you can use what ever
        // code you would like to work with the object here
        System.out.println(apiObject.toString(4));
        }
}
/*
* Requirements
* NodeJS: v16.14.2
* Axios:  0.27.2
*/

// Load modules
const axios = require('axios');

// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
  try {
    const params  = {
      "command": "MaxDemandPeriodSet",
      "target": "meter",
      "target_id": "000350000900",
      "params": {
          "max_demand_period": 1,
          "meter_password": "00000000"
      }
  }  

    const res = await axios.post(
        'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', params, {
          headers: {
            'Accept': 'application/json',
            // eslint-disable-next-line max-len
            'Authorization': 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk',
          }});
    const apiResData = res.data;    
    console.log(JSON.stringify(apiResData, null, 2));
  } catch (error) {
    console.error(error.message);
  }
})();

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">

// The example function is called from the
// body tag when the page loads
function example(){

// Call the callApi function to create a usable
// object named apiObject from the API request URL.
// Put the API request URL in the call
callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw',function(apiObject){

      // This just displays the object in the result div
      // you can use what ever code you would like to work
      // with the object here
      document.getElementById("result").innerHTML = "<pre>"+JSON.stringify(apiObject, null, 4)+"</pre>";
      });

};

// This code accesses the apiRequest URL and converts
// the contents to a usable JSON object named apiObject
function callApi(apiRequest,callback) {
    var xhttp = new XMLHttpRequest();
    const params  = {
    "command": "MaxDemandPeriodSet",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "Max_Demand_Period": 1,
        "meter_password": "00000000"
    }
}

    xhttp.onreadystatechange = function() {
      if (xhttp.readyState == 4 && xhttp.status == 200) {
        var jsonObject = JSON.parse(xhttp.responseText);
        callback(jsonObject);
      }
    };
    xhttp.open("POST", apiRequest, true);
    xhttp.setRequestHeader("Content-Type", "application/json; charset=UTF-8");
    xhttp.send(JSON.stringify(params));
}
</script>

</head>
  <body onload="example()">
    <div id="result"> </div>
  </body>
</html>

Adjust according to the demand period that is determined by your utility, if your utility does apply demand charges to your utility bill.

You could set the Max Demand Period with the command MaxDemandPeriodSet and the parameter max_demand_period:

{ "target": "meter", "target_id": "000350000900", "command": "MaxDemandPeriodSet" , "params": { "max_demand_period": PERIOD_VALUE, "meter_password": "00000000" } }

PERIOD_VALUE is a number between 1 and 3.

JSON PARAMETERS

PARAMETER DESCRIPTION
max_demand_period (int) - the new period.

Possible values:

VALUE DESCRIPTION
1 For a period of 15 minutes.
2 For a period of 30 minutes.
3 For a period of 60 minutes.

To set a period of 15 minutes, your JSON object should look like the following:

{ "command": "MaxDemandPeriodSet", target": "meter", target_id": "000350000900", params": { "max_demand_period": 1, "meter_password": "00000000" } }

Gateway Set Max Demand Reset Now

curl -i -X POST 'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw' -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk" --data-raw '{"command":"MaxDemandResetNow", "target":"meter", "target_id":"000350000900", "params":{"meter_password":"00000000"}}'
# Ruby Version: 3.1.2

# Load required modules
require 'net/http'
require 'json'
require 'uri'

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call

def call_api(api_path, data)
  req_header = {        
    'Content-Type' => 'application/json',
    'Accept' => 'application/json',
    'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk'
  }
  uri = URI.parse("https://api.ekmpush.com#{api_path}")

  # Create the HTTP objects
  https = Net::HTTP.new(uri.host, uri.port)
  https.use_ssl = true
  request = Net::HTTP::Post.new(uri.request_uri, req_header)
  request.body = data

  # Send the request
  response = https.request(request)
  JSON.parse(response.body)
end

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
# URI only NOT URL - Do not include https://api.ekmpush.com
req_data = '{
  "command": "MaxDemandResetNow",
  "target": "meter",
  "target_id": "000350000900",
  "params": {
      "meter_password": "00000000"
  }
}'

api_object = call_api('/sendCommand?key=MTAxMDoyMDIw', req_data)

# This just displays the object but you can use what ever
# code you would like to work with the object here
require 'pp'
pp api_object

'''
Python version: 3.9.12
'''

# Required Python Modules
import urllib.request
import urllib.error
import urllib.parse
import json
import pprint

# This function accesses the api_request URL and converts
# the contents to a usable Python object and returns it
def call_api ( api_request, data ):
    '''Make http request'''
    headers = {
        "Accept": "application/json",
        "Content-Type": "application/json",
        "Authorization": "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk"
    }
    req = urllib.request.Request(api_request, headers=headers)
    jsondata = json.dumps(data)
    json_bytes = jsondata.encode('utf-8')   # Needs to be bytes
    response = urllib.request.urlopen(req, json_bytes)
    response = response.read()
    json_object = json.loads(response.decode())
    return json_object

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call

# Request JSON Object
req_json = {
    "command": "MaxDemandResetNow",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "meter_password": "00000000"
    }
}

api_object = call_api("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw", req_json)

# This just displays the object but you can use what ever
# code you would like to work with the object here
pprint.pprint(api_object)

<?php
// PHP 8.0.17 (cli)

$postData = '{
    "command": "MaxDemandResetNow",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "meter_password": "00000000"
    }
}';

// Call the callApi function to create a usable
// object named $apiObject from the API request URL.
// Put the API request URL in the call
$apiObject=callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', $postData);

// This just displays the object but you can use what ever
// code you would like to work with the object here
var_dump($apiObject);

// This function accesses the apiRequest URL and converts
// the contents to a usable PHP object and returns it
function callApi($apiRequest='', $postData='')
{
    $opts = array('http' =>
        array(
            'method'  => 'POST',
            'header'  => "Content-Type: application/json\r\n".
            "Accept: application/json\r\n".
            "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk\r\n",
            'content' => $postData
        )
    );
    $context = stream_context_create($opts);
    $json = file_get_contents($apiRequest, false, $context);
    $jsonObject = json_decode($json, true);
    return ($jsonObject);
}

#!/usr/bin/perl
# Perl version: v5.34
# CPAN.pm version 2.2
# Perl Modules Version:
# JSON: 4.05
# LWP::Protocol::https: 6.10
# LWP::UserAgent: 6.43
#
# OS Prerequisites
# UBUNTU
# apt install cpanminus
#
# Install Perl Modules
#       cpan LWP::UserAgent
#       cpan LWP::Protocol::https
#       cpan JSON

# Required Perl Modules
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use Data::Dumper;

# This function accesses the api_request URL and converts
# the contents to a usable Perl object and returns it
sub call_api {
    my $req_json = {
        'target'    => 'meter',
        'target_id' => '000350000900',
        'command'   => 'MaxDemandResetNow',
        'params'    => {
            'meter_password' => '00000000'
        }
    };
    my $api_request = shift;
    my $req         = HTTP::Request->new( 'POST', $api_request );
    $req->header( 'Accept' => 'application/json' );
    $req->header( 'Content-Type' => 'application/json' );
    $req->header( 'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk' );
    $req->content( encode_json $req_json );
    my $lwp         = LWP::UserAgent->new;
    my $res         = $lwp->request($req);
    my $content     = $res->decoded_content();
    my $json_object = JSON->new->utf8->decode($content);
    return $json_object;
}

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
my $api_object =
  call_api('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw');

# This just displays the object but you can use what ever
# code you would like to work with the object here
print Dumper($api_object);    ## no critic (InputOutput::RequireCheckedSyscalls)

/*
 openjdk version "17.0.2" 2022-01-18

 Download the correct org.json jar version for your
 needs from: https://mvnrepository.com/artifact/org.json/json

 This example uses version 20220320 accessible here:
 https://repo1.maven.org/maven2/org/json/json/20220320/json-20220320.jar

 Instructions to run this program

 1. Put this code in a file named EKM.java
 2. Copy the downloaded org.json jar and EKM.java to the same directory
 3. Compile
  javac -cp .:./json-20220320.jar ./EKM.java
 4. Run
  java -cp .:./json-20220320.jar EKM
*/

//Import required classes
import java.net.*;
import java.io.*;
import org.json.*;

@java.lang.SuppressWarnings({"java:S106", "java:S112", "java:S125"})

public class EKM {
    public static JSONObject callApiPost(String apiRequest) throws Exception {

        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object

        URL url = new URL(apiRequest);        
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty( "Accept", "application/json");
        connection.setRequestProperty( "Content-type", "application/json");
        connection.setRequestProperty( "Authorization", "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk");
        connection.setDoOutput(true);

        String reqData = "{\"command\": \"MaxDemandResetNow\", \"target\": \"meter\", \"target_id\": \"000350000900\", \"params\": {\"meter_password\": \"00000000\"}}";
        try(OutputStream os = connection.getOutputStream()) {
            byte[] input = reqData.getBytes("utf-8");
            os.write(input, 0, input.length);           
        }

        try(BufferedReader br = new BufferedReader(
            new InputStreamReader(connection.getInputStream(), "utf-8"))) {
                StringBuilder response = new StringBuilder();
                String responseLine = null;
                while ((responseLine = br.readLine()) != null) {
                    response.append(responseLine.trim());
                }
                return new JSONObject(response.toString());
            }        
    }
    public static JSONObject callApi(String apiRequest) throws Exception {
        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object
        URL url = new URL(apiRequest);
        URLConnection yc = url.openConnection();
        BufferedReader in = new BufferedReader(new InputStreamReader(
                                    yc.getInputStream()));
        String inputLine;
        while ((inputLine = in.readLine()) != null) 
            System.out.println(inputLine);
        in.close();
        return new JSONObject(inputLine.toString());
    }

    public static void main(String[] args) throws Exception {
        /*
         Call callApiPost to create a usable
         object named apiObject from the API request URL.
         Put the API request URL in the call
         */
        JSONObject apiObject = EKM.callApiPost("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw");


        // This just displays the object but you can use what ever
        // code you would like to work with the object here
        System.out.println(apiObject.toString(4));
        }
}
/*
* Requirements
* NodeJS: v16.14.2
* Axios:  0.27.2
*/

// Load modules
const axios = require('axios');

// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
  try {
    const params  = {
      "command": "MaxDemandResetNow",
      "target": "meter",
      "target_id": "000350000900",
      "params": {
          "meter_password": "00000000"
      }
  }  

    const res = await axios.post(
        'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', params, {
          headers: {
            'Accept': 'application/json',
            // eslint-disable-next-line max-len
            'Authorization': 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk',
          }});
    const apiResData = res.data;    
    console.log(JSON.stringify(apiResData, null, 2));
  } catch (error) {
    console.error(error.message);
  }
})();

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">

// The example function is called from the
// body tag when the page loads
function example(){

// Call the callApi function to create a usable
// object named apiObject from the API request URL.
// Put the API request URL in the call
callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw',function(apiObject){

      // This just displays the object in the result div
      // you can use what ever code you would like to work
      // with the object here
      document.getElementById("result").innerHTML = "<pre>"+JSON.stringify(apiObject, null, 4)+"</pre>";
      });

};

// This code accesses the apiRequest URL and converts
// the contents to a usable JSON object named apiObject
function callApi(apiRequest,callback) {
    var xhttp = new XMLHttpRequest();
    const params  = {
    "command": "MaxDemandResetNow",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "meter_password": "00000000"
    }
  }

    xhttp.onreadystatechange = function() {
      if (xhttp.readyState == 4 && xhttp.status == 200) {
        var jsonObject = JSON.parse(xhttp.responseText);
        callback(jsonObject);
      }
    };
    xhttp.open("POST", apiRequest, true);
    xhttp.setRequestHeader("Accept", "application/json");
    xhttp.setRequestHeader("Content-Type", "application/json");
    xhttp.setRequestHeader("Authorization", "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk");
    xhttp.send(JSON.stringify(params));
}
</script>

</head>
  <body onload="example()">
    <div id="result"> </div>
  </body>
</html>

if you would like to manually reset the max demand value to 0 you have to send the next JSON Object via POST:

{ "target": "meter", "target_id": "000350000900", "command": "MaxDemandResetNow" , "params": { "meter_password": "00000000" } }

Set LCD

curl -i -X POST 'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw' -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk" --data-raw '{"command": "DisplaySet", "target": "meter", "target_id": "000350000900", "params": {"display_fields": [ "kWh_Tot", "Rev_kWh_Tot"], "meter_password": "00000000"}}'
# Ruby Version: 3.1.2

# Load required modules
require 'net/http'
require 'json'
require 'uri'

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call

def call_api(api_path, data)
  req_header = {        
    'Content-Type' => 'application/json',
    'Accept' => 'application/json',
    'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk'
  }
  uri = URI.parse("https://api.ekmpush.com#{api_path}")

  # Create the HTTP objects
  https = Net::HTTP.new(uri.host, uri.port)
  https.use_ssl = true
  request = Net::HTTP::Post.new(uri.request_uri, req_header)
  request.body = data

  # Send the request
  response = https.request(request)
  JSON.parse(response.body)
end

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
# URI only NOT URL - Do not include https://api.ekmpush.com
req_data = '{
  "command": "DisplaySet",
  "target": "meter",
  "target_id": "000350000900",
  "params": {
      "display_fields": [
          "kWh_Tot",
          "Rev_kWh_Tot"
      ],
      "meter_password": "00000000"
  }
}'

api_object = call_api('/sendCommand?key=MTAxMDoyMDIw', req_data)

# This just displays the object but you can use what ever
# code you would like to work with the object here
require 'pp'
pp api_object

'''
Python version: 3.9.12
'''

# Required Python Modules
import urllib.request
import urllib.error
import urllib.parse
import json
import pprint

# This function accesses the api_request URL and converts
# the contents to a usable Python object and returns it
def call_api ( api_request, data ):
    '''Make http request'''
    headers = {
        "Accept": "application/json",
        "Content-Type": "application/json",
        "Authorization": "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk"
    }
    req = urllib.request.Request(api_request, headers=headers)
    jsondata = json.dumps(data)
    json_bytes = jsondata.encode('utf-8')   # Needs to be bytes
    response = urllib.request.urlopen(req, json_bytes)
    response = response.read()
    json_object = json.loads(response.decode())
    return json_object

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call

# Request JSON Object
req_json = {
    "command": "DisplaySet",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "display_fields": [
            "kWh_Tot",
            "Rev_kWh_Tot"
        ],
        "meter_password": "00000000"
    }
}

api_object = call_api("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw", req_json)

# This just displays the object but you can use what ever
# code you would like to work with the object here
pprint.pprint(api_object)

<?php
// PHP 8.0.17 (cli)

$postData = '{
    "command": "DisplaySet",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "display_fields": [
            "kWh_Tot",
            "Rev_kWh_Tot"
        ],
        "meter_password": "00000000"
    }
}';

// Call the callApi function to create a usable
// object named $apiObject from the API request URL.
// Put the API request URL in the call
$apiObject=callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', $postData);

// This just displays the object but you can use what ever
// code you would like to work with the object here
var_dump($apiObject);

// This function accesses the apiRequest URL and converts
// the contents to a usable PHP object and returns it
function callApi($apiRequest='', $postData='')
{
    $opts = array('http' =>
        array(
            'method'  => 'POST',
            'header'  => "Content-Type: application/json\r\n".
            "Accept: application/json\r\n".
            "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk\r\n",
            'content' => $postData
        )
    );
    $context = stream_context_create($opts);
    $json = file_get_contents($apiRequest, false, $context);
    $jsonObject = json_decode($json, true);
    return ($jsonObject);
}

#!/usr/bin/perl
# Perl version: v5.34
# CPAN.pm version 2.2
# Perl Modules Version:
# JSON: 4.05
# LWP::Protocol::https: 6.10
# LWP::UserAgent: 6.43
#
# OS Prerequisites
# UBUNTU
# apt install cpanminus
#
# Install Perl Modules
#       cpan LWP::UserAgent
#       cpan LWP::Protocol::https
#       cpan JSON

# Required Perl Modules
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use Data::Dumper;

# This function accesses the api_request URL and converts
# the contents to a usable Perl object and returns it
sub call_api {
    my $req_json = {
        'target'    => 'meter',
        'target_id' => '000350000900',
        'command'   => 'DisplaySet',
        'params'    => {
            'display_fields'    => ['kWh_Tot', 'Rev_kWh_Tot'],
            'meter_password' => '00000000'
        }
    };
    my $api_request = shift;
    my $req         = HTTP::Request->new( 'POST', $api_request );
    $req->header( 'Accept' => 'application/json' );
    $req->header( 'Content-Type' => 'application/json' );
    $req->header( 'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk' );
    $req->content( encode_json $req_json );
    my $lwp         = LWP::UserAgent->new;
    my $res         = $lwp->request($req);
    my $content     = $res->decoded_content();
    my $json_object = JSON->new->utf8->decode($content);
    return $json_object;
}

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
my $api_object =
  call_api('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw');

# This just displays the object but you can use what ever
# code you would like to work with the object here
print Dumper($api_object);    ## no critic (InputOutput::RequireCheckedSyscalls)

/*
 openjdk version "17.0.2" 2022-01-18

 Download the correct org.json jar version for your
 needs from: https://mvnrepository.com/artifact/org.json/json

 This example uses version 20220320 accessible here:
 https://repo1.maven.org/maven2/org/json/json/20220320/json-20220320.jar

 Instructions to run this program

 1. Put this code in a file named EKM.java
 2. Copy the downloaded org.json jar and EKM.java to the same directory
 3. Compile
  javac -cp .:./json-20220320.jar ./EKM.java
 4. Run
  java -cp .:./json-20220320.jar EKM
*/

//Import required classes
import java.net.*;
import java.io.*;
import org.json.*;

@java.lang.SuppressWarnings({"java:S106", "java:S112", "java:S125"})

public class EKM {
    public static JSONObject callApiPost(String apiRequest) throws Exception {

        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object

        URL url = new URL(apiRequest);        
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty( "Accept", "application/json");
        connection.setRequestProperty( "Content-type", "application/json");
        connection.setRequestProperty( "Authorization", "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk");
        connection.setDoOutput(true);

        String reqData = "{\"command\": \"DisplaySet\", \"target\": \"meter\", \"target_id\": \"000350000900\", \"params\": {\"display_fields\": [\"kWh_Tot\",\"Rev_kWh_Tot\"], \"meter_password\": \"00000000\"}}";
        try(OutputStream os = connection.getOutputStream()) {
            byte[] input = reqData.getBytes("utf-8");
            os.write(input, 0, input.length);           
        }

        try(BufferedReader br = new BufferedReader(
            new InputStreamReader(connection.getInputStream(), "utf-8"))) {
                StringBuilder response = new StringBuilder();
                String responseLine = null;
                while ((responseLine = br.readLine()) != null) {
                    response.append(responseLine.trim());
                }
                return new JSONObject(response.toString());
            }        
    }
    public static JSONObject callApi(String apiRequest) throws Exception {
        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object
        URL url = new URL(apiRequest);
        URLConnection yc = url.openConnection();
        BufferedReader in = new BufferedReader(new InputStreamReader(
                                    yc.getInputStream()));
        String inputLine;
        while ((inputLine = in.readLine()) != null) 
            System.out.println(inputLine);
        in.close();
        return new JSONObject(inputLine.toString());
    }

    public static void main(String[] args) throws Exception {
        /*
         Call callApiPost to create a usable
         object named apiObject from the API request URL.
         Put the API request URL in the call
         */
        JSONObject apiObject = EKM.callApiPost("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw");


        // This just displays the object but you can use what ever
        // code you would like to work with the object here
        System.out.println(apiObject.toString(4));
        }
}
/*
* Requirements
* NodeJS: v16.14.2
* Axios:  0.27.2
*/

// Load modules
const axios = require('axios');

// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
  try {
    const params  = {
      "command": "DisplaySet",
      "target": "meter",
      "target_id": "000350000900",
      "params": {
          "display_fields": [
              "kWh_Tot",
              "Rev_kWh_Tot"
          ],
          "meter_password": "00000000"
      }
  }

    const res = await axios.post(
        'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', params, {
          headers: {
            'Accept': 'application/json',
            // eslint-disable-next-line max-len
            'Authorization': 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk',
          }});
    const apiResData = res.data;    
    console.log(JSON.stringify(apiResData, null, 2));
  } catch (error) {
    console.error(error.message);
  }
})();

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">

// The example function is called from the
// body tag when the page loads
function example(){

// Call the callApi function to create a usable
// object named apiObject from the API request URL.
// Put the API request URL in the call
callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw',function(apiObject){

      // This just displays the object in the result div
      // you can use what ever code you would like to work
      // with the object here
      document.getElementById("result").innerHTML = "<pre>"+JSON.stringify(apiObject, null, 4)+"</pre>";
      });

};

// This code accesses the apiRequest URL and converts
// the contents to a usable JSON object named apiObject
function callApi(apiRequest,callback) {
    var xhttp = new XMLHttpRequest();
    const params  = {
    "command": "DisplaySet",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "display_fields": [
            "kWh_Tot",
                  "Rev_kWh_Tot"
        ],
        "meter_password": "00000000"
      }
    }

    xhttp.onreadystatechange = function() {
      if (xhttp.readyState == 4 && xhttp.status == 200) {
        var jsonObject = JSON.parse(xhttp.responseText);
        callback(jsonObject);
      }
    };
    xhttp.open("POST", apiRequest, true);
    xhttp.setRequestHeader("Accept", "application/json");
    xhttp.setRequestHeader("Content-Type", "application/json");
    xhttp.setRequestHeader("Authorization", "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk");
    xhttp.send(JSON.stringify(params));
}
</script>

</head>
  <body onload="example()">
    <div id="result"> </div>
  </body>
</html>

The LCD screens of the v.4 and v.5 Omnimeters display a lot of data by default. They cycle through 40 different data values before starting over. This is often more than you will need and it can be time consuming to wait for the data that you actually need. Fortunately, these meters have the ability to be set to display only what you need.

To set values on your meter display your JSON object should look like:

{ "target": "meter", "target_id": "000350000900", "command": "DisplaySet" , "params": { "display_fields": ["FIRST_VALUE", "SECOND_VALUE"], "meter_password": "00000000" } }

You could pass 1 parameter inside the list [“FIRST_VALUE”] or multiple parameters separated by comma : [“FIRST_VALUE”, “SECOND_VALUE”, “THIRD_VALUE”].

If you want to show on your meter display values kWh_Tot and Rev_kWh_Tot you could set your JSON object like this:

{ "target": "meter", "target_id": "000350000900", "command":"DisplaySet", "params": { "Display_Fields": ["kWh_Tot", "Rev_kWh_Tot"], "meter_password": "00000000" } }

JSON PARAMETERS

PARAMETER DESCRIPTION
display_fields (list) - list of display fields.

Values that you could set on your meter display:

VALUE DESCRIPTION
kWh_Tot Total Kwh
Rev_kWh_Tot Reverse Kwh
RMS_Volts_Ln_1 Volts L1
RMS_Volts_Ln_2 Volts L2
RMS_Volts_Ln_3 Volts L3
Amps_Ln_1 Amps L1
Amps_Ln_2 Amps L2
Amps_Ln_3 Amps L3
RMS_Watts_Ln_1 Watts L1
RMS_Watts_Ln_2 Watts L2
RMS_Watts_Ln_3 Watts L3
RMS_Watts_Tot Total Watts
Power_Factor_Ln_1 Power Factor L1
Power_Factor_Ln_2 Power Factor L2
Power_Factor_Ln_3 Power Factor L3
kWh_Tariff_1 kWh Tariff 1
kWh_Tariff_2 kWh Tariff 2
kWh_Tariff_3 kWh Tariff 3
kWh_Tariff_4 kWh Tariff 4
Rev_kWh_Tariff_1 Reverse kWh Tariff 1
Rev_kWh_Tariff_2 Reverse kWh Tariff 2
Rev_kWh_Tariff_3 Reverse kWh Tariff 3
Rev_kWh_Tariff_4 Reverse kWh Tariff 4
Reactive_Pwr_Ln_1 Reactive Power (VAR) L1
Reactive_Pwr_Ln_2 Reactive Power L2
Reactive_Pwr_Ln_3 Reactive Power L3
Reactive_Pwr_Tot Total Reactive Power
Line_Freq Line Frequency (Hz)
Pulse_Cnt_1 Pulse Count 1
Pulse_Cnt_2 Pulse Count 2
Pulse_Cnt_3 Pulse Count 3
kWh_Ln_1 kWh L1
Rev_kWh_Ln_1 Reverse kWh L1
kWh_Ln_2 kWh L2
Rev_kWh_Ln_2 Reverse kWh L2
kWh_Ln_3 kWh L3
Rev_kWh_Ln_3 Reverse kWh L3
Reactive_Energy_Tot Total Reactive Power (kVArh
kWh_Rst Resettable kWh
Rev_kWh_Rst Resettable Reverse kWh
State_Inputs 3 Pulse Inputs High/Low
Max_Demand Maximum Demand
Raw_Pulse_1 Resettable raw pulse count 1
Raw_Pulse_2 Resettable raw pulse count 2
Raw_Pulse_3 Resettable raw pulse count 3
CT_Ratio CT Ratio
Calc_Fwd_kWh Calculated forward kWh

If you want more information about those variables you could read the Glossary of Omnimeter Data Terms

Set Pulse Input Ratio

curl -i -X POST 'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw' -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk" --data-raw '{"command": "PulseInputRatioSet", "target": "meter", "target_id": "000350000900", "params": {"Pulse_Line": 1, "Pulse_Input_Ratio": 1, "meter_password": "00000000"}}'
# Ruby Version: 3.1.2

# Load required modules
require 'net/http'
require 'json'
require 'uri'

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call

def call_api(api_path, data)
  req_header = {        
    'Content-Type' => 'application/json',
    'Accept' => 'application/json',
    'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk'
  }
  uri = URI.parse("https://api.ekmpush.com#{api_path}")

  # Create the HTTP objects
  https = Net::HTTP.new(uri.host, uri.port)
  https.use_ssl = true
  request = Net::HTTP::Post.new(uri.request_uri, req_header)
  request.body = data

  # Send the request
  response = https.request(request)
  JSON.parse(response.body)
end

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
# URI only NOT URL - Do not include https://api.ekmpush.com
req_data = '{
  "command": "PulseInputRatioSet",
  "target": "meter",
  "target_id": "000350000900",
  "params": {
      "Pulse_Line": 1,
      "Pulse_Input_Ratio": 1,
      "meter_password": "00000000"
  }
}'

api_object = call_api('/sendCommand?key=MTAxMDoyMDIw', req_data)

# This just displays the object but you can use what ever
# code you would like to work with the object here
require 'pp'
pp api_object

'''
Python version: 3.9.12
'''

# Required Python Modules
import urllib.request
import urllib.error
import urllib.parse
import json
import pprint

# This function accesses the api_request URL and converts
# the contents to a usable Python object and returns it
def call_api ( api_request, data ):
    '''Make http request'''
    headers = {
        "Accept": "application/json",
        "Content-Type": "application/json",
        "Authorization": "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk"
    }
    req = urllib.request.Request(api_request, headers=headers)
    jsondata = json.dumps(data)
    json_bytes = jsondata.encode('utf-8')   # Needs to be bytes
    response = urllib.request.urlopen(req, json_bytes)
    response = response.read()
    json_object = json.loads(response.decode())
    return json_object

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call

# Request JSON Object
req_json = {
    "command": "PulseInputRatioSet",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "Pulse_Line": 1,
        "Pulse_Input_Ratio": 1,
        "meter_password": "00000000"
    }
}

api_object = call_api("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw", req_json)

# This just displays the object but you can use what ever
# code you would like to work with the object here
pprint.pprint(api_object)

<?php
// PHP 8.0.17 (cli)

$postData = '{
    "command": "PulseInputRatioSet",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "Pulse_Line": 1,
        "Pulse_Input_Ratio": 1,
        "meter_password": "00000000"
    }
}';

// Call the callApi function to create a usable
// object named $apiObject from the API request URL.
// Put the API request URL in the call
$apiObject=callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', $postData);

// This just displays the object but you can use what ever
// code you would like to work with the object here
var_dump($apiObject);

// This function accesses the apiRequest URL and converts
// the contents to a usable PHP object and returns it
function callApi($apiRequest='', $postData='')
{
    $opts = array('http' =>
        array(
            'method'  => 'POST',
            'header'  => "Content-Type: application/json\r\n".
            "Accept: application/json\r\n".
            "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk\r\n",
            'content' => $postData
        )
    );
    $context = stream_context_create($opts);
    $json = file_get_contents($apiRequest, false, $context);
    $jsonObject = json_decode($json, true);
    return ($jsonObject);
}

#!/usr/bin/perl
# Perl version: v5.34
# CPAN.pm version 2.2
# Perl Modules Version:
# JSON: 4.05
# LWP::Protocol::https: 6.10
# LWP::UserAgent: 6.43
#
# OS Prerequisites
# UBUNTU
# apt install cpanminus
#
# Install Perl Modules
#       cpan LWP::UserAgent
#       cpan LWP::Protocol::https
#       cpan JSON

# Required Perl Modules
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use Data::Dumper;

# This function accesses the api_request URL and converts
# the contents to a usable Perl object and returns it
sub call_api {
    my $req_json = {
        'target'    => 'meter',
        'target_id' => '000350000900',
        'command'   => 'PulseInputRatioSet',
        'params'    => {
            'Pulse_Line'    => 1,
            'Pulse_Input_Ratio'    => 1,
            'meter_password' => '00000000'
        }
    };
    my $api_request = shift;
    my $req         = HTTP::Request->new( 'POST', $api_request );
    $req->header( 'Accept' => 'application/json' );
    $req->header( 'Content-Type' => 'application/json' );
    $req->header( 'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk' );
    $req->content( encode_json $req_json );
    my $lwp         = LWP::UserAgent->new;
    my $res         = $lwp->request($req);
    my $content     = $res->decoded_content();
    my $json_object = JSON->new->utf8->decode($content);
    return $json_object;
}

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
my $api_object =
  call_api('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw');

# This just displays the object but you can use what ever
# code you would like to work with the object here
print Dumper($api_object);    ## no critic (InputOutput::RequireCheckedSyscalls)

/*
 openjdk version "17.0.2" 2022-01-18

 Download the correct org.json jar version for your
 needs from: https://mvnrepository.com/artifact/org.json/json

 This example uses version 20220320 accessible here:
 https://repo1.maven.org/maven2/org/json/json/20220320/json-20220320.jar

 Instructions to run this program

 1. Put this code in a file named EKM.java
 2. Copy the downloaded org.json jar and EKM.java to the same directory
 3. Compile
  javac -cp .:./json-20220320.jar ./EKM.java
 4. Run
  java -cp .:./json-20220320.jar EKM
*/

//Import required classes
import java.net.*;
import java.io.*;
import org.json.*;

@java.lang.SuppressWarnings({"java:S106", "java:S112", "java:S125"})

public class EKM {
    public static JSONObject callApiPost(String apiRequest) throws Exception {

        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object

        URL url = new URL(apiRequest);        
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty( "Accept", "application/json");
        connection.setRequestProperty( "Content-type", "application/json");
        connection.setRequestProperty( "Authorization", "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk");
        connection.setDoOutput(true);

        String reqData = "{\"command\": \"PulseInputRatioSet\", \"target\": \"meter\", \"target_id\": \"000350000900\", \"params\": {\"Pulse_Line\": 1, \"Pulse_Input_Ratio\": 1, \"meter_password\": \"00000000\"}}";
        try(OutputStream os = connection.getOutputStream()) {
            byte[] input = reqData.getBytes("utf-8");
            os.write(input, 0, input.length);           
        }

        try(BufferedReader br = new BufferedReader(
            new InputStreamReader(connection.getInputStream(), "utf-8"))) {
                StringBuilder response = new StringBuilder();
                String responseLine = null;
                while ((responseLine = br.readLine()) != null) {
                    response.append(responseLine.trim());
                }
                return new JSONObject(response.toString());
            }        
    }
    public static JSONObject callApi(String apiRequest) throws Exception {
        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object
        URL url = new URL(apiRequest);
        URLConnection yc = url.openConnection();
        BufferedReader in = new BufferedReader(new InputStreamReader(
                                    yc.getInputStream()));
        String inputLine;
        while ((inputLine = in.readLine()) != null) 
            System.out.println(inputLine);
        in.close();
        return new JSONObject(inputLine.toString());
    }

    public static void main(String[] args) throws Exception {
        /*
         Call callApiPost to create a usable
         object named apiObject from the API request URL.
         Put the API request URL in the call
         */
        JSONObject apiObject = EKM.callApiPost("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw");


        // This just displays the object but you can use what ever
        // code you would like to work with the object here
        System.out.println(apiObject.toString(4));
        }
}
/*
* Requirements
* NodeJS: v16.14.2
* Axios:  0.27.2
*/

// Load modules
const axios = require('axios');

// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
  try {
    const params  = {
      "command": "PulseInputRatioSet",
      "target": "meter",
      "target_id": "000350000900",
      "params": {
          "Pulse_Line": 1,
          "Pulse_Input_Ratio": 1,
          "meter_password": "00000000"
      }
  }

    const res = await axios.post(
        'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', params, {
          headers: {
            'Accept': 'application/json',
            // eslint-disable-next-line max-len
            'Authorization': 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk',
          }});
    const apiResData = res.data;    
    console.log(JSON.stringify(apiResData, null, 2));
  } catch (error) {
    console.error(error.message);
  }
})();

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">

// The example function is called from the
// body tag when the page loads
function example(){

// Call the callApi function to create a usable
// object named apiObject from the API request URL.
// Put the API request URL in the call
callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw',function(apiObject){

      // This just displays the object in the result div
      // you can use what ever code you would like to work
      // with the object here
      document.getElementById("result").innerHTML = "<pre>"+JSON.stringify(apiObject, null, 4)+"</pre>";
      });

};

// This code accesses the apiRequest URL and converts
// the contents to a usable JSON object named apiObject
function callApi(apiRequest,callback) {
    var xhttp = new XMLHttpRequest();
    const params  = {
    "command": "PulseInputRatioSet",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "Pulse_Line": 1,
        "Pulse_Input_Ratio": 1,
        "meter_password": "00000000"
      }
    }

    xhttp.onreadystatechange = function() {
      if (xhttp.readyState == 4 && xhttp.status == 200) {
        var jsonObject = JSON.parse(xhttp.responseText);
        callback(jsonObject);
      }
    };
    xhttp.open("POST", apiRequest, true);
    xhttp.setRequestHeader("Accept", "application/json");
    xhttp.setRequestHeader("Content-Type", "application/json");
    xhttp.setRequestHeader("Authorization", "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk");
    xhttp.send(JSON.stringify(params));
}
</script>

</head>
  <body onload="example()">
    <div id="result"> </div>
  </body>
</html>

The v.4/5 Omnimeters now default to 1:1 ratio of pulses counted to pulse incremented in the data. This is the ratio we recommend and we do not recommend that you change this setting unless you have a compelling reason to do so.

The example below sets for the Pulse_Line 1 a Pulse_Input_Ratio of 1 with the next JSON object:

{ "target": "meter", "target_id": "000350000900", "command": "PulseInputRatioSet" , "params": { "Pulse_Line": 1, "Pulse_Input_Ratio": 1, "meter_password": "00000000" } }

JSON PARAMETERS

PARAMETER DESCRIPTION
pulse_line (int) - the pulse input line number.
pulse_input_ratio (int) - the new input ratio.

Set Pulse Output Ratio

curl -i -X POST 'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw' -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk" --data-raw '{"command": "SetPulseOutputRatio", "target": "meter", "target_id": "000350000900", "params": {"Pulse_Output_Ratio": 800, "CT_Ratio": 200, "meter_password": "00000000" }}'
# Ruby Version: 3.1.2

# Load required modules
require 'net/http'
require 'json'
require 'uri'

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call

def call_api(api_path, data)
  req_header = {        
    'Content-Type' => 'application/json',
    'Accept' => 'application/json',
    'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk'
  }
  uri = URI.parse("https://api.ekmpush.com#{api_path}")

  # Create the HTTP objects
  https = Net::HTTP.new(uri.host, uri.port)
  https.use_ssl = true
  request = Net::HTTP::Post.new(uri.request_uri, req_header)
  request.body = data

  # Send the request
  response = https.request(request)
  JSON.parse(response.body)
end

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
# URI only NOT URL - Do not include https://api.ekmpush.com
req_data = '{
  "command": "SetPulseOutputRatio",
  "target": "meter",
  "target_id": "000350000900",
  "params": {
      "Pulse_Output_Ratio": 800,
      "CT_Ratio": 200,
      "meter_password": "00000000"
  }
}'

api_object = call_api('/sendCommand?key=MTAxMDoyMDIw', req_data)

# This just displays the object but you can use what ever
# code you would like to work with the object here
require 'pp'
pp api_object

'''
Python version: 3.9.12
'''

# Required Python Modules
import urllib.request
import urllib.error
import urllib.parse
import json
import pprint

# This function accesses the api_request URL and converts
# the contents to a usable Python object and returns it
def call_api ( api_request, data ):
    '''Make http request'''    
    headers = {
        "Accept": "application/json",
        "Content-Type": "application/json",
        "Authorization": "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk"
    }
    req = urllib.request.Request(api_request, headers=headers)    
    jsondata = json.dumps(data)
    json_bytes = jsondata.encode('utf-8')   # Needs to be bytes
    response = urllib.request.urlopen(req, json_bytes)
    response = response.read()
    json_object = json.loads(response.decode())
    return json_object

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call

# Request JSON Object
req_json = {
    "command": "SetPulseOutputRatio",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "Pulse_Output_Ratio": 800,
        "CT_Ratio": 200,
        "meter_password": "00000000"
    }
}

api_object = call_api("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw", req_json)

# This just displays the object but you can use what ever
# code you would like to work with the object here
pprint.pprint(api_object)

<?php
// PHP 8.0.17 (cli)

$postData = '{
    "command": "SetPulseOutputRatio",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "Pulse_Output_Ratio": 800,
        "CT_Ratio": 200,
        "meter_password": "00000000"
    }
}';

// Call the callApi function to create a usable
// object named $apiObject from the API request URL.
// Put the API request URL in the call
$apiObject=callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', $postData);

// This just displays the object but you can use what ever
// code you would like to work with the object here
var_dump($apiObject);

// This function accesses the apiRequest URL and converts
// the contents to a usable PHP object and returns it
function callApi($apiRequest='', $postData='')
{
    $opts = array('http' =>
        array(
            'method'  => 'POST',
            'header'  => "Content-Type: application/json\r\n".
            "Accept: application/json\r\n".
            "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk\r\n",
            'content' => $postData
        )
    );
    $context = stream_context_create($opts);
    $json = file_get_contents($apiRequest, false, $context);
    $jsonObject = json_decode($json, true);
    return ($jsonObject);
}

#!/usr/bin/perl
# Perl version: v5.34
# CPAN.pm version 2.2
# Perl Modules Version:
# JSON: 4.05
# LWP::Protocol::https: 6.10
# LWP::UserAgent: 6.43
#
# OS Prerequisites
# UBUNTU
# apt install cpanminus
#
# Install Perl Modules
#       cpan LWP::UserAgent
#       cpan LWP::Protocol::https
#       cpan JSON

# Required Perl Modules
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use Data::Dumper;

# This function accesses the api_request URL and converts
# the contents to a usable Perl object and returns it
sub call_api {
    my $req_json = {
        'target'    => 'meter',
        'target_id' => '000350000900',
        'command'   => 'SetPulseOutputRatio',
        'params'    => {
            'Pulse_Output_Ratio'    => 800,
            'CT_Ratio'    => 200,
            'meter_password' => '00000000'
        }
    };
    my $api_request = shift;
    my $req         = HTTP::Request->new( 'POST', $api_request );
    $req->header( 'Accept' => 'application/json' );
    $req->header( 'Content-Type' => 'application/json' );
    $req->header( 'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk' );
    $req->content( encode_json $req_json );
    my $lwp         = LWP::UserAgent->new;
    my $res         = $lwp->request($req);
    my $content     = $res->decoded_content();
    my $json_object = JSON->new->utf8->decode($content);
    return $json_object;
}

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
my $api_object =
  call_api('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw');

# This just displays the object but you can use what ever
# code you would like to work with the object here
print Dumper($api_object);    ## no critic (InputOutput::RequireCheckedSyscalls)

/*
 openjdk version "17.0.2" 2022-01-18

 Download the correct org.json jar version for your
 needs from: https://mvnrepository.com/artifact/org.json/json

 This example uses version 20220320 accessible here:
 https://repo1.maven.org/maven2/org/json/json/20220320/json-20220320.jar

 Instructions to run this program

 1. Put this code in a file named EKM.java
 2. Copy the downloaded org.json jar and EKM.java to the same directory
 3. Compile
  javac -cp .:./json-20220320.jar ./EKM.java
 4. Run
  java -cp .:./json-20220320.jar EKM
*/

//Import required classes
import java.net.*;
import java.io.*;
import org.json.*;

@java.lang.SuppressWarnings({"java:S106", "java:S112", "java:S125"})

public class EKM {
    public static JSONObject callApiPost(String apiRequest) throws Exception {

        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object

        URL url = new URL(apiRequest);        
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty( "Accept", "application/json");
        connection.setRequestProperty( "Content-type", "application/json");
        connection.setRequestProperty( "Authorization", "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk");
        connection.setDoOutput(true);

        String reqData = "{\"command\": \"SetPulseOutputRatio\", \"target\": \"meter\", \"target_id\": \"000350000900\", \"params\": {\"Pulse_Output_Ratio\": 800, \"CT_Ratio\": 200, \"meter_password\": \"00000000\"}}";
        try(OutputStream os = connection.getOutputStream()) {
            byte[] input = reqData.getBytes("utf-8");
            os.write(input, 0, input.length);           
        }

        try(BufferedReader br = new BufferedReader(
            new InputStreamReader(connection.getInputStream(), "utf-8"))) {
                StringBuilder response = new StringBuilder();
                String responseLine = null;
                while ((responseLine = br.readLine()) != null) {
                    response.append(responseLine.trim());
                }
                return new JSONObject(response.toString());
            }        
    }
    public static JSONObject callApi(String apiRequest) throws Exception {
        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object
        URL url = new URL(apiRequest);
        URLConnection yc = url.openConnection();
        BufferedReader in = new BufferedReader(new InputStreamReader(
                                    yc.getInputStream()));
        String inputLine;
        while ((inputLine = in.readLine()) != null) 
            System.out.println(inputLine);
        in.close();
        return new JSONObject(inputLine.toString());
    }

    public static void main(String[] args) throws Exception {
        /*
         Call callApiPost to create a usable
         object named apiObject from the API request URL.
         Put the API request URL in the call
         */
        JSONObject apiObject = EKM.callApiPost("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw");


        // This just displays the object but you can use what ever
        // code you would like to work with the object here
        System.out.println(apiObject.toString(4));
        }
}
/*
* Requirements
* NodeJS: v16.14.2
* Axios:  0.27.2
*/

// Load modules
const axios = require('axios');

// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
  try {
    const params  = {
      "command": "SetPulseOutputRatio",
      "target": "meter",
      "target_id": "000350000900",
      "params": {
          "Pulse_Output_Ratio": 800,
          "CT_Ratio": 200,
          "meter_password": "00000000"
      }
  }

    const res = await axios.post(
        'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', params, {
          headers: {
            'Accept': 'application/json',
            // eslint-disable-next-line max-len
            'Authorization': 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk',
          }});
    const apiResData = res.data;
    console.log(JSON.stringify(apiResData, null, 2));
  } catch (error) {
    console.error(error.message);
  }
})();

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">

// The example function is called from the
// body tag when the page loads
function example(){

// Call the callApi function to create a usable
// object named apiObject from the API request URL.
// Put the API request URL in the call
callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw',function(apiObject){

      // This just displays the object in the result div
      // you can use what ever code you would like to work
      // with the object here
      document.getElementById("result").innerHTML = "<pre>"+JSON.stringify(apiObject, null, 4)+"</pre>";
      });

};

// This code accesses the apiRequest URL and converts
// the contents to a usable JSON object named apiObject
function callApi(apiRequest,callback) {
    var xhttp = new XMLHttpRequest();
    const params  = {
    "command": "SetPulseOutputRatio",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "Pulse_Output_Ratio": 800,
        "CT_Ratio": 200,
        "meter_password": "00000000"
    }
}

    xhttp.onreadystatechange = function() {
      if (xhttp.readyState == 4 && xhttp.status == 200) {
        var jsonObject = JSON.parse(xhttp.responseText);
        callback(jsonObject);
      }
    };
    xhttp.open("POST", apiRequest, true);
    xhttp.setRequestHeader("Accept", "application/json");
    xhttp.setRequestHeader("Content-Type", "application/json");
    xhttp.setRequestHeader("Authorization", "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk");
    xhttp.send(JSON.stringify(params));
}
</script>

</head>
  <body onload="example()">
    <div id="result"> </div>
  </body>
</html>

Adjust if you would like to change the number of pulses that are generated by the Omnimeter per kWh recorded.

The example below set the Pulse_Output_Ratio 800 and CT_Ratio 200 with the next JSON object:

{ "target": "meter", "target_id": "000350000900", "command": "SetPulseOutputRatio" , "params": { "Pulse_Output_Ratio": 800, "CT_Ratio": 200, "meter_password": "00000000" } }

JSON PARAMETERS

PARAMETER DESCRIPTION
Pulse_Output_Ratio (int) - the pulse input line number.
CT_Ratio (int) - the new output ratio.

Possible values for the Pulse_Output_Ratio:

VALUE DESCRIPTION
1 1 imp/kWh
2 2 imp/kWh
4 4 imp/kWh
5 5 imp/kWh
6 6 imp/kWh
8 8 imp/kWh
10 10 imp/kWh
16 16 imp/kWh
20 20 imp/kWh
25 25 imp/kWh
40 40 imp/kWh
50 50 imp/kWh
80 80 imp/kWh
100 100 imp/kWh
200 200 imp/kWh
400 400 imp/kWh
800 800 imp/kWh
1600 1600 imp/kWh

Possible values for the CT_Ratio:

VALUE DESCRIPTION
100 100A: 26.6 mA
200 200A: 26.6 mA
400 400A: 26.6 mA
600 600A: 26.6 mA
800 800A: 26.6 mA
1500 1500A: 26.6 mA
3000 3000A: 26.6 mA
5000 5000A: 26.6 mA

Set Zero Resettable KWH

curl -i -X POST 'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw' -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk" --data-raw '{ "command": "kWhReset", "target": "meter", "target_id": "000350000900", "params": { "meter_password": "00000000" }}'
# Ruby Version: 3.1.2

# Load required modules
require 'net/http'
require 'json'
require 'uri'

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call

def call_api(api_path, data)
  req_header = {        
    'Content-Type' => 'application/json',
    'Accept' => 'application/json',
    'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk'
  }
  uri = URI.parse("https://api.ekmpush.com#{api_path}")

  # Create the HTTP objects
  https = Net::HTTP.new(uri.host, uri.port)
  https.use_ssl = true
  request = Net::HTTP::Post.new(uri.request_uri, req_header)
  request.body = data

  # Send the request
  response = https.request(request)
  JSON.parse(response.body)
end

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
# URI only NOT URL - Do not include https://api.ekmpush.com
req_data = '{
  "command": "kWhReset",
  "target": "meter",
  "target_id": "000350000900",
  "params": {
    "meter_password": "00000000"
  }
}'

api_object = call_api('/sendCommand?key=MTAxMDoyMDIw', req_data)

# This just displays the object but you can use what ever
# code you would like to work with the object here
require 'pp'
pp api_object

'''
Python version: 3.9.12
'''

# Required Python Modules
import urllib.request
import urllib.error
import urllib.parse
import json
import pprint

# This function accesses the api_request URL and converts
# the contents to a usable Python object and returns it
def call_api ( api_request, data ):
    '''Make http request'''
    headers = {
        "Accept": "application/json",
        "Content-Type": "application/json",
        "Authorization": "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk"
    }
    req = urllib.request.Request(api_request, headers=headers)
    jsondata = json.dumps(data)
    json_bytes = jsondata.encode('utf-8')   # Needs to be bytes
    response = urllib.request.urlopen(req, json_bytes)
    response = response.read()
    json_object = json.loads(response.decode())
    return json_object

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call

# Request JSON Object
req_json = {
    "command": "kWhReset",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "meter_password": "00000000"
    }
}

api_object = call_api("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw", req_json)

# This just displays the object but you can use what ever
# code you would like to work with the object here
pprint.pprint(api_object)

<?php
// PHP 8.0.17 (cli)

$postData = '{
    "command": "kWhReset",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "meter_password": "00000000"
    }
}';

// Call the callApi function to create a usable
// object named $apiObject from the API request URL.
// Put the API request URL in the call
$apiObject=callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', $postData);

// This just displays the object but you can use what ever
// code you would like to work with the object here
var_dump($apiObject);

// This function accesses the apiRequest URL and converts
// the contents to a usable PHP object and returns it
function callApi($apiRequest='', $postData='')
{
    $opts = array('http' =>
        array(
            'method'  => 'POST',
            'header'  => "Content-Type: application/json\r\n".
            "Accept: application/json\r\n".
            "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk\r\n",
            'content' => $postData
        )
    );
    $context = stream_context_create($opts);
    $json = file_get_contents($apiRequest, false, $context);
    $jsonObject = json_decode($json, true);
    return ($jsonObject);
}

#!/usr/bin/perl
# Perl version: v5.34
# CPAN.pm version 2.2
# Perl Modules Version:
# JSON: 4.05
# LWP::Protocol::https: 6.10
# LWP::UserAgent: 6.43
#
# OS Prerequisites
# UBUNTU
# apt install cpanminus
#
# Install Perl Modules
#       cpan LWP::UserAgent
#       cpan LWP::Protocol::https
#       cpan JSON

# Required Perl Modules
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use Data::Dumper;

# This function accesses the api_request URL and converts
# the contents to a usable Perl object and returns it
sub call_api {
    my $req_json = {
        'target'    => 'meter',
        'target_id' => '000350000900',
        'command'   => 'kWhReset',
        'params'    => {
            'meter_password' => '00000000'
        }
    };
    my $api_request = shift;
    my $req         = HTTP::Request->new( 'POST', $api_request );
    $req->header( 'Accept' => 'application/json' );
    $req->header( 'Content-Type' => 'application/json' );
    $req->header( 'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk' );
    $req->content( encode_json $req_json );
    my $lwp         = LWP::UserAgent->new;
    my $res         = $lwp->request($req);
    my $content     = $res->decoded_content();
    my $json_object = JSON->new->utf8->decode($content);
    return $json_object;
}

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
my $api_object =
  call_api('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw');

# This just displays the object but you can use what ever
# code you would like to work with the object here
print Dumper($api_object);    ## no critic (InputOutput::RequireCheckedSyscalls)

/*
 openjdk version "17.0.2" 2022-01-18

 Download the correct org.json jar version for your
 needs from: https://mvnrepository.com/artifact/org.json/json

 This example uses version 20220320 accessible here:
 https://repo1.maven.org/maven2/org/json/json/20220320/json-20220320.jar

 Instructions to run this program

 1. Put this code in a file named EKM.java
 2. Copy the downloaded org.json jar and EKM.java to the same directory
 3. Compile
  javac -cp .:./json-20220320.jar ./EKM.java
 4. Run
  java -cp .:./json-20220320.jar EKM
*/

//Import required classes
import java.net.*;
import java.io.*;
import org.json.*;

@java.lang.SuppressWarnings({"java:S106", "java:S112", "java:S125"})

public class EKM {
    public static JSONObject callApiPost(String apiRequest) throws Exception {

        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object

        URL url = new URL(apiRequest);        
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty( "Accept", "application/json");
        connection.setRequestProperty( "Content-type", "application/json");
        connection.setRequestProperty( "Authorization", "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk");
        connection.setDoOutput(true);

        String reqData = "{\"command\": \"kWhReset\", \"target\": \"meter\", \"target_id\": \"000350000900\", \"params\": {\"meter_password\": \"00000000\"}}";
        try(OutputStream os = connection.getOutputStream()) {
            byte[] input = reqData.getBytes("utf-8");
            os.write(input, 0, input.length);
        }

        try(BufferedReader br = new BufferedReader(
            new InputStreamReader(connection.getInputStream(), "utf-8"))) {
                StringBuilder response = new StringBuilder();
                String responseLine = null;
                while ((responseLine = br.readLine()) != null) {
                    response.append(responseLine.trim());
                }
                return new JSONObject(response.toString());
            }        
    }
    public static JSONObject callApi(String apiRequest) throws Exception {
        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object
        URL url = new URL(apiRequest);
        URLConnection yc = url.openConnection();
        BufferedReader in = new BufferedReader(new InputStreamReader(
                                    yc.getInputStream()));
        String inputLine;
        while ((inputLine = in.readLine()) != null) 
            System.out.println(inputLine);
        in.close();
        return new JSONObject(inputLine.toString());
    }

    public static void main(String[] args) throws Exception {
        /*
         Call callApiPost to create a usable
         object named apiObject from the API request URL.
         Put the API request URL in the call
         */
        JSONObject apiObject = EKM.callApiPost("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw");


        // This just displays the object but you can use what ever
        // code you would like to work with the object here
        System.out.println(apiObject.toString(4));
        }
}
/*
* Requirements
* NodeJS: v16.14.2
* Axios:  0.27.2
*/

// Load modules
const axios = require('axios');

// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
  try {
    const params  = {
        "target": "meter",
        "target_id": "000350000900",
        "command": "kWhReset",
        "params": {
          "meter_password": "00000000"
        }
    }

    const res = await axios.post(
        'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', params, {
          headers: {
            'Accept': 'application/json',
            // eslint-disable-next-line max-len
            'Authorization': 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk',
          }});
    const apiResData = res.data;    
    console.log(JSON.stringify(apiResData, null, 2));
  } catch (error) {
    console.error(error.message);
  }
})();

/*
* Requirements
* NodeJS: v16.14.2
* Axios:  0.27.2
*/

// Load modules
const axios = require('axios');

// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
  try {
    const params  = {
        "target": "meter",
        "target_id": "000350000900",
        "command": "kWhReset",
        "params": {
          "meter_password": "00000000"
        }
    }

    const res = await axios.post(
        'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', params, {
          headers: {
            'Accept': 'application/json',
            // eslint-disable-next-line max-len
            'Authorization': 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk',
          }});
    const apiResData = res.data;    
    console.log(JSON.stringify(apiResData, null, 2));
  } catch (error) {
    console.error(error.message);
  }
})();

The v.4/5 Omnimeter models have a secondary kWh register that is resettable, in addition to the Total kWh register that is not resettable.

If you would like the resettable kWh register to reset to 0 kWh, the JSON Object should look like this:

{ "target": "meter", "target_id": "000350000900", "command": "kWhReset" , "params": { "meter_password": "00000000" } }

Set Relay

curl -i -X POST 'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw' -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk" --data-raw '{"command": "SetRelay", "target": "meter", "target_id": "000350000900", "params": { "Relay": "Relay_1", "Status": "close", "Duration": 1, "meter_password": "00000000"}}'
# Ruby Version: 3.1.2

# Load required modules
require 'net/http'
require 'json'
require 'uri'

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call

def call_api(api_path, data)
  req_header = {        
    'Content-Type' => 'application/json',
    'Accept' => 'application/json',
    'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk'
  }
  uri = URI.parse("https://api.ekmpush.com#{api_path}")

  # Create the HTTP objects
  https = Net::HTTP.new(uri.host, uri.port)
  https.use_ssl = true
  request = Net::HTTP::Post.new(uri.request_uri, req_header)
  request.body = data

  # Send the request
  response = https.request(request)
  JSON.parse(response.body)
end

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
# URI only NOT URL - Do not include https://api.ekmpush.com
req_data = '{
  "command": "SetRelay",
  "target": "meter",
  "target_id": "000350000900",
  "params": {
      "Relay": "Relay_1",
      "Status": "close",
      "Duration": 1,
      "meter_password": "00000000"
  }
}'

api_object = call_api('/sendCommand?key=MTAxMDoyMDIw', req_data)

# This just displays the object but you can use what ever
# code you would like to work with the object here
require 'pp'
pp api_object

'''
Python version: 3.9.12
'''

# Required Python Modules
import urllib.request
import urllib.error
import urllib.parse
import json
import pprint

# This function accesses the api_request URL and converts
# the contents to a usable Python object and returns it
def call_api ( api_request, data ):
    '''Make http request'''
    headers = {
        "Accept": "application/json",
        "Content-Type": "application/json",
        "Authorization": "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk"
    }
    req = urllib.request.Request(api_request, headers=headers)
    jsondata = json.dumps(data)
    json_bytes = jsondata.encode('utf-8')   # Needs to be bytes
    response = urllib.request.urlopen(req, json_bytes)
    response = response.read()
    json_object = json.loads(response.decode())
    return json_object

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call

# Request JSON Object
req_json = {
    "command": "SetRelay",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "Relay": "Relay_1",
        "Status": "close",
        "Duration": 1,
        "meter_password": "00000000"
    }
}

api_object = call_api("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw", req_json)

# This just displays the object but you can use what ever
# code you would like to work with the object here
pprint.pprint(api_object)

<?php
// PHP 8.0.17 (cli)

$postData = '{
    "command": "SetRelay",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "Relay": "Relay_1",
        "Status": "close",
        "Duration": 1,
        "meter_password": "00000000"
    }
}';

// Call the callApi function to create a usable
// object named $apiObject from the API request URL.
// Put the API request URL in the call
$apiObject=callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', $postData);

// This just displays the object but you can use what ever
// code you would like to work with the object here
var_dump($apiObject);

// This function accesses the apiRequest URL and converts
// the contents to a usable PHP object and returns it
function callApi($apiRequest='', $postData='')
{
    $opts = array('http' =>
        array(
            'method'  => 'POST',
            'header'  => "Content-Type: application/json\r\n".
            "Accept: application/json\r\n".
            "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk\r\n",
            'content' => $postData
        )
    );
    $context = stream_context_create($opts);
    $json = file_get_contents($apiRequest, false, $context);
    $jsonObject = json_decode($json, true);
    return ($jsonObject);
}

#!/usr/bin/perl
# Perl version: v5.34
# CPAN.pm version 2.2
# Perl Modules Version:
# JSON: 4.05
# LWP::Protocol::https: 6.10
# LWP::UserAgent: 6.43
#
# OS Prerequisites
# UBUNTU
# apt install cpanminus
#
# Install Perl Modules
#       cpan LWP::UserAgent
#       cpan LWP::Protocol::https
#       cpan JSON

# Required Perl Modules
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use Data::Dumper;

# This function accesses the api_request URL and converts
# the contents to a usable Perl object and returns it
sub call_api {
    my $req_json = {
        'target'    => 'meter',
        'target_id' => '000350000900',
        'command'   => 'SetRelay',
        'params'    => {
            'Relay' => 'Relay_1',
            'Status' => 'close',
            'Duration' => 1,
            'meter_password' => '00000000'
        }
    };
    my $api_request = shift;
    my $req         = HTTP::Request->new( 'POST', $api_request );
    $req->header( 'Accept' => 'application/json' );
    $req->header( 'Content-Type' => 'application/json' );
    $req->header( 'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk' );
    $req->content( encode_json $req_json );
    my $lwp         = LWP::UserAgent->new;
    my $res         = $lwp->request($req);
    my $content     = $res->decoded_content();
    my $json_object = JSON->new->utf8->decode($content);
    return $json_object;
}

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
my $api_object =
  call_api('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw');

# This just displays the object but you can use what ever
# code you would like to work with the object here
print Dumper($api_object);    ## no critic (InputOutput::RequireCheckedSyscalls)

/*
 openjdk version "17.0.2" 2022-01-18

 Download the correct org.json jar version for your
 needs from: https://mvnrepository.com/artifact/org.json/json

 This example uses version 20220320 accessible here:
 https://repo1.maven.org/maven2/org/json/json/20220320/json-20220320.jar

 Instructions to run this program

 1. Put this code in a file named EKM.java
 2. Copy the downloaded org.json jar and EKM.java to the same directory
 3. Compile
  javac -cp .:./json-20220320.jar ./EKM.java
 4. Run
  java -cp .:./json-20220320.jar EKM
*/

//Import required classes
import java.net.*;
import java.io.*;
import org.json.*;

@java.lang.SuppressWarnings({"java:S106", "java:S112", "java:S125"})

public class EKM {
    public static JSONObject callApiPost(String apiRequest) throws Exception {

        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object

        URL url = new URL(apiRequest);        
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty( "Accept", "application/json");
        connection.setRequestProperty( "Content-type", "application/json");
        connection.setRequestProperty( "Authorization", "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk");
        connection.setDoOutput(true);

        String reqData = "{\"command\": \"SetRelay\", \"target\": \"meter\", \"target_id\": \"000350000900\", \"params\": {\"Relay\": \"Relay_1\", \"Status\": \"close\", \"Duration\": 1, \"meter_password\": \"00000000\"}}";
        try(OutputStream os = connection.getOutputStream()) {
            byte[] input = reqData.getBytes("utf-8");
            os.write(input, 0, input.length);           
        }

        try(BufferedReader br = new BufferedReader(
            new InputStreamReader(connection.getInputStream(), "utf-8"))) {
                StringBuilder response = new StringBuilder();
                String responseLine = null;
                while ((responseLine = br.readLine()) != null) {
                    response.append(responseLine.trim());
                }
                return new JSONObject(response.toString());
            }        
    }
    public static JSONObject callApi(String apiRequest) throws Exception {
        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object
        URL url = new URL(apiRequest);
        URLConnection yc = url.openConnection();
        BufferedReader in = new BufferedReader(new InputStreamReader(
                                    yc.getInputStream()));
        String inputLine;
        while ((inputLine = in.readLine()) != null) 
            System.out.println(inputLine);
        in.close();
        return new JSONObject(inputLine.toString());
    }

    public static void main(String[] args) throws Exception {
        /*
         Call callApiPost to create a usable
         object named apiObject from the API request URL.
         Put the API request URL in the call
         */
        JSONObject apiObject = EKM.callApiPost("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw");


        // This just displays the object but you can use what ever
        // code you would like to work with the object here
        System.out.println(apiObject.toString(4));
        }
}
/*
* Requirements
* NodeJS: v16.14.2
* Axios:  0.27.2
*/

// Load modules
const axios = require('axios');

// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
  try {
    const params  = {
      "command": "SetRelay",
      "target": "meter",
      "target_id": "000350000900",
      "params": {
          "Relay": "Relay_1",
          "Status": "close",
          "Duration": 1,
          "meter_password": "00000000"
      }
  }

    const res = await axios.post(
        'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', params, {
          headers: {
            'Accept': 'application/json',
            // eslint-disable-next-line max-len
            'Authorization': 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk',
          }});
    const apiResData = res.data;    
    console.log(JSON.stringify(apiResData, null, 2));
  } catch (error) {
    console.error(error.message);
  }
})();

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">

// The example function is called from the
// body tag when the page loads
function example(){

// Call the callApi function to create a usable
// object named apiObject from the API request URL.
// Put the API request URL in the call
callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw',function(apiObject){

      // This just displays the object in the result div
      // you can use what ever code you would like to work
      // with the object here
      document.getElementById("result").innerHTML = "<pre>"+JSON.stringify(apiObject, null, 4)+"</pre>";
      });

};

// This code accesses the apiRequest URL and converts
// the contents to a usable JSON object named apiObject
function callApi(apiRequest,callback) {
    var xhttp = new XMLHttpRequest();
    const params  = {
    "command": "SetRelay",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "Relay": "Relay_1",
        "Status": "close",
        "Duration": 1,
        "meter_password": "00000000"
    }
}

    xhttp.onreadystatechange = function() {
      if (xhttp.readyState == 4 && xhttp.status == 200) {
        var jsonObject = JSON.parse(xhttp.responseText);
        callback(jsonObject);
      }
    };
    xhttp.open("POST", apiRequest, true);
    xhttp.setRequestHeader("Accept", "application/json");
    xhttp.setRequestHeader("Content-Type", "application/json");
    xhttp.setRequestHeader("Authorization", "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk");
    xhttp.send(JSON.stringify(params));
}
</script>

</head>
  <body onload="example()">
    <div id="result"> </div>
  </body>
</html>

You can set the number of seconds that you would like each relay to stay on or off.

For close Relay 1 for 1 second on meter 000350000900, we will pass the request JSON object:

{ "command": "SetRelay", "target": "meter", "target_id": "000350000900", "params": { "relay": "Relay_1", "status": "close", "duration": 1, "meter_password": "00000000" } }

JSON PARAMETERS

PARAMETER DESCRIPTION
relay (string) - the relay name (ie. “Relay_1”)
status (string) - relay state (“open” or “close”)
duration (int) - state duration in seconds. A value of 0 (zero) means hold indefinitely.

Set Schedule

curl -i -X POST 'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw' -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk" --data-raw '{"command":"SetSchedule","target":"meter","target_id":"000350000900","params":{"Schedule":4,"Hour_1":7,"Min_1":0,"Tariff_1":1,"Hour_2":22,"Min_2":0,"Tariff_2":2,"meter_password":"00000000"}}'
# Ruby Version: 3.1.2

# Load required modules
require 'net/http'
require 'json'
require 'uri'

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call

def call_api(api_path, data)
  req_header = {        
    'Content-Type' => 'application/json',
    'Accept' => 'application/json',
    'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk'
  }
  uri = URI.parse("https://api.ekmpush.com#{api_path}")

  # Create the HTTP objects
  https = Net::HTTP.new(uri.host, uri.port)
  https.use_ssl = true
  request = Net::HTTP::Post.new(uri.request_uri, req_header)
  request.body = data

  # Send the request
  response = https.request(request)
  JSON.parse(response.body)
end

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
# URI only NOT URL - Do not include https://api.ekmpush.com
req_data = '{
  "command": "SetSchedule",
  "target": "meter",
  "target_id": "000350000900",
  "params": {
      "Schedule": 4,
      "Hour_1": 7,
      "Min_1": 0,
      "Tariff_1": 1,
      "Hour_2": 22,
      "Min_2": 0,
      "Tariff_2": 2,
      "meter_password": "00000000"
  }
}'

api_object = call_api('/sendCommand?key=MTAxMDoyMDIw', req_data)

# This just displays the object but you can use what ever
# code you would like to work with the object here
require 'pp'
pp api_object

'''
Python version: 3.9.12
'''

# Required Python Modules
import urllib.request
import urllib.error
import urllib.parse
import json
import pprint

# This function accesses the api_request URL and converts
# the contents to a usable Python object and returns it
def call_api ( api_request, data ):
    '''Make http request'''
    headers = {
        "Accept": "application/json",
        "Content-Type": "application/json",
        "Authorization": "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk"
    }
    req = urllib.request.Request(api_request, headers=headers)
    jsondata = json.dumps(data)
    json_bytes = jsondata.encode('utf-8')   # Needs to be bytes
    response = urllib.request.urlopen(req, json_bytes)
    response = response.read()
    json_object = json.loads(response.decode())
    return json_object

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call

# Request JSON Object
req_json = {
    "command": "SetSchedule",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "Schedule": 4,
        "Hour_1": 7,
        "Min_1": 0,
        "Tariff_1": 1,
        "Hour_2": 22,
        "Min_2": 0,
        "Tariff_2": 2,
        "meter_password": "00000000"
    }
}

api_object = call_api("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw", req_json)

# This just displays the object but you can use what ever
# code you would like to work with the object here
pprint.pprint(api_object)

<?php
// PHP 8.0.17 (cli)

$postData = '{
    "command": "SetSchedule",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "Schedule": 4,
        "Hour_1": 7,
        "Min_1": 0,
        "Tariff_1": 1,
        "Hour_2": 22,
        "Min_2": 0,
        "Tariff_2": 2,
        "meter_password": "00000000"
    }
}';

// Call the callApi function to create a usable
// object named $apiObject from the API request URL.
// Put the API request URL in the call
$apiObject=callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', $postData);

// This just displays the object but you can use what ever
// code you would like to work with the object here
var_dump($apiObject);

// This function accesses the apiRequest URL and converts
// the contents to a usable PHP object and returns it
function callApi($apiRequest='', $postData='')
{
    $opts = array('http' =>
        array(
            'method'  => 'POST',
            'header'  => "Content-Type: application/json\r\n".
            "Accept: application/json\r\n".
            "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk\r\n",
            'content' => $postData
        )
    );
    $context = stream_context_create($opts);
    $json = file_get_contents($apiRequest, false, $context);
    $jsonObject = json_decode($json, true);
    return ($jsonObject);
}

#!/usr/bin/perl
# Perl version: v5.34
# CPAN.pm version 2.2
# Perl Modules Version:
# JSON: 4.05
# LWP::Protocol::https: 6.10
# LWP::UserAgent: 6.43
#
# OS Prerequisites
# UBUNTU
# apt install cpanminus
#
# Install Perl Modules
#       cpan LWP::UserAgent
#       cpan LWP::Protocol::https
#       cpan JSON

# Required Perl Modules
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use Data::Dumper;

# This function accesses the api_request URL and converts
# the contents to a usable Perl object and returns it
sub call_api {
    my $req_json = {
    'target'=> 'meter',
    'target_id'=> '000350000900',
    'command'=> 'SetSchedule',
    'params'=> {
        'Schedule'=> 4,
        'Hour_1'=> 7,
        'Min_1'=> 0,
        'Tariff_1'=> 1,
        'Hour_2'=> 22,
        'Min_2'=> 0,
        'Tariff_2'=> 2,
        'meter_password'=> '00000000'
        }
    };
    my $api_request = shift;
    my $req         = HTTP::Request->new( 'POST', $api_request );
    $req->header( 'Accept' => 'application/json' );
    $req->header( 'Content-Type' => 'application/json' );
    $req->header( 'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk' );
    $req->content( encode_json $req_json );
    my $lwp         = LWP::UserAgent->new;
    my $res         = $lwp->request($req);
    my $content     = $res->decoded_content();
    my $json_object = JSON->new->utf8->decode($content);
    return $json_object;
}

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
my $api_object =
  call_api('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw');

# This just displays the object but you can use what ever
# code you would like to work with the object here
print Dumper($api_object);    ## no critic (InputOutput::RequireCheckedSyscalls)

/*
 openjdk version "17.0.2" 2022-01-18

 Download the correct org.json jar version for your
 needs from: https://mvnrepository.com/artifact/org.json/json

 This example uses version 20220320 accessible here:
 https://repo1.maven.org/maven2/org/json/json/20220320/json-20220320.jar

 Instructions to run this program

 1. Put this code in a file named EKM.java
 2. Copy the downloaded org.json jar and EKM.java to the same directory
 3. Compile
  javac -cp .:./json-20220320.jar ./EKM.java
 4. Run
  java -cp .:./json-20220320.jar EKM
*/

//Import required classes
import java.net.*;
import java.io.*;
import org.json.*;

@java.lang.SuppressWarnings({"java:S106", "java:S112", "java:S125"})

public class EKM {
    public static JSONObject callApi(String apiRequest) throws Exception {

        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object

        URL url = new URL(apiRequest);        
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty( "Accept", "application/json");
        connection.setRequestProperty( "Content-type", "application/json");
        connection.setRequestProperty( "Authorization", "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk");
        connection.setDoOutput(true);

        String reqData = "{\"target\": \"meter\", \"target_id\": \"000350000900\", \"command\": \"SetSchedule\", \"params\": {\"Schedule\": 4,\"Hour_1\": 7,\"Min_1\": 0,\"Tariff_1\": 1,\"Hour_2\": 22,\"Min_2\": 0,\"Tariff_2\": 2,\"meter_password\": \"00000000\" }}";
        try(OutputStream os = connection.getOutputStream()) {
            byte[] input = reqData.getBytes("utf-8");
            os.write(input, 0, input.length);           
        }

        try(BufferedReader br = new BufferedReader(
            new InputStreamReader(connection.getInputStream(), "utf-8"))) {
                StringBuilder response = new StringBuilder();
                String responseLine = null;
                while ((responseLine = br.readLine()) != null) {
                    response.append(responseLine.trim());
                }
                return new JSONObject(response.toString());
            }        
    }    

    public static void main(String[] args) throws Exception {
        /*
         Call callApiPost to create a usable
         object named apiObject from the API request URL.
         Put the API request URL in the call
         */
        JSONObject apiObject = EKM.callApi("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw");

        // This just displays the object but you can use what ever
        // code you would like to work with the object here
        System.out.println(apiObject.toString(4));
        }
}
/*
* Requirements
* NodeJS: v16.14.2
* Axios:  0.27.2
*/

// Load modules
const axios = require('axios');

// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
  try {
    const params  = {
      "target": "meter",
      "target_id": "000350000900",
      "command": "SetSchedule",
      "params": {
        "Schedule": 4,
        "Hour_1": 7,
        "Min_1": 0,
        "Tariff_1": 1,
        "Hour_2": 22,
        "Min_2": 0,
        "Tariff_2": 2,
        "meter_password": "00000000"
        }
      }

    const res = await axios.post(
        'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', params, {
          headers: {
            'Accept': 'application/json',
            // eslint-disable-next-line max-len
            'Authorization': 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk',
          }});
    const apiResData = res.data;    
    console.log(JSON.stringify(apiResData, null, 2));
  } catch (error) {
    console.error(error.message);
  }
})();

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">

// The example function is called from the
// body tag when the page loads
function example(){

// Call the callApi function to create a usable
// object named apiObject from the API request URL.
// Put the API request URL in the call
callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw',function(apiObject){

      // This just displays the object in the result div
      // you can use what ever code you would like to work
      // with the object here
      document.getElementById("result").innerHTML = "<pre>"+JSON.stringify(apiObject, null, 4)+"</pre>";
      });

};

// This code accesses the apiRequest URL and converts
// the contents to a usable JSON object named apiObject
function callApi(apiRequest,callback) {
    var xhttp = new XMLHttpRequest();
    const params  = {
  "target": "meter",
  "target_id": "000350000900",
  "command": "SetSchedule",
  "params": {
    "Schedule": 4,
    "Hour_1": 7,
    "Min_1": 0,
    "Tariff_1": 1,
    "Hour_2": 22,
    "Min_2": 0,
    "Tariff_2": 2,
    "meter_password": "00000000"
    }
  }

    xhttp.onreadystatechange = function() {
      if (xhttp.readyState == 4 && xhttp.status == 200) {
        var jsonObject = JSON.parse(xhttp.responseText);
        callback(jsonObject);
      }
    };
    xhttp.open("POST", apiRequest, true);
    xhttp.setRequestHeader("Accept", "application/json");
    xhttp.setRequestHeader("Content-Type", "application/json");
    xhttp.setRequestHeader("Authorization", "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk");
    xhttp.send(JSON.stringify(params));
}
</script>

</head>
  <body onload="example()">
    <div id="result"> </div>
  </body>
</html>

The meter can keep track of four separate TOU tariffs (T1,T2,T3,T4) to calculate the energy used at different periods of time. For example, if your energy is more expensive from 1PM to 7PM and it is cheaper from 7PM to 11PM, the meter can separately keep track of the kWh recorded in these different periods of time. It can be set for up to 4 time periods per day and it can specify the tariff for that period (from T1 to T4). .

JSON Object to define the schedule should look like this:

{ "target": "meter", "target_id": "000350000900", "command": "SetSchedule" , "params": { "Schedule": 5, "Hour_1": 8, "Min_1": 0, "Tariff_1": 1, "Hour_2": 22, "Min_2": 0, "Tariff_2": 2, "Hour_3": 0, "Min_3": 0, "Tariff_3": 0, "Hour_4": 0, "Min_4": 0, "Tariff_4": 0, "meter_password": "00000000" } }

JSON PARAMETERS

PARAMETER DESCRIPTION
Schedule (int) You can set a schedule between 1 to 6.
Hour_[1-4] (int) Indicates the hour to set a tariff.
Min_1[1-4] (int) Indicates the minutes for an hour to set a tariff.
Tariff_1[1-4] (int) Define a tariff for the schedule.

Set Seasons

curl -i -X POST 'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw' -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk" --data-raw '{"command": "SetSeasonSchedules", "target": "meter", "target_id": "000350000900", "params": {"Season_1_Start_Day": 1, "Season_1_Start_Month": 3, "Season_1_Schedule": 1}}'
# Ruby Version: 3.1.2

# Load required modules
require 'net/http'
require 'json'
require 'uri'

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call

def call_api(api_path, data)
  req_header = {        
    'Content-Type' => 'application/json',
    'Accept' => 'application/json',
    'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk'
  }
  uri = URI.parse("https://api.ekmpush.com#{api_path}")

  # Create the HTTP objects
  https = Net::HTTP.new(uri.host, uri.port)
  https.use_ssl = true
  request = Net::HTTP::Post.new(uri.request_uri, req_header)
  request.body = data

  # Send the request
  response = https.request(request)
  JSON.parse(response.body)
end

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
# URI only NOT URL - Do not include https://api.ekmpush.com
req_data = '{
  "command": "SetSeasonSchedules",
  "target": "meter",
  "target_id": "000350000900",
  "params": {
    "Season_1_Start_Day": 1,
    "Season_1_Start_Month": 3,
    "Season_1_Schedule": 1
    }
  }'

api_object = call_api('/sendCommand?key=MTAxMDoyMDIw', req_data)

# This just displays the object but you can use what ever
# code you would like to work with the object here
require 'pp'
pp api_object

'''
Python version: 3.9.12
'''

# Required Python Modules
import urllib.request
import urllib.error
import urllib.parse
import json
import pprint

# This function accesses the api_request URL and converts
# the contents to a usable Python object and returns it
def call_api ( api_request, data ):
    '''Make http request'''
    headers = {
        "Accept": "application/json",
        "Content-Type": "application/json",
        "Authorization": "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk"
    }
    req = urllib.request.Request(api_request, headers=headers)
    jsondata = json.dumps(data)
    json_bytes = jsondata.encode('utf-8')   # Needs to be bytes
    response = urllib.request.urlopen(req, json_bytes)
    response = response.read()
    json_object = json.loads(response.decode())
    return json_object

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call

# Request JSON Object
req_json = {
    "command": "SetSeasonSchedules",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "Season_1_Start_Day": 1,
        "Season_1_Start_Month": 3,
        "Season_1_Schedule": 1
    }
}

api_object = call_api("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw", req_json)

# This just displays the object but you can use what ever
# code you would like to work with the object here
pprint.pprint(api_object)

<?php
// PHP 8.0.17 (cli)

$postData = '{
    "command": "SetSeasonSchedules",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "Season_1_Start_Day": 1,
        "Season_1_Start_Month": 3,
        "Season_1_Schedule": 1
    }
}';

// Call the callApi function to create a usable
// object named $apiObject from the API request URL.
// Put the API request URL in the call
$apiObject = callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', $postData);

// This just displays the object but you can use what ever
// code you would like to work with the object here
var_dump($apiObject);

// This function accesses the apiRequest URL and converts
// the contents to a usable PHP object and returns it
function callApi($apiRequest = '', $postData = '')
{
    $opts = array(
        'http' =>
        array(
            'method'  => 'POST',
            'header'  => "Content-Type: application/json\r\n" .
                "Accept: application/json\r\n" .
                "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk\r\n",
            'content' => $postData
        )
    );
    $context = stream_context_create($opts);
    $json = file_get_contents($apiRequest, false, $context);
    $jsonObject = json_decode($json, true);
    return ($jsonObject);
}

#!/usr/bin/perl
# Perl version: v5.34
# CPAN.pm version 2.2
# Perl Modules Version:
# JSON: 4.05
# LWP::Protocol::https: 6.10
# LWP::UserAgent: 6.43
#
# OS Prerequisites
# UBUNTU
# apt install cpanminus
#
# Install Perl Modules
#       cpan LWP::UserAgent
#       cpan LWP::Protocol::https
#       cpan JSON

# Required Perl Modules
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use Data::Dumper;

# This function accesses the api_request URL and converts
# the contents to a usable Perl object and returns it
sub call_api {
    my $req_json = {
    'target'=> 'meter',
    'target_id'=> '000350000900',
    'command'=> 'SetSeasonSchedules',
    'params'=> {
        'Season_1_Start_Day'=> 1,
        'Season_1_Start_Month'=> 3,
        'Season_1_Schedule'=> 1,
        }
    };
    my $api_request = shift;
    my $req         = HTTP::Request->new( 'POST', $api_request );
    $req->header( 'Accept' => 'application/json' );
    $req->header( 'Content-Type' => 'application/json' );
    $req->header( 'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk' );
    $req->content( encode_json $req_json );
    my $lwp         = LWP::UserAgent->new;
    my $res         = $lwp->request($req);
    my $content     = $res->decoded_content();
    my $json_object = JSON->new->utf8->decode($content);
    return $json_object;
}

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
my $api_object =
  call_api('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw');

# This just displays the object but you can use what ever
# code you would like to work with the object here
print Dumper($api_object);    ## no critic (InputOutput::RequireCheckedSyscalls)

/*
 openjdk version "17.0.2" 2022-01-18

 Download the correct org.json jar version for your
 needs from: https://mvnrepository.com/artifact/org.json/json

 This example uses version 20220320 accessible here:
 https://repo1.maven.org/maven2/org/json/json/20220320/json-20220320.jar

 Instructions to run this program

 1. Put this code in a file named EKM.java
 2. Copy the downloaded org.json jar and EKM.java to the same directory
 3. Compile
  javac -cp .:./json-20220320.jar ./EKM.java
 4. Run
  java -cp .:./json-20220320.jar EKM
*/

//Import required classes
import java.net.*;
import java.io.*;
import org.json.*;

@java.lang.SuppressWarnings({"java:S106", "java:S112", "java:S125"})

public class EKM {
    public static JSONObject callApi(String apiRequest) throws Exception {

        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object

        URL url = new URL(apiRequest);        
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty( "Accept", "application/json");
        connection.setRequestProperty( "Content-type", "application/json");
        connection.setRequestProperty( "Authorization", "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk");
        connection.setDoOutput(true);

        String reqData = "{\"target\": \"meter\", \"target_id\": \"MTAxMDoyMDIw\", \"command\": \"SetSeasonSchedules\", \"params\": {\"Season_1_Start_Day\": 1,\"Season_1_Start_Month\": 3,\"Season_1_Schedule\": 1 }}";
        try(OutputStream os = connection.getOutputStream()) {
            byte[] input = reqData.getBytes("utf-8");
            os.write(input, 0, input.length);           
        }

        try(BufferedReader br = new BufferedReader(
            new InputStreamReader(connection.getInputStream(), "utf-8"))) {
                StringBuilder response = new StringBuilder();
                String responseLine = null;
                while ((responseLine = br.readLine()) != null) {
                    response.append(responseLine.trim());
                }
                return new JSONObject(response.toString());
            }        
    }    

    public static void main(String[] args) throws Exception {
        /*
         Call callApiPost to create a usable
         object named apiObject from the API request URL.
         Put the API request URL in the call
         */
        JSONObject apiObject = EKM.callApi("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw");

        // This just displays the object but you can use what ever
        // code you would like to work with the object here
        System.out.println(apiObject.toString(4));
        }
}
/*
* Requirements
* NodeJS: v20.10.0
* Axios:  0.27.2
*/

// Load modules
const axios = require('axios');

// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
  try {
    const params  = {
      "target": "meter",
      "target_id": "000350000900",
      "command": "SetSeasonSchedules",
      "params": {
        "Season_1_Start_Day": 1,
        "Season_1_Start_Month": 3,
        "Season_1_Schedule": 1
      }
    }

    const res = await axios.post(
        'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', params, {
          headers: {
            'Accept': 'application/json',
            // eslint-disable-next-line max-len
            'Authorization': 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk',
          }});
    const apiResData = res.data;    
    console.log(JSON.stringify(apiResData, null, 2));
  } catch (error) {
    console.error(error.message);
  }
})();

<!DOCTYPE html>
<html>
  <head>
    <script type="text/javascript">
      // The example function is called from the
      // body tag when the page loads
      function example() {
        // Call the callApi function to create a usable
        // object named apiObject from the API request URL.
        // Put the API request URL in the call
        callApi(
          "https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw",
          function (apiObject) {
            // This just displays the object in the result div
            // you can use what ever code you would like to work
            // with the object here
            document.getElementById("result").innerHTML =
              "<pre>" + JSON.stringify(apiObject, null, 4) + "</pre>";
          }
        );
      }

      // This code accesses the apiRequest URL and converts
      // the contents to a usable JSON object named apiObject
      function callApi(apiRequest, callback) {
        var xhttp = new XMLHttpRequest();
        const params = {
          target: "meter",
          target_id: "000350000900",
          command: "SetSeasonSchedules",
          params: {
            Season_1_Start_Day: 1,
            Season_1_Start_Month: 3,
            Season_1_Schedule: 1,
          },
        };

        xhttp.onreadystatechange = function () {
          if (xhttp.readyState == 4 && xhttp.status == 200) {
            var jsonObject = JSON.parse(xhttp.responseText);
            callback(jsonObject);
          }
        };
        xhttp.open("POST", apiRequest, true);
        xhttp.setRequestHeader("Accept", "application/json");
        xhttp.setRequestHeader("Content-Type", "application/json");
        xhttp.setRequestHeader(
          "Authorization",
          "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk"
        );
        xhttp.send(JSON.stringify(params));
      }
    </script>
  </head>
  <body onload="example()">
    <div id="result"></div>
  </body>
</html>

Define the start month and day for each of the four seasons and assign a schedule to each.

To set it, your JSON object should look like this:

{ "target": "meter", "target_id": "000350000900", "command": "SetSeasonSchedules" , "params": { "Season_1_Start_Day": 1, "Season_1_Start_Month": 3, "Season_1_Schedule: 1 } }

In the example above, Season 1 is set to start on Day 1 of Month 3 (March), and Schedule 1 is assigned to this season.

If you want to add another season, you need to keep the existing one and add the new season. { "target": "meter", "target_id": "000350000900", "command": "SetSeasonSchedules" , "params": { "Season_1_Start_Day": 1, "Season_1_Start_Month": 3, "Season_1_Schedule: 1, "Season_2_Start_Day": 1, "Season_2_Start_Month": 6, "Season_2_Schedule: 2 } }

In the example above, Season 1 is set to start on Day 1 of Month 3 (March), and Schedule 1 is assigned to this season. Season 2 is set to start on Day 1 of Month 6 (June), and Schedule 2 is assigned to this season.

PARAMETER DESCRIPTION
Season_[1-4]_Start_Day (int) - Indicates the day. Example: 1, for the day 1. Days are numbered from 1 to 31 and Season is numbered from 1 to 4.
Season_[1-4]_Start_Month (int) - Indicates the month. Example: 3, for the month of March. Months are numbered from 1 to 12 and Season is numbered from 1 to 4.
Season_[1-4]_Schedule (int) - Indicates the schedule to set. Example: 4, for schedule 4. Schedules are numbered from 1 to 6 and Season is numbered from 1 to 4.

Set Holiday Date

curl -i -X POST 'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw' -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk" --data-raw '{ "command": "SetHolidayDates", "target": "meter", "target_id": "000350000900", "params": { "Holiday_1_Month": "1", "Holiday_1_Day": "21", "Holiday_2_Month": 0, "Holiday_2_Day": 0, "Holiday_3_Month": 0, "Holiday_3_Day": 0, "Holiday_4_Month": 0, "Holiday_4_Day": 0, "Holiday_5_Month": 0, "Holiday_5_Day": 0, "Holiday_6_Month": 0, "Holiday_6_Day": 0, "Holiday_7_Month": 0, "Holiday_7_Day": 0, "Holiday_8_Month": 0, "Holiday_8_Day": 0, "Holiday_9_Month": 0, "Holiday_9_Day": 0, "Holiday_10_Month": 0, "Holiday_10_Day": 0, "Holiday_11_Month": 0, "Holiday_11_Day": 0, "Holiday_12_Month": 0, "Holiday_12_Day": 0, "Holiday_13_Month": 0, "Holiday_13_Day": 0, "Holiday_14_Month": 0, "Holiday_14_Day": 0, "Holiday_15_Month": 0, "Holiday_15_Day": 0, "Holiday_16_Month": 0, "Holiday_16_Day": 0, "Holiday_17_Month": 0, "Holiday_17_Day": 0, "Holiday_18_Month": 0, "Holiday_18_Day": 0, "Holiday_19_Month": 0, "Holiday_19_Day": 0, "Holiday_20_Month": 0, "Holiday_20_Day": 0, "meter_password": "00000000" }}'
# Ruby Version: 3.1.2

# Load required modules
require 'net/http'
require 'json'
require 'uri'

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call

def call_api(api_path, data)
  req_header = {        
    'Content-Type' => 'application/json',
    'Accept' => 'application/json',
    'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk'
  }
  uri = URI.parse("https://api.ekmpush.com#{api_path}")

  # Create the HTTP objects
  https = Net::HTTP.new(uri.host, uri.port)
  https.use_ssl = true
  request = Net::HTTP::Post.new(uri.request_uri, req_header)
  request.body = data

  # Send the request
  response = https.request(request)
  JSON.parse(response.body)
end

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
# URI only NOT URL - Do not include https://api.ekmpush.com
req_data = '{
  "command": "SetHolidayDates",
  "target": "meter",
  "target_id": "000350000900",
  "params": {
      "Holiday_1_Month": "1",
      "Holiday_1_Day": "21",
      "Holiday_2_Month": 0,
      "Holiday_2_Day": 0,
      "Holiday_3_Month": 0,
      "Holiday_3_Day": 0,
      "Holiday_4_Month": 0,
      "Holiday_4_Day": 0,
      "Holiday_5_Month": 0,
      "Holiday_5_Day": 0,
      "Holiday_6_Month": 0,
      "Holiday_6_Day": 0,
      "Holiday_7_Month": 0,
      "Holiday_7_Day": 0,
      "Holiday_8_Month": 0,
      "Holiday_8_Day": 0,
      "Holiday_9_Month": 0,
      "Holiday_9_Day": 0,
      "Holiday_10_Month": 0,
      "Holiday_10_Day": 0,
      "Holiday_11_Month": 0,
      "Holiday_11_Day": 0,
      "Holiday_12_Month": 0,
      "Holiday_12_Day": 0,
      "Holiday_13_Month": 0,
      "Holiday_13_Day": 0,
      "Holiday_14_Month": 0,
      "Holiday_14_Day": 0,
      "Holiday_15_Month": 0,
      "Holiday_15_Day": 0,
      "Holiday_16_Month": 0,
      "Holiday_16_Day": 0,
      "Holiday_17_Month": 0,
      "Holiday_17_Day": 0,
      "Holiday_18_Month": 0,
      "Holiday_18_Day": 0,
      "Holiday_19_Month": 0,
      "Holiday_19_Day": 0,
      "Holiday_20_Month": 0,
      "Holiday_20_Day": 0,
      "meter_password": "00000000"
  }
}'

api_object = call_api('/sendCommand?key=MTAxMDoyMDIw', req_data)

# This just displays the object but you can use what ever
# code you would like to work with the object here
require 'pp'
pp api_object

'''
Python version: 3.9.12
'''

# Required Python Modules
import urllib.request
import urllib.error
import urllib.parse
import json
import pprint

# This function accesses the api_request URL and converts
# the contents to a usable Python object and returns it
def call_api ( api_request, data ):
    '''Make http request'''
    headers = {
        "Accept": "application/json",
        "Content-Type": "application/json",
        "Authorization": "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk"
    }
    req = urllib.request.Request(api_request, headers=headers)
    jsondata = json.dumps(data)
    json_bytes = jsondata.encode('utf-8')   # Needs to be bytes
    response = urllib.request.urlopen(req, json_bytes)
    response = response.read()
    json_object = json.loads(response.decode())
    return json_object

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call

# Request JSON Object
req_json = {
    "command": "SetHolidayDates",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "Holiday_1_Month": "1",
        "Holiday_1_Day": "21",
        "Holiday_2_Month": 0,
        "Holiday_2_Day": 0,
        "Holiday_3_Month": 0,
        "Holiday_3_Day": 0,
        "Holiday_4_Month": 0,
        "Holiday_4_Day": 0,
        "Holiday_5_Month": 0,
        "Holiday_5_Day": 0,
        "Holiday_6_Month": 0,
        "Holiday_6_Day": 0,
        "Holiday_7_Month": 0,
        "Holiday_7_Day": 0,
        "Holiday_8_Month": 0,
        "Holiday_8_Day": 0,
        "Holiday_9_Month": 0,
        "Holiday_9_Day": 0,
        "Holiday_10_Month": 0,
        "Holiday_10_Day": 0,
        "Holiday_11_Month": 0,
        "Holiday_11_Day": 0,
        "Holiday_12_Month": 0,
        "Holiday_12_Day": 0,
        "Holiday_13_Month": 0,
        "Holiday_13_Day": 0,
        "Holiday_14_Month": 0,
        "Holiday_14_Day": 0,
        "Holiday_15_Month": 0,
        "Holiday_15_Day": 0,
        "Holiday_16_Month": 0,
        "Holiday_16_Day": 0,
        "Holiday_17_Month": 0,
        "Holiday_17_Day": 0,
        "Holiday_18_Month": 0,
        "Holiday_18_Day": 0,
        "Holiday_19_Month": 0,
        "Holiday_19_Day": 0,
        "Holiday_20_Month": 0,
        "Holiday_20_Day": 0,
        "meter_password": "00000000"
    }
}

api_object = call_api("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw", req_json)

# This just displays the object but you can use what ever
# code you would like to work with the object here
pprint.pprint(api_object)

<?php
// PHP 8.0.17 (cli)

$postData = '{
    "command": "SetHolidayDates",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "Holiday_1_Month": "1",
        "Holiday_1_Day": "21",
        "Holiday_2_Month": 0,
        "Holiday_2_Day": 0,
        "Holiday_3_Month": 0,
        "Holiday_3_Day": 0,
        "Holiday_4_Month": 0,
        "Holiday_4_Day": 0,
        "Holiday_5_Month": 0,
        "Holiday_5_Day": 0,
        "Holiday_6_Month": 0,
        "Holiday_6_Day": 0,
        "Holiday_7_Month": 0,
        "Holiday_7_Day": 0,
        "Holiday_8_Month": 0,
        "Holiday_8_Day": 0,
        "Holiday_9_Month": 0,
        "Holiday_9_Day": 0,
        "Holiday_10_Month": 0,
        "Holiday_10_Day": 0,
        "Holiday_11_Month": 0,
        "Holiday_11_Day": 0,
        "Holiday_12_Month": 0,
        "Holiday_12_Day": 0,
        "Holiday_13_Month": 0,
        "Holiday_13_Day": 0,
        "Holiday_14_Month": 0,
        "Holiday_14_Day": 0,
        "Holiday_15_Month": 0,
        "Holiday_15_Day": 0,
        "Holiday_16_Month": 0,
        "Holiday_16_Day": 0,
        "Holiday_17_Month": 0,
        "Holiday_17_Day": 0,
        "Holiday_18_Month": 0,
        "Holiday_18_Day": 0,
        "Holiday_19_Month": 0,
        "Holiday_19_Day": 0,
        "Holiday_20_Month": 0,
        "Holiday_20_Day": 0,
        "meter_password": "00000000"
    }
}';

// Call the callApi function to create a usable
// object named $apiObject from the API request URL.
// Put the API request URL in the call
$apiObject=callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', $postData);

// This just displays the object but you can use what ever
// code you would like to work with the object here
var_dump($apiObject);

// This function accesses the apiRequest URL and converts
// the contents to a usable PHP object and returns it
function callApi($apiRequest='', $postData='')
{
    $opts = array('http' =>
        array(
            'method'  => 'POST',
            'header'  => "Content-Type: application/json\r\n".
            "Accept: application/json\r\n".
            "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk\r\n",
            'content' => $postData
        )
    );
    $context = stream_context_create($opts);
    $json = file_get_contents($apiRequest, false, $context);
    $jsonObject = json_decode($json, true);
    return ($jsonObject);
}

#!/usr/bin/perl
# Perl version: v5.34
# CPAN.pm version 2.2
# Perl Modules Version:
# JSON: 4.05
# LWP::Protocol::https: 6.10
# LWP::UserAgent: 6.43
#
# OS Prerequisites
# UBUNTU
# apt install cpanminus
#
# Install Perl Modules
#       cpan LWP::UserAgent
#       cpan LWP::Protocol::https
#       cpan JSON

# Required Perl Modules
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use Data::Dumper;

# This function accesses the api_request URL and converts
# the contents to a usable Perl object and returns it
sub call_api {
    my $req_json = {
        'command'   => 'SetHolidayDates',
        'target'    => 'meter',
        'target_id' => '000350000900',
        'params'    => {
            'Holiday_1_Month'  => '1',
            'Holiday_1_Day'    => '21',
            'Holiday_2_Month'  => 0,
            'Holiday_2_Day'    => 0,
            'Holiday_3_Month'  => 0,
            'Holiday_3_Day'    => 0,
            'Holiday_4_Month'  => 0,
            'Holiday_4_Day'    => 0,
            'Holiday_5_Month'  => 0,
            'Holiday_5_Day'    => 0,
            'Holiday_6_Month'  => 0,
            'Holiday_6_Day'    => 0,
            'Holiday_7_Month'  => 0,
            'Holiday_7_Day'    => 0,
            'Holiday_8_Month'  => 0,
            'Holiday_8_Day'    => 0,
            'Holiday_9_Month'  => 0,
            'Holiday_9_Day'    => 0,
            'Holiday_10_Month' => 0,
            'Holiday_10_Day'   => 0,
            'Holiday_11_Month' => 0,
            'Holiday_11_Day'   => 0,
            'Holiday_12_Month' => 0,
            'Holiday_12_Day'   => 0,
            'Holiday_13_Month' => 0,
            'Holiday_13_Day'   => 0,
            'Holiday_14_Month' => 0,
            'Holiday_14_Day'   => 0,
            'Holiday_15_Month' => 0,
            'Holiday_15_Day'   => 0,
            'Holiday_16_Month' => 0,
            'Holiday_16_Day'   => 0,
            'Holiday_17_Month' => 0,
            'Holiday_17_Day'   => 0,
            'Holiday_18_Month' => 0,
            'Holiday_18_Day'   => 0,
            'Holiday_19_Month' => 0,
            'Holiday_19_Day'   => 0,
            'Holiday_20_Month' => 0,
            'Holiday_20_Day'   => 0,
            'meter_password'   => '00000000'
        }
    };
    my $api_request = shift;
    my $req         = HTTP::Request->new( 'POST', $api_request );
    $req->header( 'Accept' => 'application/json' );
    $req->header( 'Content-Type' => 'application/json' );
    $req->header( 'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk' );
    $req->content( encode_json $req_json );
    my $lwp         = LWP::UserAgent->new;
    my $res         = $lwp->request($req);
    my $content     = $res->decoded_content();
    my $json_object = JSON->new->utf8->decode($content);
    return $json_object;
}

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
my $api_object =
  call_api('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw');

# This just displays the object but you can use what ever
# code you would like to work with the object here
print Dumper($api_object);    ## no critic (InputOutput::RequireCheckedSyscalls)

/*
 openjdk version "17.0.2" 2022-01-18

 Download the correct org.json jar version for your
 needs from: https://mvnrepository.com/artifact/org.json/json

 This example uses version 20220320 accessible here:
 https://repo1.maven.org/maven2/org/json/json/20220320/json-20220320.jar

 Instructions to run this program

 1. Put this code in a file named EKM.java
 2. Copy the downloaded org.json jar and EKM.java to the same directory
 3. Compile
  javac -cp .:./json-20220320.jar ./EKM.java
 4. Run
  java -cp .:./json-20220320.jar EKM
*/

//Import required classes
import java.net.*;
import java.io.*;
import org.json.*;

@java.lang.SuppressWarnings({"java:S106", "java:S112", "java:S125"})

public class EKM {
    public static JSONObject callApi(String apiRequest) throws Exception {

        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object

        URL url = new URL(apiRequest);        
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty( "Accept", "application/json");
        connection.setRequestProperty( "Content-type", "application/json");
        connection.setRequestProperty( "Authorization", "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk");
        connection.setDoOutput(true);

        String reqData = "{\"command\": \"SetHolidayDates\",\"target\": \"meter\",\"target_id\": \"000350000900\",\"params\": { \"Holiday_1_Month\": \"1\", \"Holiday_1_Day\": \"21\", \"Holiday_2_Month\": 0, \"Holiday_2_Day\": 0, \"Holiday_3_Month\": 0, \"Holiday_3_Day\": 0, \"Holiday_4_Month\": 0, \"Holiday_4_Day\": 0, \"Holiday_5_Month\": 0, \"Holiday_5_Day\": 0, \"Holiday_6_Month\": 0, \"Holiday_6_Day\": 0, \"Holiday_7_Month\": 0, \"Holiday_7_Day\": 0, \"Holiday_8_Month\": 0, \"Holiday_8_Day\": 0, \"Holiday_9_Month\": 0, \"Holiday_9_Day\": 0, \"Holiday_10_Month\": 0, \"Holiday_10_Day\": 0, \"Holiday_11_Month\": 0, \"Holiday_11_Day\": 0, \"Holiday_12_Month\": 0, \"Holiday_12_Day\": 0, \"Holiday_13_Month\": 0, \"Holiday_13_Day\": 0, \"Holiday_14_Month\": 0, \"Holiday_14_Day\": 0, \"Holiday_15_Month\": 0, \"Holiday_15_Day\": 0, \"Holiday_16_Month\": 0, \"Holiday_16_Day\": 0, \"Holiday_17_Month\": 0, \"Holiday_17_Day\": 0, \"Holiday_18_Month\": 0, \"Holiday_18_Day\": 0, \"Holiday_19_Month\": 0, \"Holiday_19_Day\": 0, \"Holiday_20_Month\": 0, \"Holiday_20_Day\": 0, \"meter_password\": \"00000000\"}}";
        try(OutputStream os = connection.getOutputStream()) {
            byte[] input = reqData.getBytes("utf-8");
            os.write(input, 0, input.length);           
        }

        try(BufferedReader br = new BufferedReader(
            new InputStreamReader(connection.getInputStream(), "utf-8"))) {
                StringBuilder response = new StringBuilder();
                String responseLine = null;
                while ((responseLine = br.readLine()) != null) {
                    response.append(responseLine.trim());
                }
                return new JSONObject(response.toString());
            }        
    }

    public static void main(String[] args) throws Exception {
        /*
         Call callApiPost to create a usable
         object named apiObject from the API request URL.
         Put the API request URL in the call
         */
        JSONObject apiObject = EKM.callApi("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw");


        // This just displays the object but you can use what ever
        // code you would like to work with the object here
        System.out.println(apiObject.toString(4));
        }
}
/*
* Requirements
* NodeJS: v16.14.2
* Axios:  0.27.2
*/

// Load modules
const axios = require('axios');

// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
  try {
    const params  = {
      "command": "SetHolidayDates",
      "target": "meter",
      "target_id": "000350000900",
      "params": {
          "Holiday_1_Month": "1",
          "Holiday_1_Day": "21",
          "Holiday_2_Month": 0,
          "Holiday_2_Day": 0,
          "Holiday_3_Month": 0,
          "Holiday_3_Day": 0,
          "Holiday_4_Month": 0,
          "Holiday_4_Day": 0,
          "Holiday_5_Month": 0,
          "Holiday_5_Day": 0,
          "Holiday_6_Month": 0,
          "Holiday_6_Day": 0,
          "Holiday_7_Month": 0,
          "Holiday_7_Day": 0,
          "Holiday_8_Month": 0,
          "Holiday_8_Day": 0,
          "Holiday_9_Month": 0,
          "Holiday_9_Day": 0,
          "Holiday_10_Month": 0,
          "Holiday_10_Day": 0,
          "Holiday_11_Month": 0,
          "Holiday_11_Day": 0,
          "Holiday_12_Month": 0,
          "Holiday_12_Day": 0,
          "Holiday_13_Month": 0,
          "Holiday_13_Day": 0,
          "Holiday_14_Month": 0,
          "Holiday_14_Day": 0,
          "Holiday_15_Month": 0,
          "Holiday_15_Day": 0,
          "Holiday_16_Month": 0,
          "Holiday_16_Day": 0,
          "Holiday_17_Month": 0,
          "Holiday_17_Day": 0,
          "Holiday_18_Month": 0,
          "Holiday_18_Day": 0,
          "Holiday_19_Month": 0,
          "Holiday_19_Day": 0,
          "Holiday_20_Month": 0,
          "Holiday_20_Day": 0,
          "meter_password": "00000000"
      }
    }

    const res = await axios.post(
        'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', params, {
          headers: {
            'Accept': 'application/json',
            // eslint-disable-next-line max-len
            'Authorization': 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk',
          }});
    const apiResData = res.data;    
    console.log(JSON.stringify(apiResData, null, 2));
  } catch (error) {
    console.error(error.message);
  }
})();

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">

// The example function is called from the
// body tag when the page loads
function example(){

// Call the callApi function to create a usable
// object named apiObject from the API request URL.
// Put the API request URL in the call
callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw',function(apiObject){

      // This just displays the object in the result div
      // you can use what ever code you would like to work
      // with the object here
      document.getElementById("result").innerHTML = "<pre>"+JSON.stringify(apiObject, null, 4)+"</pre>";
      });

};

// This code accesses the apiRequest URL and converts
// the contents to a usable JSON object named apiObject
function callApi(apiRequest,callback) {
    var xhttp = new XMLHttpRequest();
    const params  = {
      "command": "SetHolidayDates",
      "target": "meter",
      "target_id": "000350000900",
      "params": {
        "Holiday_1_Month": "1",
        "Holiday_1_Day": "21",
        "Holiday_2_Month": 0,
        "Holiday_2_Day": 0,
        "Holiday_3_Month": 0,
        "Holiday_3_Day": 0,
        "Holiday_4_Month": 0,
        "Holiday_4_Day": 0,
        "Holiday_5_Month": 0,
        "Holiday_5_Day": 0,
        "Holiday_6_Month": 0,
        "Holiday_6_Day": 0,
        "Holiday_7_Month": 0,
        "Holiday_7_Day": 0,
        "Holiday_8_Month": 0,
        "Holiday_8_Day": 0,
        "Holiday_9_Month": 0,
        "Holiday_9_Day": 0,
        "Holiday_10_Month": 0,
        "Holiday_10_Day": 0,
        "Holiday_11_Month": 0,
        "Holiday_11_Day": 0,
        "Holiday_12_Month": 0,
        "Holiday_12_Day": 0,
        "Holiday_13_Month": 0,
        "Holiday_13_Day": 0,
        "Holiday_14_Month": 0,
        "Holiday_14_Day": 0,
        "Holiday_15_Month": 0,
        "Holiday_15_Day": 0,
        "Holiday_16_Month": 0,
        "Holiday_16_Day": 0,
        "Holiday_17_Month": 0,
        "Holiday_17_Day": 0,
        "Holiday_18_Month": 0,
        "Holiday_18_Day": 0,
        "Holiday_19_Month": 0,
        "Holiday_19_Day": 0,
        "Holiday_20_Month": 0,
        "Holiday_20_Day": 0,
        "meter_password": "00000000"
      }
    }

    xhttp.onreadystatechange = function() {
      if (xhttp.readyState == 4 && xhttp.status == 200) {
        var jsonObject = JSON.parse(xhttp.responseText);
        callback(jsonObject);
      }
    };
    xhttp.open("POST", apiRequest, true);
    xhttp.setRequestHeader("Accept", "application/json");
    xhttp.setRequestHeader("Content-Type", "application/json");
    xhttp.setRequestHeader("Authorization", "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk");
    xhttp.send(JSON.stringify(params));
}
</script>

</head>
  <body onload="example()">
    <div id="result"> </div>
  </body>
</html>

This endpoint let you program up to twenty holidays if the TOU tariffs change throughout the year. You will need to refer to your utility bill to determine your TOU tariffs and what other settings might apply in your case.

To set January 21 as a holiday date the JSON Object should look like this:

{ "target": "meter", "target_id": "000350000900", "command": "SetHolidayDates" , "params": { "Holiday_1_Month": "1", "Holiday_1_Day": "21", "Holiday_2_Day": 0, "Holiday_3_Month": 0, "Holiday_3_Day": 0, "Holiday_4_Month": 0, "Holiday_4_Day": 0, "Holiday_5_Month": 0, "Holiday_5_Day": 0, "Holiday_6_Month": 0, "Holiday_6_Day": 0, "Holiday_7_Month": 0, "Holiday_7_Day": 0, "Holiday_8_Month": 0, "Holiday_8_Day": 0, "Holiday_9_Month": 0, "Holiday_9_Day": 0, "Holiday_10_Month": 0, "Holiday_10_Day": 0, "Holiday_11_Month": 0, "Holiday_11_Day": 0, "Holiday_12_Month": 0, "Holiday_12_Day": 0, "Holiday_13_Month": 0, "Holiday_13_Day": 0, "Holiday_14_Month": 0, "Holiday_14_Day": 0, "Holiday_15_Month": 0, "Holiday_15_Day": 0, "Holiday_16_Month": 0, "Holiday_16_Day": 0, "Holiday_17_Month": 0, "Holiday_17_Day": 0, "Holiday_18_Month": 0, "Holiday_18_Day": 0, "Holiday_19_Month": 0, "Holiday_19_Day": 0, "Holiday_20_Month": 0, "Holiday_20_Day": 0, "meter_password": "00000000" } }

JSON PARAMETERS

PARAMETER DESCRIPTION
Holiday_[1-20]_Month (int) - Indicates the month of the holiday. Example: 1, for January.
Holiday_[1-20]_Day (int) - Indicates the day of the month. Example: 21, for January 21.

Set Weekend Holiday Schedules

curl -i -X POST 'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw' -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk" --data-raw '{ "command": "SetWeekendHolidaySchedules", "target": "meter", "target_id": "000350000900", "params": {"Weekend_Schedule": "1","Holiday_Schedule": "4","meter_password": "00000000" }}'
# Ruby Version: 3.1.2

# Load required modules
require 'net/http'
require 'json'
require 'uri'

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call

def call_api(api_path, data)
  req_header = {        
    'Content-Type' => 'application/json',
    'Accept' => 'application/json',
    'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk'
  }
  uri = URI.parse("https://api.ekmpush.com#{api_path}")

  # Create the HTTP objects
  https = Net::HTTP.new(uri.host, uri.port)
  https.use_ssl = true
  request = Net::HTTP::Post.new(uri.request_uri, req_header)
  request.body = data

  # Send the request
  response = https.request(request)
  JSON.parse(response.body)
end

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
# URI only NOT URL - Do not include https://api.ekmpush.com
req_data = '{
  "command": "SetWeekendHolidaySchedules",
  "target": "meter",
  "target_id": "000350000900",
  "params": {
      "Weekend_Schedule": "1",
      "Holiday_Schedule": "4",
      "meter_password": "00000000"
  }
}'

api_object = call_api('/sendCommand?key=MTAxMDoyMDIw', req_data)

# This just displays the object but you can use what ever
# code you would like to work with the object here
require 'pp'
pp api_object

'''
Python version: 3.9.12
'''

# Required Python Modules
import urllib.request
import urllib.error
import urllib.parse
import json
import pprint

# This function accesses the api_request URL and converts
# the contents to a usable Python object and returns it
def call_api ( api_request, data ):
    '''Make http request'''
    headers = {
        "Accept": "application/json",
        "Content-Type": "application/json",
        "Authorization": "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk"
    }
    req = urllib.request.Request(api_request, headers=headers)
    jsondata = json.dumps(data)
    json_bytes = jsondata.encode('utf-8')   # Needs to be bytes
    response = urllib.request.urlopen(req, json_bytes)
    response = response.read()
    json_object = json.loads(response.decode())
    return json_object

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call

# Request JSON Object
req_json = {
    "command": "SetWeekendHolidaySchedules",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "Weekend_Schedule": "1",
        "Holiday_Schedule": "4",
        "meter_password": "00000000"
    }
}

api_object = call_api("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw", req_json)

# This just displays the object but you can use what ever
# code you would like to work with the object here
pprint.pprint(api_object)

<?php
// PHP 8.0.17 (cli)

$postData = '{
    "command": "SetWeekendHolidaySchedules",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "Weekend_Schedule": "1",
        "Holiday_Schedule": "4",
        "meter_password": "00000000"
    }
}';

// Call the callApi function to create a usable
// object named $apiObject from the API request URL.
// Put the API request URL in the call
$apiObject=callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', $postData);

// This just displays the object but you can use what ever
// code you would like to work with the object here
var_dump($apiObject);

// This function accesses the apiRequest URL and converts
// the contents to a usable PHP object and returns it
function callApi($apiRequest='', $postData='')
{
    $opts = array('http' =>
        array(
            'method'  => 'POST',
            'header'  => "Content-Type: application/json\r\n".
            "Accept: application/json\r\n".
            "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk\r\n",
            'content' => $postData
        )
    );
    $context = stream_context_create($opts);
    $json = file_get_contents($apiRequest, false, $context);
    $jsonObject = json_decode($json, true);
    return ($jsonObject);
}

#!/usr/bin/perl
# Perl version: v5.34
# CPAN.pm version 2.2
# Perl Modules Version:
# JSON: 4.05
# LWP::Protocol::https: 6.10
# LWP::UserAgent: 6.43
#
# OS Prerequisites
# UBUNTU
# apt install cpanminus
#
# Install Perl Modules
#       cpan LWP::UserAgent
#       cpan LWP::Protocol::https
#       cpan JSON

# Required Perl Modules
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use Data::Dumper;

# This function accesses the api_request URL and converts
# the contents to a usable Perl object and returns it
sub call_api {
    my $req_json = {
        'command'   => 'SetWeekendHolidaySchedules',
        'target'    => 'meter',
        'target_id' => '000350000900',
        'params'    => {
            'Weekend_Schedule' => '1',
            'Holiday_Schedule' => '4',
            'meter_password'   => '00000000'
        }
    };
    my $api_request = shift;
    my $req         = HTTP::Request->new( 'POST', $api_request );
    $req->header( 'Accept' => 'application/json' );
    $req->header( 'Content-Type' => 'application/json' );
    $req->header( 'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk' );
    $req->content( encode_json $req_json );
    my $lwp         = LWP::UserAgent->new;
    my $res         = $lwp->request($req);
    my $content     = $res->decoded_content();
    my $json_object = JSON->new->utf8->decode($content);
    return $json_object;
}

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
my $api_object =
  call_api('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw');

# This just displays the object but you can use what ever
# code you would like to work with the object here
print Dumper($api_object);    ## no critic (InputOutput::RequireCheckedSyscalls)

/*
 openjdk version "17.0.2" 2022-01-18

 Download the correct org.json jar version for your
 needs from: https://mvnrepository.com/artifact/org.json/json

 This example uses version 20220320 accessible here:
 https://repo1.maven.org/maven2/org/json/json/20220320/json-20220320.jar

 Instructions to run this program

 1. Put this code in a file named EKM.java
 2. Copy the downloaded org.json jar and EKM.java to the same directory
 3. Compile
  javac -cp .:./json-20220320.jar ./EKM.java
 4. Run
  java -cp .:./json-20220320.jar EKM
*/

//Import required classes
import java.net.*;
import java.io.*;
import org.json.*;

@java.lang.SuppressWarnings({"java:S106", "java:S112", "java:S125"})

public class EKM {
    public static JSONObject callApi(String apiRequest) throws Exception {

        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object

        URL url = new URL(apiRequest);        
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty( "Accept", "application/json");
        connection.setRequestProperty( "Content-type", "application/json");
        connection.setRequestProperty( "Authorization", "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk");
        connection.setDoOutput(true);

        String reqData = "{\"command\": \"SetWeekendHolidaySchedules\",\"target\": \"meter\",\"target_id\": \"000350000900\",\"params\": { \"Weekend_Schedule\": \"1\", \"Holiday_Schedule\": \"4\", \"meter_password\": \"00000000\"}}";
        try(OutputStream os = connection.getOutputStream()) {
            byte[] input = reqData.getBytes("utf-8");
            os.write(input, 0, input.length);           
        }

        try(BufferedReader br = new BufferedReader(
            new InputStreamReader(connection.getInputStream(), "utf-8"))) {
                StringBuilder response = new StringBuilder();
                String responseLine = null;
                while ((responseLine = br.readLine()) != null) {
                    response.append(responseLine.trim());
                }
                return new JSONObject(response.toString());
            }        
    }    

    public static void main(String[] args) throws Exception {
        /*
         Call callApiPost to create a usable
         object named apiObject from the API request URL.
         Put the API request URL in the call
         */
        JSONObject apiObject = EKM.callApi("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw");

        // This just displays the object but you can use what ever
        // code you would like to work with the object here
        System.out.println(apiObject.toString(4));
        }
}
/*
* Requirements
* NodeJS: v16.14.2
* Axios:  0.27.2
*/

// Load modules
const axios = require('axios');

// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
  try {
    const params  = {
      "command": "SetWeekendHolidaySchedules",
      "target": "meter",
      "target_id": "000350000900",
      "params": {
          "Weekend_Schedule": "1",
          "Holiday_Schedule": "4",
          "meter_password": "00000000",
      }
  }

    const res = await axios.post(
        'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', params, {
          headers: {
            'Accept': 'application/json',
            // eslint-disable-next-line max-len
            'Authorization': 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk',
          }});
    const apiResData = res.data;    
    console.log(JSON.stringify(apiResData, null, 2));
  } catch (error) {
    console.error(error.message);
  }
})();

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">

// The example function is called from the
// body tag when the page loads
function example(){

// Call the callApi function to create a usable
// object named apiObject from the API request URL.
// Put the API request URL in the call
callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw',function(apiObject){

      // This just displays the object in the result div
      // you can use what ever code you would like to work
      // with the object here
      document.getElementById("result").innerHTML = "<pre>"+JSON.stringify(apiObject, null, 4)+"</pre>";
      });

};

// This code accesses the apiRequest URL and converts
// the contents to a usable JSON object named apiObject
function callApi(apiRequest,callback) {
    var xhttp = new XMLHttpRequest();
    const params  = {
    "command": "SetWeekendHolidaySchedules",
    "target": "meter",
    "target_id": "000350000900",
    "params": {
        "Weekend_Schedule": "1",
        "Holiday_Schedule": "2",
        "meter_password": "00000000"
    }
  }

    xhttp.onreadystatechange = function() {
      if (xhttp.readyState == 4 && xhttp.status == 200) {
        var jsonObject = JSON.parse(xhttp.responseText);
        callback(jsonObject);
      }
    };
    xhttp.open("POST", apiRequest, true);
    xhttp.setRequestHeader("Accept", "application/json");
    xhttp.setRequestHeader("Content-Type", "application/json");
    xhttp.setRequestHeader("Authorization", "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk");
    xhttp.send(JSON.stringify(params));
}
</script>

</head>
  <body onload="example()">
    <div id="result"> </div>
  </body>
</html>

To assign the appropriate schedule for Weekends and/or Holidays, the JSON Object to define the schedule should look like:

{ "command": "SetWeekendHolidaySchedules", "target": "meter", "target_id": "000350000900", "params": { "Weekend_Schedule": "1", "Holiday_Schedule": "2", "meter_password": "00000000" } }

URL PARAMETERS

PARAMETER DESCRIPTION
weekend_schedule (int) - the weekend schedule number.
holiday_schedule (int) - the holiday schedule number

Get Schedule

curl -i -X POST 'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw' -H "Content-Type: application/json" -H "Authorization: Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk" --data-raw '{"command": "GetSchedules", "target": "meter", "target_id": "000350000900", "params": {"meter_password": "00000000"}}'
# Ruby Version: 3.1.2

# Load required modules
require 'net/http'
require 'json'
require 'uri'

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
def call_api(api_path, params)
  req_header = {        
    'Content-Type' => 'application/json',
    'Accept' => 'application/json',
    'Authorization' => 'Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk'
  }
  uri = URI("https://api.ekmpush.com#{api_path}")
  https = Net::HTTP.new(uri.host, uri.port)
  https.use_ssl = true

  request = Net::HTTP::Post.new(uri, req_header)  
  request.body = JSON.dump(params)

  response = https.request(request)
  JSON.parse(response.body)  
end

# Set Request JSON Object
req_data = {
    "command": "GetSchedules",
    "target": "meter",
    "target_id": "000350000900",
    "params": {}
}

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
# URI only NOT URL - Do not include https://api.ekmpush.com
api_object = call_api('/sendCommand?key=MTAxMDoyMDIw', req_data)

# This just displays the object but you can use what ever
# code you would like to work with the object here
require 'pp'
pp api_object

'''
Python version: 3.9.12
'''

# Required Python Modules
import urllib.request
import urllib.error
import urllib.parse
import json
import pprint

# This function accesses the api_request URL and converts
# the contents to a usable Python object and returns it
def call_api ( api_request, data ):
    '''Make http request'''
    headers = {
        "Accept": "application/json",
        "Content-Type": "application/json",
        "Authorization": "Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk"
    }
    req = urllib.request.Request(api_request, headers=headers)
    req.add_header('Content-Type', 'application/json')
    jsondata = json.dumps(data)
    json_bytes = jsondata.encode('utf-8')   # Needs to be bytes
    response = urllib.request.urlopen(req, json_bytes)
    response = response.read()
    json_object = json.loads(response.decode())
    return json_object

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call

# Request JSON Object
req_json = {
    "command": "GetSchedules",
    "target": "meter",
    "target_id": "000350000900",
    "params": {}
}

api_object = call_api("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw", req_json)

# This just displays the object but you can use what ever
# code you would like to work with the object here
pprint.pprint(api_object)

<?php
// PHP 8.0.17 (cli)

$postData = '{
    "command": "GetSchedules",
    "target": "meter",
    "target_id": "000350000900",
    "params": {}
}';

// Call the callApi function to create a usable
// object named $apiObject from the API request URL.
// Put the API request URL in the call
$apiObject=callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', $postData);

// This just displays the object but you can use what ever
// code you would like to work with the object here
var_dump($apiObject);

// This function accesses the apiRequest URL and converts
// the contents to a usable PHP object and returns it
function callApi($apiRequest='', $postData='')
{
    $opts = array('http' =>
        array(
            'method'  => 'POST',
            'header'  => "Content-Type: application/json\r\n".
            "Accept: application/json\r\n".
            "Authorization: Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk\r\n",
            'content' => $postData
        )
    );
    $context = stream_context_create($opts);
    $json = file_get_contents($apiRequest, false, $context);
    $jsonObject = json_decode($json, true);
    return ($jsonObject);
}

#!/usr/bin/perl
# Perl version: v5.34
# CPAN.pm version 2.2
# Perl Modules Version:
# JSON: 4.05
# LWP::Protocol::https: 6.10
# LWP::UserAgent: 6.43
#
# OS Prerequisites
# UBUNTU
# apt install cpanminus
#
# Install Perl Modules
#       cpan LWP::UserAgent
#       cpan LWP::Protocol::https
#       cpan JSON

# Required Perl Modules
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use Data::Dumper;

# This function accesses the api_request URL and converts
# the contents to a usable Perl object and returns it
sub call_api {
    my $req_json = {
        'command' => 'GetSchedules',
        'target' => 'meter',
        'target_id' => '000350000900',
        'params' => {}
    };
    my $api_request = shift;
    my $req         = HTTP::Request->new( 'POST', $api_request );
    $req->header( 'Accept' => 'application/json' );
    $req->header( 'Content-Type' => 'application/json' );
    $req->header( 'Authorization' => 'Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk' );
    $req->content( encode_json $req_json );
    my $lwp         = LWP::UserAgent->new;
    my $res         = $lwp->request($req);
    my $content     = $res->decoded_content();
    my $json_object = JSON->new->utf8->decode($content);
    return $json_object;
}

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
my $api_object =
  call_api('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw');

# This just displays the object but you can use what ever
# code you would like to work with the object here
print Dumper($api_object);    ## no critic (InputOutput::RequireCheckedSyscalls)

/*
 openjdk version "17.0.2" 2022-01-18

 Download the correct org.json jar version for your
 needs from: https://mvnrepository.com/artifact/org.json/json

 This example uses version 20220320 accessible here:
 https://repo1.maven.org/maven2/org/json/json/20220320/json-20220320.jar

 Instructions to run this program

 1. Put this code in a file named EKM.java
 2. Copy the downloaded org.json jar and EKM.java to the same directory
 3. Compile
  javac -cp .:./json-20220320.jar ./EKM.java
 4. Run
  java -cp .:./json-20220320.jar EKM
*/

//Import required classes
import java.net.*;
import java.io.*;
import org.json.*;

@java.lang.SuppressWarnings({"java:S106", "java:S112", "java:S125"})

public class EKM {
    public static JSONObject callApi(String apiRequest) throws Exception {

        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object

        URL url = new URL(apiRequest);        
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty( "Accept", "application/json");
        connection.setRequestProperty( "Content-type", "application/json");
        connection.setRequestProperty( "Authorization", "Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk");
        connection.setDoOutput(true);

        String reqData = "{\"command\": \"GetSchedules\",\"target\": \"meter\",\"target_id\": \"000350000900\",\"params\": {}}";
        try(OutputStream os = connection.getOutputStream()) {
            byte[] input = reqData.getBytes("utf-8");
            os.write(input, 0, input.length);           
        }

        try(BufferedReader br = new BufferedReader(
            new InputStreamReader(connection.getInputStream(), "utf-8"))) {
                StringBuilder response = new StringBuilder();
                String responseLine = null;
                while ((responseLine = br.readLine()) != null) {
                    response.append(responseLine.trim());
                }
                return new JSONObject(response.toString());
            }        
    }    

    public static void main(String[] args) throws Exception {
        /*
         Call callApiPost to create a usable
         object named apiObject from the API request URL.
         Put the API request URL in the call
         */
        JSONObject apiObject = EKM.callApi("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw");

        // This just displays the object but you can use what ever
        // code you would like to work with the object here
        System.out.println(apiObject.toString(4));
        }
}
/*
* Requirements
* NodeJS: v16.14.2
* Axios:  0.27.2
*/

// Load modules
const axios = require('axios');

// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
  try {
    const params  = {
      "command": "GetSchedules",
      "target": "meter",
      "target_id": "000350000900",
      "params": {}
    }

    const res = await axios.post(
        'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', params, {
            headers: {
              'Accept': 'application/json',
              // eslint-disable-next-line max-len
              'Authorization': 'Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk',
            }});
    const apiResData = res.data;    
    console.log(JSON.stringify(apiResData, null, 2));
  } catch (error) {
    console.error(error.message);
  }
})();

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">

// The example function is called from the
// body tag when the page loads
function example(){

// Call the callApi function to create a usable
// object named apiObject from the API request URL.
// Put the API request URL in the call
callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw',function(apiObject){

      // This just displays the object in the result div
      // you can use what ever code you would like to work
      // with the object here
      document.getElementById("result").innerHTML = "<pre>"+JSON.stringify(apiObject, null, 4)+"</pre>";
      });
};

// This code accesses the apiRequest URL and converts
// the contents to a usable JSON object named apiObject
function callApi(apiRequest,callback) {
    var xhttp = new XMLHttpRequest();
    const params  = {
      "command": "GetSchedules",
      "target": "meter",
      "target_id": "000350000900",
      "params": {}
    }

    xhttp.onreadystatechange = function() {
      if (xhttp.readyState == 4 && xhttp.status == 200) {
        var jsonObject = JSON.parse(xhttp.responseText);
        callback(jsonObject);
      }
    };
    xhttp.open("POST", apiRequest, true);
    xhttp.setRequestHeader("Accept", "application/json");
    xhttp.setRequestHeader("Content-Type", "application/json");
    xhttp.setRequestHeader("Authorization", "Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk");
    xhttp.send(JSON.stringify(params));
}
</script>

</head>
  <body onload="example()">
    <div id="result"> </div>
  </body>
</html>

This endpoint show you all Schedules regarded to a specific meter.

JSON Object to Get all schedules look like this:

{ "target": "meter", "target_id": "000350000900", "command": "GetSchedules" , "params": { "meter_password": "00000000" } }

Get Tariff Data

curl -i -X POST 'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw' -H "Content-Type: application/json" -H "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk" --data-raw '{"command": "GetTariffData", "target": "meter", "target_id": "000350000900", "params": {"meter_password": "00000000"}}'
# Ruby Version: 3.1.2

# Load required modules
require 'net/http'
require 'json'
require 'uri'

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
def call_api(api_path, params)
  req_header = {        
    'Content-Type' => 'application/json',
    'Accept' => 'application/json',
    'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk'
  }
  uri = URI("https://api.ekmpush.com#{api_path}")
  https = Net::HTTP.new(uri.host, uri.port)
  https.use_ssl = true

  request = Net::HTTP::Post.new(uri, req_header)  
  request.body = JSON.dump(params)

  response = https.request(request)
  JSON.parse(response.body)  
end

# Set Request JSON Object
req_data = {
    "command": "GetTariffData",
    "target": "meter",
    "target_id": "000350000900",
    "params": {}
}

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
# URI only NOT URL - Do not include https://api.ekmpush.com
api_object = call_api('/sendCommand?key=MTAxMDoyMDIw', req_data)

# This just displays the object but you can use what ever
# code you would like to work with the object here
require 'pp'
pp api_object

'''
Python version: 3.9.12
'''

# Required Python Modules
import urllib.request
import urllib.error
import urllib.parse
import json
import pprint

# This function accesses the api_request URL and converts
# the contents to a usable Python object and returns it
def call_api ( api_request, data ):
    '''Make http request'''
    headers = {
        "Accept": "application/json",
        "Content-Type": "application/json",
        "Authorization": "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk"
    }
    req = urllib.request.Request(api_request, headers=headers)
    jsondata = json.dumps(data)
    json_bytes = jsondata.encode('utf-8')   # Needs to be bytes
    response = urllib.request.urlopen(req, json_bytes)
    response = response.read()
    json_object = json.loads(response.decode())
    return json_object

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call

# Request JSON Object
req_json = {
    "command": "GetTariffData",
    "target": "meter",
    "target_id": "000350000900",
    "params": {}
}

api_object = call_api("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw", req_json)

# This just displays the object but you can use what ever
# code you would like to work with the object here
pprint.pprint(api_object)

<?php
// PHP 8.0.17 (cli)

$postData = '{
    "command": "GetTariffData",
    "target": "meter",
    "target_id": "000350000900",
    "params": {}
}';

// Call the callApi function to create a usable
// object named $apiObject from the API request URL.
// Put the API request URL in the call
$apiObject=callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', $postData);

// This just displays the object but you can use what ever
// code you would like to work with the object here
var_dump($apiObject);

// This function accesses the apiRequest URL and converts
// the contents to a usable PHP object and returns it
function callApi($apiRequest='', $postData='')
{
    $opts = array('http' =>
        array(
            'method'  => 'POST',
            'header'  => "Content-Type: application/json\r\n".
            "Accept: application/json\r\n".
            "Authorization: Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk\r\n",
            'content' => $postData
        )
    );
    $context = stream_context_create($opts);
    $json = file_get_contents($apiRequest, false, $context);
    $jsonObject = json_decode($json, true);
    return ($jsonObject);
}

#!/usr/bin/perl
# Perl version: v5.34
# CPAN.pm version 2.2
# Perl Modules Version:
# JSON: 4.05
# LWP::Protocol::https: 6.10
# LWP::UserAgent: 6.43
#
# OS Prerequisites
# UBUNTU
# apt install cpanminus
#
# Install Perl Modules
#       cpan LWP::UserAgent
#       cpan LWP::Protocol::https
#       cpan JSON

# Required Perl Modules
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use Data::Dumper;

# This function accesses the api_request URL and converts
# the contents to a usable Perl object and returns it
sub call_api {
    my $req_json = {
        'command' => 'GetTariffData',
        'target' => 'meter',
        'target_id' => '000350000900',
        'params' => {}
    };
    my $api_request = shift;
    my $req         = HTTP::Request->new( 'POST', $api_request );
    $req->header( 'Accept' => 'application/json' );
    $req->header( 'Content-Type' => 'application/json' );
    $req->header( 'Authorization' => 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk' );
    $req->content( encode_json $req_json );
    my $lwp         = LWP::UserAgent->new;
    my $res         = $lwp->request($req);
    my $content     = $res->decoded_content();
    my $json_object = JSON->new->utf8->decode($content);
    return $json_object;
}

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
my $api_object =
  call_api('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw');

# This just displays the object but you can use what ever
# code you would like to work with the object here
print Dumper($api_object);    ## no critic (InputOutput::RequireCheckedSyscalls)

/*
 openjdk version "17.0.2" 2022-01-18

 Download the correct org.json jar version for your
 needs from: https://mvnrepository.com/artifact/org.json/json

 This example uses version 20220320 accessible here:
 https://repo1.maven.org/maven2/org/json/json/20220320/json-20220320.jar

 Instructions to run this program

 1. Put this code in a file named EKM.java
 2. Copy the downloaded org.json jar and EKM.java to the same directory
 3. Compile
  javac -cp .:./json-20220320.jar ./EKM.java
 4. Run
  java -cp .:./json-20220320.jar EKM
*/

//Import required classes
import java.net.*;
import java.io.*;
import org.json.*;

@java.lang.SuppressWarnings({"java:S106", "java:S112", "java:S125"})

public class EKM {
    public static JSONObject callApi(String apiRequest) throws Exception {

        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object

        URL url = new URL(apiRequest);        
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty( "Accept", "application/json");
        connection.setRequestProperty( "Content-type", "application/json");
        connection.setRequestProperty( "Authorization", "Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk");
        connection.setDoOutput(true);

        String reqData = "{\"command\": \"GetTariffData\",\"target\": \"meter\",\"target_id\": \"000350000900\",\"params\": {}}";
        try(OutputStream os = connection.getOutputStream()) {
            byte[] input = reqData.getBytes("utf-8");
            os.write(input, 0, input.length);           
        }

        try(BufferedReader br = new BufferedReader(
            new InputStreamReader(connection.getInputStream(), "utf-8"))) {
                StringBuilder response = new StringBuilder();
                String responseLine = null;
                while ((responseLine = br.readLine()) != null) {
                    response.append(responseLine.trim());
                }
                return new JSONObject(response.toString());
            }        
    }    

    public static void main(String[] args) throws Exception {
        /*
         Call callApiPost to create a usable
         object named apiObject from the API request URL.
         Put the API request URL in the call
         */
        JSONObject apiObject = EKM.callApi("https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw");

        // This just displays the object but you can use what ever
        // code you would like to work with the object here
        System.out.println(apiObject.toString(4));
        }
}
/*
* Requirements
* NodeJS: v16.14.2
* Axios:  0.27.2
*/

// Load modules
const axios = require('axios');

// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
  try {
    const params  = {
      "command": "GetTariffData",
      "target": "meter",
      "target_id": "000350000900",
      "params": {}
    }

    const res = await axios.post(
        'https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw', params, {
          headers: {
            'Accept': 'application/json',
            // eslint-disable-next-line max-len
            'Authorization': 'Bearer BztDe2_5hz61WQuDG0OHeMhG7mcEqJu8VrzHSywCkPk',
          }});
    const apiResData = res.data;
    console.log(JSON.stringify(apiResData, null, 2));
  } catch (error) {
    console.error(error.message);
  }
})();

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">

// The example function is called from the
// body tag when the page loads
function example(){

// Call the callApi function to create a usable
// object named apiObject from the API request URL.
// Put the API request URL in the call
callApi('https://api.ekmpush.com/sendCommand?key=MTAxMDoyMDIw',function(apiObject){

      // This just displays the object in the result div
      // you can use what ever code you would like to work
      // with the object here
      document.getElementById("result").innerHTML = "<pre>"+JSON.stringify(apiObject, null, 4)+"</pre>";
      });
};

// This code accesses the apiRequest URL and converts
// the contents to a usable JSON object named apiObject
function callApi(apiRequest,callback) {
    var xhttp = new XMLHttpRequest();
    const params  = {
      "command": "GetTariffData",
      "target": "meter",
      "target_id": "000350000900",
      "params": {}
    }

    xhttp.onreadystatechange = function() {
      if (xhttp.readyState == 4 && xhttp.status == 200) {
        var jsonObject = JSON.parse(xhttp.responseText);
        callback(jsonObject);
      }
    };
    xhttp.open("POST", apiRequest, true);
    xhttp.setRequestHeader("Content-Type", "application/json; charset=UTF-8");
    xhttp.send(JSON.stringify(params));
}
</script>

</head>
  <body onload="example()">
    <div id="result"> </div>
  </body>
</html>

This endpoint show you all Tariff Data regarded to a specific meter.

JSON Object to Get Tariff Data should look like this:

{ "target": "meter", "target_id": "000350000900", "command": "GetTariffData" , "params": { "meter_password": "00000000" } }

Trigger API

Click here to go to Trigger API Documentation

A REST API to lookup/create/update/delete triggers.

EKM Push3 gateway triggers are one of the most powerful tools that EKM has to offer. You can automate how and when the EKM Push system will react to metered values. You can have the Push gateway send you an email or control a relay to turn on/off a switch or close a valve based on the metered data for example. Push3 gateways have the ability trigger specific actions based on conditions that you set up. Triggers live on the Push3 gateways so they will continue to function even without an internet connection. Triggers can control the relays on the v.4 Omnimeters, in order to turn something on or off, or they can email you notifications of the trigger. Please note: v.3 Omnimeters do not have controllable relays, so the relay triggers will not work, but the email triggers will.

Summary API

Click here to go to Summary Documentation

Our Summary API takes every Real-Time read, over 15 minute time periods, and summarizes them into single 15 minute summaries. We store this data forever to provide a long term historical dataset for each meter. Our system can then combine these summaries together to summarize hours, days, weeks, and months. This dataset is often the best way to get historical values like kWh, pulse counts, etc. It also provides averages, min. and max. values, difference, and more. We make this data available to you via our Summary API in a very similar way to our Real-Time API.

You can use the Summary API definition to access the data you need, from 15 minutes to years of data. We have gone to great lengths to provide this data for free in order to add value to our metering systems. The Summary API, the Real-Time API, great affordable hardware, and scalable access to your data are all components of the most powerful, and highest value metering system available in the world.

We also have a Summary API Request Builder Tool found here: Summary API Builder

Summary V2 API

Click here to go to Summary V2 Documentation

Summary V2 API is a new set of summary features, such as First/Last to get the first and/or last reported date for the given meter(s)/ioStack(s), GStat for getting the status of one or more gateways, IOStack for getting information from new sensors, and more.

The API V2 summary and documentation are currently in beta, signifying that they are subject to changes and updates. It’s important to note that the API V2 calls and specifications provided in this documentation may undergo modifications as the beta phase progresses. Users should stay informed and regularly check for updates to ensure compatibility and adherence to the latest specifications

RS-485 Communications

Click here to go to RS-485 Documentation

This section is for developers, or individuals, that want to communicate with their EKM Meters directly using their own software or embedded solution.

The code examples found in this section are in the simplest possible method to get you started. You are welcome to make them more robust.

First we start you out just connecting to the meter. You will find there is a very simple command line process to help you get started.

After that we cover the CRC method required for most communication to the meter.

Then we put it all together, in a simple test script that will show reads, and also open and close the relays.

Last we cover how to convert the 255 character strings that the meter responds with to a usable array containing field names and their values. It is our hope that after you go through these steps you will have all the information you need, to build whatever tools you like to access the meter.

Our meters use an IEC 62056-21 communication standard that has been optimized for our own needs. We are more than happy to share this with you. With this you can write your own software or embedded solution to access your meter data.

IEC 62056 is a set of standards for Electricity metering data exchange by International Electrotechnical Commission.

To learn more about the IEC 62056 standard click the button below to visit the WikiPedia website.

Additional PDF docs are available:

v.3 Meter Settings Protocol

v.3 Meter Parsing

v.4/v.5 Meter Settings Protocol

v.4/v.5 Meter Parsing

v.4/v.5 Meter Alternate Modbus Protocol

If you are coding in Python you can also make use of our ekmmeters.py API.

Status Codes

EKM uses conventional HTTP response codes in addition to our API Status Codes to indicate the success or failure of an API request. In general, codes in the 2xx range indicate success, codes in the 4xx range indicate an error that failed given the information provided, and codes in the 5xx range indicate an error with EKM’s servers (these are rare).

The EKM API uses the following API specific Status codes:

API Status Code Meaning
1000 There is not data for: {meters}
1001 There is not data for: {meters} between ${startDate} and ${endDate}
1002 There is not data for: {meters} This meter first reported on:
1003 There is not data for: {meters} This meter last reported on:
1004 Timezone is not supported for this date range request
1100 All invalid query requests
1101 Invalid format
1102 Invalid value
1103 Invalid parameter
1200 Found invalid meter: {meter} for key: MTAxMDoyMDIw
1300 Oops! It looks like there was an unexpected error. Try checking your query for issues or hold tight while we see what we can do. This error has been reported.

The EKM API also uses the following HTTP Status codes:

HTTP Status Code Meaning
200 OK – The request succeeded.
400 Bad Request – The server could not understand the request due to invalid syntax.
401 Unauthorized – Although the HTTP standard specifies “unauthorized”, semantically this response means “unauthenticated”. That is, the client must authenticate itself to get the requested response.
403 Forbidden – The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client’s identity is known to the server.
404 Not Found – The server can not find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web.
429 Too Many Requests – The user has sent too many requests in a given amount of time (“rate limiting”).
500 Internal Server Error – The server has encountered a situation it does not know how to handle.
501 Not Implemented – The Vertical Bar otherwise known as “pipe” request method is not supported by the server and cannot be handled. The only methods that servers are required to support (and therefore that must not return this code) are GET and HEAD.
502 Bad Gateway – This error response means that the server, while working as a gateway to get a response needed to handle the request, got an invalid response.
503 Service Unavailable – The server is not ready to handle the request. Common causes are a server that is down for maintenance or that is overloaded. Note that together with this response, a user-friendly page explaining the problem should be sent. This response should be used for temporary conditions and the Retry-After HTTP header should, if possible, contain the estimated time before the recovery of the service. The webmaster must also take care about the caching-related headers that are sent along with this response, as these temporary condition responses should usually not be cached.
504 Gateway Timeout – This error response is given when the server is acting as a gateway and cannot get a response in time.
505 HTTP Version Not Supported – The HTTP version used in the request is not supported by the server.
506 Variant Also Negotiates – The server has an internal configuration error: the chosen variant resource is configured to engage in transparent content negotiation itself, and is therefore not a proper end point in the negotiation process.
510 Not Extended – Further extensions to the request are required for the server to fulfill it.
511 Network Authentication Required – Indicates that the client needs to authenticate to gain network access.

Widget Documentation

Click here to go to Widget Documentation

Access free web-based real-time and historical graphs showcasing your EKM Push data, covering all your devices including meters and ioStacks. It’s quick, easy, and doesn’t require a login.

The EKM Widget offers a convenient means to gain visual insights into your systems’ performance. We utilize it to monitor our office’s current consumption and solar power generation in real-time. Additionally, the historical chart helps us track the impact of efficiency upgrades on our usage and monitor the energy consumption of our electric car over time.