Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

How do I fire several events on one if?

If you have a question or need help, this is the place to be.
Post Reply
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

How do I fire several events on one if?

Post by Mastiff »

I have this code:

Code: Select all

if eg.globals.Ovnmodus_WC == 1:
        if float(eg.globals.WC_temperatur) < eg.globals.Minimums_Dagtemperatur_WC: #Sjekke om det er for kaldt
            eg.plugins.RFXtrx.send_AC(u'Anslut 1 p\xe5', u'AC', u'012e77fe', u'1', u'on', u'0', None) #Slå på ovnen hvis det er for kaldt
            eg.globals.WC_ovn = 'paa.jpg' #Vise ovn på for webserver
            print("Ovnen slås på")
            
        if float(eg.globals.WC_temperatur) > eg.globals.Maksimums_Dagtemperatur_WC: #Sjekke om det er for varmt
            eg.plugins.RFXtrx.send_AC(u'Anslut 1 p\xe5', u'AC', u'012e77fe', u'1', u'off', u'0', None) #Slå av ovnen hvis det er for varmt
            eg.globals.WC_ovn = 'av.jpg' #Vise ovn av for webserver
            print("Ovnen slås av")

So if the first condition is met, it does the two next if checks. But it seems like it's only firing the first command in the sub-if that's true, so it fires the eg.plugins... but not the eg.globals or print. What have I done wrong here?
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: How do I fire several events on one if?

Post by krambriw »

I elaborated a bit with your script (added some variables and stuff just to test it) and I think it works ok

Code: Select all


eg.globals.Ovnmodus_WC = 1
eg.globals.WC_temperatur = 17.0
eg.globals.Minimums_Dagtemperatur_WC = 18.0
eg.globals.Maksimums_Dagtemperatur_WC = 22.0

if eg.globals.Ovnmodus_WC == 1:
    if float(eg.globals.WC_temperatur) < eg.globals.Minimums_Dagtemperatur_WC: #Sjekke om det er for kaldt
        eg.plugins.RFXtrx.send_AC(u'Anslut 1 p\xe5', u'AC', u'012e77fe', u'1', u'on', u'0', None) #Slå på ovnen hvis det er for kaldt
        eg.globals.WC_ovn = 'paa.jpg' #Vise ovn på for webserver
        print("Ovnen slås på")
        
    if float(eg.globals.WC_temperatur) > eg.globals.Maksimums_Dagtemperatur_WC: #Sjekke om det er for varmt
        eg.plugins.RFXtrx.send_AC(u'Anslut 1 p\xe5', u'AC', u'012e77fe', u'1', u'off', u'0', None) #Slå av ovnen hvis det er for varmt
        eg.globals.WC_ovn = 'av.jpg' #Vise ovn av for webserver
        print("Ovnen slås av")

print eg.globals.WC_ovn
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: How do I fire several events on one if?

Post by Mastiff »

Think angry Donald Duck when the kids are throwing snowballs at him: ¤#!"%!¤&"#%%!(#&#¤&#%!!!!!!

My mistake. I needed '1' instead of 1 for the first variable! I pick the value from the system registry, and it seems to come as a text 1 and not a number 1! So nothing actually worked, it was just not evident since it took some time before the temp came into an area where it should react!

Is there something similar to the opposite of "tostring" in LUA to make this a number, not text, so I can check it without using the ' ' to mark it?
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: How do I fire several events on one if?

Post by Mastiff »

Never mind. Here's one for me:

http://www.bit.ly/to_mastiff

The answer is :

Code: Select all

eg.globals.Ovnmodus_WC = int(eg.globals.Ovnmodus_WC)
Or directly in the command that picks up the registry value:

Code: Select all

eg.globals.Ovnmodus_WC = int(eg.plugins.System.RegistryQuery(HKEY_CURRENT_USER, u'Software\\Automatisering\\Styring av ovner\\WC', u'Modus', 1, u''))
Post Reply