0
Завершен

Change State when Value change

Vuong Xuan Phuc 8 лет назад обновлен Dmitry - support (expert) 8 лет назад 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!

Ответ

Ответ

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);
}
}
});
Ответ

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);
}
}
});
Завершен

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.

Сервис поддержки клиентов работает на платформе UserEcho