Hi, I have a three part question, but I’m being held up by the roadblock in the same place.
I’m trying to implement the “Has Barkley Been Fed” SmartApp, but updating it since I feed the dog twice a day. Currently, the Smart App looks to see if the dog has been fed since midnight, but I’d like to change midnight to a user selectable value (such as 5pm). My code is failing trying to calculate “EventsBetween” the two times. I’ve tried a lot of different code, such as:
def feedstart = Date(time1)
log.trace feedstart
def feederEvents = feeder1.eventsBetween(date feedstart, date now) or
def feederEvents = feeder1.eventsBetween(time0, time1)
But they are all failing becuase I am apparently misrepresenting time in that “eventsbetween” handler. Also, I’m looking to specify the event type to be a “contact open” and not just any event. Any help?
My other two projects are depending on me properly able to calculate which events have occurred recently relative to each other. For example, I’m trying to set off a notification when my door opens, but only if it happened from the outside.
So once the “contact open” program runs, I want it to look at my motion sensor and see if there was any motion (which is indoors) within the past 30 seconds or minute. If it sees motion prior to the contact sensor being opened, I would not send out the notification as someone is probably just leaving the house.
Lastly, I’m looking to implement the opposite of the above item. If a motion sensor triggers, BUT the door is opened within 30 seconds following that motion then I don’t want a notification. But if there is motion and the contact DOES NOT open, then I want a notification.
Any help would be greatly appreciated. I haven’t had good luck looking up Java time conversions.