1.0.0-alpha.6 • Published 1 year ago

ezrun-mqtt v1.0.0-alpha.6

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

ezrun-mqtt

ezrun-mqtt for ezrun plugin

Tag details

TagsDescription
ezrun-mqttDeclare a mqtt connector
ezrun-mqtt'pubPublish a message to topics in mqtt
ezrun-mqtt'quitStop subscribed. Only used in "ezrun-mqtt'sub"
ezrun-mqtt'subSubscribe topics in mqtt

ezrun-mqtt

Declare a mqtt connector

Example:

  - 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

  - 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

ezrun-mqtt'pub

Publish a message to topics in mqtt

Example:

Publish a message to mqtt

  - 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

  - 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

ezrun-mqtt'quit

Stop subscribed. Only used in "ezrun-mqtt'sub"

Example:

  - 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

ezrun-mqtt'sub

Subscribe topics in mqtt

Example:

  - 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

  - 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

Have fun :)

1.0.0-alpha.7

1 year ago

1.0.0-alpha.6

1 year ago

1.0.0-alpha.5

1 year ago

1.0.0-alpha.4

1 year ago

1.0.0-alpha.3

1 year ago

1.0.0-alpha.8

1 year ago

1.0.0-alpha.2

1 year ago

1.0.0-alpha.1

1 year ago

1.0.0-alpha.0

1 year ago

0.0.0-alpha.0

1 year ago