Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Bug Reports
 PowerHome Messageboard : PowerHome Bug Reports
Subject Topic: ph_modifytimedevent - possible issue Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
smarty
Super User
Super User
Avatar

Joined: May 21 2006
Location: United States
Online Status: Offline
Posts: 728
Posted: May 22 2012 at 21:04 | IP Logged Quote smarty

ph_modifytimedevent ( id, active, reftime, flags )

Argument Description
id - String. The ID of the Timed Event you wish to modify.
active - Integer. Use 0 to set the Timed Event inactive. Use 1 to set the Timed Event active. Controlled by the flags parameter.
reftime - DateTime. The new reftime for the specified Timed Event. Controlled by the flags parameter.
flags - Integer. Determines which parameters are used to update the Timed Event. Add values together. 1 - Recalculate a new StartTime, 2 - Update the Active parameter, 4 - Set a new RefTime and recalculate StartTime

Return value
Integer. Returns 0 if successful. 1 if the Timed Event specified does not exist.
================================================
My formula is this:
ph_modifytimedevent("ALARM CLOCK",1,{AC_DATETIME},7)

It returns a 0 (successful). For my testing purposes, the pre-existing timed event calls a raw formula (ph_tts("alarm clock macro").

What I believe is a bug is that when I issue the above ph_modifytimedevent command, my timed event FIRES immediately (and it updates to enabled and updates per the other flags as expected). What was not expected was the immediate firing of the raw formula.

My {AC_DATETIME} is a datetime value that is in the FUTURE, and thus (in my mind) the timed event should only fire when the datetime is reached, right??

I have also tried :
ph_modifytimedevent("ALARM CLOCK",1,{AC_DATETIME},1)ph_modifytimedevent("ALARM CLOCK",1,{AC_DATETIME},3)ph_modifytimedevent("ALARM CLOCK",1,{AC_DATETIME},4)ph_modifytimedevent("ALARM CLOCK",1,{AC_DATETIME},5)
They all fire the timedevent immediatley.

However,
ph_modifytimedevent("ALARM CLOCK",1,{AC_DATETIME},2)
only "enables" the timed event (as expected), and DOES NOT fire the timed event immediately.

Edited by smarty - May 22 2012 at 21:07


__________________
Elk - Insteon - BlueIris - DMC1 - PowerHome - XLobby - HA_Bridge w/Dots - Brultech
Back to Top View smarty's Profile Search for other posts by smarty
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: May 23 2012 at 12:39 | IP Logged Quote dhoward

Smarty,

I checked the sourcecode and couldnt find anything that would cause that behaviour. I also created a test timed event and worked through it and could not duplicate your results. Therefore, Im thinking it may have something to do with the format of the datetime value in the {AC_DATETIME} global variable.

Literal datetimes must be in the format of YYYY-MM-DD HH:MM:SS in order for them to work properly. If you have a different format such as mm/dd/yyyy hh:mm:ss then I would recommend retrieving the global using ph_getglobal_dt("AC_DATETIME") vs using variable substitution. The proper format of the formula would then look like:

ph_modifytimedevent("ALARM CLOCK",1,ph_getglobal_dt("AC_DATETIME"),5)

The ph_getglobal_dt formula is nice because it will convert from other date formats. It basically searches for the first space in the global and then takes everything to the left and converts it to a date accepting multiple date formats including mm/dd/yyyy and takes everything to the right of the first space and converts it to a time. It then combines the two into a proper datetime value.

Give that a try and see if it doesnt yield better results.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
smarty
Super User
Super User
Avatar

Joined: May 21 2006
Location: United States
Online Status: Offline
Posts: 728
Posted: May 24 2012 at 07:40 | IP Logged Quote smarty

Well, that was what I kinda figured as well, but I still see the same issue (no success yet).

A bit more information/clarity......
The pre-existing timed event that I am modifiying is a "daily" timed event.

I am using the formula

ph_modifytimedevent("ALARM CLOCK",1,ph_getglobal_dt("AC_DATETIME"),7)
to turn on, and update

and using
ph_modifytimedevent("ALARM CLOCK",0,ph_getglobal_dt("AC_DATETIME"),7)
to turn off, and update

the alarm time for an alarm clock wake up routine. As I develop/debug the routine, I change the alarm times and the on/off status quite a bit. It seems to me that the above formula seemed to work as expected the first time, but then the timed event is executed each subsequent time I use the formula (I haven't been able to replicate it working the first time again...and then not thereafter).

Lastly, my datetime value in my timed event is
2012-05-25 06:34:00

while my formula
ph_getglobal_dt("AC_DATETIME")
gives me
05/25/2012 06:34:00

Both of which are 1 day ahead of today 5/24/12 =>and thus the timed event SHOULD NOT fire (in my way of thinking).

__________________
Elk - Insteon - BlueIris - DMC1 - PowerHome - XLobby - HA_Bridge w/Dots - Brultech
Back to Top View smarty's Profile Search for other posts by smarty
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum