# ezrun-mqtt

> Integrate MQTT into ezrun platform

Latest version **1.0.0-alpha.6** (published 2023-01-17) · ISC license · 0 weekly downloads

## Install

```sh
npm install ezrun-mqtt
pnpm add ezrun-mqtt
yarn add ezrun-mqtt
bun add ezrun-mqtt
```

## 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.0-alpha.6 |
| Published | 2023-01-17 |
| First published | 2022-12-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 36.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | doanthuanthanh88@gmail.com |
| Maintainers | doanthuanthanh88 |
| Keywords | mqtt, ezrun, ezrun plugin, cli |

## Links

- npm: https://www.npmjs.com/package/ezrun-mqtt
- Repository: https://github.com/doanthuanthanh88/ezrun-mqtt
- Homepage: https://github.com/doanthuanthanh88/ezrun-mqtt#readme
- Issues: https://github.com/doanthuanthanh88/ezrun-mqtt/issues
- npm.io page: https://npm.io/package/ezrun-mqtt

## Dependencies (1)

- [mqtt](https://npm.io/package/mqtt.md) ^4.3.7

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 1.0.0-alpha.6 (latest) — 2023-01-17
- 1.0.0-alpha.8 (alpha) — 2023-01-24
- 1.0.0-alpha.7 — 2023-01-19
- 1.0.0-alpha.5 — 2023-01-16
- 1.0.0-alpha.4 — 2023-01-15
- 1.0.0-alpha.3 — 2023-01-12
- 1.0.0-alpha.2 — 2022-12-27
- 1.0.0-alpha.1 — 2022-12-25
- 1.0.0-alpha.0 — 2022-12-24
- 0.0.0-alpha.0 — 2022-12-23

## README

# ezrun-mqtt
ezrun-mqtt for ezrun plugin


<br/>

# Tag details

| Tags | Description |
|---|---|
| [ezrun-mqtt](#ezrun-mqtt) | Declare a mqtt connector |
| [ezrun-mqtt'pub](#ezrun-mqtt'pub) | Publish a message to topics in mqtt |
| [ezrun-mqtt'quit](#ezrun-mqtt'quit) | Stop subscribed. Only used in "ezrun-mqtt'sub" |
| [ezrun-mqtt'sub](#ezrun-mqtt'sub) | Subscribe topics in mqtt |



## <a id="ezrun-mqtt"></a>ezrun-mqtt  
  
Declare a mqtt connector  

Example:  

```yaml
  - ezrun-mqtt:
      title: "[mqtt] localhost"
      uri: mqtt://user:pass@mqtt            # Mqtt uri
      runs:                                 # When a message is received then it will runs them
        - echo: Mqtt is connected
```
Publish a message to topics
```yaml
  - ezrun-mqtt:
      title: "[mqtt] localhost"
      uri: mqtt://user:pass@mqtt            # Mqtt uri
      runs:                                 # When a message is received then it will runs them
        - ezrun-mqtt'pub:
            title: Publish a message
            topics:
              - test
            data:
              msg: Hello world
```  


## <a id="ezrun-mqtt'pub"></a>ezrun-mqtt'pub  
  
Publish a message to topics in mqtt  

Example:  

Publish a message to mqtt
```yaml
  - ezrun-mqtt'pub:
      title: "[mqtt] localhost"
      uri: mqtt://user:pass@mqtt
      topic: topic1
      topics:
        - topic2
        - topic3
      pubOpts:
        qos?: 0 | 1 | 2
      data:
        name: thanh
```

Reuse mqtt connection to publish multiple times
```yaml
  - ezrun-mqtt:
      title: "[mqtt] localhost"
      uri: mqtt://user:pass@mqtt
      runs:
        - ezrun-mqtt'pub:
            topics:
              - topic1
            pubOpts:
              qos?: 0 | 1 | 2
            data:
              name: thanh
        - ...
        # Other elements
```  


## <a id="ezrun-mqtt'quit"></a>ezrun-mqtt'quit  
  
Stop subscribed. Only used in "ezrun-mqtt'sub"  

Example:  

```yaml
  - ezrun-mqtt'sub:
      uri: redis://redis:6379
      topics:                     # Topics which is subscribed
        - topic1
      runs:                       # When a message is received then it will runs them
        - ezrun-mqtt'stop:        # Stop subscribed
```  


## <a id="ezrun-mqtt'sub"></a>ezrun-mqtt'sub  
  
Subscribe topics in mqtt  

Example:  

```yaml
  - ezrun-mqtt'sub:
      title: "[mqtt] localhost"
      uri: mqtt://user:pass@mqtt
      topic: topic1
      topics:                               # topics which is subscribed
        - topic1
        - topic2
      runs:                                 # When a message is received then it will runs them
        - ${this.parentState}               # - Received data in a topic
        - ${this.parentState.topicName}     # - Topic name
        - ${this.parentState.topicData}     # - Received message which is cast to object
        - ${this.parentState.topicMsg}      # - Received message which is text

        - ...
        # Other elements
```
Used in global mqtt
```yaml
  - ezrun-mqtt:
      title: Global MQTT
      uri: mqtt://user:pass@mqtt
      runs:
        - ezrun-mqtt'sub:
            title: "[mqtt] localhost"
            topic: topic1
            topics:                               # topics which is subscribed
              - topic1
              - topic2
            runs:                                 # When a message is received then it will runs them
              - ${this.parentState}               # - Received data in a topic
              - ${this.parentState.topicName}     # - Topic name
              - ${this.parentState.topicData}     # - Received message which is cast to object
              - ${this.parentState.topicMsg}      # - Received message which is text

              - ...
              # Other elements
```  


<br/>

### Have fun :)

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