variables
Returns a list of the defined global variables and their current values.
Example (GET): curl -o - 'http://host-ip:8111/api/v1/variables'
[{
"name": "alpha",
"expr": "time()",
"index": 1,
"serial": 357,
"mdt": 1634912369613,
"value": 1635981908351,
"since": 1635981908351
}, {
"name": "timeStamp",
"expr": "t=dateparts(time()),str(t.year)+\"-\"+str(t.month)+\"-\"+str(t.day)",
"index": 5,
"mdt": 1634912360804,
"serial": 223,
"value": "2021-11-3",
"since": 1635940828855
},{
"name": "attic_dewpoint",
"expr": "((( entity( \"hubitat>76\" ).attributes.temperature_sensor.value - 32 ) / 1.8 ) - ((100 - entity( \"hubitat>76\" ).attributes.humidity_sensor.value )/5.0)) * 1.8 + 32",
"index": 17,
"mdt": 1634912360806,
"serial": 51,
"value": 47.480000000000004,
"since": 1636053296940
},{
"name": "testVar",
"expr": "",
"index": 13,
"mdt": 1634912360804,
"serial": 274,
"value": null
"since": 1638334834698
}]
variable/:name
Returns the value of the named global variable.
Example: (GET) curl -o - 'http://host-ip:8111/api/v1/variable/attic_dewpoint'
{
"name": "attic_dewpoint",
"expr": "((( entity( \"hubitat>76\" ).attributes.temperature_sensor.value - 32 ) / 1.8 ) - ((100 - entity( \"hubitat>76\" ).attributes.humidity_sensor.value )/5.0)) * 1.8 + 32",
"index": 17,
"mdt": 1634912360806,
"serial": 51,
"value": 47.480000000000004,
"since": 1636053296940
}
variable/:name/set
Sets the value of the named global variable. The variable named must be expressionless; that is, its expression must be empty. It is not possible to set the value of expression-driven variables, and attempting to do so will result in an error.
Example: (GET) curl -o - 'http://host-ip:8111/api/v1/variable/testVar/set?value=123'
Example: (PUT) curl -o - -X PUT -H 'content-type: application/json' -d '123' 'http://host-ip:8111/api/v1/variable/testVar/set'
In both cases, a successful assignment of the value returns the same JSON response as variable/:name
(query) with the updated value. A 400 error is returned if the named variable is not expressionless. A 404 error is returned if the global variable is not defined (you cannot create a variable using this API).
Note that setting a value on a global variable may cause re-evaluation of dependent rules.