npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

oncloud.simple-api

v1.6.3

Published

RESTful interface for oncloud.

Downloads

7

Readme

Logo oncloud simple-api adapter

NPM version Downloads Tests

NPM

This is RESTFul interface to read the objects and states from oncloud and to write/control the states over HTTP Get/Post requests.

Usage

Call in browser http://ipaddress:8087/help to get the help about API. The result is:

{
  "getPlainValue": "http://ipaddress:8087/getPlainValue/stateID",
  "get": "http://ipaddress:8087/get/stateID/?prettyPrint",
  "getBulk": "http://ipaddress:8087/getBulk/stateID1,stateID2/?prettyPrint",
  "set": "http://ipaddress:8087/set/stateID?value=1&prettyPrint",
  "toggle": "http://ipaddress:8087/toggle/stateID&prettyPrint",
  "setBulk": "http://ipaddress:8087/setBulk?stateID1=0.7&stateID2=0&prettyPrint",
  "objects": "http://ipaddress:8087/objects?pattern=system.adapter.admin.0*&prettyPrint",
  "objects": "http://ipaddress:8087/objects?pattern=system.adapter.admin.0*&type=adapter&prettyPrint",
  "states": "http://ipaddress:8087/states?pattern=system.adapter.admin.0*&prettyPrint"
}

getPlainValue

Call e.g.:

http://ipaddress:8087/getPlainValue/system.adapter.admin.0.alive

Result:

true

get

Call e.g.:

http://ipaddress:8087/get/system.adapter.admin.0.alive

Result:

{"val":true,"ack":true,"ts":1442432193,"from":"system.adapter.admin.0","lc":1442431190,"expire":23437,"_id":"system.adapter.admin.0.alive","type":"state","common":{"name":"admin.0.alive","type":"boolean","role":"indicator.state"},"native":{}}

or call e.g.:

http://ipaddress:8087/get/system.adapter.admin.0.alive?prettyPrint

Result:

{
  "val": true,
  "ack": true,
  "ts": 1442432238,
  "from": "system.adapter.admin.0",
  "lc": 1442431190,
  "expire": 28494,
  "_id": "system.adapter.admin.0.alive",
  "type": "state",
  "common": {
    "name": "admin.0.alive",
    "type": "boolean",
    "role": "indicator.state"
  },
  "native": {}
}

getBulk

get many states with one request

set

Call e.g.:

http://ipaddress:8087/set/javascript.0.test?value=1

Result:

{"id":"javascript.0.test","value":1}

or call e.g.:

http://ipaddress:8087/set/javascript.0.test?value=1&prettyPrint

Result:

{
  "id": "javascript.0.test",
  "value": 1
}

Of course the data point javascript.0.test must exist.

toggle

toggles value:
  • boolean: true => false, false => true
  • number without limits: x => 100-x
  • number with limits: x => max - (x - min)

setBulk

Set many states with one request. This request supports POST method too, for POST data should be in body and not URL.

setValueFromBody

Allows to set the value of a given State be set by the POST body content.

objects

states

help

Gives this output back

Install

node oncloud.js add simple-api

Usage

Assume, we have no security and the server runs on default port 8087.

For all queries the name or id of the state can be specified.

For every requiest that returns JSON you can set parameter prettyPrint to get the output in human readable form.

If authentication is enabled, two other fields are mandatory: ?user=admin&pass=oncloud

getPlainValue

Read state value as text. You can specify more ids divided by semicolon

get

Read state and object data of state as json. You can specify more ids divided by semicolon. If more than one ID requested, the JSON array will be returned.

getBulk

Read the states of more IDs with timestamp. You can specify more ids divided by semicolon. Always the JSON array will be returned.

set

Write the states with specified IDs. You can specifiy wait option in milliseconds to wait for answer from driver.

If no answer will be recieved in specified time, the null value will be returned. In the first case the answer will be returned immediately and ack is false. In the second case ack is true. That means it was response from driver.

setBulk

  • write bulk of IDs in one request.

You can send this request as POST too.

objects

Get the list of all objects for pattern. If no pattern specified all objects as JSON array will be returned.

Get all control objects of adapter system.adapter.admin.0:

states

Get the list of all states for pattern. If no pattern specified all states as JSON array will be returned.

Get all control objects of adapter system.adapter.admin.0:

Changelog

1.6.3 (2018-04-15)

  • (Apollon77) Return used character encoding (UTF-8)

1.6.2 (2017-11-27)

  • (Apollon77) Fix decoding problems

1.6.1 (2017-09-25)

  • (Apollon77) Fix statuscode for setBulk and optimize permission errors

1.6.0 (2017-07-10)

  • (Apollon77) Fix handling of URL-encoded values, they are now decoded properly
  • (Apollon77) Optimize Permission handling
  • (Apollon77) add possibility to only allow access to states where user is also owner, finally works correct with js-controller 1.1.1!

1.5.0 (2017-03-10)

  • (greyhound) Add new POST method setValueFromBody

1.4.0 (2017-01-05)

  • (bluefox) new web server plugin support

1.3.0 (2016-08-30)

  • (bluefox) сompatible only with new admin

1.2.0 (2016-08-27)

  • (bluefox) support of letsencrypt certificates

1.1.1 (2016-07-06)

  • (bluefox) support of chained certificates

1.1.0 (2016-02-09)

  • (bluefox) fix toggle, objects, states, setBulk, POST
  • (bluefox) add tests

1.0.0 (2015-09-30)

  • (bluefox) stop adapter before update

0.1.2 (2015-06-28)

  • (bluefox) add description in readme.md
  • (bluefox) change "toggle" for boolean and numbers

0.1.1 (2015-06-28)

  • (bluefox) change setForeignState api
  • (bluefox) add type to io-package.json
  • (bluefox) enable run from "web"
  • (bluefox) add default user

0.1.0 (2015-06-10)

  • (bluefox) change setForeignState api
  • (bluefox) support of user permissions

0.0.4 (2015-03-11)

  • (bluefox) remove socket.io from file

0.0.3 (2015-02-13)

  • (bluefox) remove socket.io from dependencies

0.0.2 (2015-02-12)

  • (bluefox) enable be a part of "web"

0.0.1 (2015-02-06)

  • (bluefox) initial commit