Conditional wit out...
 

Conditional wit output duration?  

  RSS

nico
 nico
(@nico)
Active Member
Joined: 1 week ago
Posts: 7
09/09/2019 11:52 am  

Hi

I'm trying to use conditional that check if an output is already activated, but i can't get it to work.

 

My code is reading a temp sensor and an output state duration to determine what to do..

I'm trying to read the ON duration of the fridge compressor (temps_compresseur) and do something only of its OFF.

In fact i need 2 things:

-1 to be able to know when it's on or off

-2 to know how long it's been on or off.

Is there a was to see what's inside 'temps_compresseur" (for debug)?

 

Here is a part of the code

 

temperature_int = self.measure("{54fc3f48}")
temps_compresseur = self.measure("{54fc3f48}")
if temperature_int is not None and temperature_int > 13.5 and temps_compresseur = 0:
self.run_action("{675eb5e8}")
if temperature_int is not None and temperature_int < 12:
self.run_action("{7d4fecd9}")




thanks

Quote
Kyle Gabriel
(@kylegabriel)
Member Admin
Joined: 5 years ago
Posts: 0
09/09/2019 9:01 pm  

It looks like you're using the same ID "54fc3f48" for both measurements. You should change the ID to match the ID of each condition. You should have one as a measurement and the other as an output state.

As for how to develop the conditional statement, I need to know more about what you're trying to accomplish. What do you want to happen and what conditions must be met for it to trigger that thing to happen?

When using the measure() function for a measurement, it will return None or a value, and for an output either None, True for HIGH, and False for LOW.

You can see the current state of the Outputs on the Setup -> Outputs page. 

Without knowing anymore details, I would also, in addition to fixing the duplicate ID for the measure() functions, perhaps change the output evaluation, so the code looks like this:

temperature_int = self.measure("{54fc3f48}")
temps_compresseur = self.measure("{54fc3f48}") # <- Fix this ID. It should not be the same as the ID above it.
if temperature_int is not None and temperature_int > 13.5 and not temps_compresseur:
self.run_action("{675eb5e8}")
if temperature_int is not None and temperature_int < 12:
self.run_action("{7d4fecd9}")
This post was modified 6 days ago by Kyle Gabriel

ReplyQuote
nico
 nico
(@nico)
Active Member
Joined: 1 week ago
Posts: 7
10/09/2019 2:45 am  

Hi Kyle, thanks for the answer

 

Yes, i did a wrong copy/paste, the ID where different :)

 

What i would like to do is:

 

if temp > 13.5 and output1 is OFF

=> Activate output1

if temp > 12 and output1 is ON

=> desactivate output1

if temps > 16 and output1 is ON since more than 600sec

=> send email alert

 

 

 

 

Thank you for the help


ReplyQuote
nico
 nico
(@nico)
Active Member
Joined: 1 week ago
Posts: 7
11/09/2019 3:57 pm  

Any ideas ?

 

thanks


ReplyQuote
Kyle Gabriel
(@kylegabriel)
Member Admin
Joined: 5 years ago
Posts: 0
11/09/2019 6:06 pm  

You should have two Conditions. You currently only have one (Measurement, ID 54fc3f48). You need to add an Output State Condition.
You should have 3 Action. You currently only have 2 actions. Add an email action. Here is the code that should accomplish what you described:

temperature_int = self.measure('{MEASURE CONDITION ID}')
temps_compresseur = self.measure('{OUTPUT CONDITION ID}')

if temperature_int is not None:
if temperature_int > 13.5 and temps_compresseur == 'off':
self.run_action("{675eb5e8}") # Turn output on
elif temperature_int < 12 and temps_compresseur == 'on':
self.run_action("{7d4fecd9}") # Turn output off

if temperature_int is None or (temperature_int is not None and temperature_int > 16):
output_on_duration = self.control.output_sec_currently_on('1b6ada50-1e69-403a-9fa6-ec748b16dc23')
if output_on_duration > 600:
self.run_action("{7d4fecd9}") # Turn output off
self.run_action("{EMAIL ACTION ID}") # email
This post was modified 4 days ago 2 times by Kyle Gabriel

ReplyQuote
nico
 nico
(@nico)
Active Member
Joined: 1 week ago
Posts: 7
12/09/2019 2:34 am  

great!

Many thanks


ReplyQuote