# CoRE - Get peer assistance here with setting up Pistons

I have something similar set up. This is what I have:

IF
◦ Time is between 30 minutes before sunset and 11:00 PM EDT
03:40:55
◦ Time is between 6:00 AM EDT and sunrise
15:07:55
◦ Weather illuminance is less than or equal to 1000lux
◦ Hall Motion Sensor motion is active
When true…
Using Hall Light…
► Turn on
► Set level to 100%
◦ Hall Motion Sensor motion is active
BUT IF
◦ Hall Motion Sensor motion is inactive
THEN…
Using Hall Light…
► Wait 2 minutes
► Fade level from 100% to 0% in 5s

I think all you would need to do is change the WHEN TRUE to do the Routine.

This seems close, but I think I really need to track multiple motion events over a 30 minute period between 07:00 and 10:00.

Here’s my scenario:
I have my good morning routine to change mode when activity starts between 06:00 - 10:00. This changes the brightness level of my hall lights (Outside of all bedrooms) to 85%. (In addition to other things) Now that fall is here, 06:00 is still pretty dark and people can potentially wake up to a bright hallway which isn’t very comfortable.

What I would like to do is only run the routine if motion is detected multiple times across 3 different motion sensors.

This is beyond my knowledge but my guess is that you will have to use some variables to time the motion detections and count the times that it is happening. I would like to see how this is done as I have one piston that I would like to set a timer on.

When you say multiple, do you mean multiple subsequent motion events from EACH of the sensors or at least one from each of the three within 30 min?

Do you get any voltage reading on the power meter? Aeon HDS does provide voltage and amperage (current), as well as wattage (power). If so, you should see voltage go down to 0 briefly - perhaps your generator provides a different voltage - not sure how to tell when the voltage is line or generator sourced. Perhaps you need a device that reports voltage that’s NOT connected to the generator…

I get both I believe. See below activity feed. My generator takes 10 seconds to kick in and that is the time I can tell if I have no power.this is the smartapp that works for me now: Power Sensor

Nah, you are getting instant power and energy (accumulation of power). And the 10s tell you when the power is out, but not when the power is back on. Ever thought of a dry contact sensor or vibration sensor on the generator to know when it’s running?

This is my Aeon Heavy Duty Switch controlling my water heater

I actually do that too. However, I still like to know when power goes out and comes back as the vibration sensor on my generator will give out false positives when it’s windy or the landscapers are mowing my lawn close by :). This smartapp is my true way of telling when my home loses power. I assumed since this smartapp can do it, CoRe can?

Also, how will any hard wired device report 0V? It itself would have no power to report the lack of said power

So you have something that actually works? Look up the device in the IDE and show me the Attributes list… any voltage there? Power is not a good measure since power can be 0 with or without electricity…

Yes that smartapp I posted the link to above works perfect! Attributes in IDE are:

switch: on
energy: 29.325 kWh
power: 0 W

Do you have a device plugged in that always draws power? My washer is always at 2.9-3W when idle, so being at 0 would mean that, but otherwise I don’t see how instant power can lead to having electricity determinations…

Yes I have my dryer(1kw)and washer(29kw) and each draw some power. So should I use that equal to zero as my condition?

What I don’t understand is if that loses power it can’t communicate at all to my hub, right? How is the smartapp doing it?

I don’t know but I would like to see that app

Here it is:

/**

• Power Is Out
• Updated by JMZ
*/
definition(
name: “Power Is Out”,
namespace: “smartthings”,
author: “JMZ”,
description: “Alert me of power loss using motion detector’s change from wired-power to battery-power. SmartThings hub and internet connection must be working! You can connect the hub and internet connection device (e.g. modem, router, etc.) to a battery backup power strip so that the motion detector and detect the loss and the hub and router will still have enough power to get the message out before they fail as well.”,
category: “Safety & Security”,
iconUrl: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png”,
iconX2Url: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png
)

preferences {
section(“When there is wired-power loss on…”) {
input “motion1”, “capability.motionSensor”, title: “Where?”
}
section(“Via a push notification and a text message(optional)”){
input “pushAndPhone”, “enum”, title: “Send Text?”, required: false, metadata: [values: [“Yes”,“No”]]
input “phone1”, “phone”, title: “Phone Number (for Text, optional)”, required: false

``````}
``````

}

def installed() {
subscribe(motion1, “powerSource.battery”, onBatteryPowerHandler)
subscribe(motion1, “powerSource.powered”, PoweredPowerHandler)
}

def updated() {
unsubscribe()
subscribe(motion1, “powerSource.battery”, onBatteryPowerHandler)
subscribe(motion1, “powerSource.powered”, PoweredPowerHandler)
}

def onBatteryPowerHandler(evt) {
log.trace "\$evt.value: \$evt"
def msg = “\${motion1.label ?: motion1.name} sensed Power is Out!”

``````log.debug "sending push for power is out"
sendPush(msg)

if ( phone1 && pushAndPhone ) {
log.debug "sending SMS to \${phone1}"
sendSms(phone1, msg)
}
``````

}

def PoweredPowerHandler(evt) {
log.trace "\$evt.value: \$evt"
def msg = “\${motion1.label ?: motion1.name} sensed Power is Back On!”

``````log.debug "sending push for power is back on"
sendPush(msg)

if ( phone1 && pushAndPhone ) {
log.debug "sending SMS to \${phone1}"
sendSms(phone1, msg)
}
``````

}

That app used a motion sensor that is plugged in and also has a battery. Not sure which device fits that description, but it’s definitely not using a power meter. What device are you using with the app?

Wow I’m losing my mind! You are right. I have a motion sensor plugged in to wall but it has batteries in it. It senses right away when it switches to battery. Can CoRe do this?

Sure can. What sensor is that? Lots of people are looking for such a device…

1 Like

Must be the v1 ST motion? Not sure the new ones have that.