Timed Triggers

I’m really scratching my head on this 1!

As you could see the last line is my issue! I just added the message checks to see where the break is tomorrow, but I’m hoping maybe someone could find an error, because I’ve been trying to figure this out for awhile.

Could you perhaps describe the problem in more detail? What doesn’t work?

Each flow should generally work. I can’t see any mistakes.
However, it’s impossible to tell whether the flows might not be working because, for example, logic variables aren’t functioning properly or have been set incorrectly.

Note: The crossed-out logic cards labeled “Work Mode: is not exactly 0” can all be deleted. These cards do not have any effect, except in the top-most flow.

I don’t really get the Send step 3 part:

"Send Step 3, School day = yes, work mode is set to 0. "

If I see it correctly you say at the logic card " School_day’ is equal to ‘yes’ " that the result is NO (based on the orange line) and than go to the ALL card and sent the message. Should the line not be at the YES (blue line) instead ?

Perhaps I misunderstood the message part and I know this is just for troubleshooting, but perhaps this says something about what goes wrong ?

But as DirkG already said, with a bit more detail about what the issue exactly is we can have a better image about what the issue is and hopefully that can lead to a solution.

I think that this flow can be greatly simplified if you make use of the alarms feature. Just go into settings/alarms. Here you can create several scheduled alarms and repeat them for specific days of the week. You can for instance create alarm schedules for every room. and just use a bunch of “When [alarm] goes off” cards.

If you want to keep track of the state of a room. In stead of using a global variable for it, I would create a virtual device in each room that allows you to keep track of the state. You can use the virtual devices app for that: Virtual Devices | Homey

I think those two improvements can simplify your flows a lot.
Hope this helps.

The “extra” =0 cards are so I could flip 1 variable and it’ll disable it, as well as other routines.

I do that so I could enable/disable multiple routines with the simple flip of a variable.

OK so, Replace the “WHEN” cards with alarms? I never thought of that, but honestly, I’m not 100% sure how I would implement that and have it work like I want to.

So using a virtual device instead of a variable? That’s interesting…but I’m just curious as to how that’d be better/different then using a variable?

I’m still a little new at this so I’m totally open to other ways, just want to understand them.

Those were just markers, so I could track where the routine breaks.

I understood those where just for troubleshooting, but the message you send and what the flow does are not the same thing (if I read it correctly).

So could you please explain in detail what you expected the flow would do and what actually happens that is not how you expected ?

I know what numerical variables can be used for, but in your flows, the logic card “Work Mode: is not exactly 0” doesn’t make sense, since flows 2 through 7 always include a logic card that says “Work Mode: is exactly 1 or 2.” This automatically implies that the “Work Mode” variable, of course, cannot be equal to 0.

That’s the big question. You still haven’t told us how the flow is supposed to work, or what’s not working with it. As @Justin_de_Knegt has also mentioned again.

In my opinion, that should be clarified first before you start using Alarm Flow cards and virtual devices.

I’m sorry, I didn’t fully understood the complexity of the flow before. I assumed most logic could be programmed in a schedule, but now that I have a closer look, it seems that most of this flow is a bit of an anti pattern to me anyways. let me explain:

In software development and automation, it’s a good practice to keep a single source of truth. You should not try to store data that can also simply be derived from other states. If a certain state can be derived from other states, it should be calculated on the fly, rather than being stored.

It seems that this flow is designed to run in a timed interval. In the industry, this is called a cron job. This flow mostly keeps track of a derived state. All the modes for every room are simply derived by time and a few other variables like School_Day. These room modes are probably being used by other flows. These other flows are triggered by their own events.

At first glance such a cron job to keep track of a simple variable that can be used by all other flows seems like a very logical solution. You’ll offload some of the logic to it’s own flow, and you’ll also have a single flow responsible for it. However, you’ll soon be running into a lot of edge cases and situations where state is outdated or not what you expect it to be. Also, as automations become more and more complex, these jobs are responsible to keep track of more and more derived states. Therefore, the calculations also become more and more complex and they need to run ever more often. This will end up taking up more resources from the system. In reality, it would be far more efficient to just calculate these room modes when they are needed.

There are multiple other ways to do that, but to help you with figuring out what the best solution would be, I would really need more info on where and how these room modes are being used.

OK, sorry let me explain Exactly how the flow is supposed to work!

Let me start by first explaining the logic:

Work Mode: 0 = Default or off

1 = “early work mode” where I have to get up by 5:30 and leave by 5:45

2 = Normal work time where I get up at 6:10, snooze for 10 minutes, then get out of bed by 6:20 and leave at 6:35

Master Bedroom: Controls lighting modes: 0 = Disabled as all lighting automatons are disabled

1 = Normal mode where if the light is dim enough it will turn the lights on in day mode and both the presence sensor and motion sensor will trigger the lights

2 = Away mode where the lights will only work with a smart button, both sensors are disabled

3 = Sleep mode, works the same as mode 2 but does other things in other flows

4 = Enables the motion sensor ONLY (presence sensor remains disabled) and turns the lights on ONLY with the motion sensor (keeps me moving in the morning)

Downstairs Mode: Controls lighting modes: 0 = Disabled as all lighting automatons are disabled

1 = Presence sensor turns lights on when light is dim enough

2 = Away mode, works with button only, presence sensor is disabled

3 = Sleep mode, Sleep mode, works the same as mode 2 but does other things in other flows

School day: “Obvious” is just that.

