CoRE - Get peer assistance here with setting up Pistons

Sorry for the slow reply - I have the override switched off by my alarm (via a couple of Tasker plugins on my phone) or a Piston that runs at a set time in the morning (whichever comes first)

Any idea anyone? This simple thing is killing me. All I need is something like:

@PreviousValue = @Value
if (something) then
@value := newValue;
end if;
if (@Value != @PreviousValue )
execute piston
end if;

The problem is that in the highlighted line the only option for the @PreviousValue that I see in the Core UI is a constant value, ie I canā€™t pull it from the @PreviousValue variable (or I donā€™t know how).

It looks like I need some more help with CoRE. Iā€™m trying to setup a piston that will dim a pair of dumb lights connected to a ST dimming outlet based on the Mode and a ST Motion Sensor in the room.

This is the Latching piston I have setup right nowā€¦

So far the only part of this piston that is working is ā€œWhen Mode Changes to Eveningā€.

It does not respond to any motion in the room (and motion is being detected as seen in the ST app).

Any help would be greatly appreciated as this is one of the automations the wife actually asked for. LOL

I think itā€™s a common misconception about Core - people often confuse triggers and states, i.e. what happens momentarily, i.e. when something has occurred and the continuous state.

Basically, what you want for the 1st part is something like

When (Bedroom motion sensor motion changes OR The House That Hajj built changes) AND (The House That Hajj built is Day AND Bedroom Motion Sensor motion is inactive) WHEN TRUEā€¦ MBR Lights Turn Off

Same thing for all other conditions.

1 Like

Can someone tell me why my WeMo switch isnā€™t turning off after 10 minutes?

Thanks for the reply. If I understand my piston logic above, the States are the Mode that my house is in and the Triggers are the detected motion.

What I ultimately want the lights to do is thisā€¦

  • During Day the lights off unless motion is detected, then turn on at 100%. When motion stops, turn back off.

  • When the Mode changes to Evening, turn on the lights at 40%.

  • When the Mode is Evening and motion is detected, set the level to 75%. When the motion stops, set level back to 40%.

  • When the Mode changes to Night, set the level to 0%.

  • When the Mode is Night and motion is detected, set the level to 28%. When the motion stops, set the level back to 0%.

So I donā€™t think I need the ā€œOR The House That Hajj built changesā€ in the When statement do I?

I was able to get the lights to brighten and then dim back down base on motion alone (no Mode settings) with a simple Or-If piston using "when the motion sensor changes to active and inactive. But I donā€™t see a way to string multiple Or-If statements together.

Well, you kinda do - itā€™s an edge case actually. If Mode was, lets say, Morning - not sure if you have that or not, and then changed to Day, and at the same time motion was already active - you want this action to be triggered, thus you need both conditions to be triggered. Again, itā€™s a very edge case, but you might want to think about it.
Same thing is true for the Evening mode - you want to react to both Mode change (from Day to Evening) and motion change - cause you donā€™t know which one happens first and which one is going to be active (state) when another happens (trigger). And since only trigger actually TRIGGERS the action, you want both events to TRIGGER.

1 Like

Oh, thatā€™s a good point. So when Iā€™m entering that in CoRE, would that need to be entered as:

"Add a group " = Bedroom motion sensor motion changes OR The House That Hajj built changes
"Add a group " = The House That Hajj built is Day AND Bedroom Motion Sensor motion is inactive

Or would I need to add each of those ā€œgroupsā€ inside a higher level ā€œgroupā€ā€¦ if that makes sense.

Thanks again for the help on this!

Yes you need to use logical grouping. You only need a higher level of grouping if you have more than one AND group, as in

((X OR Y) AND (A AND B)) OR ((X1 OR Y1) AND (A1 AND B1))

Sweet, Iā€™ve got this part workingā€¦

Now I want to set up the active and inactive light levels for the mode Night. I tried to add it the same way, but it adds it as an AND function and I think I need it to be an OR function. Is that possible?

Also, do I need to add the ā€œThe House That Hajj Built changes OR Bedroom Motion Sensor motion changesā€ at the start of each Modeā€™s section, or is just the one at the top good?

Well, since the action is different for every Mode, then yes, unfortunately youā€™ll need to repeat that ā€œchangedā€ clause every time. If you only have 2 modes, evening and Night, why donā€™t you repeat same thing in the ā€œelseā€ clause for the If statement, ie

IF
(evening statement)
true -
false -
ELSE
(night statement)
true -
false -

If it was only as easy as two Modes. I need to set this up for the following Modes:

Evening 40% - 75%
Night 0% - 28%
Dawn 0% - 28%
Morning 0% - 28%
Day 0% - 100%

The first percentage is the inactive level and the second percentage is the active level in each Mode.

Trying to add the Night statement I get thisā€¦

Iā€™m pretty sure I need to get the green arrow changed to an OR and the orange arrow changed to an ANDā€¦ but I have no clue how to do that or if it is even possible.

I would do it in 3 pistons - that way itā€™ll be easier to create complex ifs

1 - set mode based on time and store it in a global variable, ie

if (time between midnight and 9am) then @daymode=night
else if (time between 9am and 5pm) then @daymode=day
etcā€¦
execute piston 3

2 - set % based on motion
if (motion detected) then @motion=true
else @motion=false
execute piston 3

3 - put it all together
if (@motion=true) then
if (@daymode=night or @daymode=dawn or @daymode=morning) then set%=28
if (@daymode=evening) then set%=75
if (@daymode=day) then set%=100
else
if (@daymode = evening) then set%=40 else set%=0
end if

Okay, I can follow the logic of that. A couple of things:

  1. I currently have a ā€œSet Modeā€ piston that changes the Mode based on day of week and time of day. Here is a chart that I used to keep things straight in my head when it comes to Modesā€¦

  1. Iā€™ve never messed with global variables, and I donā€™t see any documentation about setting those up in the CoRE wiki.
  2. IF I did set up global variables to handle the Modes for this use case, would it override (or should I remove) my current ā€œSet Modeā€ piston?

Iā€™m sorry if it seems Iā€™m giving you information piece mail, Iā€™m just not sure what is relevant and what would just be confusing.

1 Like

Cool!
I know itā€™s probably silly to make such a request (i.e. I could just do the same myself), but would you be willing to post/upload a copy of that spreadsheet?

Has anyone found a reliable source or used core to query the wind speed outside in order to use it for sprinklers or motion sensors outside.

I donā€™t think I can upload an excel sheet to the site. If you want to PM me your email, Iā€™ll send it directly to you though.

I donā€™t have any time based automation activities between 8:30am and 4:00pm, so you will need to add in those rows if you need them. I also Merged & Centered pretty much all of the cells to get the appearance the way I wanted it.

1 Like

Well, first of all, I would leave Location Mode alone, you donā€™t want to mix 2 completely different things - presence and time of day. What if you are going away for a vacation? What if you are traveling for business? Do you want your lights to behave the way when you are home?
So, create a global variable that will store your @DayTime, create a piston that updates / recalculates it and then create and call a piston that will perform an action based on the updated value of the @DayTime.
This way your Home/Away status might serve as an additional flag in the future to differentiate the actions. In addition you might want to make Night a separate flag. Think about it, night is not really a time of the day, but a time when people sleep in the house :slight_smile: So you probably donā€™t really want the lights to drive people behavior, but follow it. What I basically did, I created a flag Night, when all the automatic light updates stop. I set this flag when I go to bed and start sleep tracking using Sleep as Android. When in the morning an alarm is dismissed the flag is reset, the whole calculation is triggered, and based on the time of the day it sets the @DayTime properly, thus triggering a proper light scene.

A global var is always prefixed with @.

Interesting. I thought the whole point of Modes was to control when routines executed based on the ā€œstatusā€ of you and your house. Based on that Iā€™ve got multiple pistons that control cameras and lights based on what Mode the house is in (which as you saw from the above post, is based on the day and time of day).

I believe we are getting a little out of scope for this thread since we are now talking more about automation philosophy. Iā€™m very interested in this subject and you views on it, but perhaps we should take it to a separate thread or PM?

1 Like