[DEPRECATED Thread: visit community.webcore.co for assistance] webCoRE - Piston Design Help (ask your fellow members for assistance)

The only thing I can think of is that your Hue lights may take more time than your allotted 1 second wait time to communicate all of their current states that you’ve requested to webCoRE. In my example below, I’ve added a 1 second delay - which made all the difference for successful execution of the piston, but I’m only asking for level and switch attributes from three z-wave switches that are all fairly close to the hub. I’m not aware of Hue lights taking longer to communicate (don’t have any) and I don’t know how close they are to the hub, but just as a test, you might try adding 5 seconds for the capturing of your various states to see if that solves the problem you’re having with the Hue lights. If that works, try cutting back as far as possible to still have it work. If it’s not that, I’m not sure what the issue is.

Good luck!

Try capturing/restoring only a subset of the attributes. The color attribute includes saturation, level, and hue. Try restoring just color and switch and see if that fixes it. Or try with saturation, level, hue, and switch - but never with all of them. If lights still stay on, try restoring color or h/s/l, then add one second and then restore the switch

Whats the best way to set up a condition that triggers the first time something happens each day after a certain time, but only the first time? And it resets as of 6am.

For example:
IF this is the 1st time since 7am that the door has been open THEN…

So let’s say the door opens at 8am for the first time that day, it should trigger. If the door opens again at 10am it should not trigger. Then overnight, once 6am rolls around, it should be considered a new day and the next time the door opens would trigger.

I know I could do it like this, but was wondering if there’s a better way:
var x;

every day at 6am set var x to null
if door changes to open and var x is null then
take action
set x = $now
end if

Is there a better/more straight-forward way?

Thanks,

Here’s how I do it. you can base your piston off of this one.

Thanks. However that would not work in my case, since I want a new day to be considered 6am, whereas in your case using $day it would be considered at midnight. Similar idea tho, I suppose.

EUREKA. Turns out I’ve been using external software to change the colors of my Hues, and the states weren’t updating in SmartThings. I added a refresh command before capturing the bulbs’ attributes, and VOILA! It works. Thanks to you and @lflorack for your help.

P.S. @ady624, do you ever sleep?

Yes this “stale” state issue has been a big one for me too with the LIFX bulbs. They are slow to update. And a refresh takes over 7 seconds with all my bulbs…

Wait… (yawn)… what?

2 Likes

I use something like this:

global boolean @NewDay;

piston 0:
every day at 6am set @NewDay to true;

other piston:
if door changes to open and @NewDay is true then
take action
set @NewDay to false
end if

Thanks. That’s exactly what I have in mind. Tho for ease of maintenance I will have both in the same piston. I was just wondering if there was an easier way do to a check to see if something happened for the first since x o’clock. webCoRE has some many switches and options and I like to use as much built-in stuff as available.

well you could always use if {$previousEventDate} is before datetime(“06:00:00”)

if that if is true then this is the first event after 6am today. but it would depend on what events your piston is subscribed to.

or you could use if ($currentEventDate - age([Sensor : Contact}}) is before datetime(“06:00:00”)

if that if is true then the last event before this was before 6am so this is the first event after 6am.

edit: btw, the full check would be as follows — otherwise you may be checking the wrong event date if that piston subscribes to other events:

if Contact changes to Open && ($currentEventDate - age([Sensor : Contact}}) is before datetime(“06:00:00”)

@ady624 I have a piston that says “IF Motion 1 STAYS INACTIVE for 150 seconds THEN turn off a light” and a separate piston that does the same thing but for a different motion sensor and light. I noticed the lights had been on for over an hour despite there not being any motion for that whole time. So either the task that was supposed to monitor for the motions staying inactive for 150 seconds never go schedule, or somehow the communication that 150 seconds passed with no activity never got sent or maybe there was a ST platform glitch at the time (around 6:52pm EDT tonight)?

Any ideas? This piston has been working flawlessly for about 3 weeks since I wrote it. Not sure what caused that event to be missed. I just tested it now and it worked fine this time. Any ideas?

@bangali, very good catch. I am learning too but having so much fun with this. :smile: I did some testing and I think this one will work. Still brainstorming on ideas on how to enhance this for different scenarios to make the smartest mailbox in the world. :grinning:

@kpdillon hey, we are all learning here. except @ady624 off course, who keeps unleashing things to learn on us. :slight_smile:

btw, for the last if and the nested if, have you considered just checking for this so you know when the mailbox is stuffed and not closed?

if Contact sensor 3 stays open for 5 minutes?

@bangali well, I suppose I could enhance the first if statement to check if it’s overstuffed and send an alert if it is, but I think I also want that last statement so that I get notified once the mail has been retrieved (meaning the mailbox sensor finally closes). Is that what you mean?

Hi all,
I am trying to send data from a python script to my piston using external request feature from webcore.
I have no problem triggering the piston and passing the data with a POST request and JSON in my python script.

import requests

url=“https://graph.api.smartthings.com/api/token/xxxxxxxxxxxxxxxxxxxxxx/smartapps/installations/xxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxx/execute/:xxxxxxxxxxxxxxx:

data = {“id”:“6248889874650987”,“systemIdentify”:“s08”,“sourceChannel”: 12}

headers = {‘Content-type’: ‘application/json’}

rsp = requests.post(url, json=data, headers=headers)

My problem is, How do I access all this data from my piston?
Is it automatically stored in a variable?

Thank you,
Any help is appreciated

Log to console the contents of $args

1 Like

Sorry to bump this, but I only have this weekend to move over to a new hub. Maybe these are stupid questions?
"Is it possible to control the devices on two ST hubs from one instance of webCoRE?
If so, could you give me some guidance as to how I will do that?"
I suppose the alternative question is how does one transfer webCoRE to a new hub? Do I have to restore backups of the Pistons? That is not such a major hassle, but what about things like Global Variables? Do I have to re-create them?

Thank you,
It’s working perfectly :relaxed:

1 Like

@kpdillon or you could handle it this way and still get the relevant notifications … with an added “feature” :slight_smile:

if Contact sensor 3 changes to closed

  • if lastday is different than $day
    • send notification mail was delivered …
    • set lastday = $day
  • else
    • send notification mail was retrieved …
  • end if
    end if
    if Contact sensor 3 stays open for 15 mins
  • if lastday is different than $day
    • send notification mail was delivered and mailman left the mailbox open
    • set lastday = $day
  • else
    • send notification whoever retrieved the mail left the mailbox open
  • end if
    end if