If Value is less than variable

Posted on
Thu Jun 11, 2020 2:08 pm
petematheson offline
Posts: 847
Joined: Sep 14, 2014
Location: Southampton, UK

If Value is less than variable

I'm trying to do something fairly simple.

If the current cost of electricity (using the Octopus Energy Plugin) is less than a variable I set (say, less than 4p) then do action...

Is there a way to achieve this at all?

Reason being, I want to be able to change the variable value each day depending on what the cost of electricity will be tomorrow, without having to fire up the full client on my mac.

Posted on
Thu Jun 11, 2020 2:45 pm
neilk offline
Posts: 715
Joined: Jul 13, 2015
Location: Reading, UK

Re: If Value is less than variable

Pete.

I haven't had a chance to test this properly, but think this is close.

First setup a trigger on the Tariff device for "Current Electricity Rate" for "Has any Change"

Then in the condition try the python below

Code: Select all
variable_threshold = float(indigo.variables[34475465].value) # use ID of your Indigo variable
tariff_device = indigo.devices[84950009]  # use ID of your Indigo device
return indigo.devices[tariff_device].states['Current_Electricity_Rate'] < variable_threshold # not sure if you want to use <, <=, >, or >= here.


I need to wait 30 minutes for the rate to change to test it, but is should be close.

I am also interested in what manual logic you are using to set the variable value. I am contemplating some functionality that determines the optimum period to run an action (Say you want to run a Tumble dryer and it will take 3 hours) which is the best time to run it on a given day. No idea how to approach this yet, but the latest pre-release version publishes device states for all upcoming rates so it opens the door to this kind of logic.

Neil

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests