Jump to content

Random Message Generator


Recommended Posts

Hello , I am currently using a program that will send a message after 30 minutes that my shed is done heating up . Although the message is based on time is seems to work okay for the most part. I use the notify command after the wait 30 minutes command to accomplish this . I currently have only one message that sends out via a text message. I would like to make many messages that say the same thing but choose a different message each time I use the sauna to keep things interesting. Is it possible to accomplish this task and randomly choose which message goes out ? COuld I use a counter that would send a different message each time I use the sauna and increment a  counter  that chooses a different message to send? Thank you for your help anyone. WOuld appreciate any program examples to accomplish this. 

Link to comment

I use the notify command after the wait 30 minutes command to accomplish this . I currently have only one message that sends out via a text message. I would like to make many messages that say the same thing but choose a different message each time I use the sauna to keep things interesting. Is it possible to accomplish this task and randomly choose which message goes out ? Could I use a counter that would send a different message each time I use the sauna and increment a counter  that chooses a different message to send?

I can't think of a simple and elegant way to accomplish this with just the ISY994.

 

Best option I can come up with would be to have a folder with a whole bunch of "Sauna is ready" programs, and have each one disable itself and then enable the next program, sort of like this:

 

===================================================================================
Sauna is ready Folder - [ID 00FE][Parent 0001]

-----------------------------------------------------------------------------------
Message 1 - [ID 00FF][Parent 00FE]

If
        Time is Last Run Time for 'Warm up Sauna' + 30 minutes
 
Then
        Send Notification to 'Phone' content "First Message"
        Disable Program 'Message 1'
        Enable Program 'Message 2'
 
-----------------------------------------------------------------------------------
Message 2 - [ID 0100][Parent 00FE]

If
        Time is Last Run Time for 'Warm up Sauna' + 30 minutes
 
Then
        Send Notification to 'Phone' content "Second Message"
        Disable Program 'Message 2'
        Enable Program 'Message 3'
 
-----------------------------------------------------------------------------------
Message 3 - [ID 0101][Parent 00FE]

If
        Time is Last Run Time for 'Warm up Sauna' + 30 minutes
 
Then
        Send Notification to 'Phone' content "Third Message"
        Disable Program 'Message 3'
        Enable Program 'Message 1'
 

 

 

Alternately you could have each program check the value of a variable named "$Sauna_is_Ready" to decide which one gets to run, like this (You would have the program 'Warm up Sauna' increment the variable by 1 each time it runs.

 

 

===================================================================================
Sauna is ready Folder - [ID 00FE][Parent 0001]

-----------------------------------------------------------------------------------
Message 1 - [ID 00FF][Parent 00FE]

If
        Time is Last Run Time for 'Warm up Sauna' + 30 minutes
    and $Sauna_is_Ready is 1
 
Then
        Send Notification to 'Phone' content "First Message"
 
-----------------------------------------------------------------------------------
Message 2 - [ID 0100][Parent 00FE]

If
        Time is Last Run Time for 'Warm up Sauna' + 30 minutes
    and $Sauna_is_Ready is 2
 
Then
        Send Notification to 'Phone' content "Second Message"
 
-----------------------------------------------------------------------------------
Message 3 - [ID 0101][Parent 00FE]

If
        Time is Last Run Time for 'Warm up Sauna' + 30 minutes
    and $Sauna_is_Ready is 3
 
Then
        Send Notification to 'Phone' content "Third Message"
 

-----------------------------------------------------------------------------------
Reset Sauna Variable - [ID 0102][Parent 00FE]

If  $Sauna_is_Ready is > 3
 
Then
        $Sauna_is_Ready = 0
Link to comment

Disclaimer:  I have not set up and tested this solution, but it should work (I have done something similar using random).

 

1 - set up the spa notifications messages you want to use, you will need separate notification for each message. name them something like "spa_message_1", etc.  For our example let pretned you created 10 of them, spa_message_1 through spa_message_10

2 - Create a STATE variable called something like "Spa_Notification", leave it set to zero (and init zero)

3 - Now create a Spa Notification program folder.  In this folder make a program for EACH notification you created in step 1, (i.e. if you have 10 possible messages you will need 10 programs)

 

Each program should follow the same logic, changing only 2 things:


New Program - [ID 0073][Parent 0001]

If
        $Spa_Notification is 1
 
Then
        Send Notification to 'test1' content 'spa_message_1'
        $Spa_Notification  = 0
 
Else
   - No Actions - (To add one, press 'Action')

in the next program, change the IF to "$Spa_Notification is 2" and the 'content'  of the notification to the next spa message 'spa_message_2'

in the next program, change the IF to "$Spa_Notification is 3" and the 'content'  of the notification to the next spa message 'spa_message_3'

....and so on... until you have a program for each message up though

the last program, change the IF to "$Spa_Notification is 10" and the 'content'  of the notification to the next spa message 'spa_message_10'

 

and finally in,

 

Step 4:  In whatever program would normally turn the spa on and send your notification, use the following in then or else to send the notification:

 

$Spa_Notification  = Random 10

 

which will generate a random number 1 thru 10 that will then trigger a program that send the message.

 

---

 

Program logic:

 

State Variable "Spa_Notification" changes from zero to a non-zero value from the random number generator,

which causes one message specific program (of a series of programs) to run,

the last statement of the message specific program returns the variable to zero (a pseudo "wait state" since zero doesn't exist as a message).

 

CAVEAT:

 

Be careful to set the Random value in step 4, to the correct max value.  A value to high will cause the notification program to miss sending when random tries to send a notification the doesn't exist.  A value to low will cause some notifications to never be used. 

Link to comment

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...