Setting modes based on time of day and presence

mode
presence

#21

Thanks for sharing this! I made a simplified version for myself based on your variables and it works great to set the correct mode when arriving home.


#22

@RobinWinbourne

So I have been using this Piston for a few months that you helped me streamline. So far it has been working fairly well but there are a couple of issues that I would like assistance with addressing.

  1. When night time mode triggers (11:00PM) it doesn’t turn off the lights in the light variable. I thing this might be a simple change but I’m not sure.
  2. Sometimes when leaving certain lights will not go off, I’m not 100% how to troubleshoot this issue as it is random when it happens.
  3. How hard would it be to set Arlo mode based on presence in this same Piston?

#23

Hi All,

Im new here. Please go soft! :slight_smile:

I have tried to install this app. I get this error when I run the test…

Error setting location mode. Mode ‘Home - Day’ does not exist.

Where do you need to create the Home - Day location? Within the IDE im guessing? Do you need one for each mode?


#24

Modes have to be created and named in the IDE.

You need a mode matching each one on listed in post 1, or rename them in the piston as desired.


#25

Got it. Thanks. :slight_smile:


#26

This works great Robin! Thanks for putting together…

If I wanted to add a few new modes in would it just be a case of adding the new “time” then defining in the “time of home” and “time of night”…

I wanted to add a new day mode from 10am to 2pm then a evening mode (between 6pm and 6:30pm) and then one between 6:30pm and 20:00


#27

It’s a bit more in depth than that… ternary operators need updating.

If I get time later I’ll see if I can update it for you.


#28

This should do the trick:

Rather than trying to guess your mode names, I’ve just called them:

  • Sleep
  • Home - 1
  • Home - 2
  • Home - 3
  • Home - 4
  • Home - 5
  • Home - 6
  • Away - 1
  • Away - 2
  • Away - 3
  • Away - 4
  • Away - 5
  • Away - 6

You just need to change these mode names to your desired names in both of the ternary operators (‘timeOfDayHome’ & ‘timeOfDayAway’)

If you don’t need all the steps, just have 2 of 3 times in the middle apply the same mode name.


#29

Cheers dude. I will give this a try.

Thanks for taking the time to put this together !


#30

I think I have done something wrong… Seems to be showing the wrong mode, its ahead by a mode.


#31

Quick Facts
Piston state: Home - Bathtime was initiated on Tue, Apr 3 2018 @ 2:55:11 PM BST

Last executed: 03/04/2018, 14:55:11

Next scheduled: 03/04/2018, 18:00:20

Subscriptions: 3 events, 23 controls

Devices used: 26

Memory used: 31% (31498 bytes)

External URL: (click to open/execute)


#32

That is working correctly… your example:

Triggered at 14:55 so time was less than ‘<’ time4 (18:00), so Home-Bathtime was set.

You need to move everything along by one mode, I’m guessing less than 18:30 is the intended bath time?

p.s. I wish I could get my little one to stop and come upstairs for a bath on such a tight schedule lol


#33

Its a challenge I can tell you, but a 4 months we are still managing it! :slight_smile:

So needs to be this?
($time24 < time0 ? ‘Sleep’ : ($time24 < time1 ? ‘Home - Morning’ : ($time24 < time2 ? ‘Home - Afternoon’ : ($time24 < time3 ? ‘Home - Bathtime’ : ($time24 < time4 ? ‘Home - Evening’ : ($time24 < time5 ? ‘Home - Night’ : ($time24 < time6 ? ‘Home - Dawn’ : ‘Sleep’)))))))

Thanks again.


#34

Unless you’re planning bathtime for 10am no… You need to move it all right, not left.

$time24 < time3 ? ‘Home - Bathtime’ :

in words:

If Time now is less than time3 then set mode {bathtime] else…

So you want:

$time24 < time5 ? ‘Home - Bathtime’ :


#36

Thanks a bunch for the piston! I made a small change to the if statement for my needs… I am basically telling webcore to check either if the presence is home / away or changes to home / away… I made this change since it wasn’t properly changing the modes based on when we left the house… at least for me it wasn’t… It would only change when it ran again based on the time slots… I also have the mode change section changing the profile on my BlueIris install…


#37

Hi,
How would one go about making the string used for dawnTime in the example to be say 20 minutes before sunrise? I have seen other examples using different methods, just curious as to how it would be done in this specific example.

Thanks in advance!


#38

The first thing I’d do is start with verifying your username. :wink::rofl:


#39

this is great. trying it out now!


#40

How would I go about if I wanted to create an offset to “sunrise” and “sunset”. Say “sunrise + 30 min”.


#41