Back to ITRS Internal Only FAQ

Internal documentation only

This page has been marked as draft.

REST Extractor Example - Tesla Powerwall Gateway API

As of GA4.11 there is a new REST Extractor plugin. You will need a new license token and file to use it. Check your gateway-licenceUsage dataviews to see if it’s listed.

As a real-world test of the new REST Extractor plugin, this is pointed in the Tesla Powerwall Gateway. The PW Gateway has a number of community documented REST endpoints and these can be used to monitor your battery system. For more information, check powerwall2 public repo.

Note

As of Tesla’s 20.49 update to their gateway software, this example no longer works without additional authentication and the article has not yet been updated to demonstrate that.

The following are three basic queries with some JQ filters. The first two could be Geneos Headlines as they are single value numbers, but the first iteration of the REST Extractor doesn’t support this.

Tesla PW stats

The REST Extractor ignores SSL/TLS certificate errors, and this is intentional. Later release may make certificate chain checking an option. Currently it works just like curl -s -k URL.

The data returned above are simulated using curl:

$ curl -s -k [URL]/api/system_status/soe |jq
{
 "percentage": 58.28107024900731
}

This gives the following result with a different value:

State of Charge values

$ curl -s -k [URL]/api/status |jq
{
 "start_time": "2019-05-03 03:56:26 +0800",
 "up_time_seconds": "4h55m3.196047617s",
 "is_new": false,
 "version": "1.34.3",
 "git_hash": "90b583f90cb815cec7678797ce7fcf4ac8065666"
}

Some time later, this results to the following:

Status dataview

$ curl -s -k [URL]/api/meters/aggregates |jq
{
 "site": {
 "last_communication_time": "2019-05-03T08:53:00.293620242+01:00",
 "instant_power": 37.746665954589844,
 "instant_reactive_power": -770.258544921875,
 "instant_apparent_power": 771.1828815630255,
 "frequency": 49.95012283325195,
 "energy_exported": 57865.79811281392,
 "energy_imported": 2506552.357557258,
 "instant_average_voltage": 243.95315551757812,
 "instant_total_current": 0,
 "i_a_current": 0,
 "i_b_current": 0,
 "i_c_current": 0,
 "timeout": 1500000000
 },
 "battery": {
 "last_communication_time": "2019-05-03T08:53:00.293914573+01:00",
 "instant_power": 3400,
 "instant_reactive_power": -40,
 "instant_apparent_power": 3400.2352859765456,
 "frequency": 49.938,
 "energy_exported": 1820190,
 "energy_imported": 2126270,
 "instant_average_voltage": 245.25,
 "instant_total_current": -80.60000000000001,
 "i_a_current": 0,
 "i_b_current": 0,
 "i_c_current": 0,
 "timeout": 1500000000
 },

...
}

This result in a dataview like this (computed test columns hidden):

Meter Aggregates

Sampler xml:

<sampler name="Tesla PW Stats">
 <sampleInterval>
  <data>10</data>
 </sampleInterval>
 <plugin>
  <rest-extractor>
   <dataviews>
    <dataview>
     <name>State of Charge</name>
     <url>
      <var ref="TESLA\_GW\_URL"/>
      <data>/api/system_status/soe</data>
     </url>
     <query>
      <data>to_entries</data>
     </query>
     <mode>complete</mode>
    </dataview>
    <dataview>
     <name>Status</name>
     <url>
      <var ref="TESLA\_GW\_URL"/>
      <data>/api/status</data>
     </url>
     <query>
      <data>to_entries</data>
     </query>
     <mode>complete</mode>
    </dataview>
    <dataview>
     <name>Meter Aggregates</name>
     <url>
      <var ref="TESLA\_GW\_URL"/>
      <data>/api/meters/aggregates</data>
     </url>
     <query>
      <data>[to_entries | .[] | { title: .key} + .value]</data>
     </query>
     <mode>complete</mode>
    </dataview>
   </dataviews>
  </rest-extractor>
 </plugin>
 <dataviews>
  <dataview name="Meter Aggregates">
   <additions>
    <var-columns>
     <data>
      <column>
       <data>imported_today</data>
      </column>
      <column>
       <data>exported_today</data>
      </column>
     </data>
    </var-columns>
   </additions>
  </dataview>
 </dataviews>
</sampler>
["Geneos"] ["FAQ"]

Was this topic helpful?