# node-unifi-poecontrol

> A unifi controller wrapper to control poe ports on switches

Latest version **1.1.2** (published 2022-07-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-unifi-poecontrol
pnpm add node-unifi-poecontrol
yarn add node-unifi-poecontrol
bun add node-unifi-poecontrol
```

## 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.1.2 |
| Published | 2022-07-04 |
| First published | 2020-06-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 4.2 MB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Peter Peerdeman |
| Maintainers | peterpeerdeman |
| Keywords | unifi, poe, node, api |

## Links

- npm: https://www.npmjs.com/package/node-unifi-poecontrol
- Repository: https://github.com/peterpeerdeman/node-unifi-poecontrol
- Homepage: https://github.com/peterpeerdeman/node-unifi-poecontrol#readme
- Issues: https://github.com/peterpeerdeman/node-unifi-poecontrol/issues
- npm.io page: https://npm.io/package/node-unifi-poecontrol

## Dependencies (1)

- [axios](https://npm.io/package/axios.md) ^0.21.4

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 1.1.2 (latest) — 2022-07-04
- 1.1.1 — 2021-05-16
- 1.1.0 — 2020-06-13
- 1.0.0 — 2020-06-13

## README

# node-unifi-poecontrol
[![Build Status](https://travis-ci.org/peterpeerdeman/node-unifi-poecontrol.svg?branch=master)](https://travis-ci.org/peterpeerdeman/node-unifi-poecontrol)

A Unifi API client for node, aimed at controlling the POE ports on switches

was tested with UniFi Switch 8 POE-60W, should work with all unifi POE switches.

![unifi poe port scaling in action](./node-unifi-poeport.gif)

## Usage
```javascript
// Import the Unifi client
const Unifi = require('node-unifi-poecontrol');

// Create a new unifi instance, initialize with controller url
const unifi = new Unifi('https://192.168.1.5:8443');

// Login first
unifi.login('controllerusername', 'controllerpassword').then(loginresponse => {
    // Then get the devices
    unifi.getDevices().then(response => {
        const device_id = response.data[0].device_id;

        // set first and second poe port to be enabled, third one to be disabled
        unifi.setPoePorts(device_id, [true, true, false]).then(response => {
            console.log(response);
        });
    });

    // writing the port overrides manually
    // create port ovverrides
    const port_overrides = {
        "port_overrides": [
            {
                "poe_mode": "off",
                "port_idx": 5,
                "port_security_mac_address": [],
                "portconf_id": "5ee12ed5da6ad50006e3176f"
            },
            {
                "poe_mode": "off",
                "port_idx": 6,
                "port_security_mac_address": [],
                "portconf_id": "5ee12ed5da6ad50006e3176f"
            },
            {
                "poe_mode": "off",
                "port_idx": 7,
                "port_security_mac_address": [],
                "portconf_id": "5ee12ed5da6ad50006e3176f"
            }
        ]
    };

    unifi.writePortOverrides('5ee13048da6ad50006e3177b', port_overrides).then(response => {
        console.log(response);
    })
})

```

Please find the call reponses in the testfolder example

The following API calls are available
```javascript
/**********************/
/* High-level methods */
/**********************/
unifi.setPoePorts(deviceId, [Boolean]);

/**********************/
/* Low-level methods */
/**********************/
unifi.getTag();
unifi.getDevices();
unifi.getDevice([macaddress1, macaddress2]);
unifi.writePortOverrides();
```

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