I could use help automating a fan with an ir power toggle

Posted on
Wed May 18, 2016 12:11 pm
SHKnapp offline
Posts: 33
Joined: May 05, 2009

I could use help automating a fan with an ir power toggle

I've been using Indigo for years, but mostly as a remote control. I'm finally getting into the automation part of home automation an I feel like I'm tapping into parts if Indigo that I'm less familiar with and I'm questioning my approach.

Here's the situation:

I've got a ir remote control fan that has a single ir code to toggle power. I want to automate the turning on and off of this fan based on occupancy. These are the pieces I have all setup to do the heavy lifting:

Cynical Cache plugin with a Global Cache Flex to send ir commands - works perfectly
Z-Wave plug that I can poll power usage to check if the fan is ON - works great
fingscan plugin + mother plugin with mother motion cookie to determine occupancy - totally reliable Sen.se Mother is my fav new HA toy!

So, hardware wise I think I'm good to go, it's the Indigo logic I could use help with.

My 1st attempt:
because the ir command is a power toggle, I decided that the easiest way to do this was use the ir code to turn the fan ON and use the z-wave plug to turn it OFF by simply cutting power to the fan, then turn the plug back on. This causes the fan to go back to it's default settings. It takes about 6 button presses to get the fan back to the state I want it in. If I use the ir code to turn it off, it stays in the desired state.

I've started down my 2nd attempt with out the brute force power OFF, but I thought I'd check here to find out what the pros would do :) It seems like a simple problem, but my solution feels more complicated then it needs to be. So I'd love to hear peoples suggestions on how they would do it.

thanks,
Spencer

Posted on
Wed May 18, 2016 12:23 pm
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: I could use help automating a fan with an ir power toggl

Without fully grasping the full issue (not understanding the 6 button presses thing), I would probably do something like this:

Create a variable "FanIsOn" and set it to false
Trigger for when the zwave power change is detected on the fan to change the variable to true or false depending on if we have power
Now you know if the fan is on or off and can automate based on that (be it cutting zwave power or using the IR)

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Wed May 18, 2016 12:31 pm
johnpolasek offline
Posts: 911
Joined: Aug 05, 2011
Location: Aggieland, Texas

Re: I could use help automating a fan with an ir power toggl

Two triggers:

First trigger; Device or Variable" Occupancy state" becomes "occupied" (however the Fingscan delivers that information); Condition Zwave power consumption < a little more than whatever the fan draws when off; action Toggle IR.
Second trigger: Device or Variable "Occupancy state" becomes "not occupied"; Condition Z-wave power > half of what the fan draws when running; Action Toggle IR.

Posted on
Wed May 18, 2016 6:02 pm
SHKnapp offline
Posts: 33
Joined: May 05, 2009

Re: I could use help automating a fan with an ir power toggl

I over simplified the use case. Occupancy isn't the only thing that controls the fan. I want it on for an hour when I first get home. I also turn it on using it's own controls from time to time. I want to make sure it's off when I go to bed or leave the house.

Colorado4Wheeler thanks for the reply
The 6 button press thing is required when the fans power is and then restored. It resets to defaults i.e. highest fan speed, no conciliation etc.. it takes a total of 6 button presses on the fan itself to get it back in the state that I prefer... so rather then recreate those ir commands when turning it ON after cutting the power to shut it off., I'd rather use the fans power toggle. It's what has put me in this situation... maybe I should get a dumber fan.

johnpolasek thanks for the reply
That would perfectly solve my original overly simplified initial post use case. In an effort to ensure I wasn't overly complicating things I overly simplified the problem. oops




Creating a var to know if the fan is ON or OFF is the path I've recently started. Because the fan won't be exclusivity controlled by my occupancy I need to poll the plug frequently and maintain the variable state. This seems to require TWO triggers. If the trigger condition had an else, then it could be one... frustrating. or am I missing something?

let's say I'm not missing anything and now I have my two triggers and a variable. Indigo now knows if the fan is ON or OFF. Now I need to turn the fan OFF under the following situations:
1. An hour after I return home
2. An hour after turned on at the fans local controls
3. bedtime
4. leaving the house

It feels to me, if I'm understanding the underlying logic behind action groups, that I would want to create a "living room fan OFF" routine that can get called by other action groups. "going to bed" "leaving home". Because this routine has a condition, it has to be a trigger. Triggers are the only place I see an opportunity to apply a condition... correct? it feels like it's just a simple IF statement that I want to run from multiple places.

any other thoughts?
thanks,
Spencer

Posted on
Thu May 19, 2016 5:34 am
johnpolasek offline
Posts: 911
Joined: Aug 05, 2011
Location: Aggieland, Texas

