Page 1 of 1

Value from system variable

PostPosted: Fri Dec 14, 2018 2:58 pm
by farberm
I need to assign to a variable AirTemperature the value from a system deivice defined by the Pentair Plugin

-Air Temperature: The previous version of the plugin reported the system's air temperature to a variable. As air temperature is now a state of the 'System' device, the variable will no longer be updated.

The python script should be something like this but I am not sure:

AirTemperature = state (indigo.device (deviceID))

I know what the system device ID is that contains the value of the air temperature. Just do not know the syntax for the python script.

Re: Value from system variable

PostPosted: Fri Dec 14, 2018 4:56 pm
by DaveL17
Should be something like:
Code: Select all
device_value = indigo.devices[DEVICE ID HERE].states['DEVICE STATE NAME HERE']
indigo.variable.updateValue('AirTemperature', str(device_value))

Replace DEVICE ID HERE with the ID number of the Indigo device you're getting the value from (not in quotes).
Replace 'DEVICE STATE NAME HERE' with the exact name of the device state where the value is from (in quotes).

Strongly encouraged:
Replace the variable name 'AirTemperature' (in quotes) with the variable's ID number (not in quotes). Using a variable ID number will keep your script from breaking if you ever decide to rename the variable later on. The variable name will work (in quotes) but the ID is the preferred approach.

EDIT: adds string conversion to updateValue() statement.

Re: Value from system variable

PostPosted: Sat Dec 15, 2018 11:12 am
by farberm
Ok almost have this correct. Seems like one error

Pool Controller ID 1867668806
PentairAirTemperature variable ID 558303937

Python Script is as follows:

device_value = indigo.devices[1867668806].states['airtemp']
indigo.variable.updateValue(558303937, device_value)

Device State name I think is airtime (see image below)


I still get the following error

Script Error embedded script: Python argument types in
VariableCmds.updateValue(VariableCmds, int, int)
did not match C++ signature:
updateValue(_VariableCmds {lvalue}, boost::python::api::object elem, CCString value)
Script Error Exception Traceback (most recent call shown last):

embedded script, line 2, at top level
ArgumentError: Python argument types in
VariableCmds.updateValue(VariableCmds, int, int)
did not match C++ signature:
updateValue(_VariableCmds {lvalue}, boost::python::api::object elem, CCString value)

Re: Value from system variable

PostPosted: Sat Dec 15, 2018 11:21 am
by DaveL17
Apologies. Indigo stores its values as strings, so you need to convert it:

Code: Select all
device_value = indigo.devices[DEVICE ID HERE].states['DEVICE STATE NAME HERE']
indigo.variable.updateValue('AirTemperature', str(device_value))

Re: Value from system variable

PostPosted: Sat Dec 15, 2018 1:09 pm
by farberm
Great now working fine