# @haum/device

> ## Example ```javascript const device = require('@haum/device')

Latest version **1.2.5** (published 2020-06-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install @haum/device
pnpm add @haum/device
yarn add @haum/device
bun add @haum/device
```

## 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.2.5 |
| Published | 2020-06-29 |
| First published | 2020-05-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 3.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | haum |

## Links

- npm: https://www.npmjs.com/package/@haum/device
- npm.io page: https://npm.io/package/@haum/device

## Dependencies (1)

- [@haum/mqtt](https://npm.io/package/@haum/mqtt.md) ^1.0.1

## Recent versions

- 1.2.5 (latest) — 2020-06-29
- 1.2.4 — 2020-06-29
- 1.2.3 — 2020-06-29
- 1.2.2 — 2020-06-29
- 1.2.1 — 2020-06-29
- 1.2.0 — 2020-06-29
- 1.1.0 — 2020-05-18
- 1.0.0 — 2020-05-18

## README

# Haum Device

## Example
```javascript
const device = require('@haum/device')

// Create a new device
const myDevice = device('myDevice')

// Let others discover the device
myDevice.discovery({
  items: {
    myItem: {
      type: 'string'
    }
  }
})

// Listen for change requests and emit new state
myDevice.item('myItem').on('change', value => {
  console.log('CHANGE:', value)
  myDevice.item('myItem').emit('state', msg)
})

// Does the same as above
myDevice.on('myItem', 'change', value => {
  console.log('CHANGE:', value)
  myDevice.emit('myItem', 'state', msg)
})
```

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