Variables and WebCoRE

I’ve got a little fan heater in our outside studio on a smart plug which I can control through SharpTools. I’ve also got a temperature sensor out there. In WebCoRE, I have a piston that turns the plug off if the temperature hits 18.5. That’s ok so far.

What I’d like though is for that 18.5 to be a variable in WebCoRE and for my other half to be able to adjust it on a tile.

Is this possible with SharpTools? Or is there anything was to do it with SharpTools without using WebCoRE?

Cheers
Andy

1 Like

Thinking before having coffee, but here goes:

Create a virtual switch and tile in ST. In webCore, code the switch to be momentary (when it goes on, WAIT then OFF). Also code your variable to increment by some value each time the switch turns on. You’ll probably have to do something to have the heater turn on if the variable increments as well.

You’ll need two switches/tiles. One for up and the other for down.

I haven’t ever used a momentary switch, but theoretically this should work.

3 Likes

That makes sense. I am drinking coffee and will have a play now.

@andy I like the use case. Variable is not currently supported, but is in our list, so I will note your use case in the design. Meanwhile, I think @Bry method would work, but don’t forget to check the watt your fan heater uses and the smart plug. :smile:

Edit: SharpTools now has it’s own variables which can be used in SharpTools Rules and Dashboards:

Yeah, plenty there to play with on the current front.

1 Like

We also added some HTTP Request features for power users to the latest beta. We haven’t announced / documented these features yet, but they’d allow you to bypass the need for a Momentary Switch since WebCoRE has the option to trigger a Piston via HTTP.

In your WebCoRE piston, you’d copy the “External URL” (Right Click → Copy Link Address):
image

Then anywhere that you can use a Hyperlink in SharpTools (eg. a Hyperlink Tile or in the action for a Media Tile), you can use a special syntax for the URL which tells the system to make the request without actually opening the page in a new window:

$.get("https://graph.api.smartthings.com/api/token/XXXX/smartapps/installations/XXXX/execute/:XXXX:", {"proxy": true})

For example, here’s a dashboard with:

  1. Hyperlink Tile (Decrease)
  2. Media Tile (Current Value, Tap to Reset)
  3. Hyperlink Tile (Increase)

Edit: The REST API Hyperlink Syntax feature is now released and you can find documentation on it here:

:link: How To: Call REST API from Hyperlink Tiles (Syntax)

Edit: And here’s the topic showing how you can display WebCoRE variables in SharpTools (what the media tile is doing in the screenshot above):

:link: How To: View WebCoRE Variables in SharpTools Dashboards

LOL. Just when you think you have it nailed, @josh comes out with a cool new feature!!!

Sweet! :grinning:

3 Likes

Well I’ve got it working with @Bry’s solution. Seems to be ok. I followed another tutorial on here for displaying the target. It’s a bit laggy using that image thing but it’ll do for now. It works so that it will only come on when motion is detected. It’s my other half’s domain. She does arty stuff and has a kiln out there but isn’t out there all the time. So the heater comes on for 30 minutes every day just to keep things from getting damp. If motion is detected then the heating will stay on until it reaches whatever target temperature she sets. I’ve got it all working on one piston to write the variable, do the ‘put’ to myjson.com, read it back, set a global variable, copy it to a local variable, etc. All untested at the moment but I’m confident :wink:

I’m going to move a tablet out there so I might put the beta on that one and try @josh’s method. I wonder if it’ll work with Alexa? Firing the virtual button would probably be OK but it would be neat to be able to write a value straight to WebCoRE with a voice command.

2 Likes

That’s the one I followed. It would definitely be nice to be able to just pull the variables directly from WebCoRE though.

Glad to hear you got it all working. That sounds like a really neat setup.

Is the goal of pulling directly from WebCoRE reducing the lag? I would think the lag would primarily be related to the refresh interval that’s chosen for Media Tile.

As far as I’m aware, WebCoRE doesn’t expose an API, but even if they did we would still likely have to poll periodically, so I don’t know if that would solve the lag.

Instead of using WebCoRE variables, another approach is to use an attribute on a custom virtual device. When device values are changed, those subscribed events are immediately pushed over to SharpTools and down to your browser.

The HTTP stuff all happens directly in your browser, so it won’t work with Alexa… but if you are using a Virtual Device then you could definitely use that in Alexa (as long as it’s a supported type like a switch, etc.)

In this particular setup, I’m wondering if a Virtual Thermostat doesn’t make more sense? It would show up in SharpTools like a thermostat control meaning you’d see the temperature in the center and the ability to directly adjust the temperature up and down quickly and easily (a much smoother user experience).

You could still use the temperature attribute in WebCoRE like a variable and would still have direct access to reading and changing the temperature as if it were your target temperature.

1 Like

Yes, I’ve got the refresh interval set to 10 seconds at the moment. I’m not sure of the AUP on shields.io? Could I set it to 1 second?

I did think about the virtual thermostat. I might play with that one a bit later.

1 Like

You could, but as you noted that’s probably pushing the limits of the intentions of shields.io and the myjson service.

The Virtual Thermostat is definitely a better approach with respect to refreshing the data as it doesn’t have to poll. The data gets pushed from the virtual device to your browser, so it’s much more efficient. :slight_smile:

1 Like

I tried adding it as a simulated thermostat but that just appears as a switch. I changed it to a thermostatdevicetile and it now looks like a thermostat apart from being in F rather than C.

Oh, and if anyone knows why I get access denied in Chrome when I’m editing or adding things in the ST IDE I’d love to know. I have to do it in an incognito window and keep forgetting :frowning:

I have a custom Simulated Heating Thermostat driver I used when testing heat only thermostats… let me see if I can find a copy and post it.

1 Like

Well, I’m pretty sure I have a simplified Simulated Heating Thermostat somewhere, but I can’t seem to find it at the moment.

In the meantime, I think this version should get you going:
(it’s a modified version of the SmartThings simulated thermostat, focused just on heating)

1 Like

Tried that and it seems to work a treat. The only thing I’m struggling with is the steps. On the tile, it uses 0.5 steps. If I set it to 18.5 then the variable in webcore gets set to 18 (even though I have a decimal variable type). Then, a few seconds later, the target temp changes to 18 as well. Not a hug problem as I just need to tell my other half to only use integers if she wants to set the temp but I’m wondering if there’s a way round it.

Let me double check the driver. I vaguely recall the SmartThings version of the driver tries to round to integers.

1 Like

I’ve updated the GitHub gist to simplify the driver a bit (removed all the nonsense about proposing temperatures and evaluating them as integers).

Can you try updating your copy of the DTH with the new version and see if that helps?

https://gist.github.com/joshualyon/eaf45129a0e68c46e859278ca3faac8f

1 Like

Thanks, Josh, but sorry, the only difference I can see is that the target on the tile stays at (for example) 20.5 whereas the variable in WebCoRE is 20.

Unless you have a hunger to get to the bottom of it, I wouldn’t worry to much. It’s no real issue to tell the other half to use integers.

Oh, I even deleted the tile from SharpTools and re-added it. Just in case. I wonder if it’s a WebCoRE issue?