Giter VIP home page Giter VIP logo

cli-example-nodejs's People

Contributors

beckje01 avatar jimmyjames avatar john-u avatar jonathanporta avatar unixbeast avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cli-example-nodejs's Issues

Should be command and not commands in actuate call

I believe the code is correct as is, but the commands and the use of commands instead of command is wrong. In the code below, it looks like commands can not be an array (only a string), yet commands implies array as well as the comment specifies an array. Am I wrong?

/**

  • Configures and returns a request-promise to actuate a device using the
  • SmartThings API.
  • @param {string} switchId - The ID of the switch.
  • @param {Array} commands - An array of commands to send to the device.
  • @returns {Object} - The request-promise for this API request.
    */
    function actuate(switchId, commands) {
    const options = {
    method: 'POST',
    url: ${api}/devices/${switchId}/commands,
    json: true,
    headers: {
    'Authorization': 'Bearer: ' + token
    },
    body: commands
    };
    return rp(options);
    }

Status / Events

Thanks for this.

What ideally should be added is a demo of how to watch devices to see when their state changes.

I'm not fully versed in the API yet, but it looks like you have to poll each device? If so, any rate limiting would kick in pretty quick (or you have some massive lag in updating your UI).

Ideally, this demo (cli-example-nodejs) would have a "monitor" command. When you run sthelper monitor the program would sit there waiting for you to turn on/off switches (etc.). If I go to the wall switch and turn it on, the program would print "Kitchen Lights On". If I turn the switch off, the program would print "Kitchen Lights Off." If I use the SmartThings App to turn on the lights, the running sthelper would print "Kitchen Lights On" and so on.

There really should be a websocket capability to receive a stream of notifications for the device state changes (on connection, all device states would be sent). Otherwise, my home has 30 smartthings devices and to poll for 30 things with a 60/second limit would mean very infrequent polling of each device (and a lot of network overhead for the polling).

The Nest developer API uses EventSource, which is perfect for this application.

https://developer.mozilla.org/en-US/docs/Web/API/EventSource

I don't want to implement a full blown SmartApp - I just want to use the personal token and REST API like this demo uses. I absolutely do not want to run an HTTP server open to the internet on my home network so SmartThings cloud can post to it. Seems silly that I already have a device that's open to the Internet talking to SmartThings cloud - the SmartThings hub itself.

Timing Problem with Shades and this CLI version

I have Lutron shades that work perfectly with the SmartThings IOS app. They always go all the way up, all the way down when I command. If I stop them from going up or down midway with a remote switch, then every time, the mobile app does exactly the right thing when I instruct the shade to go up or down agan.

With this CLI version, I've got two commands I use.

sthelper turnon "Den Den Shade"
sthelper turnoff "Den Den Shade"

which both work some of the time. The problem is that they consistently will not bring the shade all the way up or all the way down. That is, the shade will just stop moving after it starts moving. If I do stop the shade with the pica remote, then the shade will never finish it's up or down when instructed by the CLI here (commands above). The mobile app works 100% of the time in this case.

In all cases, the CLI's

Successfully sent commands 'on' to device Den Den Shade
Successfully sent commands 'off' to device Den Den Shade

is output.

As I test more, I found this also:
Once I stop the shade from opening with the pico switch, then when I repeated send CLI commands to open, nothing happens. The events get sent as I can see in the event viewer (screen shot attached), but the shade does not move. If I go into the mobile app, press open, the shade continues to open immediately.

Screen Shot

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.