Page 1 of 1
How to check variables... then Trigger Macro, or not?
Posted: Fri Apr 19, 2013 10:43 pm
by Livin
I'm now finding a need to look at 2 different variables (using pVar to create/set them) and based on their value trigger a Macro, or stop the current Macro.
Does anyone have code I can leverage?
btw, a Plugin for this would be awesome!
Re: How to check variables... then Trigger Macro, or not?
Posted: Sat Apr 27, 2013 8:17 pm
by Livin
no help?
Re: How to check variables... then Trigger Macro, or not?
Posted: Sun Apr 28, 2013 1:09 am
by jonib
Livin wrote:I'm now finding a need to look at 2 different variables (using pVar to create/set them) and based on their value
With the Python "if" you can test the variables and do different stuff based on their value. You don't give enough info for more specific answer.
trigger a Macro,
To trigger a macro you can use the
eg.TriggerEvent function to trigger an event that triggers the macro you want. Sorry don't know how to trigger a macro directly from Python.
or stop the current Macro.
Don't know sorry.
Next time no one answers a question try to expand it with more info/specifics, at least it would motivate me to try to help if I don't have to figure out exactly what you need.
jonib
Re: How to check variables... then Trigger Macro, or not?
Posted: Mon Apr 29, 2013 6:36 am
by Livin
here's one thing I'm looking to do...
XBMC or my NVidia card (not sure which) has trouble when switching from the laptop screen to the TV.
- when the laptop lid is closed, then I open it I can see my Win7 desktop, as desired.
- when I then close the laptop screen and the video tries to switch to the TV it has problems. Often the resolution is incorrect and can only be fixed by shutting down XBMC and then restarting XBMC.
So, what I want to do is detect the state of each screen and set pVar's for each screen... which I already do. Then I need logic that triggers on ANY change to either variable... then the logic evaluates BOTH variables so that only when the Laptop state changes from Attached to Removed + TV state changes from Removed to Attached, will EG close / restart XBMC.
I really wish we had a plugin that could evaluate multiple Var states and changes.
btw, for those intereste in Home Automation... a plugin like this could be used for many things: motion detection, scene management, etc
Re: How to check variables... then Trigger Macro, or not?
Posted: Sun May 12, 2013 8:28 pm
by cfull1
Livin,
In the mean time could you convert what you have in the macro to a python script? You could check your variables and then call TriggerEvent or stop macro.
I agree something like this is missing from EG.
I thought about developing something to solve this, but I've been going over in my head what it would look like exactly.
I would want to make it generic enough to be used for multiple purposes.
What are your thoughts on this?
I've had another thought to create a "ConditionalAction" that would combine the functionality of a macro and a jump if action.
It could be multilevel and check the value of multiple things.
Does this sound like something that would solve your problem?
Re: How to check variables... then Trigger Macro, or not?
Posted: Sun May 12, 2013 9:03 pm
by Livin
cfull1,
I think a ConditionalAction is perfect. Here's some functionality thoughts...
Conditions:
Evaluate Vars using AND / OR
Condition Outcome:
True / False
Actions:
Jump
Trigger
Do Nothing - move to the next item in the Macro
Stop Macro - stops current Macro
example...
IF
(onkyo.connected==1 AND laptop.connected==0) is TRUE
AND
(onkyo.connected==0 AND laptop.connected==0) is FALSE
THEN
Trigger restart.xbmc
ELSE
Do Nothing
Re: How to check variables... then Trigger Macro, or not?
Posted: Sun May 12, 2013 10:02 pm
by cfull1
Cool, sounds similar to what I was thinking.
However, instead of hardcoding actions like Jump or Trigger it would just be a submacro it would execute if the condition(s) were True.
Actions like Jump or Trigger or multiple things could be inside the submacro.
Re: How to check variables... then Trigger Macro, or not?
Posted: Sun May 12, 2013 10:17 pm
by Livin
gotcha
let me know when you have test code...
Re: How to check variables... then Trigger Macro, or not?
Posted: Sun May 12, 2013 10:19 pm
by cfull1
Well don't hold your breathe lol.
I'll start working on it after graduation this week.
It'll have to be in EG's core as well, not a plugin.
Hopefully I'll have something in a couple weeks.
Re: How to check variables... then Trigger Macro, or not?
Posted: Sun May 12, 2013 10:52 pm
by Livin
while having it in the core is desirable but if it is easier to make a plugin, maybe that is better? Whatever you decide... i'm in for testing!
Re: How to check variables... then Trigger Macro, or not?
Posted: Sun May 12, 2013 11:32 pm
by cfull1
Well I say core because I don't think the Action class has the necessary functionality.
But awesome! I'll let you know when I have something to show!