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.
Two triggers to disable/enable macro
Two triggers to disable/enable macro
Hi everyone!
I guess I need some python-scripting support again...
What I wan't to do is: When both "rfid.person1.is.away" and "rfid.person2.is.away" has triggered I want a macro (or trigger), lets call it "No one home" to be enabled or disabled (or triggered).
Can anyone help me with this?
Thanks!
I guess I need some python-scripting support again...
What I wan't to do is: When both "rfid.person1.is.away" and "rfid.person2.is.away" has triggered I want a macro (or trigger), lets call it "No one home" to be enabled or disabled (or triggered).
Can anyone help me with this?
Thanks!
-
themaster1
- Experienced User
- Posts: 133
- Joined: Wed Feb 03, 2010 9:02 pm
Re: Two triggers to disable/enable macro
can you post your current .xml config maybe 'cause i don't understand the way you explain it
what are rfid.person1-2.is.away ? (actions, events or what)
what are rfid.person1-2.is.away ? (actions, events or what)
Re: Two triggers to disable/enable macro
Ohh, sorry, when those two, "rfid..." which are triggers, each connected to a macro, when both has been triggered, it should generate a new trigger that is connected with a third macro!
Are you with me?
Or, if I'll put it like this!
I leave home, and then I put me rfid-key to the reader, which sets "me" as out of the house, then when my girlfriend leaves home two hours later she does the same thing, first when we're both out of the house, things should start to happen.
Are you with me?
Or, if I'll put it like this!
I leave home, and then I put me rfid-key to the reader, which sets "me" as out of the house, then when my girlfriend leaves home two hours later she does the same thing, first when we're both out of the house, things should start to happen.
Re: Two triggers to disable/enable macro
Use variables.. Each event should set a variable for each person you want to track. Then create a Macro that checks the variables when any variable is set... Thus if a person leaves a macro sets the variable P1 to Away, then the same macro checks all the variables, if they are all set to away then it triggers your House Empty macro.
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: Two triggers to disable/enable macro
Even better... Have only one variable that is binary... Increment it every time someone is detected to leave, then the macro only have to check one variable for a specific value.. Whatever the # of people is.
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: Two triggers to disable/enable macro
Sounds like good solutions both of them! But since I don't know any python it's kinda hard, do you have some sample code achieving this that I could look at and try?
Thanks!
Thanks!
Re: Two triggers to disable/enable macro
there are several examples... just do a quick search of the forum.
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: Two triggers to disable/enable macro
Been searching around, but I didn't find anything similar to what you suggested, it's probably just me who doesn't find it.
Maybe one could store the values of the variable in a file, then, if EG for some reason is restared, it could read from the file to see which is or/were home/away before it restarted.
Maybe one could store the values of the variable in a file, then, if EG for some reason is restared, it could read from the file to see which is or/were home/away before it restarted.
-
krambriw
- Plugin Developer
- Posts: 2570
- Joined: Sat Jun 30, 2007 2:51 pm
- Location: Stockholm, Sweden
- Contact:
Re: Two triggers to disable/enable macro
I assume that you would receive some events also for each person coming home!?
Like you have "rfid.person1.is.away" and "rfid.person2.is.away" you would need "rfid.person1.is.home" and "rfid.person2.is.home".
Also to make it more generic and easier to make a script to keep track of the house status, could you try so that the events has the format like rfid.away 'person1' and rfid.home 'person1'
The event suffix should hold the state and the payload the actual id of the person. In this way it will be easy to count the people coming home and leaving.
As soon as the first person comes home, the counter is incrementing and an event "house not empty" can be triggered.
When people start leaving the counter is decremented until it reaches zero, then a new event "house empty" can be triggered.
Best regards, Walter
Like you have "rfid.person1.is.away" and "rfid.person2.is.away" you would need "rfid.person1.is.home" and "rfid.person2.is.home".
Also to make it more generic and easier to make a script to keep track of the house status, could you try so that the events has the format like rfid.away 'person1' and rfid.home 'person1'
The event suffix should hold the state and the payload the actual id of the person. In this way it will be easy to count the people coming home and leaving.
As soon as the first person comes home, the counter is incrementing and an event "house not empty" can be triggered.
When people start leaving the counter is decremented until it reaches zero, then a new event "house empty" can be triggered.
Best regards, Walter
My released plugins
https://drive.google.com/drive/folders/ ... y01eVBKeHM
https://drive.google.com/drive/folders/ ... y01eVBKeHM
Re: Two triggers to disable/enable macro
there are many, many threads on python scripting with EG, variables ant the like...Samme wrote:Been searching around, but I didn't find anything similar to what you suggested, it's probably just me who doesn't find it.
Maybe one could store the values of the variable in a file, then, if EG for some reason is restared, it could read from the file to see which is or/were home/away before it restarted.
http://www.eventghost.org/forum/viewtop ... f=2&t=3413 (If/Then)
viewtopic.php?f=10&t=2376&p=19146&hilit=variable#p19146 (persistent variables)
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: Two triggers to disable/enable macro
Thanks for your help and directions! I've read a lot at the forum and the web, for the last two days! But I'm not that smart at these things...anyway...
I've rearranged the triggers according to Walters idea,
So now I have Rfid.Away.Person1 0 and Rfid.Home.Person1 1
So how do I pass the payload from Rfid.Home.Person1 1 to be saved in my variable? So that eg.globals.AllAway = 0 increases and decreases?
Thankful for all and any help in the right direction!
I've rearranged the triggers according to Walters idea,
So now I have Rfid.Away.Person1 0 and Rfid.Home.Person1 1
So how do I pass the payload from Rfid.Home.Person1 1 to be saved in my variable? So that eg.globals.AllAway = 0 increases and decreases?
Thankful for all and any help in the right direction!
-
krambriw
- Plugin Developer
- Posts: 2570
- Joined: Sat Jun 30, 2007 2:51 pm
- Location: Stockholm, Sweden
- Contact:
Re: Two triggers to disable/enable macro
Sorry, this is not what I asked for, I asked for thisSo now I have Rfid.Away.Person1 0 and Rfid.Home.Person1 1
Code: Select all
Rfid.Away Person1 and Rfid.Home Person1BestR Walter
My released plugins
https://drive.google.com/drive/folders/ ... y01eVBKeHM
https://drive.google.com/drive/folders/ ... y01eVBKeHM
Re: Two triggers to disable/enable macro
Hmm, well now I have this:
Do you mean like this:
Code: Select all
eg.TriggerEvent("Josefin", payload=1, prefix="Rfid.Home", source=eg)
eg.TriggerEvent("Josefin", payload=0, prefix="Rfid.Away", source=eg)
Code: Select all
eg.TriggerEvent("Home", payload="Josefin", prefix="Rfid", source=eg)
eg.TriggerEvent("Away", payload="Josefin", prefix="Rfid", source=eg)
-
krambriw
- Plugin Developer
- Posts: 2570
- Joined: Sat Jun 30, 2007 2:51 pm
- Location: Stockholm, Sweden
- Contact:
Re: Two triggers to disable/enable macro
Perfect, I will start writing a script based on thateg.TriggerEvent("Home", payload="Josefin", prefix="Rfid", source=eg)
eg.TriggerEvent("Away", payload="Josefin", prefix="Rfid", source=eg)
BestR Walter
My released plugins
https://drive.google.com/drive/folders/ ... y01eVBKeHM
https://drive.google.com/drive/folders/ ... y01eVBKeHM
-
krambriw
- Plugin Developer
- Posts: 2570
- Joined: Sat Jun 30, 2007 2:51 pm
- Location: Stockholm, Sweden
- Contact:
Re: Two triggers to disable/enable macro
So here is the first proposed solution to control presence in your house. Look at the picture below:
You create 3 macros,
- first holding the python script that you copy & paste from below and the two possible events that can happen when people are using their rfid tags
- second macro with the event 'Main.HousePresenceControl|Away' and the actions you need to do when house gets empty
- third macro with the event 'Main.HousePresenceControl|Home' and the actions you need to do as soon as someone is coming home
Function will be as follows:
The script is counting when people are leaving and coming home. When there are nobody at home anymore the event 'Main.HousePresenceControl|Away' is triggered.
When the house is empty and the first person arrives home, another event 'Main.HousePresenceControl|Home' is triggered.
The two events are then used in the other two macros you have created to do the things that are needed for the two states (like turning on / off lights etc).
This solution works fine as long as you do not edit the script or restart EG (or the computer). The default state is empty house.
To make this thing survive restarts, we need to introduce persistence as indicated by Livin. It is nothing complicated (except that the script will have some more code and that you need to add that plugin pVar) but I think we shall make that in a second step once you are familiar with the script and the functions described above.
BestR Walter
- first holding the python script that you copy & paste from below and the two possible events that can happen when people are using their rfid tags
- second macro with the event 'Main.HousePresenceControl|Away' and the actions you need to do when house gets empty
- third macro with the event 'Main.HousePresenceControl|Home' and the actions you need to do as soon as someone is coming home
Function will be as follows:
The script is counting when people are leaving and coming home. When there are nobody at home anymore the event 'Main.HousePresenceControl|Away' is triggered.
When the house is empty and the first person arrives home, another event 'Main.HousePresenceControl|Home' is triggered.
The two events are then used in the other two macros you have created to do the things that are needed for the two states (like turning on / off lights etc).
This solution works fine as long as you do not edit the script or restart EG (or the computer). The default state is empty house.
To make this thing survive restarts, we need to introduce persistence as indicated by Livin. It is nothing complicated (except that the script will have some more code and that you need to add that plugin pVar) but I think we shall make that in a second step once you are familiar with the script and the functions described above.
BestR Walter
Code: Select all
#A simple house presence control
name = 'HousePresenceControl'
newEvent = str(eg.event.suffix)
newPayload = eg.event.payload
try:
counter
status
except NameError:
counter = 0
status = ''
if newEvent == 'Home':
counter += 1
if newEvent == 'Away':
counter -= 1
if counter < 0:
counter = 0
if counter == 0 and (status == 'Home' or status == ''):
status = 'Away'
eg.TriggerEvent(
name
+"|"
+status
)
if counter == 1 and (status == 'Away' or status == ''):
status = 'Home'
eg.TriggerEvent(
name
+"|"
+status
)
My released plugins
https://drive.google.com/drive/folders/ ... y01eVBKeHM
https://drive.google.com/drive/folders/ ... y01eVBKeHM