Logicblock with Additional Conditions

Hi there!

Just discovered Apilio today after realizing that IFTTT is too limited, specifically in terms of conditions.

After reading a wonderful tutorial by @Anna here, I was able to create my first working logic block.

However, I would like to tinker with it more and could use some suggestions:

Objective
To use a Wyze Motion Sensor to trigger the entrance Wiz light bulb upon motion detection.

Additionally, I would like the Wiz light bulb to go into “night mode” after midnight after the motion detector is “clear”. <-- This is what I’m having difficulty with.

Set Up

  • Boolean Variables
  1. _motion_entrance - Triggered by Wyze Motion Sensor
  2. _time_night - Triggered by Weather Underground “Sunset”
  • Conditions
  1. is_there_motion
  2. is_night
  • Logicblock
  1. light_entrance_night based on conditions #1 and #2 above

The above works well, however, I would like to include an additional criteria after a specific time to turn the Wiz light bulbs into a night light instead of it turning off.

I tried the following:

  1. Created a new boolean variable “_time_after_midnight” and a new condition “is_after_midnight”, and created a new logicblock that uses “is_there_motion”, “is_night” and “is_after_midnight”. However, this causes a conflict with the existing logicblock as I reused 2 of 3 conditions.

  2. Created new condition “is_before_midnight” and added it to the original logicblock. However, this also seems to be in conflict with the other logicblock as theoretically one logicblock will return “false” and the other “true” at the same time.

I think I am missing something here - just can’t quite figure out what. Perhaps someone can assist? I also realize I might not be painting the entire picture here, so please let me know if I missed some important information.

Thank you!

Best,
J

2 Likes

Hey @jerleong,

great example and good questions!
What is “night mode”? Is it a kind of permanent low light on?

Hi @pebneter,

Thanks for responding! I realize now after reading my initial post, that I did not provide sufficient details of what I was trying to acheive.

You are correct - “night mode” will be a type of permanent light on.

Scenario #1

  • Conditions: After Sunset/Before Sunrise/Before Midnight/Wyze Motion Detected

  • Desired Outcome: Turn On Wiz light bulb

  • Conditions: After Sunset/Before Sunrise/Before Midnight/Wyze Motion Sensor Clear

  • Desired Outcome: Turn Off Wiz light bulb

Scenario #2

  • Conditions: After Sunset/Before Sunrise/After Midnight/Wyze Motion Detected

  • Desired Outcome: Turn On Wiz light bulb

  • Conditions: After Sunset/Before Sunrise/After Midnight/Wyze Motion Sensor Clear

  • Desired Outcome: Turn On Wiz light bulb to “night mode” (for example, 5% brightness, 3000K)

If I had to write this in terms of a “IF” statement, it will probably be something like this (might be errors with parenthesis, also note new logicblocks required) :

=IF ( AND ( is_night, is_before_midnight, is_there_motion ), light_entrance_night_on, IF ( AND ( is_night, is_after_midnight, is_there_motion ), light_entrance_midnight_on, IF ( AND ( is_night, is_after_midnight, NOT (is_there_motion) ), light_entrance_midnight_off, IF ( AND ( is_night, is_before_midnight, NOT (is_there_motion) ), light_entrance_night_off )))

Or perhaps a CASE (based on my limited knowledge, also note the new condition created “is_no_motion” which would be the inverse of “is_there_motion” and new logicblocks required) :

CASE

WHEN is_night AND is_before_midnight AND is_there_motion THEN light_entrance_night_on
WHEN is_night AND is_after_midnight AND is_there_motion THEN light_entrance_midnight_on
WHEN is_night AND is_after_midnight AND is_no_motion THEN light_entrance_midnight_off
WHEN is_night AND is_before_midnight AND is_no_motion THEN light_entrance_night_off

END

Hope that provides a little more insight about what I am trying to accomplish.

Please let me know your thoughts.

Thank you!

Best,
J

1 Like

I run something like that already, if no one else has responded I will take you through my set up later :slight_smile:

1 Like

I use this. Hopefully it will have all the information you need.


This will keep the light on while people are moving around. Then switch it off after a predefined time
1 Like