I am trying to be able to dim smoothly my Yeelight LED Ceiling Lamp (JIAOYUE 650) via an HM-RC-2-PBU-FM (Wireless Transmitter 2-channel for brand switch systems)
This is how my rule looks like right now:
rule "Schlafzimmer Schalter"
when
Channel 'homematic:HM-RC-2-PBU-FM:OEQ0609246:OEQ1232671:1#PRESS' triggered CONT
then
if(YeelightLEDCeilingLampV4JIAOYUE650RGB_Brightness.state>0)
{
bright = YeelightLEDCeilingLampV4JIAOYUE650RGB_Brightness.state
bright-1
YeelightLEDCeilingLampV4JIAOYUE650RGB_Brightness.sendCommand(bright)
}
end
but i get the following error in the logs, but I do not understand why it gets the value null.
Because when I add logging the state of the brightness it shows the correct value:
Thanks a lot for the answer! I just tried it and it sends the commands but the brightness does not change. Any idea why that could be ?
val Number bright
rule "Schlafzimmer Dimming"
when
Channel 'homematic:HM-RC-2-PBU-FM:OEQ0609246:OEQ1232671:1#PRESS' triggered CONT
then
if(YeelightLEDCeilingLampV4JIAOYUE650RGB_Brightness.state as Number >0)
{
bright = YeelightLEDCeilingLampV4JIAOYUE650RGB_Brightness.state as Number
bright = bright - 1
YeelightLEDCeilingLampV4JIAOYUE650RGB_Brightness.sendCommand(bright)
}
end
Log:
2018-03-01 17:08:08.560 [vent.ChannelTriggeredEvent] - homematic:HM-RC-2-PBU-FM:OEQ0609246:OEQ1232671:1#PRESS triggered LONG
2018-03-01 17:08:08.830 [vent.ChannelTriggeredEvent] - homematic:HM-RC-2-PBU-FM:OEQ0609246:OEQ1232671:1#PRESS triggered CONT
2018-03-01 17:08:08.841 [ome.event.ItemCommandEvent] - Item 'YeelightLEDCeilingLampV4JIAOYUE650RGB_Brightness' received command 94
2018-03-01 17:08:08.850 [vent.ItemStateChangedEvent] - YeelightLEDCeilingLampV4JIAOYUE650RGB_Brightness changed from 95 to 94
2018-03-01 17:08:09.101 [vent.ChannelTriggeredEvent] - homematic:HM-RC-2-PBU-FM:OEQ0609246:OEQ1232671:1#PRESS triggered CONT
2018-03-01 17:08:09.115 [ome.event.ItemCommandEvent] - Item 'YeelightLEDCeilingLampV4JIAOYUE650RGB_Brightness' received command 93
2018-03-01 17:08:09.121 [vent.ItemStateChangedEvent] - YeelightLEDCeilingLampV4JIAOYUE650RGB_Brightness changed from 94 to 93
2018-03-01 17:08:09.374 [vent.ChannelTriggeredEvent] - homematic:HM-RC-2-PBU-FM:OEQ0609246:OEQ1232671:1#PRESS triggered CONT
I am talking with @Anthrax about this lamp in particular and there seems to be another light mode.
We will continue our talk/solution finding here in the thread so everybody can learn from this.
@Anthrax
So what you are saying is that if I want to be able to really dim from 100 (ON) to 0 (OFF) I will probably need to first dim the normal brightness down as far as possible and then switch to night mode and dim it from 100 to 0 aswell, correct ?
If yes how do I switch to night mode programmatically ?
Thank you for your answer. It is kind of working but sometimes the result show the wrong thing.
See the log here:
2018-03-02 19:10:56.208 [vent.ChannelTriggeredEvent] - homematic:HM-RC-2-PBU-FM:OEQ0609246:OEQ1232671:2#PRESS triggered CONT
2018-03-02 19:10:56.217 [ome.event.ItemCommandEvent] - Item 'YeelightLEDCeilingLampV4JIAOYUE650RGB_Actions_' received command get_prop["nl_br"]
2018-03-02 19:10:56.249 [vent.ItemStateChangedEvent] - YeelightLEDCeilingLampV4JIAOYUE650RGB_Actions_ changed from {"result":["ok"],"id":12796} to get_prop["nl_br"]
2018-03-02 19:10:56.315 [vent.ItemStateChangedEvent] - YeelightLEDCeilingLampV4JIAOYUE650RGB_Actions_ changed from get_prop["nl_br"] to {"result":["1"],"id":12799}
2018-03-02 19:10:56.491 [vent.ChannelTriggeredEvent] - homematic:HM-RC-2-PBU-FM:OEQ0609246:OEQ1232671:2#PRESS triggered CONT
2018-03-02 19:10:56.503 [ome.event.ItemCommandEvent] - Item 'YeelightLEDCeilingLampV4JIAOYUE650RGB_Actions_' received command get_prop["nl_br"]
2018-03-02 19:10:56.531 [vent.ItemStateChangedEvent] - YeelightLEDCeilingLampV4JIAOYUE650RGB_Actions_ changed from {"result":["1"],"id":12799} to get_prop["nl_br"]
==> /var/log/openhab2/openhab.log <==
2018-03-02 19:10:56.549 [INFO ] [clipse.smarthome.model.script.result] - result Flag ist ok
2018-03-02 19:10:56.549 [INFO ] [clipse.smarthome.model.script.result] - result Flag ist ok
==> /var/log/openhab2/events.log <==
2018-03-02 19:10:56.586 [vent.ItemStateChangedEvent] - YeelightLEDCeilingLampV4JIAOYUE650RGB_Actions_ changed from get_prop["nl_br"] to {"result":["1"],"id":12802}
2018-03-02 19:10:56.750 [vent.ChannelTriggeredEvent] - homematic:HM-RC-2-PBU-FM:OEQ0609246:OEQ1232671:2#PRESS triggered CONT
2018-03-02 19:10:56.776 [ome.event.ItemCommandEvent] - Item 'YeelightLEDCeilingLampV4JIAOYUE650RGB_Actions_' received command get_prop["nl_br"]
2018-03-02 19:10:56.784 [vent.ItemStateChangedEvent] - YeelightLEDCeilingLampV4JIAOYUE650RGB_Actions_ changed from {"result":["1"],"id":12802} to get_prop["nl_br"]
==> /var/log/openhab2/openhab.log <==
2018-03-02 19:10:56.791 [ERROR] [ore.transform.actions.Transformation] - Error executing the transformation 'JSONPATH': Invalid path '$.result[0]' in 'get_prop["nl_br"]'
2018-03-02 19:10:56.799 [INFO ] [clipse.smarthome.model.script.result] - result Flag ist get_prop["nl_br"]
==> /var/log/openhab2/events.log <==
2018-03-02 19:10:56.884 [vent.ItemStateChangedEvent] - YeelightLEDCeilingLampV4JIAOYUE650RGB_Actions_ changed from get_prop["nl_br"] to {"result":["1"],"id":12805}
2018-03-02 19:10:57.022 [vent.ChannelTriggeredEvent] - homematic:HM-RC-2-PBU-FM:OEQ0609246:OEQ1232671:2#PRESS triggered CONT
2018-03-02 19:10:57.032 [ome.event.ItemCommandEvent] - Item 'YeelightLEDCeilingLampV4JIAOYUE650RGB_Actions_' received command get_prop["nl_br"]
2018-03-02 19:10:57.039 [vent.ItemStateChangedEvent] - YeelightLEDCeilingLampV4JIAOYUE650RGB_Actions_ changed from {"result":["1"],"id":12805} to get_prop["nl_br"]
==> /var/log/openhab2/openhab.log <==
2018-03-02 19:10:57.039 [INFO ] [clipse.smarthome.model.script.result] - result Flag ist 1
This is how my rule looks like right now:
rule "Schlafzimmer Dimming"
when
Channel 'homematic:HM-RC-2-PBU-FM:OEQ0609246:OEQ1232671:2#PRESS' triggered LONG
then
YeelightLEDCeilingLampV4JIAOYUE650RGB_Power.sendCommand(ON)
YeelightLEDCeilingLampV4JIAOYUE650RGB_Actions_.sendCommand('set_scene["nightlight", 1]')
end
rule "Schlafzimmer Dimming"
when
Channel 'homematic:HM-RC-2-PBU-FM:OEQ0609246:OEQ1232671:2#PRESS' triggered CONT
then
YeelightLEDCeilingLampV4JIAOYUE650RGB_Actions_.sendCommand('get_prop["nl_br"]')
result = transform("JSONPATH","$.result[0]",YeelightLEDCeilingLampV4JIAOYUE650RGB_Actions_.state.toString)
logInfo("result","result Flag ist {}", result)
end
Is there any way to only get the actual correct value ?
Lol… I was going to mention that it looked like your rule would need some handling for this . What binding are you using? It seems really odd that the Channel the YeelightLEDCeilingLampV4JIAOYUE650RGB_Actions_ Item is linked to would be used for both sending commands and receiving states. If the results were only dimmer states, it would be easy, but it looks like there are some OKs coming back too. Posting all of your related items might help. I’m sure there is some discussion somewhere about how to use the binding, so that would probably be the best place to go next. But off the top of my head, I’d setup another rule triggered on YeelightLEDCeilingLampV4JIAOYUE650RGB_Actions_, like this…
rule "YeelightLEDCeilingLampV4JIAOYUE650RGB_Actions_ received update"
when
Item YeelightLEDCeilingLampV4JIAOYUE650RGB_Actions_ received update
then
if (YeelightLEDCeilingLampV4JIAOYUE650RGB_Actions_.state.toString.contains("result")) {
val String result = transform("JSONPATH","$.result[0]",json)
if (result.isNumeric) {
// do something
}
logInfo("result","result Flag ist {}", result)
}
end
You could put something like this in your existing rule, but you’d need to put in a Thread::sleep to wait for the result to come back in. Best to avoid sleeps because it ties up threads, which are a limited resource.