npm

aframe-mqtt

1.0.3 • Public • Published

aframe-mqtt

NPM

npm i aframe-mqtt
// main.js
require('aframe');
require('aframe-mqtt');

Browserify

browserify main.js -o bundle.js

Properties

derived from animation component

Example 1: Set HTML Attributes

<html>
  <head>
    <script src="bundle.js"></script> 
  </head>
  <body>
    <a-scene>
      <!-- default broker: test.mosquitto.org:8081 -->
      <a-box position = "0 0 0" scale = "1 1 1"
        mqtt-subscribe__pos = "topic:atest;property:position;dur:2000"
        mqtt-subscribe__size = "topic:atest;property:scale;dur:1000"
        mqtt-publish = "topic:atest;message:1 2 3" ></a-box>
    </a-scene>
  </body>
</html>

Example "Delock Power Switch" with local broker

<html>
  <head>
  </head>
    <script src="bundle.js"></script>  
  <body>
    <a-scene >
      <a-box 
      mqtt-publish = "broker:mqtt://127.0.0.1:8081;topic:cmnd/delock/power;message:TOGGLE" ></a-box>  
    </a-scene>
  </body>
</html>

local mqtt broker

mosquitto.org

mosquitto –v –c mosquitto.conf

mosquitto.conf

listener 1883
protocol mqtt

listener 8081
protocol websockets

ipconfig

broker_ip (e.g. 192.168.178.92)

Configure "Delock WLAN Power Socket Switch"

host = broker_ip
port = 1883

License

(c) Copyright 2020 Frank Rettig, all rights reserved.

Readme

Keywords

none

Package Sidebar

Install

npm i aframe-mqtt

Weekly Downloads

1

Version

1.0.3

License

LicenseRef-LICENSE

Unpacked Size

7.72 kB

Total Files

4

Last publish

Collaborators

  • caepackages