# also-energy-node

> Node wrapper for the Also Energy API

Latest version **1.0.2** (published 2017-02-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install also-energy-node
pnpm add also-energy-node
yarn add also-energy-node
bun add also-energy-node
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2017-02-23 |
| First published | 2017-02-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 8 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | dphaener |
| Maintainers | dphaener |

## Links

- npm: https://www.npmjs.com/package/also-energy-node
- npm.io page: https://npm.io/package/also-energy-node

## Dependencies (8)

- [soap](https://npm.io/package/soap.md) ^0.18.0
- [uuid](https://npm.io/package/uuid.md) ^3.0.1
- [ramda](https://npm.io/package/ramda.md) ^0.22.1
- [moment](https://npm.io/package/moment.md) ^2.17.1
- [es6-promise](https://npm.io/package/es6-promise.md) ^4.0.5
- [strong-soap](https://npm.io/package/strong-soap.md) ^1.2.0
- [fetch-everywhere](https://npm.io/package/fetch-everywhere.md) ^1.0.5
- [soap-as-promised](https://npm.io/package/soap-as-promised.md) ^1.16.0

## Recent versions

- 1.0.2 (latest) — 2017-02-23
- 1.0.1 — 2017-02-17
- 1.0.0 — 2017-02-16

## README

# Trimark Node

A small Node wrapper for the Trimark API.

## Installation

### NPM

```bash
$ npm install trimark-node
```

### Yarn

```bash
$ yarn add trimark-node
```

## Usage

You must have an API token supplied by Trimark in order to use the API.

```js
import Trimark from 'trimark-node';

const client = Trimark("my-token");

client.getSites();                                             // Retrieve all the sites for the account
client.sites[0].getPoints();                                   // Retrieve all the sensor points for the site
client.sites[0].points[0].history({ timeFrame: 'Yesterday' }); // Retrieve all of the data points for the sensor and the given time frame
```

## API

### Trimark

```
(apiToken) -> { sites: Array<Site> | null, getSites: () -> void }
```

The main wrapper for the API, allows you to request all sites be fetched.
After the sites are fetched `client.sites` will be populated with an array
of all the sites.

### Site

```
(
  getData: Function,           // A data getter that is passed down from the main wrapper
  site: TrimarkSiteInput       // The site as returned from the Trimark API
) -> {
  id: number,                  // The site ID
  name: string,                // The site name
  type: string,                // The type of site
  points: Array<Point> | null, // An array of points for the site, or null
  getPoints: () -> void        // Fetch all the points and populate the array
}
```

### Point

```
(
  getData: Function,                                   // A data getter passed down from the Site object
  siteId: number,                                      // The site id that this point belongs to
  point: TrimarkPointInput                             // The point as returned from the Trimark API
) -> {
  siteId: number,                                      // The site id that this point belongs to
  id: number,                                          // The id for this sensor point
  uom: string,                                         // The unit of measure for the data points
  displayName:                                         // The display name for the sensor point
  history: (query: Query) -> Promise<Array<DataPoint>> // Fetch the sensor data for this point
}
```

### DataPoint

```
(dataPoint: TrimarkDataPointInput) -> {
  intervalBegin: Object,  // The starting datetime for this data point, as a moment
  intervalEnd: Object,    // The ending datetime for this data point, as a moment
  averageValue: number,   // The average value for this data point
  minValue: number,       // The minimum value for this data point
  maxValue: number,       // The maximium value for this data point
  dataQuality: string,    // The data quality for this point
  interval: number,       // The interval of time this data point represents, in seconds
  pointId: number,        // The sensor point that this belongs to
  name: string,           // The name of the sensor point
  displayName: ?string,   // The display name for this sensor point
  uom: ?string,           // The unit of measure for this sensor point
  sumValue: ?number,      // The sum of the values for this sensor point
  rollupValue: ?number,   // The roll up value for this sensor point
  rollupUom: ?string,     // The unit of measure for the roll up value
  sampleTime: ?SampleTime // The intervals at which samples are taken
}
```

### Query

```
{
  timeFrame: enum TimeFrame,
  sampleTime: ?enum SampleTime,
  startDateTime: ?string,
  endDateTime: ?string
}
```

The representation of the query object that can be sent when fetching historical
data for a sensor point.

If a start and end date are given, those values will override anything passed in
to the `timeFrame` option, effectively transforming it to `Custom`.

### TimeFrame

An enum, one of:
```
'Today' | 'Yesterday' | 'Last3Days' | 'Last7Days' | 'MonthToDate' | 'LastMonth' | 'YearToDate' | 'LastYear' | 'Custom'
```

### SampleTime

An enum, one of:
```
'Interval' | 'Hour' | 'Day' | 'Month' | 'Year'
```

---
_Source: https://npm.io/package/also-energy-node · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
