ezrun-mqtt for ezrun plugin
Tags | Description |
---|---|
ezrun-mqtt | Declare a mqtt connector |
ezrun-mqtt'pub | Publish a message to topics in mqtt |
ezrun-mqtt'quit | Stop subscribed. Only used in "ezrun-mqtt'sub" |
ezrun-mqtt'sub | Subscribe topics in 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
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
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
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