Conditional Concepts

Hi guys, i’m a newbie so you will probably have a good laugh now and then.

I seem to be having trouble understanding the concept of if …(A)… and …(B)… or …©… then…(D)… else …(E)…

To my understanding:

If A and B are true then D
If A and C are true then E

So i’ve created a flow to watch tv based on the time of the day with sun events. Whether i need a light scene (Hue) in the living room during this flow depends on the time of the day.

A = when someone says ‘i would like to watch tv’
B = it is between sunrise and sunset
C = it is after sunset
D = turn on tv, receiver, set volume
E = turn on tv, receiver, set volume, activate ‘Chill-scene’ (Hue)

I’ve tried this tonight (after sunset) but the checkmarks appear next to events of D where i expected the checkmarks to appear next to E

What do i miss here?

If… then… else, have greater precedence over AND, OR. The way they homey app works is give OR precedence over AND

So, If A and B are true then D is correct. But ‘if A and C are true then E’ is not correct, D would ‘run’. With parentheses it’s more clear maybe
if (A and B) OR © THEN (D) else (E)

The thing is you can recreate a different behavior by duplicating cards. So,
If (A and B) OR (A and C)
would be the same as
If (A) AND (B OR C)

You just need to notice which one takes precedence.

Thanks Yianni, but is still don’t get it. How should i configure my flow then?

For ‘IF’ i can only use 1 card so it is not possible to duplicate cards using A twice.

I could be wrong but would a simple if/else statement work for you what you want?

The main change which simplifies things is - if its not day time, then it must be night time and you don’t need the ‘or’.

1 Like

Sorry I misunderstood your post. Looking back at the original post, it seems it should work. You created two separate flows, right?

@Jamie, thanks for your next-level explanation :ok_hand:t4:

I do not need the day condition indeed. I just needed to understand how to make use of IF AND THEN ELSE.

Earlier i found a small explanation in Dutch by Athom. I wonder if their instruction was written correctly or i just simply misunderstood.

Dutch Athom explanation

According to this i came up with my A, B, C, D, E in my initial post

How come the amount of options for time & date for IF are less than the amount of options for time & date for AND?

I was experimenting with a flow where Sonos plays a playlist if there is a change in brightness in a Hue bulb (me saying ‘Hey Siri, let’s eat’ which dims the lights in the kitchen) and the time is between 18:00 and 19:00

I would like to take in account that there is a possibility the lights are ON. The change of brightness won’t work in that case.

If i could use IF ‘time is between’ AND hue bulb brightness changes OR hue bulb is ON THEN start PLAY3 Kitchen and playlist ‘xxx’

Probably a good test for me whether i finally understand how to setup flows. I don’t want to disappoint @jamie after his explanation above :wink:

@Ferry_van_E I’ve moved your question out of the flow request thread as it wasn’t appropriate there.

At what moment would this flow run? I think you mean the following?

  • when HUE brightness changes and time between then play
    and
  • when light goes on and time between then play

I guess i have to create 2 flows. I cannot set a ‘between time’ for IF. There are less time options for IF compared to THEN. Why is this anyway?

Like said a couple of times before “a time between” is not a moment something happens… When do you see this working? if it’s 18.00 hours? Or if it’s 18:07:00 hours? Or 18:07:01 hours? And how often would this flow run then?

I’m new to this so it is clear i have to get used to a certain point of view. I now understand what you mean by ‘a time between’ is not an event.

Let’s say i would like to start this flow when the time is 18:00. In my believe nothing will happen if the Hue bulb changes brightness at 18:15.

Therefore i have to create 2 flows as you mentioned earlier:
IF Hue brightness changes AND time is between 18:00-19:00 THEN start play3 with playlist x

IF HUE bulb is switched ON AND time is between 18:00-19:00 THEN start Play3 with playlist x

I guess i will have to understand that it is not always possible to put all of your demands in 1 flow.

Like i said. One big learning process. Thanks for your help!

1 Like

What @bvdbos is trying to explain is the concept of a trigger or ‘when’.

This is the part which tells the flow WHEN it should run . Not the requirements of the flow to run.

Triggers are one off, ie. When sunsets - When a light is turned on, - When you come home, etc.

WHEN - Trigger
IF - Condition
THEN - Action.

I hope this helps.

Thanks @Jamie. This is clear. How does this make sense for the flow creator below? I do not see WHEN

“When” translates to “Als”

Als => When
En => AND
Dan => THEN