User Tools

Site Tools


Sidebar

dictionary:unitinformation:setvalueof

Set Value Of

Set the value of a unit as a counter.

Usage:

set value of (name of pseudo unit)

Optional Parameters:

  • to (number or string, any real number. 10, 4.5, 0.567, -5.23, or an enumerated string value “heat”, “cool”, “off”: see below)
  • by (number, any real number to add to existing value. 5, -45, 3.1415, -9.3)
  • with no script (stops the executing of the script)
  • in (integer, seconds, ie: 30, 30 * minutes, 2 * hours, 7 * days) creates a scheduled event to perform the set value in this amount of time
  • for (integer, seconds, ie: 30, 30 * minutes, 2 * hours, 7 * days) creates a scheduled event to return the unit to it’s current value after this amount of time. If the in parameter is specified then this event will be after that interval.
  • at (date) Like the in parameter, creates a Scheduled Event to set the value at the specified AppleScript date.
  • until (date) Like the for parameter, creates a Scheduled Event to return the value to the current value at the specified AppleScript date.
  • timestamp (date) Instead of updating the timestamp of the unit to the current date it will set it to the timestamp passed here. If you are receiving data from some external source that includes a timestamp that might not be right now use this to override that and display the correct time. You can also use this to preserve timestamps when rolling today/yesterday type pseudos. See example below. Keep in mind that for data stored in XTdb new records must always be after previous records. It will honor the timestamp unless that would put the new record before a previous record in which case it will ignore it.

Examples:

--increment a counter
set value of "Inside Motion Count" by 1
 
set value of “overhead light” to 50 in 10 * minutes for 30 * minutes
 
-- and an example preserving the timestamp 
 
set value of “yesterdays low temp” to (value of “todays low temp”) timestamp (timestamp of “todays low temp”)

Some units do not have values that are easily converted to numbers, the Mode setting of a Thermostat for example. If it would make more sense to use a string to describe the value you can do that using an enumerated string. The enumerations come from the “comma separated list for popup” field on the Display tab of the Edit Unit Dialog The control type does not need to be set to popup but the values must be in that field. For this example the field would contain the string “Off,Heat,Cool,EM Heat” Previous to the ability to pass strings to the set value verb you would have had to remember that to set the mode to cool you would set the value of the unit to 2. You can now pass the string “cool” to the set value verb like this:

--examples using enumerated strings
 
set value of “Thermostat Mode” to “cool”
 
-- or
 
set value of “Thermostate Mode” to “off”

The comparisons are not case sensitive. If the string is not found in the list then the value of the unit will not be set and an error will be returned.

Notes:

Setting the value to 0 will execute the OFF script, if any. Setting the value to a non-zero value will run the ON script if any.

You can use this verb instead of the dim/bright commands. This verb does not limit the value to a maximum of 100% as the dim/bright commands do.

History:

  • The ability to pass an enumerated string to the set value verb was added in XTension version 9.4.36.
dictionary/unitinformation/setvalueof.txt · Last modified: 2021/02/02 14:27 by James Sentman