<commit_before># ECOPlugs

Communicate with ECOPlugs/Wion Woods WiFi-connected outlets. Read the state of any plug(s) and turn on/off.

# Installation

    npm install ecoplugs

# Configuration

Configuration sample:

```
{
    "plugs": [
        {
            "name": "EcoPlug1",
            "host": "192.168.0.xxx",
            "id": "ECO-xxxxxxxx"
        },
        {
            "name": "EcoPlug2",
            "host": "192.168.0.yyy",
            "id": "ECO-yyyyyyyy"                        
        }
    ]
}
```

| Fields   | Description | Required |
|----------|--------------------------------------------------------------------|:---:|
| plugs    | Subsection to define individual plugs                              | Yes |
|          | *Fields for plugs subsection*                                      | --- |
| name     | Descriptive name of the plug                                       | Yes |
| host     | Hostname or IP of the EcoPlug                                      | Yes |
| port     | Port used by the EcoPlug (defaults to 80)                          | No  |
| id       | The id of the EcoPlug as shown in the ECO app under settings       | Yes |<commit_msg>Add more detail to README.<commit_after># ECOPlugs

Communicate with ECOPlugs/Wion Woods WiFi-connected outlets. Read the state of any plug(s) and turn them on/off.

# Installation

    npm install ecoplugs

# Usage

Reading plug on/off status:
```
var plugs = new EcoPlugGroup(config); // config object described below

plugs.getPowerState(config.plugs[0], (err, state) => {
  console.log(state); // true === on, false === off
});
```
Turn plug on or off:
```
var newState = true; // truthy for on, falsey for off

plugs.setPowerState(config.plugs[0], state, (err) => {
  if (err) console.log(err);
});
```

# Configuration

Example configuation object:

```
{
    "plugs": [
        {
            "name": "EcoPlug1",
            "host": "192.168.0.xxx",
            "id": "ECO-xxxxxxxx"
        },
        {
            "name": "EcoPlug2",
            "host": "192.168.0.yyy",
            "id": "ECO-yyyyyyyy"                        
        }
    ]
}
```

| Fields   | Description | Required |
|----------|--------------------------------------------------------------------|:---:|
| plugs    | Array of ECOPlugs to control                                       | Yes |
|          | *Fields for plugs subsection*                                      |     |
| name     | Descriptive name of the ECOPlug                                    | Yes |
| host     | Hostname or IP of the EcoPlug                                      | Yes |
| port     | Port used by the EcoPlug (defaults to 80)                          | No  |
| id       | The id of the EcoPlug as shown in the ECO app under settings       | Yes |
{'fraction_non_alphanumeric': 0.16654753395282346, 'fraction_numerical': 0.013581129378127233, 'mean_word_length': 1.2285031847133758, 'pattern_counts': {'":': 14, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, 'word_list_counts': {'cursed_substrings.json': 11, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7160289', 'n_tokens_mistral': 850, 'n_tokens_neox': 757, 'n_words': 229}