Giter Club home page Giter Club logo

0129765cd48a80aeab5079af20d4db1e92d34e7b1f4463681a3aedbac90cb6b2's Introduction

This repository contains some simple bash scripts which demonstrate using the REST API of the gateway using curl.

When prompted for the URL, include the http: or https: and any ports. Some example URLs:

The --insecure is required when using gateway.local. If you instead use your NAME.mozilla-iot.org name then you no longer need to use --insecure.

login.sh

$ ./login.sh
Enter      URL: https://mydomain.mozilla-iot.org
Enter    email: [email protected]
Enter password:

Running login.sh will retrieve the JSON WebToken for the user and store it in a local file called .jwt. It will also store the URL in a local file called .url.

get-things.sh

$ ./get-things.sh
[
    {
        "actions": {},
        "events": {},
        "href": "/things/HttpOnOffDevice-F714A9",
        "name": "LED-F714A9",
        "properties": {
            "on": {
                "href": "/things/HttpOnOffDevice-F714A9/properties/on",
                "type": "boolean"
            }
        },
        "type": "onOffLight"
    },
    {
        "actions": {},
        "events": {},
        "href": "/things/zb-00178801003fae06",
        "name": "zb-00178801003fae06-onOffColorLight",
        "properties": {
            "color": {
                "href": "/things/zb-00178801003fae06/properties/color",
                "type": "string"
            },
            "on": {
                "href": "/things/zb-00178801003fae06/properties/on",
                "type": "boolean"
            }
        },
        "type": "onOffColorLight"
    }
]

set-property.sh

$ ./set-property.sh zb-00178801003fae06 on false

get-property.sh

$ ./get-property.sh zb-00178801003fae06 on
{
    "on": false
}

Some additional scripts which may be useful while developing adapters.

get-addon-url.sh

$ ./get-addon-url.sh
{
    "api": 2,
    "architecture": "linux-arm",
    "url": "https://raw.githubusercontent.com/dhylands/addon-list/zwave-0.4.0/list.json"
}

get-devices.sh

NOTE: This script will only produce output when the gateway is run using the -d command line option. (i.e. npm start -- -d)

$ ./get-devices.sh
[
    {
        "actions": {},
        "adapterId": "zwave-ecf0a9e5",
        "description": "",
        "events": {},
        "id": "zwave-ecf0a9e5-3",
        "lastStatus": "ready",
        "name": "zwave-ecf0a9e5-3-Switch",
        "pluginId": "zwave-adapter",
...snip...
    }
]

get-device.sh

NOTE: This script will only produce output when the gateway is run using the -d command line option. (i.e. npm start -- -d)

$ ./get-device.sh zwave-ecf0a9e5-3
{
    "actions": {},
    "adapterId": "zwave-ecf0a9e5",
    "description": "",
    "events": {},
    "id": "zwave-ecf0a9e5-3",
    "lastStatus": "ready",
    "name": "zwave-ecf0a9e5-3-Switch",
    "pluginId": "zwave-adapter",
...snip...
}

0129765cd48a80aeab5079af20d4db1e92d34e7b1f4463681a3aedbac90cb6b2's People

Contributors

dhylands avatar mozilla-github-standards avatar rzr avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.