Event Firing when it should not (I think)

Posted on
Mon Jun 06, 2016 1:21 pm
norcoscia offline
User avatar
Posts: 1206
Joined: Sep 09, 2015

Event Firing when it should not (I think)

HI, I have created a schedule that runs every 2.5 hours - the conditions are my Nest must be in a certain mode (which it was) and the outside temp must be lower than the inside temp. I have a Netatmo which I use to pull my inside and outside temperatures into two variables every 10 min. The schedule is running even though both conditions were not met :(

Am I missing something or is this a bug in the Indigo code used for evaluating conditions. See pictures below..... Thanks for any help or ideas - I'm using the very cool ARDUINO plugin to only allow my AC unit to pull in outside (fresh) air when it will not work against my home's temp setting (AC unit). Everything on the ARDUINO plugin side seems to be working perfect but I don't understand why the schedule ran.
Attachments
2016-06-06_12-08-48.jpeg
2016-06-06_12-08-48.jpeg (52.18 KiB) Viewed 5567 times
2016-06-06_12-08-25.jpeg
2016-06-06_12-08-25.jpeg (15.45 KiB) Viewed 5567 times

_______
Norm

Posted on
Mon Jun 06, 2016 1:40 pm
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Event Firing when it should not (I think)

That's interesting, because Temp_inside is definitely NOT greater than Temp_outside so that condition should have failed since you have "All" as your condition requirement. It could be because all variables are stored as strings and the comparison isn't correct for whatever reason - which would be a bug. You can easily determine that by using the script window to throw together a quick script to do it in pure Python and convert the variables to floats.

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
Mon Jun 06, 2016 2:15 pm
norcoscia offline
User avatar
Posts: 1206
Joined: Sep 09, 2015

Re: Event Firing when it should not (I think)

Thanks Colorado4Wheeler, a script would be a long road for me since my programming skills are almost zero and I don't know Python - On the up side - I do have a 1973 Bronco :D - so all is not lost - thanks for looking though - I appreciate any help or input since it must work or I will need to disconnect the ARDUINO from my HVAC unit.....

_______
Norm

Posted on
Mon Jun 06, 2016 2:17 pm
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Event Firing when it should not (I think)

norcoscia wrote:
I do have a 1973 Bronco - so all is not lost


And I have an 88 full sized Bronco :). I'll see if I can whip up a quick script for you.

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
Mon Jun 06, 2016 2:29 pm
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Event Firing when it should not (I think)

Try this and see if it changes things:

Code: Select all
# Right click each device or variable in Indigo and replace the values
# below with the "Copy ID" command

thermostat = indigo.devices[683392491]
outsidetemp = float(indigo.variables[126548455].value)
insidetemp = float(indigo.variables[856079151].value)

if thermostat.states["hvac_mode.cool"] and insidetemp > outsidetemp:
   return True
else:
   return False

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
Mon Jun 06, 2016 2:55 pm
DaveL17 offline
User avatar
Posts: 6741
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Event Firing when it should not (I think)

IIRC, Python will compare strings based on their ASCII 'order' and strings of numbers *should* compare the same as floats or ints do. In a Python window, try:
Code: Select all
>>> print ord('1')
49
>>> print ord('2')
50
>>>

The interpreter will compare these two values when the comparators are strings. When they're groups of characters, I believe the interpreter iterates over them until it finds a difference (you can't ord() multiple characters together.)

Of course, I could also be all wet. :D
Dave

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Jun 06, 2016 3:04 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Event Firing when it should not (I think)

