Value from system variable

Posted on
Fri Dec 14, 2018 2:58 pm
farberm offline
Posts: 393
Joined: Feb 24, 2008

Value from system variable

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.

Posted on
Fri Dec 14, 2018 4:56 pm
DaveL17 offline
User avatar
Posts: 6743
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Value from system variable

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.
Last edited by DaveL17 on Sat Dec 15, 2018 3:42 pm, edited 1 time in total.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sat Dec 15, 2018 11:12 am
farberm offline
Posts: 393
Joined: Feb 24, 2008

Re: Value from system variable

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)
Attachments
Screen Shot 2018-12-15 at 12.09.25 PM.png
Screen Shot 2018-12-15 at 12.09.25 PM.png (251.24 KiB) Viewed 3794 times

Posted on
Sat Dec 15, 2018 11:21 am
DaveL17 offline
User avatar
Posts: 6743
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Value from system variable

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))

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sat Dec 15, 2018 1:09 pm
farberm offline
Posts: 393
Joined: Feb 24, 2008

Re: Value from system variable

Great now working fine

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest