Using Python to add heating variables into Variable List

Posted on
Mon Nov 20, 2017 4:09 pm
CliveS offline
Posts: 761
Joined: Jan 10, 2016
Location: Medomsley, County Durham, UK

Using Python to add heating variables into Variable List

I have an action to put my Evohome Radiator Setpoint and Actual (live) readings into the Variable List, works fine but I would like to do the same via a Python embedded script.

The Action is

Insert state (temperatureinputsall) for device ‘ev.zone: bathroom’ into variable: bathroom_temperature_live
Insert state (setpointheat) for device ‘ev zone: bathroom’ into variable: bathroom_temperature_setpoint

But I cannot get my head around the Python coding have tried everything I can think of without success.

CliveS

Indigo 2023.2.0 : macOS Ventura 13.6.3 : Mac Mini M2 : 8‑core CPU and 10‑core GPU : 8 GB : 256GB SSD
----------------------------------------------------------------------------------
The best way to get the right answer on the Internet is not to ask a question, it's to post the wrong answer

Posted on
Mon Nov 20, 2017 4:53 pm
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Using Python to add heating variables into Variable List

Hi Clive - we'll get you going. Here's a sample to update a variable value:

Code: Select all
dev = indigo.devices[1149686816]
var = indigo.variables[1961258112]

value = dev.states["windSpeed"]

indigo.variable.updateValue(var, str(value))

Obviously, you'll need to update the device and variable lines with the Indigo IDs of your source and target, and change the device state to match your use case. It's a little tough to know where you stumbled; if I had to guess, I'd bet it's because you didn't convert the state values into a string before trying to save the value to the variable. In Indigo, every variable value is a string and trying to save anything else to a variable will result in an error.

But if I might ask, why do you need to put a state value into a variable? Why not work with the state directly?

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

[My Plugins] - [My Forums]

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests