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?
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.
@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.
Edit: SharpTools now has it’s own variables which can be used in SharpTools Rules and Dashboards:
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):
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:
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
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.
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.
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.
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.