Setting Power/Energy on Switch


#1

1) Give a description of the problem
I am working on building a piston for a wifi switch that uses http. I am able to parse the data and set it into variables or whatever I need to, but I am having difficulty finding out how to add the data to the tile.

See below screenshot. I am able to capture data into the variable, but no idea how to send that to the device.

2) What is the expected behaviour?

Tell WebCoRE to update the tile with the power data from the http session

3) What is happening/not happening?
I cannot find a way to pull data from a variable and set it on a device

**4) Post a Green Snapshot of the piston
I would do this, but I have sensitive data in my piston.

Question: Is there a way to put IPs/Usernames/Passwords in a secure method?
Here’s a screen shot regardless

5) Attach logs after turning logging level to Full
No logs relevant to this


#2

At the bottom of that piston, you can use the code:
Set piston tile
to draw the tile.

Title is the top line, Text is the large middle area, and footer is the bottom. If you are using Expressions (as seen here), then the variable names should be outside of quotes. (with normal text inside of quotes)

In this example, tempPC and battPC are both variables…

Which draws this tile for me:

temp


Side Note:
Normally, “Tile index” is 1, but each piston can draw up to 16 tiles.
The example above just happens to be my third tile in that piston.


#3

If you store a IP or web address in the top define section as you have done, it is not anonymized by the green snapshot.

but…

If a web address is in the body of the code, then the green snapshot only shows us an anonymized version (safe).

Storing in a global variable is also safe…


#4

Thanks for the steps. I was more looking for setting the actual device to those metrics, rather than the dashboard tile but it doesn’t appear that is possible.

Regarding the username/password, I found out that I have to pass those as Base64 HTTP header, so it’s much easier to obscure that way.


#5

Variables can be used anywhere using the same structure as depicted above.

For example, using an integer variable:

temp

Line 24 will set the brightness, based on the number in the variable.
This concept carries over in an infinite number of ways…


Perhaps you should read up on acceptable commands for your specific device. If it accepts commands, there is a real good chance that webCoRE can do what you wish…


#6

I think it’s mostly because these are virtual switches, as I am doing HTTP calls to control them. I’ll paste what I have just as a code review.


#7

Here’s the Piston! If anyone has any suggestions on how to optimize this, I’d be more than happy to do so.


#8

I am sorry. There is way too many things that I would do differently with this piston. I would be here all night talking about it, and the final product would look nothing like it does now… If you are new to webCoRE (Joined 5 hours ago) I would highly recommend learning the basics before trying to tackle a piston like this…

If you imported someone else’s piston, an alternative is to talk to that person to get advice from them.


#9

Understood, I’ve used webcore for a while on simple stuff but nothing this complex. I developed this today, and I’ve have several different drafts. I am not stuck on the power/energy presentation, however I would like to get your feedback, so far as what you see wrong.I am not expecting a fix, but rather some pointers so I can figure out how to get this better optimized. I’m just not aware of the limitations of the platform. I normally code in Powershell, so I use a lot of the same logic that saves steps, but I understand the processing power on ST is very limited.