Author Topic: Program Logic Event Generator Plugin  (Read 400059 times)

Offline RichardTSchaefer

  • Moderator
  • Master Member
  • *****
  • Posts: 10091
  • Karma: +763/-142
Re: UPDATED: Program Logic Event Generator Plugin
« Reply #30 on: January 21, 2013, 08:00:40 am »
Show the ADVANCED Tab settings for PLEG

The device type should be:
urn:schemas-rts-services-com:device:ProgramLogicEG:1

If it's not change and save and then reload the browser window.

Offline skropko

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-1
Re: UPDATED: Program Logic Event Generator Plugin
« Reply #31 on: January 21, 2013, 09:04:16 am »
RichardTSchaefer

Thank you for the explanation above.  Makes sense to me now.  Thanks again!

-Scott

Offline xeinth

  • Full Member
  • ***
  • Posts: 143
  • Karma: +1/-0
Re: UPDATED: Program Logic Event Generator Plugin
« Reply #32 on: January 21, 2013, 10:43:57 pm »
Richard,

First, thanks for your work.  It seems to be rather complete, although I'm apparently struggling with a few concepts I hoped you could clarify.

I'm looking to do something I'd consider somewhat simple, but struggling to figure out how to maintain a persistent state for evaluating an 'away' switch for programming a thermostat.  I've got a virtual switch in use, and the concept is that when that switch in active, the schedules are ignored and the temperature held.

What I've run into is that it seems the status of the virtual switch seems to not be updated when the trigger is fired by the switch.  Perhaps I'm not using it correctly, but at the moment I have a trigger set for the switch changing state which works, a schedule and a status of the away switch.  When I build conditions without the status, it seems to fire triggers to my scene with no problem, but alas no magic with the away switch.

I'm not sure if you have any suggestions there, but I was curious if this can be done with a sequential condition in some way?  Its not clear to me if the conditions are persistent between events, or if they evaluate from the beginning between sequential calls.  What confused me was the possibility of the 'now' command which seemed to imply either the execution stalls waiting for now, or is maintained between calls.

Thanks for the help,
brian

Offline RichardTSchaefer

  • Moderator
  • Master Member
  • *****
  • Posts: 10091
  • Karma: +763/-142
Re: UPDATED: Program Logic Event Generator Plugin
« Reply #33 on: January 22, 2013, 07:48:18 am »
Check this reply:
http://forum.micasaverde.com/index.php/topic,12759.msg99169.html#msg99169

You can use a Virtual Device Switch in PLEG:
    PLEG
      Input
         Trigger
            OCCUPIED =   Virtual Switch ## is ON
      Condition
          Schedule =   OCCUPIED and ( 8:00:00; NOW; 20:00:00)
          Hold = Not Schedule

Then two scenes:
      ScheduleThermostat where PLEG has satisfied Schedule
      HoldThermostat where PLEG has satisfied Hold


Offline niharmehta

  • Sr. Member
  • ****
  • Posts: 348
  • Karma: +15/-0
Re: UPDATED: Program Logic Event Generator Plugin
« Reply #34 on: January 25, 2013, 02:43:11 am »
Hopefully someone can help. I hate to ask what seems like a simple question but I have been struggling with this for a couple of days since I  started using PLEG to do the following.
When I got to bed, I set a scene "Sleep" that does various actions in the house.  I also set a couple of variables so that the state is tracked for later. One is AtHome(v2) , the other is IsSleep(v3).  Setting the "Sleep" scene sets these variables to '1'.
The issue is that with PLEG, I create a condition that matches a specific time daily (t3) in the morning to set the thermostat, disable some sensors and turn on various Smartswitches only if : t1(v2)==1 and t2(v3)==1

Triggers t1==1
             t2==1
Schedules
            t3 (Days 1-7  0600)
Condition WakeUp : (t1==1 and t2==1) and t3 . I have also just did a  t1==1 and t2==1 and t3

What is happening is that I can set the Variables using the Sleep Scene the first time which sets the v2/v3 variables in the container. At the specified schedule time, the WakeUp scene matching the condition fires. 
However, when I later try to set the Sleep scene again later which sets the variables back to the sleep settings , the WakeUp scene fires immediately again. Even if the time has passed for quite a while in which case it should not be a match for t3 set time. Even if I put PLEG in to Bypass mode this keeps happening.

No matter what I have tried including re-installing the plugin and at the latest version and recreating the scenes, this keeps happening. It seems that either the condition match is first match for one or both of the variables in  the triggers and not evaluating if the time is correct. Or, almost as if some flag for the time is stuck so that t3 always returns true.

