Cool, no issues so far with over 9000 characters.
For reference, this would be the JS side - not sure if it already works with authentication:
https://github.com/inorganik/digest-auth-requestUntested code
- Code: Select all
function updateIndigo() {
var url = 'URL/variables/test.json';
var getRequest = new digestAuthRequest('GET', url, USER, PWD);
getRequest.request(function(data) {
// success callback
var obj=data;
},function(errorCode) {
// error callback
});
//var obj = JSON.parse( '{ "value": "John:1;Mike:2" }' );
valueArray=obj.value;
valueArray = valueArray.split(";");
lengthArray = valueArray.length;
var jsonText = {};
for (var i = 0; i < lengthArray; i++) {
variableArray = valueArray[i].split(":");
setName = variableArray[0];
setValue = variableArray[1];
jsonText[setName] = setValue;
}
alert(jsonText["John"]);
}
Now I need to tackle the Python side. Is it ok to write status every second in the variable or do you suggest to do it on demand? Would you use Schedule or just have one python script running forever?
I think it is more efficient to do it every second, since the variables might change more often than this. Hence a group trigger would trigger this too often.
The goal is to get this string:
LightKitchen:true;TemperatureKitchen:22.1;LightBasement:50
Something like this might be a start for variables:
- Code: Select all
bigVariable = ""
#Variables
id = [794830341, 794830341]
lengthArray = len(id)
for x in range(0, lengthArray):
value = indigo.variables[id[x]].value
name = indigo.variables[id[x]].name
bigVariable = bigVariable + name + ':' + value +';'
#Switches
id = [794830341, 794830341]
lengthArray = len(id)
for x in range(0, lengthArray):
value = indigo.variables[id[x]].value
name = indigo.variables[id[x]].name
bigVariable = bigVariable + name + ':' + value +';'
#Brightness devices
id = [794830341, 794830341]
lengthArray = len(id)
for x in range(0, lengthArray):
value = indigo.variables[id[x]].value
name = indigo.variables[id[x]].name
bigVariable = bigVariable + name + ':' + value +';'
indigo.variable.updateValue(1603257068, bigVariable)
indigo.server.log(bigVariable)
The name ist the name of variable or the device. The value is either value or brightness, ...
How can I get all the ids for a specific device or variable?