Jump to content

Variable string substitution function for notifications


larryllix

Recommended Posts

Posted

With regards to this thread

 

http://forum.universal-devices.com/topic/16744-if-statements-in-notifications/

 

I am requesting a function that could be used in notifications. Possibly fairly easy to implement after v5 gets released and some debugging 'rounds.

 

This would be a function that can substitute inline text strings for variable integer values.

The best way I can think to relay this method is by examples.

 

 

 

The lamp is $Substitute( ${var.1.23}, "Off", "On", "Dimmed", "Unknown state" )

 

Var1.23    Text substitution 

  0             "Off"

  1             "On"

  2             "Dimmed"

  3-999...   "Unknown state"

 

 

The number of parameters tacked into the function could be a variable quantity terminated by the closing parenthesis  so that long lists of string substitutions could be handled.

 

Most cases would only need only one or two parameters. Eg: On/Off, Yes/No, True/False, Running/Stopped,

 

eg.

Just unlocked door with combo is  $Substitute( {var.2.23}, "unknown",  "Sarah", "Sam", "Joe", "Peter", "Mom", "Dad", " ")

 

 

The current weather is $Substitute( {var.2.34}, "Hail"," Blowing dust", "Blowing sand", "Mist", "Blowing snow", " Fog", "Frost","Haze", "Ice Crystals", "Ice fog", "Ice pellets / sleet", "Smoke", "Drizzle", "Rain", "Rain showers",......)

Posted

Of course the function name could be changed to protect the innocent. :)

 

Negative values are not handled in the syntax, either. May need to just forget them to keep it simple.

Posted

Hi larryllix,

 

Good point. Negative numbers may cause a crash. The other issue is that these values might not be linear. So, for instance, INSTEON levels are incremented by 2 or 3 (I forget now) and not 1.

 

In short, still need to do more investigation to see the impact.

 

With kind regards,

Michel

Posted

Hi larryllix,

 

Good point. Negative numbers may cause a crash. The other issue is that these values might not be linear. So, for instance, INSTEON levels are incremented by 2 or 3 (I forget now) and not 1.

 

In short, still need to do more investigation to see the impact.

 

With kind regards,

Michel

My first idea (spurred by the linked thread post in #1) was just for the use of  On/Off text and then True/false followed with Yes/No etc.. This would take many functions to do this or type cast variables (whoa!) making a massive task to implement.

 

The list following the variable should allow ISY to parse a variable quantity of parameters easily. Some stops need to be in place for syntax errors in the text like no end parenthesis and ISY parses forever. A possible parsing error could be to limit the list to 15 items or so.

 

States of analogue devices and random groupings of states by value would have to be converted to a limited variable (0-15) value.

eg. -30 to -10 degrees = 0 = "cold", -10 to +5 degrees = 1 = "cool",  +5 to +15 = 2  = "mild", etc..

 

I was trying to think of a way to put a cases structure to it something like this.

 

$Substitute( ${var.1.23}, -9999-0= "Cold", 1-10= "Cool", 11-18= "Mild", 19- = "Hot") but then ISY becomes an interpretive parsing engine job and  what happens with logical syntax errors 11-18 ="xx" and 17-23 ="yy" ?  (overlap in values)

The plot thickens too much, maybe. I wouldn't want to code the parsing engine. :)

 

....so the request went in as just recognising the first say up to the 15 positive integer values and simple substitution. Maybe the first string substitution could cover the negative values just for flag and error detection.

 

The current state is $Substitute( ${var.1.23}, "Error!", "None", "Positive")

so that the first, second, third,....last parameter strings would represent 'negative values',  0,  1,  2, .... , not defined values.

 

Just some thoughts.

Posted

Hi guys,

 

I really like this idea!  Even in the form first proposed. I have plenty of places in my system where I could/would make use of this.  Between the 5.0 feature set and this, I could easily reduce the number of network resources I have by 50%

 

Just my .02

 

-Xathros

Archived

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

×
×
  • Create New...