Weird behaviour on a virtual switch

I have a virtual switch to controll my Xioami vacuum via Alexa
.Items:

String actionControl  "Steuern"   <vacuum>  (gVac)    {channel="miio:vacuum:0705301C:actions#control" } 

.rules:

val String filename = "Roborock.rules"

rule "Roborock alexa"
when 
Item VacAlexa received command
then 
switch VacAlexa.state.toString{
case "ON":{
actionControl.sendCommand("vacuum")
logInfo(filename,"Staubsauger wurde eingeschalten")
}
case "OFF":{
actionControl.sendCommand("dock")
logInfo(filename,"Staubsauger wurde ausgeschalten")
}
}
end

logs:

2019-01-07 15:53:08.204 [ome.event.ItemCommandEvent] - Item 'VacAlexa' received command ON

2019-01-07 15:53:08.233 [nt.ItemStatePredictedEvent] - VacAlexa predicted to become NULL

rules not getting fired, where does the ā€˜Predictionā€™ in the logs come from?

@kai wrote about this a while back ā€“ canā€™t lay hands on the reference at the moment. Essentially, the result of a new ā€œfeatureā€ in core OH. Causes grief specifically to me also specifically because rules donā€™t fire. The hack around it is to use the phrase

... , autoupdate="false" ....}

in the channel descriptor for the real item. Adding that to the real item seems to make derived-virtual-item targetted rules fire as expected.

1 Like

Tidy up a bit:

val String filename = "Roborock.rules"

rule "Roborock alexa"
when 
    Item VacAlexa received command
then 
    switch receivedCommand {
        case ON:{
            actionControl.sendCommand("vacuum")
            logInfo(filename,"Staubsauger wurde eingeschalten")
        }
        case OFF:{
            actionControl.sendCommand("dock")
            logInfo(filename,"Staubsauger wurde ausgeschalten")
        }
    }
end