Git Product home page Git Product logo

ushelly's Introduction

Micro Shelly

This is a example implementation of real-time-events API offered from Shelly cloud

Setup

  • Obtain and setup OAuth Authentication code
  • Create JS/TS code to handle device status events
  • Issue control commands back to devices from your JS/TS code

Obtaining OAuth Authentication code

Production code should have a dedicated web service hosting to receive the web callbacks from Shelly Cloud's OAuth grant page. For the purpose of this demo we suggest you register a account to http://pipedream.com and use their wonderful service RequestBin to "land" the web callback. If your RequestBin url is

https://some_random_string.m.pipedream.net

you can visit

https://my.shelly.cloud/oauth_login.html?client_id=shelly-diy&redirect_uri=https://some_random_string.m.pipedream.net

do the login and then you can extract the code from the RequestBin UI

Runing the demo

Once you have the OAuth Authentication code:

  • install dependencies npm i
  • build npm run build or just ./tsc
  • configure node . -a my_very_secret_auth_code

at this point you can just run the demo with

node .

Make it work for you

for expiration take a look at src/ucode/example.ts all it does is add some more console.log but you can see how to enumerate devices at startup, and how to hook to various events emitted form parsed messages coming from the cloud. Any .js file in build/ucode get loaded and start()ed after the demo initiates so you don't actually need typescript if you're not comfortable with it.

HAVE FUN

ushelly's People

Contributors

sdrsdr avatar 0nikola1 avatar

Stargazers

Quentin Chaillard avatar Aaron Hritz avatar  avatar

Watchers

 avatar Kiril Zyapkov avatar James Cloos avatar Mircho Mirev avatar Dimitar Buckoff avatar  avatar  avatar

ushelly's Issues

Duration parameter of roller command request

The GEN1 rest and GEN2 RPC API have an optional duration parameter for the roller open and close command. This is missing in this library. Is it not available in Shelly Cloud Account API or just missing in this example?

If it is missing could it be added for reference.

params: {go: String(go), id:channel}

Timeout on WebSocket connection

Hi, when I try to run the example, I get the following error:

...boot...
restored access token...
devices_new devid: 265292 ( 040c4c ) code: SHPLG-S
...establish_event_link...
reusing access token...
...connection_lost... code: Error: connect ETIMEDOUT <ip address>:6113
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1595:16) {
  errno: -4039,
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: '<ip address>',
  port: 6113
}  reason: undefined

It seems that when I try to connect to wss://<shelly_cloud_server>:6113/shelly/wss/hk_sock?t=<ACCESS_TOKEN>, I am getting timeout.

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.