I just recreated your scenario (with an Insteon thermostat since I don't have any Nests) and it works correctly - with the values you have for the two variables, it doesn't run, when I change the inside temp to 87.0 it executes. Indigo will cast the variable values into numbers (if possible) before it does the comparison.

I'm quite positive that the variable comparison is working, assuming that there aren't any hidden characters in the variable values that would cause the cast to a float to fail. It's possible to paste in carriage returns into a variable value so that you can't see the extra lines. Likewise, if you have a script populating the variable it can insert stuff that's not necessarily visible.

Did you perchance try to test it by clicking the Execute Actions Now button? If so, that's the problem - clicking that button does exactly what it says regardless of the conditions.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Jun 06, 2016 3:27 pm
norcoscia offline
User avatar
Posts: 1206
Joined: Sep 09, 2015

Re: Event Firing when it should not (I think)

Colorado4Wheeler - I tried the script - when I try to compile it - I get an error and a blue line in the script on the period between indigo.devices within "thermostat = indigo.devices[1875376265]"

The log shows
Error script error: around characters 126 to 127
Error script error: Expected end of line, etc. but found unknown token. (-2741)

I looked at the indigo docs and I see no issues with the syntax - but like I said -- greater chance of me building a time machine than successfully working with code...

# Right click each device or variable in Indigo and replace the values
# below with the "Copy ID" command

thermostat = indigo.devices[1875376265]
outsidetemp = float(indigo.variables[355977342].value)
insidetemp = float(indigo.variables[1756838287].value)

if thermostat.states["hvac_mode.cool"] and insidetemp > outsidetemp:
   return True
else:
   return False

Dave - I'm afraid I'm not smart enough to even know what you are talking about - apologies

Jay - the value are being inserted by indigo - see below - hard to test now since it is hot and AC is cycling on - WAF risk if I mess with it now...

PS - My wife (who is smarter than me) says it might be because it Indigo trying to use applescript vice python but I did not know that is selectable or how to set it...
Attachments
2016-06-06_14-23-16.jpeg
2016-06-06_14-23-16.jpeg (36.45 KiB) Viewed 5496 times

_______
Norm

Posted on
Mon Jun 06, 2016 3:55 pm
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Event Firing when it should not (I think)

norcoscia wrote:
I get an error and a blue line in the script on the period between indigo.devices within "thermostat = indigo.devices[1875376265]"


It could be a web copy/paste problem, try deleting and putting a period back in there manually. Do the same thing for any double quotes in the script, they sometimes copy strangely as well.

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
Mon Jun 06, 2016 4:02 pm
DaveL17 offline
User avatar
Posts: 6741
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Event Firing when it should not (I think)

norcoscia wrote:
Dave - I'm afraid I'm not smart enough to even know what you are talking about - apologies.

Yes you are, and no apologies are necessary. And don't worry about it if it doesn't make sense to you. My post was directed at the part of the conversation wondering whether casting the values as strings was making a difference and I'm alleging that it isn't. :D

Dave

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Jun 06, 2016 4:03 pm
norcoscia offline
User avatar
Posts: 1206
Joined: Sep 09, 2015

Re: Event Firing when it should not (I think)

Applescript seems to be what is getting invoked in the condition script window (not sure why) - I went to the action tab - created a server action to run a script

Inserted the same code and no problems - it compiled w/o error, when I changed it to applescript it got the same error - also, when it did the compile under python it changed all of the fonts in the script - so I tried copying that over to the condition script window but no joy -- same error - very strange - that time machine thing is looking easier every min....

_______
Norm

Posted on
Mon Jun 06, 2016 4:18 pm
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Event Firing when it should not (I think)

norcoscia wrote:
Applescript seems to be what is getting invoked in the condition script window


Sorry, that's on me, I wasn't even thinking (nor did I realize) that the trigger script window only ran Applescript, I assumed (which you know what this does) that it ran either. Oops.

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
Mon Jun 06, 2016 4:23 pm
norcoscia offline
User avatar
Posts: 1206
Joined: Sep 09, 2015

Re: Event Firing when it should not (I think)

No worries - much much better than a ghost in the machine :D

I'm still befuddled about the script running when the conditions were not met but at least I'm back down to one problem....

_______
Norm

Posted on
Tue Jun 07, 2016 9:09 am
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Event Firing when it should not (I think)

You didn't answer my last question: Did you perchance try to test it by clicking the Execute Actions Now button? If so, that's the problem - clicking that button does exactly what it says ( without evaluating the conditions).

Otherwise, I'm not sure what's going on. I just confirmed that if Indigo can't cast the variable values correctly into numbers, the condition returns false and the actions don't run.

Here's my condition:

ss93.png
ss93.png (30.95 KiB) Viewed 5338 times


It's running a schedule that executes every 5 seconds, and the action it to just speak "condition is true".

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Jun 07, 2016 10:06 am
norcoscia offline
User avatar
Posts: 1206
Joined: Sep 09, 2015

Re: Event Firing when it should not (I think)

Hi Jay, sorry I did not answer your question - yes I had been using it on my desk (not hooked up to my HVAC) and I could always get it to switch the relay. Last night I tried trashing the whole schedule and built a new one, but this time I reversed the comparison.

It started working and I added a printout to the log. It ran perfect all night cycling my fresh air vent on while it was cooler outside. My fingers are crossed now because the sun is up and I'm 8 degrees away from the outside temp creeping past the inside temp.

I hope it works because there will be significant energy savings if I can run the outside vent only when it does not fight the AC (or heating) but still allows a reasonable amount of fresh air exchange in my home.

I also wanted to say thanks for taking the time to test my setup and help me - Indigo is a great product and the fantastic support you provide really hits it out of the park - you have a customer for life!!!

_______
Norm

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests

cron