I have three downlights (Xiaomi Philips ZhiRui) whose brightness is controlled by a slider in HABpanel.
The problem is that sometimes brightness isn’t change although slider was moved. Only helps shifting slider a little, like send similar value once again.
In logs I see that command was sent, devices predict to become new value, but not changed finally.
Log of successful action:
Item 'phil_1_3_brigtness' received command 57
phil_1_3_brigtness changed from 100 to 57
Item 'phil1_brightness' received command 57
Item 'phil2_brightness' received command 57
Item 'phil3_brightness' received command 57
phil1_brightness predicted to become 57
phil2_brightness predicted to become 57
phil3_brightness predicted to become 57
phil1_brightness changed from 74 to 57
phil2_brightness changed from 74 to 57
phil3_brightness changed from 74 to 57
Log of unsuccessful action:
Item 'phil_1_3_brigtness' received command 32
phil_1_3_brigtness changed from 12 to 32
Item 'phil1_brightness' received command 32
Item 'phil2_brightness' received command 32
Item 'phil3_brightness' received command 32
phil1_brightness predicted to become 32
phil2_brightness predicted to become 32
phil3_brightness predicted to become 32
Items part:
Number phil1_brightness "Brightness" (G_light) {channel="miio:generic:057F51E5:brightness"}
Number phil2_brightness "Brightness" (G_light) {channel="miio:generic:0578B9D8:brightness"}
Number phil3_brightness "Brightness" (G_light) {channel="miio:generic:057F3CCD:brightness"}
Number phil_1_3_brigtness
Slider changes “phil_1_3_brigtness” item.
Rules part:
rule "brigtness Phil_1_3"
when
Item phil_1_3_brigtness received command
then
var Number p1_3_b = phil_1_3_brigtness.state as Number
sendCommand(phil1_brightness,p1_3_b)
sendCommand(phil2_brightness,p1_3_b)
sendCommand(phil3_brightness,p1_3_b)
end
It isn’t depends from speed of sending commands. It could be in state for 40 minutes, after I shift the slider for the new position - no response, immediately shift a little and get the result.
Seems I found the decision, at least it works for few last shiftings. Let see how it behaviors for a couple day.
Have changed rule as below:
rule "brigtness Phil_1_3"
when
Item phil_1_3_brigtness received command
then
sendCommand(phil1_brightness,receivedCommand)
sendCommand(phil2_brightness,receivedCommand)
sendCommand(phil3_brightness,receivedCommand)
end
i had similar problems since updated to oh2.5: i found out for rules that trigger a item with “received command” i have to use “recievedCommand” in the “then”-section. if i use “itemxx.state” it often does not work correct - semms the “state” takes a little longer to be updated and because of that the value is not set when the rule triggers. so i checked that all my rules with “recieved command” in “when”-section i now use “recievedCommand” in “then”-section. (rules with “changed” in the “when”-seciton work ok with “.state” in “then”-section.
This is indeed a timing issue as @bastler said.
Other way to accomplish this is to use
“ Item phil_1_3_brigtness changed” instead of “receive command”
This will trigger the rule after the item has processed the command