Hello,
My configuration:
Ikea Tradfri Roller-Shutter with Ikea Tradfri Remote for Roller-Shutter.
Xiaomi Magnet.
They are connected to IKEA Gateway, connected through Tradfri Binding.
Wit the Remote, I am steering the Roller - it works without OH.
What I want to do is - to stop the Roller going down when the window is open:
rule "rolety-otvorene_okna"
when
Item RoletaZadna_Position changed
then
logInfo("rolety-otvorene_okna.rules", "Rule rolety-otvorene_okna.rules spustene")
if(MagnetOknoDetska_OpenStatus.state == OPEN) {
RoletaZadna_Position.sendCommand(UP)
}
end
It works, but the line Item RoletaZadna_Position changed needs to be defined better, as the roller is going a bit down, then up and when it is fully UP, i can hear 5-6 times the Roller clicking sound trying to go even more up.
2021-02-13 22:11:13.420 [INFO ] [el.script.rolety-otvorene_okna.rules] - Rule rolety-otvorene_okna.rules spustene
2021-02-13 22:11:13.438 [INFO ] [el.script.rolety-otvorene_okna.rules] - Rule rolety-otvorene_okna.rules spustene
2021-02-13 22:11:13.484 [INFO ] [el.script.rolety-otvorene_okna.rules] - Rule rolety-otvorene_okna.rules spustene
2021-02-13 22:11:13.505 [INFO ] [el.script.rolety-otvorene_okna.rules] - Rule rolety-otvorene_okna.rules spustene
2021-02-13 22:11:13.416 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'RoletaZadna_Position' changed from 0 to 9
2021-02-13 22:11:13.425 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'RoletaZadna_Position' received command UP
2021-02-13 22:11:13.429 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'RoletaZadna_Position' predicted to become UP
2021-02-13 22:11:13.433 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'RoletaZadna_Position' changed from 9 to 0
2021-02-13 22:11:13.443 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'RoletaZadna_Position' received command UP
2021-02-13 22:11:13.447 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'RoletaZadna_Position' predicted to become UP
2021-02-13 22:11:13.480 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'RoletaZadna_Position' changed from 0 to 4
2021-02-13 22:11:13.489 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'RoletaZadna_Position' received command UP
2021-02-13 22:11:13.492 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'RoletaZadna_Position' predicted to become UP
2021-02-13 22:11:13.499 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'RoletaZadna_Position' changed from 4 to 0
2021-02-13 22:11:13.510 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'RoletaZadna_Position' received command UP
2021-02-13 22:11:13.515 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'RoletaZadna_Position' predicted to become UP
My first idea was to add to Item RoletaZadna_Position changed from 0, but sometimes the roller starts from 1, or even 2,3? How can I define the range - from 0 to lets say 2? Can I do it through variable somehow? Definition <2 does not work
But the Roller will never received command UP, as it is steered with IKEA GW and the command is for OH invisible, I can catch it only through Item 'RoletaZadna_Position' changed from X to Y
Even the Roller remote is sending command DOWN (through Tradfri GW) in this case.
I would recommend only electrically enabling the motor when the reed switch shows window closed. However if you don’t want to rewire you blinds and disable it with openHAB like you have done.
So to answer your question you can use multiple expressions in your if statement.
Please use Implicit Variable
rule "rolety-otvorene_okna"
when
Item RoletaZadna_Position changed
then
logInfo("rolety-otvorene_okna.rules", "Rule rolety-otvorene_okna.rules spustene")
if(MagnetOknoDetska_OpenStatus.state == OPEN && receivedCommand == DOWN ) {
RoletaZadna_Position.sendCommand(UP)
}
end
OK, but I can’t see the remote action, or log about receivedCommand == DOWN in OH. It is going through IKEA Tradfri internally, as the Roller and Remote are connected to it.
I can see only the reaction - that the Roller has started to move:
2021-02-13 23:05:05.973 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'RoletaZadna_Position' changed from 0 to 1
2021-02-13 23:05:07.043 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'RoletaZadna_Position' changed from 1 to 6
2021-02-13 23:05:08.062 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'RoletaZadna_Position' changed from 6 to 11
Your solution will not work, only if I use ZigBee2MQTT instead of IKEA GW. And I am too weak-spirited to change connections to ZigBee2MQTT.
You can’t put that in the trigger, but you can make test in the rule body
if (MagnetOknoDetska_OpenStatus.state == OPEN && RoletaZadna_Position.state > 3) {
RoletaZadna_Position.sendCommand(UP)
Because you have position sensing on your roller Item, you might consider disabling autoupdate on the Item to reduce false readings when you do issue commands in openHAB.
Your solution has solved the case, if the roller will be already lower as position 3. - means roller is already behind the danger position of hitting the window.
However, the ticks when the position reaches back to 0 are still there:
2021-02-13 23:45:05.461 [INFO ] [el.script.rolety-otvorene_okna.rules] - Rule rolety-otvorene_okna.rules spustene
2021-02-13 23:45:05.482 [INFO ] [el.script.rolety-otvorene_okna.rules] - Rule rolety-otvorene_okna.rules spustene
2021-02-13 23:45:05.526 [INFO ] [el.script.rolety-otvorene_okna.rules] - Rule rolety-otvorene_okna.rules spustene
2021-02-13 23:45:05.548 [INFO ] [el.script.rolety-otvorene_okna.rules] - Rule rolety-otvorene_okna.rules spustene
==> /var/log/openhab/events.log <==
2021-02-13 23:45:05.457 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'RoletaZadna_Position' changed from 0 to 1
2021-02-13 23:45:05.469 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'RoletaZadna_Position' received command UP
2021-02-13 23:45:05.473 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'RoletaZadna_Position' predicted to become UP
2021-02-13 23:45:05.479 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'RoletaZadna_Position' changed from 1 to 0
2021-02-13 23:45:05.490 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'RoletaZadna_Position' received command UP
2021-02-13 23:45:05.496 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'RoletaZadna_Position' predicted to become UP
2021-02-13 23:45:05.523 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'RoletaZadna_Position' changed from 0 to 1
2021-02-13 23:45:05.533 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'RoletaZadna_Position' received command UP
2021-02-13 23:45:05.539 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'RoletaZadna_Position' predicted to become UP
2021-02-13 23:45:05.545 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'RoletaZadna_Position' changed from 1 to 0
2021-02-13 23:45:05.555 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'RoletaZadna_Position' received command UP
2021-02-13 23:45:05.560 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'RoletaZadna_Position' predicted to become UP
==> /var/log/openhab/openhab.log <==
2021-02-13 23:45:06.123 [INFO ] [el.script.rolety-otvorene_okna.rules] - Rule rolety-otvorene_okna.rules spustene
2021-02-13 23:45:06.144 [INFO ] [el.script.rolety-otvorene_okna.rules] - Rule rolety-otvorene_okna.rules spustene
2021-02-13 23:45:06.493 [INFO ] [el.script.rolety-otvorene_okna.rules] - Rule rolety-otvorene_okna.rules spustene
==> /var/log/openhab/events.log <==
2021-02-13 23:45:06.120 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'RoletaZadna_Position' changed from 0 to 1
2021-02-13 23:45:06.129 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'RoletaZadna_Position' received command UP
2021-02-13 23:45:06.133 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'RoletaZadna_Position' predicted to become UP
2021-02-13 23:45:06.137 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'RoletaZadna_Position' changed from 1 to 0
2021-02-13 23:45:06.152 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'RoletaZadna_Position' received command UP
2021-02-13 23:45:06.155 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'RoletaZadna_Position' predicted to become UP
2021-02-13 23:45:06.489 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'RoletaZadna_Position' changed from 0 to 6
==> /var/log/openhab/openhab.log <==
2021-02-13 23:45:07.510 [INFO ] [el.script.rolety-otvorene_okna.rules] - Rule rolety-otvorene_okna.rules spustene
==> /var/log/openhab/events.log <==
2021-02-13 23:45:07.507 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'RoletaZadna_Position' changed from 6 to 9
==> /var/log/openhab/openhab.log <==
2021-02-13 23:45:09.563 [INFO ] [el.script.rolety-otvorene_okna.rules] - Rule rolety-otvorene_okna.rules spustene
==> /var/log/openhab/events.log <==
2021-02-13 23:45:09.560 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'RoletaZadna_Position' changed from 9 to 0
2021-02-13 23:45:09.569 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'RoletaZadna_Position' received command UP
2021-02-13 23:45:09.574 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'RoletaZadna_Position' predicted to become UP
This could be something I am probably looking for: How can I disable temporarily the autoupdate on Item?
When left as default, openHAB’s autoupdate function attempts to predict the outcome of a command on the Item state. This prediction may be influenced by any linked channels. autoupdate="false" is a special instruction which keeps the current state of the Item, even if a command has been received. This way, the Item is unchanged unless you explicitly post an update to the Item, or a binding updates it. autoupdate="true" forces autoupdate to act, overriding any binding recommendations.
You are right! Too late night for my brain to work
My first though was to catch the movement - when number of position is increasing, but now I see it does not matter. Any movement definition is enough - if it is already at 0,1,2, its fully up, it can go only down.
So the ticks will be solved with disabled autoupdate?
So I leave it as it was on original, without adding && RoletaZadna_Position.state > 2, as it has no influence.
As in the beginning, the Roller is rolled DOWN cca 20cm, then stopped, and going back. When it is on 0, it is tickling few times.
So this is the rule for one roller. What if I want to do it for more of them, in one rule. Is this “gramatically” correct (tail is not throwing any errors)? Is there a place for improvement? I have now up to 5 of them.
rule "rolety-otvorene_okna"
when
Item RoletaZadna_Position changed or
Item RoletaTerasaPrava changed
then
logInfo("rolety-otvorene_okna.rules", "Rule rolety-otvorene_okna.rules spustene")
if(MagnetOknoDetska_OpenStatus.state == OPEN) {
RoletaZadna_Position.sendCommand(UP)
}
if(MagnetTerasaObyvacka_OpenStatus.state == OPEN) {
RoletaTerasaPrava_Position.sendCommand(UP)
}
end