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

OpenRemoteHelpers:metrics refining parameter #217

Closed
pz1 opened this issue Feb 10, 2015 · 5 comments

Comments

Projects
None yet
2 participants
@pz1
Copy link
Contributor

commented Feb 10, 2015

The present code for metrics takes only one parameter [N] ,the device ID:

 case "metrics":
    // used HA API for all device to get metrics
    return this.controller.devices.get(N).get("metrics:level")

If in the last line "level" was filled by the second parameter [I], the function would be more versatile. It would enable not only extraction of the level of a sensor, but also the other attributes.
I could imagine that if the second parameter were omitted, the default "level" attribute was to be returned. That would make the function compatible with earlier releases.

@pz1

This comment has been minimized.

Copy link
Contributor Author

commented Feb 11, 2015

It works for me with this code

        case "metrics":
             // used HA API for all device to get metrics
             if (I !== "") {
               attrib = "metrics:" + I;
               }
             else {
               attrib = "metrics";
               }
            return this.controller.devices.get(N).get(attrib)

In this example I did chose to get all the metrics returned if the second parameter (I) is omitted.
See also forum http://forum.z-wave.me/viewtopic.php?f=3424&t=20819&p=54894#p54894

@pz1

This comment has been minimized.

Copy link
Contributor Author

commented Feb 12, 2015

While we are on it we may take the opportunity to

  1. Close the Switch construct properly with a default:
  2. Indicate the place where users can safely add their extensions to OpenRemoteHelpers
        case "metrics":
            // used HA API for all device to get metrics
            if (I !== "") {
              attrib = "metrics:" + I;
              }
            else {
               attrib = "metrics";
              }
           return this.controller.devices.get(N).get(attrib);

 // Your "case" statements may go after this line, but before default:  !

        default:
             return "Error: function " + cmd  + " is not defined in OpenRemoteHelpers";
@PoltoS

This comment has been minimized.

Copy link
Member

commented Feb 12, 2015

good idea to implement this. You can do "pull request" to easily merge it in our main code. Please do in develop branch

@pz1

This comment has been minimized.

Copy link
Contributor Author

commented Feb 17, 2015

Done

@pz1

This comment has been minimized.

Copy link
Contributor Author

commented Mar 2, 2015

Updated module has been included in develop branch,

@pz1 pz1 closed this Mar 2, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.