Security: Again obvious, enables on all security features in my house

So form the top:

WHEN work mode changes, and it’s not 0 (will change from 0 to 1 or 2), start Good Night flow

@ 5:30 AND work mode is not 0 (disabled) then check if it’s 2 (Early work mode), if it is THEN use MB: Day Mood and change Master bedroom mode to 4

@ 5:45 AND work mode is not 0 then check if it’s 2, THEN if YES send my phone and alert letting me know it’s time to leave for work THEN set Master Bedroom Mode to 3 (Sleep Mode) THEN after 5 minutes (gives me time to leave)

@ 6:10 AND work mode is not 0 (disabled) then check if it’s 1 THEN if YES check if it’s a school day and if YES Start Good Morning flow, if School Day is NO, Set master bedroom to 3 WAIT 5 minutes THEN set downstairs mode to 3, IF Work Mode is not 1, check if it’s 2, if YES check if it’s a school day and if YES Start Good Morning flow

@ 6:20 IF Work Mode = 1 Cast audio to me bedroom speaker to yell at me to get out of bed! THEN set Downstairs Mode to 1 and Security to NO

@ 6:35 IF Work Mode = 1 Send message to my phone to get going and if School Day = NO Set Master Bedroom to 3 WAIT 5 minutes THEN set Downstairs to 3

When I leave home, IF Work Mode = 1 THEN set Work Mode to 3 THEN if it’s a school day set Security to YES, IF Work Mode = 2 THEN set Work Mode to 3 AND set Security to YES

@ 7:10 if Work Mode = 3 (Which it should be at this point) Set Work Mode to 0 and if it’s not a School Day, start Good Morning Flow

For some reason every part of this flow works fine except the 7:10 part and I have no idea why

Also if there is any way to rework this flow to be more efficient (and actually work) I’m open for suggestions!

I hope that explanation is sufficient, let me know if there are any other details you need to know that I may have missed, THANK YOU for your help!

Thank you for your explanation, this give us a good idea of what you want this flow to do.

I do think that the check cards" work mode is not exactly 0" can be removed as suggested earlier by @DirkG. The reason I think that is possible is because you only check if it is not 0 but don’t have any steps if work mode IS 0 from that point. So only checking if the work mode is 1 or 2 does the same thing (if the work mode IS 1 or 2 it is NOT exactly 0), but with a check card less in the flow. To be clear: the first work mode is not exactly 0 card at the top of the flow IS needed so you can’t remove that one. But this is just my 2 cents to perhaps make the flow more efficent.

But lets get back to the issue you have with the last part of the flow. If I’m not mistaken, the work mode is only set to 3 when you leave home (and work mode is at that time 1 or 2). Just to be sure you do leave before 7:10 right? And could you check between the time you leave and 7:10 the work mode is indeed set to 3 ?

If this is correctly set, the next thing to check is if School day really set to NO (I don’t see in the flow a part that sets this to NO, but perhaps this is done in a different flow of course).
I’m afraid we cannot help you with the troubleshooting it self because we don’t have access to your flow of course. You do have set some messages as checks, do you receive all of them ?

I hope this helps you with some tests to see if we can find the cause, if something is not clear, please let me know

Just test from the card 7:10 by control clicking it and see what happens.

I think that this is where your assumption is wrong. Work_mode is set by presence, not by time. This is exactly why I think that keeping track of derived states like this is not recommended. This is one of these cases where the state is not what you think it should be because of timing issues and race conditions.
I can direct you into ways to improve this without needing these work_states, room_states etc. But I need to know when and where these states are actually used outside of this flow.

I get what you’re saying about the work mode IS NOT exactly 0, I had it like this before but I changed it for…I don’t remember what reason lol. I guess I could change it back.

Yes I always leave before 7:10, work mode is set to 3 then. I mean to check between time but always forget, I guess I could set a message to let me know what’s going on. I used to just have it check if work mode is 1 or 2 ONLY, but it didn’t work, so I though by setting it to 3 it may work…but obviously it didn’t lol

Yes school mode is set to no as it’s currently summer and my daughter is not in school in the summer, this is for my wife to get her ready for school

It works when I trigger it manually

Yes I’m curious as to how to make this better. Master bedroom mode is just used in my lighting flow for the master bedroom, Downstairs mode controls all the lighting flows for my downstairs rooms, work mode is not used in any other flows, and security just controls all my window and door sensors which is used in my security flow to just notify me if 1 is opened when security is “armed”. I assume the 7:10 part should trigger regardless of my presence state, am I wrong in that assumption?

I cannot answer the whole question, but yes, every day at 7:10 this part of the flow will be triggered to run regardless of your presence state.

In that case test it at 07:10.

one question. Work Mode in this flow is never set to 1 or 2, so according to this flow Work Mode can only be 0 or 3. Regarding to work mode, I see only 2 listeners that might influence or use Work Mode. These are “When … left Home” and “When The time is 07:10”.

Are there any other flows that might set Work mode? If not, than most of this flow can be deleted. based on this flow alone, acting on Work Mode, you will be left with only 2 listener cards, 3 condition cards, and maybe 3 then cards. I doubt that this is all of your intentions right?

I’m happy to help you out fixing all of your problems, but I need screenshots of all the flows that use (set or get) any of these variables.

Also, I would highly recommend the Heimdal app for security. It has almost all features of a modern security system. Including, armed state, partially armed state, arming timeouts and sensor checking. It will also greatly simplify your flows.