Giter Site home page Giter Site logo

Control devices? about lutron-leap-js HOT 3 CLOSED

thenewwazoo avatar thenewwazoo commented on June 12, 2024
Control devices?

from lutron-leap-js.

Comments (3)

thenewwazoo avatar thenewwazoo commented on June 12, 2024 1

Hi @sergei202, this project is only an implementation of the protocol, which doesn't have a concept of a device as such. I wrote a bit about it in the readme. This library is what you would use to communicate in order to control a dimmer, but the logic to do that would live elsewhere. It might be worth looking around to see if there are any other users of this library that could be inspiration.

from lutron-leap-js.

sergei202 avatar sergei202 commented on June 12, 2024

For anyone who arrives here looking for the same thing, it's actually very easy to control devices:

Get your device object from bridge.getDeviceInfo(), it'll look something like this:

  {
    Name: 'Cans',
    DeviceType: 'WallDimmer',
    AssociatedArea: { href: '/area/5' },
    href: '/device/11',
    SerialNumber: 64668928,
    FullyQualifiedName: [ 'Office', 'Cans'],
    Parent: { href: '/project' },
    ModelNumber: 'PD-6WCL-XX',
    LocalZones: [ { href: '/zone/8' } ],
    LinkNodes: [ { href: '/device/11/linknode/11' } ],
    DeviceRules: [ { href: '/devicerule/27' } ],
    AddressedState: 'Addressed'
  }

Then pass the LocalZones[0].href to client.request():

client.request('CreateRequest', '/zone/8/commandprocessor',
    {'Command':{'CommandType':'GoToLevel','Parameter':[{'Type':'Level','Value':50}]}}
).then(r => console.log('response=%o', r));

from lutron-leap-js.

thenewwazoo avatar thenewwazoo commented on June 12, 2024

Thank you for documenting that! I've been chewing on it, and I think having a separate abstraction for physical devices, as a place to encode the kind of logic you've written here, is probably a good idea. Given that a few different devices use similar commands, I even think a device-command-protocol MVC-ish style approach would allow a clean implementation.

from lutron-leap-js.

Related Issues (20)

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.