Fan rotation with alternating states

How can I use apilio to rotate my fan between two angles? I think this might be a tricky one…

Either:

State A: Active for 2 operations (clockwise when I am at angle 2 but desire angle 1)
fan goes clockwise directly to angle 1 and it takes 4 seconds
fan goes counterclockwise directly to angle 2 and it takes 4 seconds
Fan switches to state B

State B: Active for 2 operation (counterclockwise when I am at angle 2 but desire angle 1)
fan goes counterclockwise to angle 1 and it takes 7 seconds
fan goes clockwise to angle 2 and it takes 7 seconds
Fan switches to state A

How do I use apilio to control this deterministically?

Basically, I could base a logic block on a boolean condition where the positive result is a 4-second delayed action, and the negative result is a 7-second delayed action.

However, the boolean needs to swap states every other time I run the logic block.

So over the course of the day, every time I want to switch the angle, the logic block should behave:

4 (boolean true)
4 (boolean true) -> time to swap the variable value
7 (boolean false)
7 (boolean false) -> time to swap the variable value
4 (boolean true)
4 (boolean true) -> time to swap again

etc.

How do I set this up in apilio?

1 Like

I realize my question may be confusing, Another way to ask this question, does Apilio support external manipulation of boolean variable values?

How could I swap the value of a boolean every other time I run a logic block? Some sort of counter?

1 Like

Hey @jcarrz1, this sounds great! :smiley:

You can make a boolean variable alternate between true and false using the IFTTT action to toggle a variable: this makes a variable true if it was false and false if it was true.

So you would end your positive and negative action chains with an IFTTT event that toggles your variable. Your IFTTT applet would be:

If I receive an event from Apilio
image

then toggle a boolean variable on Apilio

image

And this will update your variable to the opposite value.

Does this help? :smile:

1 Like