https://github.com/mqttjs/mqtt-elements
Polymer elements for MQTT
https://github.com/mqttjs/mqtt-elements
Last synced: 6 months ago
JSON representation
Polymer elements for MQTT
- Host: GitHub
- URL: https://github.com/mqttjs/mqtt-elements
- Owner: mqttjs
- License: mit
- Created: 2015-06-04T08:25:19.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-10-28T08:25:22.000Z (about 9 years ago)
- Last Synced: 2025-06-05T03:15:36.682Z (7 months ago)
- Language: JavaScript
- Homepage: http://mqttjs.github.io/mqtt-elements/
- Size: 3.44 MB
- Stars: 27
- Watchers: 8
- Forks: 6
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README

=======
Polymer elements to establish a MQTT connection to a MQTT broker.
## API
[API documentation](http://mqttjs.github.io/mqtt-elements/bower_components/mqtt-elements/)
## Install
```
bower install --save mqtt-elements
```
## Import
```
```
## Usage
```
```
### Connect
```
```
The method `#connect` has to be called manually to establish the MQTT connection to the MQTT broker.
Set `#auto` flag to make the MQTT connection as soon as possible.
### Connect with Username / Password
```
```
OR
```
```
The flag `#withCredentials` indecates the MQTT connection to wait until a username and password for
the connection is supplied.
### Publish
The following example will publish on the topic »mqtt/elements« with the payload »Publishing via a HTML element«.
Every time when `#payload` changes the element will publish a new MQTT message to the topic »mqtt/elements«.
If the `#auto` flag is not set - `#publish` has to be called to publish a MQTT message to the topic
```
```
#### Publish on multiple topic
A `` element can hold any number of `` elements to publish to different topics.
```
```
#### Publish a retained message
To publish a message with the RETAINED flag set to true add the `#retained` flag.
```
```
### Subscribe
```
```
The last message to the topic will be save in `#lastMessage`. The `` stores the
last `n` messages within the `#messages` array. Set `#numberOfMessages` to the
number of messages that should be saved in `#messages`. To save every message received on the topic
set `#numberOfMessages` to `Infinity`.
## Media
* [MQTT Client Library Encyclopedia](http://www.hivemq.com/blog/mqtt-client-library-encyclopedia-mqttelements?utm_medium=social&utm_source=github-mqttjs)
## Development
```
mkdir mqtt-wrapper && cd mqtt-wrapper
git clone https://github.com/mqttjs/mqtt-elements.git
cd mqtt-elements
cp debug.bowerrc .bowerrc
npm install
bower install
grunt serve
```
#### Bundel MQTT.js, MQEmitter and Store
```
browserify -r ./node_modules/mqtt/lib/store.js:Store -r mqtt -r MQEmitter > dist/mqtt-elements-bundle.js
```