Variables and WebCoRE

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?

It might be at this point. The device driver was originally rounding to an integer when setting the value which I’ve corrected in the latest driver.

I’m not intimately familiar with WebCoRE, but I just tried setting up a piston and it seems to be setting my local variable as expected:

I changed the thermostat value to 20.5 in SharpTools…

image

Then over in WebCoRE, it looks like the Piston was triggered and the variable was updated as expected (as shown in the logs and in the variable section in the bottom right of the page:

1 Like

Thanks, Josh. So that proves it’s definitely something at my end. When I created the variable, I created it as an integer and then changed it. I can set it manually to x.5 in WebCoRE but maybe there’s something funny if you change the variable type. I’m going to delete the variable and add a new one with a different name.

1 Like

Well, that’s a bug!

Just added a new variable a decimal. Updated my piston and, as you can see, it’s now showing 20.5.

2 Likes

@andy, just wanted to let you know that we have released the Variables feature today, and it should support this scenario pretty well. You can define a number variable to be used in the rule for setting the temperature or as a trigger. This variable can also be added to the dashboard so its value can be adjusted by tapping the tile. See the post below fore details, and let me know if you have any questions.

bah, myjson is dead. been looking for a way to display a webcore variable, which would be awesome. But apparently not so simple. =/

I just discovered using the $.get(“https://graph-na02-useast1.api.smartthings…”) hyperlink tile to call a WebCoRE piston instead of using a momentary button. Works great, even though there’s a few-seconds popup of HTTP GET FAILED!

Which is odd since the piston ran correctly.

Don’t know why I’m only discovering this now. LOL

The “HTTP GET Failed” message is because the SmartThings / WebCoRE endpoint doesn’t properly support CORS. You can work around it by using the special proxy flag:

There’s some other neat tips in the linked thread as well:

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

2 Likes

Someone else found a service called jsonbin which seems to do the same thing. You can find some notes on it in the following thread:

1 Like