Skip to content

Create Read data from another Plus via HTTP GET.js #69

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

frspp
Copy link
Contributor

@frspp frspp commented Oct 1, 2023

No description provided.

Copy link
Collaborator

@taulfsime taulfsime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution, good example with comments explaining important lines.

Some nits and please register it in the readme and the manifest file.


// Settings
let ip = 'ip';
let username = 'admin'; // do not change, it is always admin
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed, since as the comment said its always 'admin'.

// Send HTTP get request with authentication
Shelly.call(
"HTTP.GET", {
"url": "http://" + username + ":" + password + "@" + ip + "/rpc/Switch.GetStatus?id=0",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move the url compilation outside of the request params.

},
function(result) {
// print(result.body); // Uncomment to see all available values.
let totalwh = JSON.parse(result.body).aenergy.total; // Reminder: On a Plus device energy total is in Watt-hours. On Gen1 device it is Watt-minutes.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Save the parsed body to an variable and then use it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants