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.
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.
IF THEN ELSE? of JUMP IF?
-
SlipStream
- Posts: 8
- Joined: Fri Feb 19, 2010 2:21 am
IF THEN ELSE? of JUMP IF?
I am a long time automation installer, and i have been trying to utilize EG for macros to run a home theater system. Now with almost all other remotes i have worked with there is some kind of a "flag" system where if said command is ran then said flag is enabled or disabled, then there is a if flag is enabled then do this or if disabled do that. is there a way to do this in EG, maybe enable/disable an item and have a check if that item is enabled or disabled then execute item/macro depending on its state?
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: IF THEN ELSE? of JUMP IF?
Given that EventGhost is based on events, I recommend use Python script action.
There you can test any conditions. As a result, then use the function eg.TriggerEvent .
Pako
There you can test any conditions. As a result, then use the function eg.TriggerEvent .
Pako
-
SlipStream
- Posts: 8
- Joined: Fri Feb 19, 2010 2:21 am
Re: IF THEN ELSE? of JUMP IF?
can you give me an example and explain it or, can you point me to a place that can explain python scrypting, I am not familar with python. Thanks
Re: IF THEN ELSE? of JUMP IF?
fyi - your title does not really give a clue to what you are really looking for. 
You want to use variables. See this thread...
viewtopic.php?f=10&t=2376&p=19146&hilit=variable#p19146
what are your trying to automate?
You want to use variables. See this thread...
viewtopic.php?f=10&t=2376&p=19146&hilit=variable#p19146
what are your trying to automate?
setup... XBMC, W7MC for DVR & Live OTA TV, JRMC for multi-zone audio, EG, MiCasaVerde Vera3, USB-UIRT IR receiver, Harmony remote, 5.2 home theater system
Re: IF THEN ELSE? of JUMP IF?
Have a look at the built-in Jump action which can be controlled by the value of eg.result (True/False).
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: IF THEN ELSE? of JUMP IF?
Attached is a simple example.SlipStream wrote:can you give me an example and explain it or, can you point me to a place that can explain python scrypting, I am not familar with python. Thanks
You have to add some events to macros Decision, MyVar_1 = True, MyVar_1 = False and Toggle MyVar_1 (or run them manually).
I think that if you do you study it, you'll know everything you need.
I think you do not need use the Persistent variables.
Pako
- Attachments
-
- IF_THEN_ELSE_example.xml
- (2.3 KiB) Downloaded 1286 times
-
SlipStream
- Posts: 8
- Joined: Fri Feb 19, 2010 2:21 am
Re: IF THEN ELSE? of JUMP IF?
Pako, thanks a bunch,its a little bulky but i think that will work. one thing i cant figure out is. is there a place to see the state of myvar_1 whether it is true or false?
Re: IF THEN ELSE? of JUMP IF?
Pako,
I'll try this in a few days when I get home. It would be cool to have this as a plugin where the plugin asks the user for the conditions and it creates the code for the user.
I'll try this in a few days when I get home. It would be cool to have this as a plugin where the plugin asks the user for the conditions and it creates the code for the user.
setup... XBMC, W7MC for DVR & Live OTA TV, JRMC for multi-zone audio, EG, MiCasaVerde Vera3, USB-UIRT IR receiver, Harmony remote, 5.2 home theater system
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: IF THEN ELSE? of JUMP IF?
Sure, it's very simple.SlipStream wrote:Pako, thanks a bunch,its a little bulky but i think that will work. one thing i cant figure out is. is there a place to see the state of myvar_1 whether it is true or false?
You can create the following macro (action Python Command):When you need to know the state of a variable, you just run this macro.
The result you will see in the logger.
Pako
-
SlipStream
- Posts: 8
- Joined: Fri Feb 19, 2010 2:21 am
Re: IF THEN ELSE? of JUMP IF?
Pako,
Thanks for all your help, i think i have a good grip on this system now, what i did for a live status update, is in the folder for the variable script, i mad a bunch of comments, named them according to what i need, then in the macro that gets triggered by the event that got fired off by the if statment, i placed disable/enable commands, so now i can just open that folder and see all the status of the variables on the fly.
One thing i am having an issue with, is these if statments have two parts the event that it fires off if it is true and the event that it fires off if it is false. Is there a way to if the if statement fire off an event if say the condition was true or false, but if the "else" was the oposite dont do anything. I still need the if logic intact, what i have been doing for the time being is this
the reason i need this is the tv-false variable might be part of another macro which is triggered by that event. so what has been happening is in the top condidtion i can state that to be tv-true or tv-false then the else i just use "DoNothing" as the event which is not linked to anything. this way i have a switch which is, if said variable is true/false do this, else do nothing. My question is this, is this the cleanest way of doing this or is there something more simple?
Thanks for all your help, i think i have a good grip on this system now, what i did for a live status update, is in the folder for the variable script, i mad a bunch of comments, named them according to what i need, then in the macro that gets triggered by the event that got fired off by the if statment, i placed disable/enable commands, so now i can just open that folder and see all the status of the variables on the fly.
One thing i am having an issue with, is these if statments have two parts the event that it fires off if it is true and the event that it fires off if it is false. Is there a way to if the if statement fire off an event if say the condition was true or false, but if the "else" was the oposite dont do anything. I still need the if logic intact, what i have been doing for the time being is this
Code: Select all
if eg.globals.Tv:
eg.TriggerEvent("Tv-True")
else:
eg.TriggerEvent("DoNothing")-
SlipStream
- Posts: 8
- Joined: Fri Feb 19, 2010 2:21 am
Re: IF THEN ELSE? of JUMP IF?
Also if you can take a look at this, tell me what you think.
This is all the work put together to function. This is designed to be a "smart" controller for an entertainment center including a tv, bluray, cable, and a receiver. You can execute the different macros in the macro folder to do a desired fuction, and then you can see the virtual status of the device on the flags/status folder. the comments that are named per device will enable/disable depending if there variable counterpart goes true/false. that will give you some sense of the device being in a state of on/enabled or off/disabled. Now the biggest reason i did this was to be able to fire a simple macro and have it check the virtual status of a device and fire a specfic command due to the status/state of that device or do nothing if it is already in the desider state. Even if the user hits the same macro again it wont behave the same because the device states have changed so it wont fire the same commands again to screw everything up.
This is all the work put together to function. This is designed to be a "smart" controller for an entertainment center including a tv, bluray, cable, and a receiver. You can execute the different macros in the macro folder to do a desired fuction, and then you can see the virtual status of the device on the flags/status folder. the comments that are named per device will enable/disable depending if there variable counterpart goes true/false. that will give you some sense of the device being in a state of on/enabled or off/disabled. Now the biggest reason i did this was to be able to fire a simple macro and have it check the virtual status of a device and fire a specfic command due to the status/state of that device or do nothing if it is already in the desider state. Even if the user hits the same macro again it wont behave the same because the device states have changed so it wont fire the same commands again to screw everything up.
- Attachments
-
- Entertainment Center.xml
- (12.74 KiB) Downloaded 360 times
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: IF THEN ELSE? of JUMP IF?
My English is poor so I'm not sure, that I understand this well. If you do not need (it is not used in any macro) the event Main.DoNothing, of course you can make the simplification:SlipStream wrote: ...the reason i need this is the tv-false variable might be part of another macro which is triggered by that event. so what has been happening is in the top condidtion i can state that to be tv-true or tv-false then the else i just use "DoNothing" as the event which is not linked to anything. this way i have a switch which is, if said variable is true/false do this, else do nothing. My question is this, is this the cleanest way of doing this or is there something more simple?
Code: Select all
if eg.globals.Tv:
eg.TriggerEvent("Tv-True")- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: IF THEN ELSE? of JUMP IF?
I, unfortunately, probably not quite understand the logic of your solution.SlipStream wrote:Also if you can take a look at this, tell me what you think.
However, (if I did not make a mistake) my simplification should do exactly the same work.
Pako
- Attachments
-
- Entertainment Center Simplification.xml
- (10.39 KiB) Downloaded 545 times