0
Completed

Change State when Value change

Vuong Xuan Phuc 8 years ago updated by Dmitry - support (expert) 7 years ago 2

Hello!

I get a temp off room. It can from 18-32oC. I want the state off room will change to state color Blue when Temp <20oC. Orange if Temp<25 and red if Temp>25.

Can you help me. Please!

Answer

Answer

Use iRidium script to set the state


One way to do this is to create a feedback in Studio to store the colour state in, in this case it is Temp Colour
Then put a multi-state button over the text showing degrees, with colour blue for state 1, colour orange state 2 and colour red state 3


Add something like this script

//put in your driver name where it says "DriverName"
IR.AddListener(IR.EVENT_TAG_CHANGE,IR.GetDevice("DriverName"),function(name, value)
{
//the name of the temperature feedback in this example is "Temp"
if (name == "Temp") {
//value is the current value of the Temp feedback
if (parseInt(value) < 20) {
IR.SetVariable("DriverName.Temp Colour", 0);
} else if ((parseInt(value) >= 20) & (parseInt(value) < 25)){
IR.SetVariable("DriverName.Temp Colour", 1);
} else {
IR.SetVariable("DriverName.Temp Colour", 2);
}
}
});
Answer

Use iRidium script to set the state


One way to do this is to create a feedback in Studio to store the colour state in, in this case it is Temp Colour
Then put a multi-state button over the text showing degrees, with colour blue for state 1, colour orange state 2 and colour red state 3


Add something like this script

//put in your driver name where it says "DriverName"
IR.AddListener(IR.EVENT_TAG_CHANGE,IR.GetDevice("DriverName"),function(name, value)
{
//the name of the temperature feedback in this example is "Temp"
if (name == "Temp") {
//value is the current value of the Temp feedback
if (parseInt(value) < 20) {
IR.SetVariable("DriverName.Temp Colour", 0);
} else if ((parseInt(value) >= 20) & (parseInt(value) < 25)){
IR.SetVariable("DriverName.Temp Colour", 1);
} else {
IR.SetVariable("DriverName.Temp Colour", 2);
}
}
});
Completed

Yes, that's right. But to display different States of the element it is better to use a Multistate level. Because Multistate button will constantly toggle the States. Ie this element is more suitable for animations in the likeness GIF.