Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapter API - setProperty() #20

Closed
benfrancis opened this issue Mar 30, 2017 · 5 comments
Closed

Adapter API - setProperty() #20

benfrancis opened this issue Mar 30, 2017 · 5 comments

Comments

@benfrancis
Copy link
Member

As a MozIoT web app developer I would like to call a method to tell an adapter to a set a property on a device.

Suggestion:

AdapterManager.setProperty(deviceId, propertyName, value)

returns a Promise which resolves once the property has been successfully set, perhaps with a representation of the new value.

My suggestion is that this can just be called on the AdapterManager directly (referencing the device ID) so that the web app doesn't necessarily need to care which adapter the Thing is connected to...

@benfrancis
Copy link
Member Author

@dhylands Have you started working on anything like this yet by any chance? I need this for the next step on the front end, to actually turn the on/off switches on and off :)

@benfrancis
Copy link
Member Author

Looking through the code of the DebugController it looks like I could create a PropertyController with a PUT handler that looks something like this...

  var device = adapterManager.getDevice(deviceId);
  if (device) {
    var attribute = device.getAttribute(attributeId);
    if (attribute) {
      var attributeValue = request.body[attributeId];
      if (attributeValue !== undefined) {
        device.setAttributeValue(attributeId, attributeValue);
        response.send();
        return;
      }

Should I do that, or do you think we should add a method on the adapter manager? Really I guess the adapter should be translating WebThing property names into Z-Wave device attribute names.

@dhylands
Copy link
Contributor

Yeah - I think that the adapter manager should be creating WebThing property names, and then those should be used to create the REST API.

So it would be very similar to what you have above, although I'd probably use 'Property' rather than 'Attribute' if we're going to generate WebThing properties.

@benfrancis
Copy link
Member Author

OK, well if there was a method on AdapterManager where I could just call AdapterManager.setProperty(deviceId, propertyName, value) with the Web Thing property name, that would be awesome :)

@benfrancis
Copy link
Member Author

Implemented

@benfrancis benfrancis modified the milestone: Q2 2017 May 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

No branches or pull requests

2 participants