There exists a need for documentation on the Homey flow cards because, sometimes, the flow card name alone is not sufficient and doesn’t convey all the needed details for users to create successful automation flows.
Problem at hand
I created two flows involving a motion sensor and two light bulbs.
One flow, named evening flow, to turn on the light at cooler color temp and higher brightness between SUNSET and midnight.
One flow, named morning flow, to turn on the light at much warmer color temp and dimmer brightness between midnight and SUNRISE.
Evening flow details
When…
the motion alarm turned on
And…
“Date & Time - It’s after sunset”
“Date & Time - The time is earlier than 11:59 PM”
Then…
set a temperature 20%
dim to 70%
turn on light
Morning flow details
When…
the motion alarm turned on
And…
“Date & Time - The time is later than 00:00 AM”
“Date & Time - It’s before sunrise”
Then…
set a temperature 90%
dim to 10%
turn on light
What I want to achieve is two different brightness/color temp at two different times from SUNSET to SUNRISE.
However, the evening flow is triggered even between midnight and SUNRISE. What I found from Homey web interface is that both “Date & Time” conditions in the evening flow are evaluated to true. Upon thinking about this, it makes sense that “The time is earlier than 11:59 PM” is evaluated to true because any time between midnight and SUNRISE is indeed earlier than 11:59 PM. But how is SUNSET (and SUNRISE too) implemented by Homey??? Since “after sunset” is still true minutes past 12 AM, I can only ASSUME that (1) “after sunset” is true from SUNSET to SUNRISE and (2) “after sunrise” is true from SUNRISE to SUNSET.
I haven’t tested/confirmed the condition evaluation of the morning flow in Homey web interface yet. Another question I have is the sequence of flows executed by Homey. Is it possible that the 4 conditions from both the flows are evaluated to true and that the morning flow is executed before the evening flow such that I see the result of the evening flow?
Having said all these, how should the flows be configured to achieve what I want? Please help.
I assume that “after sunset” means between sunset and midnight, but I haven’t tested it myself yet.
And because the flows you describe are correct in principle, I suspect that you may have made a mistake in the “real” flow. It would be better if you could post a screenshot of your flow.
The card “Het is ‘s nachts” (It’s nighttime ?) is created by reversing the “Het is overdag” (It’s daytime ?) Carré, which is the last in the Date & Time section.
The start (16:00 / 4pm) and end times (08:00 / 8am) of the time slots can be adjusted according to your location. These should be before the earliest possible sunset and after latest possible sunrise in your location.
EDIT: Of course you can also use the before / after sunset cards in combination with the “it’s between … and …” cards.
EDIT2: Another option is the Sun Events app, which has dedicated cards for testing between a sun event and a time.
I think it depends on how you build your flow with your “and” cards. You should but it so that both should be true before triggering the action card.
I think you have right about the assumption of the sunrise/sunset cards.
Before sunrise is between sunset and sunrise.
Before sunset is between sunrise and sunset.
The first flow in my example will trigger all night since one of the “and” cards is true.
The second flow will only trigger when both “and” cards are true.
Thank you, @DirkG. I tested the conditions today and can confirm that what you said is correct.
“After sunset” is the duration from sunset to sunrise.
”After sunrise” is the duration from sunrise to sunset.
It is at the exact moment of sunset or sunrise when the evaluation/state changes. In other words, “after sunset” remains true from sunset to sunrise and changes to false at sunrise while “after sunrise” remains true from sunrise to sunset and changes to false at sunset.
Below is the evening flow that didn’t work the way I wanted in that it also ran between 12:00 AM and sunrise when I wanted it to run only between sunset and 12:00 AM.
Now that I know how “after sunset’“ and “after sunrise” are defined, I can proceed to make the correction.
I completely missed the “It’s nighttime” card, and I have been wondering why there is not a “from sunset to sunrise” card instead of two separate “It’s after sunset” and “It’s after sunrise” cards. Thanks for bringing that to my attention, @s73nm. I’ll give it a try before resorting to the Sun Events app.
Hello @Oyvind_Lilleberg, I am still very new to Homey Pro. As far as I see from the advanced flows provided, the only difference between the two flows is that the bottom flow has the “ALL” entity. The “ALL” entity is also in @s73nm‘s reply. I still need to read more on advanced flow creation. What does this “ALL” entity represent/do? It doesn’t seem to have a category like “Date & Time”, “Logic”, etc.
When looking at advanced flows, try to imagine tokens moving across the lines of the flow:
When a trigger condition occurs (WHEN card), a token is placed on the line.
When the line splits, the token splits and moves across all the paths
When checking a condition (AND card), the conditions are evaluated. If the condition is met (TRUE,) the token continues along the upped output (blue line) of the AND card. If the condition is not met (FALSE), the token will move along the lower output (yellow line) of the AND card. If not line is connected to the output along which the token should progress, the token vanishes.
Whenever a token reaches the input of a card, that card is executed immediately, except for an ALL card. The ALL card waits until it receives a token on each of the input lines. When a token is received on each line, the ALL card will let a single token continue on its output line.
Also good to know: when multiple tokens reach the input of a card during a flow, only the first token that reaches the card will be allowed to continue.
Using the partial flow I posted earlier, this would mean that:
When the flow is started, 3 tokens are moving across the lines, and reach the 3 condition cards.
When it’s after 4pm, but before midnight, the token will be allowed to moved along the TRUE output line of the top AND card, otherwise it will cease to exist.
The same is true from the bottom and card, when the time is between midnight and 8AM.
The middle condition card will allow the token to pass only between sunset and sunrise.
This means that:
The first ALL card will only receive tokens on all its input when it is after sunset (and before sunrise), and after 4pm, but before midnight. Once, after midnight, the ALL card will not allow the token to pass.
The bottom ALL card will only receive tokens on all its inputs when it’s before sunrise (and after sunset), and when it is after midnight and before 8AM. Before midnight, it will never receive a token from the time check and so it will not allow the token to pass.
You find the card by right clicking on the canvas in advanced flows. There you should find the card.
Also a great tips to understand flows better is to test the flows when you are in the canvas. For example click on the icon for the WHEN card to start the flow, or right click on the card you want to test from. Then you can visually see what happens when the flow is validating each card and you can track the progress of the flow, seeing if the state of the card is true or false (blue or yellow).
Hi @Doekse, maybe you can help us get some clarity on this.
Does Athom have a specific definition for the following two “And…” flow cards?
– It’s after sunset
– It’s after sunrise
I thought that the dutch ‘het is overdag’ is called ‘it’s light’ in english. So ‘het is ‘s nachts’ is translated as ‘it’s dark’. But maybe it’s ‘daytime’/‘nighttime’
I assumed that ‘het is overdag’ is between sunrise and sunset. And ‘het is ‘s nachts’ is between sunset and sunrise.
Apparently I was wrong all the time so now I am curious when ‘het is overdag’ is true
Good question, the difference is between dawn/dusk and sunset/sunrise. Let me explain;
After sunrise and after sunset are based on the exact moment the sun crosses the horizon.
So:
After sunrise = from the moment the sun rises until it sets
After sunset = from the moment the sun sets until it rises again
That’s purely based on the sun being above or below the horizon, being 0°.
Daytime is slightly different. That one is based on civil twilight (civiele schemering in Dutch ). Homey defines daytime as the period between dawn and dusk, where dawn is when the sun is 6° below the horizon in the morning, and dusk is when it’s 6° below the horizon in the evening.
That means:
Daytime starts a bit before the actual sunrise
Daytime ends a bit after the actual sunset
So “daytime” is always slightly longer than the period between sunrise and sunset.
In practice:
If you want something to follow the exact sun-up / sun-down moment, use sunrise/sunset.
If you want it to follow when there’s already (or still) natural light outside, daytime is usually the better choice.
@Doekse: This kind of clarifications is very useful, in my opinion. Maybe your colleagues that maintain Homey’s Knowledge Base, can add it to that repository.