# mqtt-elements **Repository Path**: mirrors_mqttjs/mqtt-elements ## Basic Information - **Project Name**: mqtt-elements - **Description**: Polymer elements for MQTT - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-09 - **Last Updated**: 2026-03-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ![mqtt-elements](https://raw.githubusercontent.com/mqttjs/mqtt-elements/67266290fe6a0b6b3ff51418efb7c1c0662c78c5/assets/mqtt-elements.png) ======= 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 ```