Hopefully the solution is as simple as my condition statement being wrong.  Any help would be much appreciated.
2x VeraLite; 2xTrane Tstats; 45 x Switches/Dimmers/Appliance Modules; 4x Everspring Water Sensors; DSC Integration; 2 x Zwave Door Locks; 1x Ted5K; 1x Rainforest Eagle; Onkyo AVR; 6x Squeezebox;

Offline RichardTSchaefer

  • Moderator
  • Master Member
  • *****
  • Posts: 10091
  • Karma: +763/-142
Re: UPDATED: Program Logic Event Generator Plugin
« Reply #35 on: January 25, 2013, 07:13:39 am »
That's a bug ...
A schedule is always returning a "True" state.
I envisioned this to just kick a scene and not to represent the specified moment in time.
You have a valid scenario ... I will fix.

I think you can work around as follows:

t1==1 and t2==1 and (t3; Now< 1:00)

p.s. Did you know you can rename your trigger and timer variables names so your logic is easier to read ?
Or are you using t1, t2, t3 names to obfuscate your logic ?   

Offline niharmehta

  • Sr. Member
  • ****
  • Posts: 348
  • Karma: +15/-0
Re: UPDATED: Program Logic Event Generator Plugin
« Reply #36 on: January 25, 2013, 05:56:06 pm »
Hi Richard,
Thanks for confirmation that in this specific case, I am not going insane after about 10 frustrating hours on this. I love the PLEG capability as I previously worked around it with the Clock Plugin, Combination Switch, and the Variable Container. It was not elegant.   But easier than sitting down and learning LUA.

 I do know I can rename the variable and did not intend to obfuscate the logic, just that after recreating the PLEG plugin a dozen times I just went with the default names until I could confirm the logic  was working.  Also, figured that using the default names in the post it would not confuse the terminology.

I will try the work around shortly. Looking at the simplicity of it, I am annoyed with myself that I did not think of that a couple of days ago.

Thanks for your help!
2x VeraLite; 2xTrane Tstats; 45 x Switches/Dimmers/Appliance Modules; 4x Everspring Water Sensors; DSC Integration; 2 x Zwave Door Locks; 1x Ted5K; 1x Rainforest Eagle; Onkyo AVR; 6x Squeezebox;

Offline RichardTSchaefer

  • Moderator
  • Master Member
  • *****
  • Posts: 10091
  • Karma: +763/-142
Re: UPDATED: Program Logic Event Generator Plugin
« Reply #37 on: January 25, 2013, 07:30:38 pm »
I already fixed it ... it will be in a beta next week (maybe the weekend).

Also ...
You can modify the names in the appropriate input editor ... it will update the condition expressions for you.
« Last Edit: January 25, 2013, 07:32:29 pm by RichardTSchaefer »

Offline sjolshagen

  • Sr. Member
  • ****
  • Posts: 416
  • Karma: +5/-0
Re: UPDATED: Program Logic Event Generator Plugin
« Reply #38 on: January 25, 2013, 08:59:46 pm »
I' m getting "Invalid Value token: WINTER" in the status at the top of the UI5 page. I'm using a virtual switch device which to set "Summer mode" in the house. That switch was included in the PLEG device as a trigger (Not enabled = Winter).

Triggers:
    1st_LightsOff -> Combination Device that contains all of the lights on the 1st floor & gets triggered if all of them are off
    2nd_LightsOff -> Combination Device (same description as for 1st)
    Basement_LightsOff -> Combination Device (see 1st & 2nd)
    Winter -> Virtual Switch device -- ("Summer Mode") is turned off.
    1st_LigthsOn -> Triggered while virtual switch (Combo device) is off
    2nd_LightsOn -> Same as 1st
    Basement_LightsOn -> Same as 1st & 2nd.

Settings:
    HouseDark = 1st_LightsOff AND 2nd_LightsOff AND Basement_LightsOff
    Heat1st = Winter AND 1st_LightsOn
    HeatOff1st = Winter AND 1st_LightsOff

If I rotate "Winter" and "1st_LightsOff" the message claims the invalid token is "ST_LIGHTSOFF" (chopping the 1st character off?).

Also, in the log, there are still Schedules (that have been deleted in the plugin itself and doesn't show up there)?

Code: [Select]
50 01/25/13 20:57:14.388 luup_log:175: ProgramLogicEG:175:Initialize:Restart __LEAK__ this:24576 start:2564096 to 0x17ce000 <0x2b3e7680>
50 01/25/13 20:57:14.447 luup_log:175: ProgramLogicEG:175:EvalConditions:Condition:HouseDark Trigger:nil Result:false __LEAK__ this:126976 start:2691072 to 0x17ed000 <0x2b3e7680>
50 01/25/13 20:57:14.449 luup_log:175: ProgramLogicEG:175:EvalConditions:Condition:Heat1st Trigger:nil Result:false <0x2b3e7680>
50 01/25/13 20:57:14.460 luup_log:175: ProgramLogicEG:175:EvalConditions:Condition:HeatOff1st Trigger:nil Result:false <0x2b3e7680>
50 01/25/13 20:57:14.461 luup_log:175: ProgramLogicEG:175:SaveDB:{{name ='4am', state = true, seq = 0},{name ='9am', state = true, seq = 1359122400},{name ='SundayMovieNight', state = true, seq = 0},} <0x2b3e7680>
06 01/25/13 20:57:14.461 Device_Variable::m_szValue_set device: 175 service: urn:rts-services-com:serviceId:ProgramLogicC variable: TriggerStatusMap was: {{name ='4am', state = true, seq = 0},{name ='9am', state = true, seq = 1359122400},{name ='SundayMovieNight', state = true, seq = 0},} now: {{name ='4am', state = true, seq = 0},{name ='9am', state = true, seq = 1359122400},{name ='SundayMovieNight', state = true, seq = 0},} #hooks: 0 upnp: 0 v:0xc245f8/NONE duplicate:1 <0x2b3e7680>
50 01/25/13 20:57:14.468 luup_log:175: ProgramLogicEG:175:SweepDB:4am <0x2b3e7680>
50 01/25/13 20:57:14.469 luup_log:175: ProgramLogicEG:175:SweepDB:9am <0x2b3e7680>
50 01/25/13 20:57:14.469 luup_log:175: ProgramLogicEG:175:SweepDB:SundayMovieNight <0x2b3e7680>
Vera3/UI5 @ v1.5.622

Offline RichardTSchaefer

  • Moderator
  • Master Member
  • *****
  • Posts: 10091
  • Karma: +763/-142
Re: UPDATED: Program Logic Event Generator Plugin
« Reply #39 on: January 25, 2013, 09:23:25 pm »
Variable names can not start with a number ... it's causing a parsing error. This is true in almost every programming language.

See recent post .. it's easy to change input variable names!



Offline sjolshagen

  • Sr. Member
  • ****
  • Posts: 416
  • Karma: +5/-0
Re: UPDATED: Program Logic Event Generator Plugin
« Reply #40 on: January 25, 2013, 09:42:09 pm »
Yes it is (and I forgot about that li'l gem :))

But that doesn't explain why BLightsOn results in the same error message... :(

And after having deleted one of the PLEG devices I had created, the device info remained in the Vera config, causing warnings & messages.
Vera3/UI5 @ v1.5.622

Offline RichardTSchaefer

  • Moderator
  • Master Member
  • *****
  • Posts: 10091
  • Karma: +763/-142
Re: UPDATED: Program Logic Event Generator Plugin
« Reply #41 on: January 25, 2013, 10:34:52 pm »
If you open the Automation -> Triggers tab ... You can find the old triggers. You can delete them there.
Vera does not provide a call to the plugin when you delete a device to allow me to clean up related information.

I though I put logic to detect this and correct it when you create a NEW PLEG or PLTS device.
If you delete all your triggers before deleting a PL?? device .. you will not have a problem.


Offline sjolshagen

  • Sr. Member
  • ****
  • Posts: 416
  • Karma: +5/-0
Re: UPDATED: Program Logic Event Generator Plugin
« Reply #42 on: January 25, 2013, 10:49:23 pm »
I though I put logic to detect this and correct it when you create a NEW PLEG or PLTS device.
If you delete all your triggers before deleting a PL?? device .. you will not have a problem.

I have to delete all triggers for all PL* devices before deleting _a_ PL device & then recreate from scratch?
Vera3/UI5 @ v1.5.622

Offline RichardTSchaefer

  • Moderator
  • Master Member
  • *****
  • Posts: 10091
  • Karma: +763/-142
Re: UPDATED: Program Logic Event Generator Plugin
« Reply #43 on: January 25, 2013, 10:54:08 pm »
No just delete the triggers for the particular PL device you want to delete ... before you delete the PL device itself. It should be pretty quick ... just walk down the list clicking delete.

It should not hurt anything ... a few ms of lost computer time ... if you do not ... it will just have noise in the log file.



Offline RichardTSchaefer

  • Moderator
  • Master Member
  • *****
  • Posts: 10091
  • Karma: +763/-142
Re: UPDATED: Program Logic Event Generator Plugin
« Reply #44 on: January 25, 2013, 10:55:41 pm »
A beta update to PLEG has been provide.
See the topic http://forum.micasaverde.com/index.php/topic,13421.0.html for details.
Fixes bug with using timer inputs in a boolean expression.