1.2.1 • Published 7 months ago

ymlr-mqtt v1.2.1

Weekly downloads
-
License
ISC
Repository
github
Last release
7 months ago

ymlr-mqtt

ymlr-mqtt for ymlr plugin

Tag details

TagsDescription
ymlr-mqttDeclare a mqtt connector
ymlr-mqtt'pubPublish a message to topics in mqtt
ymlr-mqtt'subSubscribe topics in mqtt

ymlr-mqtt

Declare a mqtt connector

Example:

  - name: "[mqtt] localhost"
    ymlr-mqtt:
      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

  - name: "[mqtt] localhost"
    ymlr-mqtt:
      uri: mqtt://user:pass@mqtt            # Mqtt uri
      runs:                                 # When a message is received then it will runs them
        - name: Publish a message
          ymlr-mqtt'pub:
            topics:
              - test
            data:
              msg: Hello world

ymlr-mqtt'pub

Publish a message to topics in mqtt

Example:

Publish a message to mqtt

  - name: "[mqtt] localhost"
    ymlr-mqtt'pub:
      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

  - name: "[mqtt] localhost"
    ymlr-mqtt:
      uri: mqtt://user:pass@mqtt
      runs:
        - ymlr-mqtt'pub:
            topics:
              - topic1
            pubOpts:
              qos?: 0 | 1 | 2
            data:
              name: thanh
        - ...
        # Other elements

Or reuse by global variable Reuse mqtt connection to publish multiple times

  - name: "[mqtt] localhost"
    ymlr-mqtt:
      uri: mqtt://user:pass@mqtt
    vars:
      mqtt1: ${this}

  - ymlr-mqtt'pub:
      mqtt: ${ $vars.mqtt1 }
      topics:
        - topic1
      pubOpts:
        qos?: 0 | 1 | 2
      data:
        name: thanh

ymlr-mqtt'sub

Subscribe topics in mqtt

Example:

  - name: "[mqtt] localhost"
    ymlr-mqtt'sub:
      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
        - ${ $parentState }                 # - Received data in a topic
        - ${ $parentState.topicName }       # - Topic name
        - ${ $parentState.topicData }       # - Received message which is cast to object
        - ${ $parentState.topicMsg }        # - Received message which is text

        - ...
        # Other elements

Used in global mqtt

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

              - ...
              # Other elements

Or reuse by global variable

  - name: Global MQTT
    ymlr-mqtt:
      uri: mqtt://user:pass@mqtt
    vars:
      mqtt1: ${this}

  - name: "[mqtt] localhost"
    ymlr-mqtt'sub:
      mqtt: ${ $vars.mqtt1 }
      topic: topic1
      topics:                             # topics which is subscribed
        - topic1
        - topic2
      runs:                               # When a message is received then it will runs them
        - ${ $parentState }               # - Received data in a topic
        - ${ $parentState.topicName }     # - Topic name
        - ${ $parentState.topicData }     # - Received message which is cast to object
        - ${ $parentState.topicMsg }      # - Received message which is text

        - ...
        # Other elements

        - stop:                           # - Stop subscribing

Have fun :)

1.2.1

7 months ago

1.1.5

9 months ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.1-alpha.0

1 year ago

1.1.0

1 year ago

1.1.0-alpha.0

1 year ago

1.0.0

1 year ago

1.0.0-alpha.1

1 year ago

0.0.1

1 year ago

0.0.1-alpha.2

1 year ago

0.0.1-alpha.1

1 year ago

0.0.1-alpha.0

1 year ago

0.0.0-alpha.0

1 year ago