Re: I could use help automating a fan with an ir power toggl

You do not have to poll the Zwave; to keep track of the on/off state; you can set a trigger on z-wave power state becomes > something less than the power required when fan is on low Action: set Fan State to ON, and a second on z-wave power becomes < that value, action set Fan State to OFF. And if you want the fan to come on under other conditions, you can add another variable for that, called "FanHome" or something similar... It will take several more triggers (which is why I'd create a Fan Folder to keep them separate in), but you can have a trigger or control page or PiBeacon or FindMyPhone plugin or manual switchlinc that sets FanHome to ON and starts a timer which after an hour sets FanHome to OFF. another pair of triggers like the ones I mentioned above to trigger on FanHome Change to actually start and stop the fan, using the toggle if conditions met. and then you put a second condition in the original Toggle of "FanHome isnot ON" to keep the occupancy sensor from turning off the fan during that hour when FanHome has been used to start it.

Posted on
Thu May 19, 2016 12:15 pm
SHKnapp offline
Posts: 33
Joined: May 05, 2009

Re: I could use help automating a fan with an ir power toggl

I was totally misleading... I'm not polling the device, Indigo is through the exact set of two triggers you're describing... sorry for that confusion. I'm starting to feel like I have a better grasp on this then I originally thought. I do wish that the If/Then conditional aspect of triggers were expanded to If/Then/Else. That would cut the required triggers in half. Sure the duplicate button helps in creating them, but why have all the extra triggers to maintain if you alter your hardware.


Is there a way to have indigo not execute an ON command if the device status is already ON? I felt like I was very close to an elegant solution last night using a virtual device. I put the toggle power command for both on and off and my fan state variable as the variable to define the virtual fan device state. To a degree, this worked. but if the fan was reporting off and I hit the off button for it, Indigo would still sent the off command, which in my case would turn the fan on :(

Posted on
Thu May 19, 2016 12:36 pm
johnpolasek offline
Posts: 911
Joined: Aug 05, 2011
Location: Aggieland, Texas

Re: I could use help automating a fan with an ir power toggl

Is there a way to have indigo not execute an ON command if the device status is already ON?
That is one of the main uses of the conditions Trigger to turn on; condition device is not on; action turn on device... the glitch is if you have other "OR" conditions set up, in which case you have to go through a virtual device or variable with another trigger watching that, which (as you say) creates a huge number of triggers. If all the other conditions that you are requireing are AND, then another "AND device is not ON" can just be tacked on to the list.

Posted on
Thu May 19, 2016 2:23 pm
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: I could use help automating a fan with an ir power toggl

There are several things that complicate the various scenarios for this solution. The primary one being that determining your #2 (An hour after turned on at the fans local controls) is going to be very tricky. Sure, the Z-Wave device reports usage so you know if it's on or off, but determining if it was manually controlled (by it's remote control) or by the iTach is significantly more tricky since you somehow have to catch the fact that the iTach recently sent a command and that's what caused the power to go up/down (or not).

I suspect you can get close, but the more accurate/foolproof you want the solution to be, the more logic and parts there will be to the solution (and probably writing a script or two). It's just the nature of a device that doesn't report status and can be controlled outside of Indigo. I think you probably want to evaluate how important the various situations are to you and how much time and complexity you're willing to introduce in order to solve them all.

johnpolasek wrote:
the glitch is if you have other "OR" conditions set up


Conditions can be arbitrarily complex and hierarchical, so I don't think there is a problem.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu May 19, 2016 2:40 pm
johnpolasek offline
Posts: 911
Joined: Aug 05, 2011
Location: Aggieland, Texas

Re: I could use help automating a fan with an ir power toggl

Conditions can be arbitrarily complex and hierarchical, so I don't think there is a problem.


I wasn't criticizing; In 20 years of playing with home control I've run into a lot of the "If A and B or C but not D unless E" things that I wanted to do... And unless you want to actually put in a full language (complete with parentheses ti create precedence's; ever see LISP code?) the best way to do it is with nested triggers and/or variables/virtual devices. But he is right that having the equivalent of an "else" clause (ie Action1 if conditions TRUE; optional Action2 if conditions FALSE) would cut waaaaay down on the number of triggers I've got floating around.

Posted on
Thu May 19, 2016 3:21 pm
SHKnapp offline
Posts: 33
Joined: May 05, 2009

Re: I could use help automating a fan with an ir power toggl

The whole reason I've taken so long to get into the automation part of home automation is that I'm not willing to give up local control of any device. I'm not the only one living there and guests still need to be able to operate every device as it was originally intended to be operated... if not, then it all becomes a huge source of frustration.

Jay... it's not the complexity of the conditions. I think Indigo has that down pretty good. It's the else part that's missing
if device fanPlug > 10kwh fanState = on : else fanState = off
one trigger, not two
1/2 the maintenance if I swap the device, 1/2 the triggers to sort through and organize. I can't imagine what some peoples Indigo database must look like! :shock:

I feel like I shouldn't have to create a device and then an additional trigger for that same device just for the propose of indigo not sending a redundant command... meaning an ON command if that own device is already ON. At first I thought it was a bug with the virtual device implementation, after all the description of a virtual ON/OFF device in the docs seem to be almost exactly what I was looking for. But then I tried a non-virtual device, just a wall switch, and Indigo will send the ON command regardless of its state as well. I guess for devices that aren't reliable, people may want to turn it on many times to ensure it's on, but it sure would be nice if there were a device by device preference to prevent redundant commands... like the check box that decides if a device writes to the log.

The other thing I tried was Cynical Behaviours garage door device. It's trying to solve a similar problem. A device with a toggle button and a different device to determine state. I couldn't get it to work for my situation.

johnpolasek, your last comment got me thinking. I think I can accomplish this with the one virtual device and two triggers to ensure that device doesn't get a ON when it's on or an OFF when it's off. Then I should be able to call the appropriate ON or OFF trigger in the existing action groups I have for getting home, leaving home and going to bed. I'm assuming that the virtual device will update it's status if the fan is turned on locally, then it could be turned off after an hour with an additional trigger. That should cover all my conditions... gonna try that tonight. Thanks for the suggestion.

Posted on
Thu May 19, 2016 3:45 pm
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: I could use help automating a fan with an ir power toggl

johnpolasek wrote:
I wasn't criticizing; In 20 years of playing with home control I've run into a lot of the "If A and B or C but not D unless E" things that I wanted to do... And unless you want to actually put in a full language (complete with parentheses ti create precedence's; ever see LISP code?) the best way to do it is with nested triggers and/or variables/virtual devices.


I think you missed a feature - you can create hierarchical (parenthetical) conditions in the rule editor. Holding down the Option key turns the + button into a button with ellipses - which creates a new subgroup (parenthetical) which can be any/all/none. So you don't need to use code, it's available in the UI.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu May 19, 2016 3:54 pm
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: I could use help automating a fan with an ir power toggl

SHKnapp wrote:
The whole reason I've taken so long to get into the automation part of home automation is that I'm not willing to give up local control of any device. I'm not the only one living there and guests still need to be able to operate every device as it was originally intended to be operated... if not, then it all becomes a huge source of frustration.


Not at all what I'm suggesting.

SHKnapp wrote:
Jay... it's not the complexity of the conditions. I think Indigo has that down pretty good. It's the else part that's missing
if device fanPlug > 10kwh fanState = on : else fanState = off
one trigger, not two
1/2 the maintenance if I swap the device, 1/2 the triggers to sort through and organize. I can't imagine what some peoples Indigo database must look like! :shock:


Right now, for this scenario, it seems like a huge problem for you. In practice (anecdotally), it really isn't a huge deal. In my db, I think I have 6 triggers that could be 3 if there were an else. Out of 27. I think I might also have 2 which execute a script as the action which performs some extra logic. Once those were set up, I've rarely had to go back and edit them, so having 6 rather than 3 really isn't a big deal. We have the request to add "else" like functionality, but in all honestly it's quite low on the priority list because demand is quite low relative to other things.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri May 20, 2016 3:52 pm
SHKnapp offline
Posts: 33
Joined: May 05, 2009

Re: I could use help automating a fan with an ir power toggl

getting closer

This is going to seem like a crazy question, but is there anyway to run a trigger without a triggering event?

I'm following johnpolasek suggestion , if I'm understanding it correctly, and I've created two triggers.
trigger fan on ONLY IF fanState = off
trigger fan off ONLY IF fanState = on
but unless I'm missing something I cannot just call these triggers to run... I have to trigger then with an event. So do I create two additional variables for their corresponding triggers? and then manage the state of that variable as well?

Posted on
Sat May 21, 2016 9:48 am
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: I could use help automating a fan with an ir power toggl

What would be "calling" the trigger? That is the actual triggering event, right?

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon May 23, 2016 2:07 pm
SHKnapp offline
Posts: 33
Joined: May 05, 2009

Re: I could use help automating a fan with an ir power toggl

Maybe my approach is incorrect. My thinking is that I have a bunch of things I want done when I leave the house. I put all these things into an action group called "Leaving" for example. Most of these things are very straight forward... just a bunch of turn off device commands. But what if I want a condition on one of those tasks?... say turning on the front porch light if it's dark. What would your approach to that be?

Who is online

Users browsing this forum: No registered users and 1 guest