Home AMX User Forum AMX Technical Discussion

Alarm Clock Examples

I am looking for creative alarm clock functions using a touchpanel in order to set the alarm time, different alarm methods (TP beeps, ties to other systems), along with ways to acknowledge the alarm.

Thanks,
E.

Comments

  • eriklhayes wrote:
    I am looking for creative alarm clock functions using a touchpanel in order to set the alarm time, different alarm methods (TP beeps, ties to other systems), along with ways to acknowledge the alarm.
    QUOTE]

    If the user throws the Modero across the room smashing it against the wall and it goes offline, that should activate the SLEEP function.
  • yuriyuri Posts: 861
    just your luck, the new firmware has a builtin clock manager :p
    Make some buttons to change the beep, and set a time and you are done :)
  • DenisDenis Posts: 163
    Yuri

    Can you elaborate? I'm looking for to do same ting in MVP8400, new firmware of..... do you mean?
  • ericmedleyericmedley Posts: 4,177
    We offer an alarm clock feature on our panels. (as well as an oven/ kitchen timer)

    The feature lets the client select either a beep-beeop from the panel or will turn on soemthing in the whole house audio or their room TV.
  • DenisDenis Posts: 163
    Thanks Eric

    Only one thing, I don't have panel on hand, I have only a MVP8400 on hand,(I thing as it has new firmware) You told as the feature is accessible for customer, how the customer can access this page? By panel control? Module avaible?
  • ericmedleyericmedley Posts: 4,177
    Denis wrote: »
    Thanks Eric

    Only one thing, I don't have panel on hand, I have only a MVP8400 on hand,(I thing as it has new firmware) You told as the feature is accessible for customer, how the customer can access this page? By panel control? Module avaible?

    It's a part of the program. It's not something native to the panel itself.
  • DenisDenis Posts: 163
    Thanks, I will try to do that.
  • DHawthorneDHawthorne Posts: 4,584
    I wrote a very elaborate module once that let the user set multiple alarms from any location in his house, and could have it either pop up on the local panel, or ring a phone extension. It worked really well, but I had some half-baked ideas about making it modular that wound up in fact adding so much bloat I can barely make sense of it any more. I'd start from scratch before re-using that mess.
  • DenisDenis Posts: 163
    Hi

    I tried to wrote an alarm clock but i'm unable to do work it. The code to adjust time seem works fine ( except I don't get the ) in minute section ex: 01 min I get 1) but the rest of the code dosen't works. I goet no error from compiler.

    Some body can help me?

    ps DHawthorne if your module works fine and if is it avaible, where I can get it?

    Variables
    INTEGER nHH		// VARIABLE TO DETERMINE ALARM CLOCK
    INTEGER nMM		// VARIABLE TO DETERMINE ALARM CLOCK
    SINTEGER nTHH
    SINTEGER nTMM
    
    CHAR TimeStr [8]
    CHAR nAAHH [2]
    CHAR nAHHH [2]
    
    Start up section 
    
    nHH = 0
    nMM = 00
    
    //SECTION ALARM CLOCK
    BUTTON_EVENT [dvTP_ALLARM_SET,51]
    {
        PUSH:
        {
        IF (nHH < 23)
    	{
    	nHH = nHH +1
    	SEND_COMMAND dvTP_ALLARM_SET,"'@TXT',70,ITOA(nHH)"
    	}
        ELSE
    	{
    	IF (nHH = 23)
    	    {
    	    nHH = 0
    	    SEND_COMMAND dvTP_ALLARM_SET,"'@TXT',70,ITOA(nHH)"
    	    }
    	}
        }
    }
    
    BUTTON_EVENT [dvTP_ALLARM_SET,52]
    {
        PUSH:
        {
        IF (nHH > 0)
    	{
    	nHH = nHH - 1
    	SEND_COMMAND dvTP_ALLARM_SET,"'@TXT',70,ITOA(nHH)"
    	}
        ELSE
    	{
    	IF (nHH = 0)
    	    {
    	    nHH = 23
    	    SEND_COMMAND dvTP_ALLARM_SET,"'@TXT',70,ITOA(nHH)"
    	    }
    	}
        }
    }
    BUTTON_EVENT [dvTP_ALLARM_SET,53]
    {
        PUSH:
        {
        IF (nMM < 59)
    	{
    	nMM = nMM +1
    	SEND_COMMAND dvTP_ALLARM_SET,"'@TXT',71,ITOA(nMM)"
    	}
        ELSE
    	{
    	IF (nMM = 59)
    	    {
    	    nMM = 0
    	    SEND_COMMAND dvTP_ALLARM_SET,"'@TXT',71,ITOA(nMM)"
    	    }
    	}
        }
    }
    
    BUTTON_EVENT [dvTP_ALLARM_SET,54]
    {
        PUSH:
        {
        IF (nMM > 0)
    	{
    	nMM = nMM - 1
    	SEND_COMMAND dvTP_ALLARM_SET,"'@TXT',71,ITOA(nMM)"
    	}
        ELSE
    	{
    	IF (nMM = 0)
    	    {
    	    nMM = 59
    	    SEND_COMMAND dvTP_ALLARM_SET,"'@TXT',71,ITOA(nMM)"
    	    }
    	}
        }
    }
    
    //END OF SECTION ALARM CLOCK
    (***********************************************************)
    (*            THE ACTUAL PROGRAM GOES BELOW                *)
    (***********************************************************)
    DEFINE_PROGRAM
    nAAHH = ITOA(nHH)
    nAAMM = ITOA(nMM)
    
    nTHH = TIME_TO_HOUR (TimeStr)
    nTMM = TIME_TO_MINUTE (TimeStr)
    
    IF ((nAAHH == nAHH)&&(nAAMM == nAMM))
    {
    CALL 'CURTAINS_CLOSED'
    } 
    
    
  • I can see two items in your example.

    The first is TimeStr does not equal anything. So when you do your TIME_TO_HOUR (TimeStr)
    nothing is returned.

    If it were me I would use TIME_TO_HOUR (TIME) and not worry about TimeStr

    Second, your code is in main line so. once you get the TIME_TO_HOUR function to work right your call is going to happen a bunch of times.

    IF ((nAAHH == nAHH)&&(nAAMM == nAMM))
    {
    CALL 'CURTAINS_CLOSED'
    }

    during the minute that nAAMM == nAMM the 'curtain closed' call will be called as many times as main line can run in a 60 second period.

    One thing I like to do is setup a repeating timeline that runs once a minute. In the time line I would put the code that you have written
    TIMELINE_EVENT[tl60_Second_Update]
    {
      nAAHH = ITOA(nHH)
      nAAMM = ITOA(nMM)
    
      nTHH = TIME_TO_HOUR (TIME)
      nTMM = TIME_TO_MINUTE (TIME)
    
      IF ((nAAHH == nAHH)&&(nAAMM == nAMM))
      {
        CALL 'CURTAINS_CLOSED'
      }
    }
    
    

    Hope this helps.
  • ericmedleyericmedley Posts: 4,177
    One thing I would highly suggest is to convert you time over to Julian. (or at least change it to some kind of 'minutes past some time in the past' ) It seems difficult at first but it makes the alarm time math much nicer and you can create multiple timers much easier.
  • DHawthorneDHawthorne Posts: 4,584
    I'm not willing to share my module - it's nearly incomprehensible even to me, and I would be embarrassed to share it.
  • How do you make the scrolling code blocks?
  • mpullinmpullin Posts: 949
    ericmedley wrote: »
    One thing I would highly suggest is to convert you time over to Julian. (or at least change it to some kind of 'minutes past some time in the past' ) It seems difficult at first but it makes the alarm time math much nicer and you can create multiple timers much easier.
    Epoch time would be my preference.
    kbeattyAMX wrote: »
    How do you make the scrolling code blocks?
    Write enough code in your regular code blocks :p



    Seriously, [@CODE]DEFINE_PROGRAM wait 1 CALL 'foo'[/@CODE]
    (remove @s)
  • DenisDenis Posts: 163
    No problem Dave I understand.

    Concerning my problem, I change the variable to by more comprehensive, I tried Time line suggest by Dan
    When I put this code in main line,I get an error from compiler

    "ERROR: F:\AMX Program files Rev 2.1\Brosseau Demo,Rev 2.axs(1827): C10201: Syntax error; Illegal or Invalid syntax in code
    F:\AMX Program files Rev 2.1\Brosseau Demo,Rev 2.axs - 1 error(s), 0 warning(s) "

    When I put in Define Event section the compiler don't return error but dosen't work.



    nT for Time nA for Allarm
    INTEGER nHH    // VARIABLE TO DETERMINE ALARM CLOCK
    INTEGER nMM   // VARIABLE TO DETERMINE ALARM CLOCK
    integer tl60_Second_Update
    SINTEGER nTHH
    SINTEGER nTMM
    
    CHAR nAHH [2]
    CHAR nAMM [2]
    
    TIMELINE_EVENT[tl60_Second_Update]
    {
      nAHH = ITOA(nHH)
      nAMM = ITOA(nMM)
    
      nTHH = TIME_TO_HOUR (TIME)
      nTMM = TIME_TO_MINUTE (TIME)
    
      IF ((nAHH == nTHH)&&(nAMM == nTMM))
      {
        CALL 'CURTAINS_OPEN'
      }
    }
    
    
  • MODULE_NAME='AlarmClock COMM' (dev vdvAlarm)
    (***********************************************************)
    (***********************************************************)
    (*  FILE_LAST_MODIFIED_ON: 04/04/2006  AT: 11:33:16        *)
    (***********************************************************)
    (* System Type : NetLinx                                   *)
    (***********************************************************)
    (* REV HISTORY:                                            *)
    (***********************************************************)
    (*
        $History: $
    		
    		Channels 1-10 are pulsed when the assiciated alarm is triggered
    		
    		send_command vdvAlarm,'AlarmSet-1:12:00'
    		send_command vdvAlarm,'AlarmGet-1'
    *)    
    (***********************************************************)
    (*          DEVICE NUMBER DEFINITIONS GO BELOW             *)
    (***********************************************************)
    DEFINE_DEVICE
    
    (***********************************************************)
    (*               CONSTANT DEFINITIONS GO BELOW             *)
    (***********************************************************)
    DEFINE_CONSTANT
    
    MinuteTimeline = 1
    
    (***********************************************************)
    (*              DATA TYPE DEFINITIONS GO BELOW             *)
    (***********************************************************)
    DEFINE_TYPE
    
    (***********************************************************)
    (*               VARIABLE DEFINITIONS GO BELOW             *)
    (***********************************************************)
    DEFINE_VARIABLE
    
    integer curr_alarm_edit
    persistent char alarms[10][10]
    
    long MinuteTimelineTime[] = {60000} //1 minute
    
    DEFINE_CONSTANT
    
    (***********************************************************)
    (*              DATA TYPE DEFINITIONS GO BELOW             *)
    (***********************************************************)
    DEFINE_TYPE
    
    (***********************************************************)
    (*               LATCHING DEFINITIONS GO BELOW             *)
    (***********************************************************)
    DEFINE_LATCHING
    
    (***********************************************************)
    (*       MUTUALLY EXCLUSIVE DEFINITIONS GO BELOW           *)
    (***********************************************************)
    DEFINE_MUTUALLY_EXCLUSIVE
    
    (***********************************************************)
    (*        SUBROUTINE/FUNCTION DEFINITIONS GO BELOW         *)
    (***********************************************************)
    (* EXAMPLE: DEFINE_FUNCTION <RETURN_TYPE> <NAME> (<PARAMETERS>) *)
    (* EXAMPLE: DEFINE_CALL '<NAME>' (<PARAMETERS>) *)
    
    (***********************************************************)
    (*                STARTUP CODE GOES BELOW                  *)
    (***********************************************************)
    DEFINE_START
    
    curr_alarm_edit = 1
    
    timeline_create(MinuteTimeline,MinuteTimelineTime,1,timeline_absolute,timeline_repeat)
    
    (***********************************************************)
    (*                THE EVENTS GO BELOW                      *)
    (***********************************************************)
    DEFINE_EVENT
    
    data_event[vdvAlarm]
    {
      command:  // command format= SEND_COMMAND vdvAlarm,'AlarmSet-1:10:15' for 10:15am
    	{
    	  if (find_string(data.text,'AlarmSet-',1))
    		{
    		  remove_string(data.text,'AlarmSet-',1)
    			curr_alarm_edit = atoi(remove_string(data.text,':',1))
    			alarms[curr_alarm_edit] = data.text
    		}
    		if (find_string(data.text,'AlarmGet-',1))
    		{
    		  remove_string(data.text,'AlarmGet-',1)
    		  curr_alarm_edit = atoi(data.text) 
    		  send_string vdvAlarm,"'AlarmSet-',itoa(curr_alarm_edit),':',alarms[curr_alarm_edit]"
    		}
    	}
    }
    
    timeline_event[MinuteTimeline]
    {
    	if (find_string(time,alarms[1],1)) 	pulse[vdvAlarm,1]
    	if (find_string(time,alarms[2],1)) 	pulse[vdvAlarm,2]
    	if (find_string(time,alarms[3],1)) 	pulse[vdvAlarm,3]
    	if (find_string(time,alarms[4],1)) 	pulse[vdvAlarm,4]
    	if (find_string(time,alarms[5],1)) 	pulse[vdvAlarm,5]
    	if (find_string(time,alarms[6],1)) 	pulse[vdvAlarm,6]
    	if (find_string(time,alarms[7],1)) 	pulse[vdvAlarm,7]
    	if (find_string(time,alarms[8],1)) 	pulse[vdvAlarm,8]
    	if (find_string(time,alarms[9],1)) 	pulse[vdvAlarm,9]
    	if (find_string(time,alarms[10],1))	pulse[vdvAlarm,10]
    }  
    

    This is a COMM version of a module but there is no real AMX device to control.
    PROGRAM_NAME='Alarm Clock'
    (***********************************************************)
    (***********************************************************)
    (*  FILE_LAST_MODIFIED_ON: 04/05/2006  AT: 09:00:25        *)
    (***********************************************************)
    (* System Type : NetLinx                                   *)
    (***********************************************************)
    (* REV HISTORY:                                            *)
    (***********************************************************)
    (*
        $History: $
    *)
    (***********************************************************)
    (*          DEVICE NUMBER DEFINITIONS GO BELOW             *)
    (***********************************************************)
    DEFINE_DEVICE
    dvTP = 10001:1:0
    vdvAlarm = 33001:1:0
    
    (***********************************************************)
    (*               CONSTANT DEFINITIONS GO BELOW             *)
    (***********************************************************)
    DEFINE_CONSTANT
    
    (***********************************************************)
    (*              DATA TYPE DEFINITIONS GO BELOW             *)
    (***********************************************************)
    DEFINE_TYPE
    
    (***********************************************************)
    (*               VARIABLE DEFINITIONS GO BELOW             *)
    (***********************************************************)
    DEFINE_VARIABLE
    
    integer currTP_alarm_edit
    char time_entered[6]
    
    
    (***********************************************************)
    (*               LATCHING DEFINITIONS GO BELOW             *)
    (***********************************************************)
    DEFINE_LATCHING
    
    (***********************************************************)
    (*       MUTUALLY EXCLUSIVE DEFINITIONS GO BELOW           *)
    (***********************************************************)
    DEFINE_MUTUALLY_EXCLUSIVE
    
    define_module 'AlarmClock COMM' inst1(vdvAlarm)
    
    (***********************************************************)
    (*        SUBROUTINE/FUNCTION DEFINITIONS GO BELOW         *)
    (***********************************************************)
    (* EXAMPLE: DEFINE_FUNCTION <RETURN_TYPE> <NAME> (<PARAMETERS>) *)
    (* EXAMPLE: DEFINE_CALL '<NAME>' (<PARAMETERS>) *)
    
    (***********************************************************)
    (*                STARTUP CODE GOES BELOW                  *)
    (***********************************************************)
    DEFINE_START
    
    
    (***********************************************************)
    (*                THE EVENTS GO BELOW                      *)
    (***********************************************************)
    DEFINE_EVENT
    
                                           
    
    data_event[dvTP]  //time in from the TP
    {
      string:
    	{
    	  if (find_string(data.text,'KEYP',1))
    		{
    		  remove_string(data.text,'KEYP-',1)
    			if ((length_string(data.text) < 3) or (length_string(data.text) > 4))
    			{
    			  //no action
    			}
    			else
    			{
    			  time_entered = right_string("'00',data.text",4)
    				send_command vdvAlarm,"'AlarmSet-',itoa(currTP_alarm_edit),':',time_entered[1],time_entered[2],':',time_entered[3],time_entered[4]"
    				send_command dvTP,"'TEXT',itoa(currTP_alarm_edit),'-',time_entered[1],time_entered[2],':',time_entered[3],time_entered[4]"
    			}
    		}
    	}
    }  
    
    button_event[dvTP,0]
    {
      push:
    	{
    	  currTP_alarm_edit = button.input.channel
    	}
    }               
    
    
    (***********************************************************)
    (*            THE ACTUAL PROGRAM GOES BELOW                *)
    (***********************************************************)
    DEFINE_PROGRAM
    
    [dvTP,1] = (currTP_alarm_edit=1)
    [dvTP,2] = (currTP_alarm_edit=2)
    [dvTP,3] = (currTP_alarm_edit=3)
    [dvTP,4] = (currTP_alarm_edit=4)
    [dvTP,5] = (currTP_alarm_edit=5)
    [dvTP,6] = (currTP_alarm_edit=6)
    [dvTP,7] = (currTP_alarm_edit=7)
    
    [dvTP,11] = [vdvAlarm,1]
    [dvTP,12] = [vdvAlarm,2]
    [dvTP,13] = [vdvAlarm,3]
    [dvTP,14] = [vdvAlarm,4]
    [dvTP,15] = [vdvAlarm,5]
    [dvTP,16] = [vdvAlarm,6]
    [dvTP,17] = [vdvAlarm,7]
    [dvTP,18] = [vdvAlarm,8]
    [dvTP,19] = [vdvAlarm,9]
    [dvTP,20] = [vdvAlarm,10]
                                
    (***********************************************************)
    (*                     END OF PROGRAM                      *)
    (*        DO NOT PUT ANY CODE BELOW THIS COMMENT           *)
    (***********************************************************)
    

    This is the main code that can be changed to a UI Module. You can use whatever you want to make HH:MM. I prefer using the Keypad. Let me know what you think.

    of course to trigger any event you want just add:
    channel_event[vdvAlarm,0]
    {
      on:
      {
        switch (channel.channel)
        {
          case 1: closecurtains()
        }
      }
    }
    
  • John PaulJohn Paul Posts: 143
    Alarm code review neeeded.

    I have pasted the alarm code below, somehow i am not able to store the time value in the string variable. When i run the code, i get the following in diagnostics . Obviously i am not doing the data conversions properly. I have attached the touch panel layout, so you will know the channel nos . Please guide.

    Line 1 (20:29:41):: GetString - Error 1 Tk=0x0001
    Line 2 (20:29:41):: CopyString (Reference) - Error 1 S=0x0000 D=0x1011
    Line 3 (20:29:50):: GetString - Error 1 Tk=0x0001
    Line 4 (20:29:50):: CopyString (Reference) - Error 1 S=0x0000 D=0x1011
    Line 5 (20:34:34):: GetString - Error 1 Tk=0x0001
    Line 6 (20:34:34):: CopyString (Reference) - Error 1 S=0x0000 D=0x1011
    Line 7 (20:34:42):: GetString - Error 1 Tk=0x0001
    Line 8 (20:34:42):: CopyString (Reference) - Error 1 S=0x0000 D=0x1011





    PROGRAM_NAME='incAlarm'
    DEFINE_DEVICE
    dvTPBedRoom1Alarm = 10006:58:2

    define_constant
    MinuteTimeline = 1

    INTEGER nTP_COUNT=3

    integer nHoursMax=12
    integer nHoursMin=1

    integer nMinutesMax=59
    integer nMinutesMin=0
    // TIMELINE IDS
    LONG lPanelRING_TIMEOUT1 = 200 // TIMEOUT FOR TOUCH PANEL RING

    DEFINE_VARIABLE
    VOLATILE LONG lRING1[] = {2000}

    long MinuteTimelineTime[] = {60000} //1 minute


    volatile integer nPanel1AlarmHour= 7
    volatile integer nPanel1AlarmMinute=0
    volatile char sPanel1AlarmPeriod='AM'
    Volatile char sPanel1Alarm []= '7:00 AM'
    Volatile integer nPanel1ShutterEvent=0
    Volatile integer nPanel1LightsEvent=0
    Volatile integer nPanel1AudioEvent=0
    Volatile integer nPanel1CurtainsEvent=0
    Volatile integer nOtherEvent2=0
    Volatile integer nPanel1AlarmSet=0
    Volatile integer nPanel1SnoozeSet=0

    integer nAlarmbtns[]=
    {
    1, //Lights Events
    2, //Shutter events
    3, //Audio Events
    4, //His Table
    5, //Her Table
    6, //Hour up
    7, //Hour down
    8, //Minutes up
    9, //Minutes down
    10, //Period Up
    11, //Period Down
    12, //Period State
    13, //Alarm On/Off
    14, //Snooze On/Off
    15, //Alarm time State
    16, //Hour state
    17, //Minutes
    18, //Alarm Off
    19, //Snooze On
    20

    }


    DEFINE_function char Alarm (integer nAlarmHour,integer nAlarmMinute,char sAlarmPeriod,dev Panel)
    {



    stack_var integer nAlarmPMHour
    stack_var integer sAlarm

    if (nAlarmMinute>=10)
    {

    IF (sAlarmPeriod=='PM')

    {
    nAlarmPMHour=nAlarmHour+12
    send_command Panel,"'^TXT-15,0,',ITOA(nAlarmHour),':',ITOA(nAlarmMinute),' PM'" //Temp display

    }else
    {
    nAlarmPMHour=nAlarmHour
    send_command Panel,"'^TXT-15,0,',ITOA(nAlarmHour),':',ITOA(nAlarmMinute),' AM'"

    }
    sAlarm="ITOA(nAlarmPMHour),':',ITOA(nAlarmMinute),':00'"

    }else
    {


    IF (sAlarmPeriod=='PM')

    {
    nAlarmPMHour=nAlarmHour+12
    send_command Panel,"'^TXT-15,0,',ITOA(nAlarmHour),':0',ITOA(nAlarmMinute),' PM'" //Temp display

    }else
    {
    nAlarmPMHour=nAlarmHour
    send_command Panel,"'^TXT-15,0,',ITOA(nAlarmHour),':0',ITOA(nAlarmMinute),' AM'"

    }
    sAlarm="ITOA(nAlarmPMHour),':0',ITOA(nAlarmMinute),':00'"
    }


    REturn sAlarm

    }


    DEFINE_Call 'Alarm Time' (char sAlarm,integer nAlarmSet,integer nShutterEvent,integer nLightsEvent,integer nCurtainsEvent,integer nAudioEvent,dev Panel,integer nSnoozeSet)
    {




    IF (TIME = sAlarm)

    {
    send_String 0,"'Alarm Time =', sAlarm,' and Time =',Time"
    if (nAlarmSet==1)
    {

    IF (nShutterEvent=1)//Shutter

    {
    do_push(dvTPLutronDiwaniya52,91)
    }

    IF (nLightsEvent=1)//Lights

    {
    do_push(dvTPLutronDiwaniya52,71)
    }
    IF (nCurtainsEvent=1)//Curtains

    {
    do_push(dvTPLutronDiwaniya52,72)
    }
    IF (nAudioEvent=1)//Audio

    {
    do_push(dvTP_AMFMARRAY[5],21)
    wait 10
    do_push(dvTP_AMFMARRAY[5],18)
    // wait 30
    //do_push(virtualTPMBRTangoVolume,292)
    }
    if (Panel==dvTPBedRoom1Alarm)
    {
    IF (TIMELINE_ACTIVE(lPanelRING_TIMEOUT1))
    {
    TIMELINE_KILL(lPanelRING_TIMEOUT1)
    }
    TIMELINE_CREATE(lPanelRING_TIMEOUT1, lRING1, 1, TIMELINE_RELATIVE, TIMELINE_REPEAT)
    nPanel1AlarmSet=0
    }

    IF (nSnoozeSet=1)//Snooze

    {

    SEND_COMMAND Panel,"'^SHO-19,1'"


    }else
    {
    SEND_COMMAND Panel,"'^SHO-19,0'"

    }

    send_command Panel, "'PAGE-[Home]Main Page'"
    send_command Panel, "'@PPN-Alarm Popup'"

    }


    }

    }
    define_start
    timeline_create(MinuteTimeline,MinuteTimelineTime,1,timeline_absolute,timeline_repeat)


    DEFINE_EVENT

    DATA_EVENT [dvTPBedRoom1Alarm]// contains real and virtual TP devices

    {
    ONLINE:
    {
    if ([dvTPBedRoom1Alarm,13]==1)
    {

    SEND_COMMAND dvTPBedRoom1Alarm,"'^ENA-1.11&14,0'"
    }
    else{

    SEND_COMMAND dvTPBedRoom1Alarm,"'^ENA-1.11&14,1'"
    }
    }
    }



    BUTTON_EVENT[dvTPBedRoom1Alarm,nAlarmbtns]
    {
    PUSH:
    {

    SWITCH(GET_LAST(nAlarmbtns))
    {
    case 1:// Shutter Event
    {
    if ([dvTPBedRoom1Alarm,1]==1)
    {
    [dvTPBedRoom1Alarm,1]=0
    nPanel1ShutterEvent=0
    }
    else{
    [dvTPBedRoom1Alarm,1]=1
    nPanel1ShutterEvent=1
    }

    }
    case 2://Lights Event
    {

    if ([dvTPBedRoom1Alarm,2]==1)
    {
    [dvTPBedRoom1Alarm,2]=0
    nPanel1LightsEvent=0
    }
    else{
    [dvTPBedRoom1Alarm,2]=1
    nPanel1LightsEvent=1
    }

    }
    case 3://Audio Events
    {
    if ([dvTPBedRoom1Alarm,3]==1)
    {
    [dvTPBedRoom1Alarm,3]=0
    nPanel1AudioEvent=0
    }
    else{
    [dvTPBedRoom1Alarm,3]=1
    nPanel1AudioEvent=1
    }

    }
    case 4://Curtains Events
    {
    if ([dvTPBedRoom1Alarm,4]==1)
    {
    [dvTPBedRoom1Alarm,4]=0
    nPanel1CurtainsEvent=0
    }
    else{
    [dvTPBedRoom1Alarm,4]=1
    nPanel1CurtainsEvent=1
    }

    }
    case 5: //
    {
    if ([dvTPBedRoom1Alarm,5]==1)
    {
    [dvTPBedRoom1Alarm,5]=0
    nOtherEvent2=0
    }
    else{
    [dvTPBedRoom1Alarm,5]=1
    nOtherEvent2=1
    }
    }
    case 6://Hours up
    {
    if (nPanel1AlarmHour<nHoursMax)
    {
    nPanel1AlarmHour=nPanel1AlarmHour+1
    }
    send_command dvTPBedRoom1Alarm,"'^TXT-16,0,',ITOA(nPanel1AlarmHour)" //Temp display

    }
    case 7: //Hour down
    {
    if (nPanel1AlarmHour>nHoursMin)
    {
    nPanel1AlarmHour=nPanel1AlarmHour-1
    }else if (nPanel1AlarmHour=nHoursMin)
    {
    nPanel1AlarmHour=nHoursMin
    }
    send_command dvTPBedRoom1Alarm,"'^TXT-16,0,',ITOA(nPanel1AlarmHour)" //Temp display

    }
    case 8:// Minutes up
    {
    if (nPanel1AlarmMinute<nMinutesMax)
    {
    nPanel1AlarmMinute=nPanel1AlarmMinute+1
    }
    if (nPanel1AlarmMinute>=10)
    {
    send_command dvTPBedRoom1Alarm,"'^TXT-17,0,',ITOA(nPanel1AlarmMinute)" //Temp display
    }else
    send_command dvTPBedRoom1Alarm,"'^TXT-17,0,0',ITOA(nPanel1AlarmMinute)" //Temp display
    }
    case 9:// Minutes down
    {
    if (nPanel1AlarmMinute>nMinutesMin)
    {
    nPanel1AlarmMinute=nPanel1AlarmMinute-1
    }else if (nPanel1AlarmMinute=nMinutesMin)
    {
    nPanel1AlarmMinute=nMinutesMin
    }
    if (nPanel1AlarmMinute>=10)
    {
    send_command dvTPBedRoom1Alarm,"'^TXT-17,0,',ITOA(nPanel1AlarmMinute)" //Temp display
    }else
    send_command dvTPBedRoom1Alarm,"'^TXT-17,0,0',ITOA(nPanel1AlarmMinute)" //Temp display
    }
    case 10://Period up
    {
    off[dvTPBedRoom1Alarm,12]
    sPanel1AlarmPeriod='AM'
    }
    case 11://Period down
    {
    on[dvTPBedRoom1Alarm,12]
    sPanel1AlarmPeriod='PM'
    }
    case 13: //Alarm on/off
    {
    if (nPanel1AlarmSet==1)
    {
    [dvTPBedRoom1Alarm,13]=0
    SEND_COMMAND dvTPBedRoom1Alarm,"'^ENA-1.11&14,1'"
    }
    else{
    [dvTPBedRoom1Alarm,13]=1
    SEND_COMMAND dvTPBedRoom1Alarm,"'^ENA-1.11&14,0'"
    }
    nPanel1AlarmSet=[dvTPBedRoom1Alarm,13]
    sPanel1Alarm=''
    sPanel1Alarm= Alarm (nPanel1AlarmHour,nPanel1AlarmMinute,sPanel1AlarmPeriod,dvTPBedRoom1Alarm)
    }
    case 14://Snooze on/off
    {
    if ([dvTPBedRoom1Alarm,14]==1)
    {
    [dvTPBedRoom1Alarm,14]=0

    }
    else{
    [dvTPBedRoom1Alarm,14]=1

    }
    nPanel1SnoozeSet=[dvTPBedRoom1Alarm,14]
    }
    case 18: //Alarm off
    {
    IF (TIMELINE_ACTIVE(lPanelRING_TIMEOUT1))
    {
    TIMELINE_KILL(lPanelRING_TIMEOUT1)
    }
    [dvTPBedRoom1Alarm,13]=0
    }
    case 19://Snooze on
    {
    IF (TIMELINE_ACTIVE(lPanelRING_TIMEOUT1))
    {
    TIMELINE_KILL(lPanelRING_TIMEOUT1)
    }
    wait 6000 'Panel1Snooze'
    {
    IF (TIMELINE_ACTIVE(lPanelRING_TIMEOUT1))
    {
    TIMELINE_KILL(lPanelRING_TIMEOUT1)
    }
    TIMELINE_CREATE(lPanelRING_TIMEOUT1, lRING1, 1, TIMELINE_RELATIVE, TIMELINE_REPEAT)
    send_command dvTPBedRoom1Alarm, "'PAGE-[Home]Main Page'"
    send_command dvTPBedRoom1Alarm, "'@PPN-Alarm Popup'"
    }
    }
    }
    }
    Hold [3,REPEAT]:
    {
    SWITCH(GET_LAST(nAlarmbtns))
    {
    case 6://Hours up
    {
    if (nPanel1AlarmHour<nHoursMax)
    {
    nPanel1AlarmHour=nPanel1AlarmHour+1
    }
    send_command dvTPBedRoom1Alarm,"'^TXT-16,0,',ITOA(nPanel1AlarmHour)" //Temp display

    }
    case 7: //Hour down
    {
    if (nPanel1AlarmHour>nHoursMin)
    {
    nPanel1AlarmHour=nPanel1AlarmHour-1
    }else if (nPanel1AlarmHour=nHoursMin)
    {
    nPanel1AlarmHour=nHoursMin
    }
    send_command dvTPBedRoom1Alarm,"'^TXT-16,0,',ITOA(nPanel1AlarmHour)" //Temp display

    }
    case 8:// Minutes up
    {
    if (nPanel1AlarmMinute<nMinutesMax)
    {
    nPanel1AlarmMinute=nPanel1AlarmMinute+1
    }
    if (nPanel1AlarmMinute>=10)
    {
    send_command dvTPBedRoom1Alarm,"'^TXT-17,0,',ITOA(nPanel1AlarmMinute)" //Temp display
    }else
    send_command dvTPBedRoom1Alarm,"'^TXT-17,0,0',ITOA(nPanel1AlarmMinute)" //Temp display
    }
    case 9:// Minutes down
    {
    if (nPanel1AlarmMinute>nMinutesMin)
    {
    nPanel1AlarmMinute=nPanel1AlarmMinute-1
    }else if (nPanel1AlarmMinute=nMinutesMin)
    {
    nPanel1AlarmMinute=nMinutesMin
    }
    if (nPanel1AlarmMinute>=10)
    {
    send_command dvTPBedRoom1Alarm,"'^TXT-17,0,',ITOA(nPanel1AlarmMinute)" //Temp display
    }else
    send_command dvTPBedRoom1Alarm,"'^TXT-17,0,0',ITOA(nPanel1AlarmMinute)" //Temp display
    }
    }
    }
    }

    TIMELINE_EVENT[lPanelRING_TIMEOUT1]


    {


    SEND_COMMAND dvTPBedRoom1Alarm,"'@SOU-doorbell6.wav'"


    }

    timeline_event[MinuteTimeline]
    {
    call 'Alarm Time'(sPanel1Alarm,nPanel1AlarmSet,nPanel1ShutterEvent,nPanel1LightsEvent,nPanel1CurtainsEvent,nPanel1AudioEvent,dvTPBedRoom1Alarm,nPanel1SnoozeSet)
    }
  • John PaulJohn Paul Posts: 143
    Hey no help needed, i modified the if condition to look for the time to hour and time to minute and stopped storing the time in a variable and viola it started working
Sign In or Register to comment.