# mihome

> A simple JS wrapper for the MiHome API.

Latest version **1.0.3** (published 2020-02-16) · ISC license · 0 weekly downloads

## Install

```sh
npm install mihome
pnpm add mihome
yarn add mihome
bun add mihome
```

## 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.3 |
| Published | 2020-02-16 |
| First published | 2018-11-13 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 13.2 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Christopher Nethercott |
| Maintainers | thorin |
| Keywords | mihome, wrapper, api, nodejs |

## Links

- npm: https://www.npmjs.com/package/mihome
- Repository: https://github.com/chriscn/mihome
- Homepage: https://github.com/chriscn/mihome#readme
- Issues: https://github.com/chriscn/mihome/issues
- npm.io page: https://npm.io/package/mihome

## Dependencies (2)

- [request](https://npm.io/package/request.md) ^2.88.2
- [request-promise](https://npm.io/package/request-promise.md) ^4.2.5

## Recent versions

- 1.0.3 (latest) — 2020-02-16
- 1.0.2 — 2019-03-03
- 1.0.1 — 2018-11-15
- 1.0.0 — 2018-11-15
- 0.0.1 — 2018-11-13

## README

# mihome
A simple NodeJS wrapper and documentation for the [MiHome API](https://mihome4u.co.uk/). This provides some new functionality as well as exisiting stuff.
## Installing 
Just run `npm install mihome` for access to the API Wrapper.

## Usage
To get started you either need to get an API Key already or to get one.
If don't already have an API Key:
```js
mihome.getAPIKey('example@example.org', 'examplepassword').then(apiKey => {
	console.log(apiKey);
}).catch(err => console.error(err));
```
If you already have an API Key:
```js
mihome.login('example@example.org', 'exampleapikey'); 
```
### Weird Things.
#### Dates
As kinda of described in the [API Documentation](https://mihome4u.co.uk/docs/api-documentation), Timestamps need to be in the format. '2018-00-00T00:00:00.000Z', this String `YYYY-MM-DD[T]HH:mm:SS.SSS[Z]` can format them.  
To format dates easily I recommend [moment.js](https://momentjs.com/), and then using the format function.
```js
moment().format('YYYY-MM-DD[T]HH:mm:SS.SSS[Z]');
```
### Validation Error
For some strange reason a perfectly valid request will sometimes work but other times return a validation request.  
I will contact the Energinie Engineers to see what is causing this and hopefully fix it.
## Methods
**All methods use Promise Style Callback.**
#### `getUserProfile` - Gets information about the user that is currenlty logged in.
```js
mihome.getUserProfile().then(profile => {
	console.log(profile);
}).catch(err => console.error(err));
```
### Devices
#### `list` - Lists the Devices Available (Hub)
#### `delete(id)` - Deletes the Device with that ID.

### Sub Devices
#### `list` - Lists the Subdevices Available
#### `delete(id)` - Deletes the Subdevice with that ID.
#### `powerOn(id)` - Turns the ID on.
#### `powerOff(id)` - Turns the ID off.
#### `fetchUsageData(id, data_type, resolution, start_time, end_time, limit)` - Gets usage data between specific time
- id - The ID to get Usage Data.
- data_type - Either 'watts' or 'reported_temperature'
- resolution - Either 'instant', 'hourly', 'daily'
- start_time - Start Time: [See](#dates)
- end_time - End Time: [See](#dates)

### Subdevice Groups
#### `list` - Lists the groups Available
#### `delete(id)` - Deletes the group with that ID.
#### `powerOn(id)` - Turns the ID on.
#### `powerOff(id)` - Turns the ID off.

### Push Notifications
#### `list` - Lists the notifications subscriptions.

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