Hi everyone,
I’m using visual studio code to edit all openhab related files. It work perfectly but I ran into a small issue. The syntax validation of visual studio code gives the warning “Duplicate local variable previousState” on the first line of that rule:
rule "Dim lights for TV"
when
Thing 'samsungtv:tv:0ee6b281_00fa_1000_9021_5cf6dcd66f98' changed from OFFLINE to ONLINE or // TV switch on
Item Lamps_Salon_Toggle changed from OFF to ON or // Lights of salon software switch on
Thing "hue:0210:001788278066:14" changed from OFFLINE to ONLINE or // Lihgts of salon hardware switch on
Thing "hue:0210:001788278066:8" changed from OFFLINE to ONLINE or
Thing "hue:0210:001788278066:12" changed from OFFLINE to ONLINE
then
var sts1 = ThingAction.getThingStatusInfo("hue:0210:001788278066:14").getStatus();
var sts2 = ThingAction.getThingStatusInfo("hue:0210:001788278066:8").getStatus();
var sts3 = ThingAction.getThingStatusInfo("hue:0210:001788278066:12").getStatus();
var tv = ThingAction.getThingStatusInfo("samsungtv:tv:0ee6b281_00fa_1000_9021_5cf6dcd66f98").getStatus();
if (sts1.toString() == 'ONLINE' &&
sts2.toString() == 'ONLINE' &&
sts3.toString() == 'ONLINE' &&
Lamps_Salon_Toggle.state == ON &&
tv.toString == "ONLINE"
) {
sendCommand(Lamps_Salon_Dimmer, 10)
}
end
The rule is working perfectly.
I saw that previousState is a variable defined automatically in rules with at least one status change event trigger. This is my case I have 5 of them.
Doing some tests I noticed that I have this warning when I mix Things and Items in the when clause. If I have only items or only things I don’t have the warning.
How can I get rid of that warning when using things and items in rules?
Thanks