This project contains a demo webapp that shows how to connect to SolarFlux and consume real-time datum updates posted there.
Fill in a valid SolarNetwork security token and secret. Optionally tweak the topic pattern if you like, i.e. to narrow the nodes and/or sources the app subscribes to. Then
Topics follow this syntax:
node/N/datum/0/S
where N
is a node ID and S
is a source ID. The 0
in the topic represents the raw
aggregation level, which is level SolarNode posts datum messages at. Example topics look like:
node/1/datum/0/Meter
node/2/datum/0/Building1/Room1/Light1
node/2/datum/0/Building1/Room1/Light2
Note that any leading /
in a source ID is stripped from the topic name.
By default, the topics that get subscribed to will be automatically re-written by SolarFlux to
include a user/U
prefix, where U
is the SolarNetwork user ID of the authenticated user. That
means that the example topics above will result in topics like the following actually being
consumed:
user/123/node/1/datum/0/Meter
user/234/node/2/datum/0/Building1/Room1/Light1
user/234/node/2/datum/0/Building1/Room1/Light2
The build uses NPM or Yarn. First, initialize the dependencies:
# NPM
npm install
# or, Yarn
yarn install
Then, the development web server can be started via
# NPM
npm run start
# or, Yarn
yarn run start
and then the app can be reached at localhost:9000. For a produciton build, use
# NPM
npm run build -- --config webpack.prod.js
# or, Yarn
yarn run build --config webpack.prod.js
and the app will be built in the dist
directory.