This is autoupdate feature at work.
Autoupdate listens for commands sent to Items, and predicts what the effect will be on the Item state.
Why? For a quick response - some devices may give a prompt status update back to openHAB, some may be slow, some may never give one, some Items are not bound to any real device.
So - 2019-03-19 22:33:14.495 [ome.event.ItemCommandEvent] - Item ‘DimmerCam’ received command 37
Here’s your command.
2019-03-19 22:33:14.508 [nt.ItemStatePredictedEvent] - DimmerCam predicted to become 37
Here’s autoupdate’s prediction, or guess, at the outcome.
2019-03-19 22:33:14.531 [vent.ItemStateChangedEvent] - DimmerCam changed from UNDEF to 37
Here’s your Item actually getting updated by autoupdate
2019-03-19 22:33:14.543 [vent.ItemStateChangedEvent] - DimmerCam changed from 37 to UNDEF
What’s this then? This has come from the device binding, the real state of the device.
But the binding to your Item is in error so you get the UNDEF.
You can disable autoupdate for your Item, which will stop the guesswork part.
But of course the real problem is that your MQTT setup is not updating your Item properly.
Maybe the problem is on the channel.
I set the Dimmer “DimmerCam” but the field of the state and command in openhab are blank.
This because i want to use the dimner only to determine the time that the rule wait for turn off the switch.
I’m not expect e response from the sonoff
I think this is correct.
Don’t you think that?
If i erase the variable x and i put a number as argument of the command TIMER it works correctly
So, this is just a value to be used for timing?
Why have you made it a Dimmer Item, a Number would be more sensible surely.
If you only want to use the value in a rule why have linked it to MQTT?
That’s right. So i should unlink from the Mqtt broker.
This evening i will try and i hope to resolve.
I continue to use the dimmer only to set a % of opening of the blind
i unlink the dimmer from mqtt.
the DimmerCam is now defined as a number that i use in the rule:
rule "apertura"
when
Item LivingRoom_Light1 changed to ON
then
var x = (DimmerCam.state as Number * 0.24)
createTimer(now.plusSeconds(x)) [|
LivingRoom_Light1.sendCommand(OFF)
]
end
and this is the log
2019-03-20 18:52:35.706 [ome.event.ItemCommandEvent] - Item ‘DimmerCam’ received command 24
2019-03-20 18:52:50.914 [ome.event.ItemCommandEvent] - Item ‘LivingRoom_Light1’ received command ON
2019-03-20 18:52:51.081 [vent.ItemStateChangedEvent] - LivingRoom_Light1 changed from OFF to ON
==> /var/log/openhab2/openhab.log <==
2019-03-20 18:52:51.108 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘apertura’: Could not cast NULL to java.lang.Number; line 11, column 11, length 25
// global vars are defined at the begin of the file
var Timer tApertura = null
rule "apertura"
when
Item LivingRoom_Light1 changed to ON
then
var Number x = 0
if(DimmerCam.state instanceof Number)
x = ((DimmerCam.state as Number) * 0.24).intValue
tApertura?.cancel
tApertura = createTimer(now.plusSeconds(x)) [|
LivingRoom_Light1.sendCommand(OFF)
]
end