nice code, learned a lot.
I tried the sample but the timer fires to fast for the raspberry.
I got a lot of identical commands
16:36:35.292 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'Hue_Fade_Next' received command 2017-11-06T16:35:41.143+0100
16:36:35.698 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'RGB_Lampe_01_Farbe' received command 5,100,100
16:36:36.142 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'RGB_Lampe_01_Farbe' received command 4,100,100
16:36:36.573 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'RGB_Lampe_01_Farbe' received command 4,100,100
16:36:36.981 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'RGB_Lampe_01_Farbe' received command 5,100,100
16:36:37.408 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'RGB_Lampe_01_Farbe' received command 4,100,100
and warnings
16:38:58.840 [WARN ] [core.internal.events.OSGiEventManager] - Dispatching event to subscriber 'org.eclipse.smarthome.io.monitor.internal.EventLogger@1bdc1af' takes more than 5000ms.
16:39:09.588 [WARN ] [core.internal.events.OSGiEventManager] - Dispatching event to subscriber 'org.eclipse.smarthome.io.monitor.internal.EventLogger@1bdc1af' takes more than 5000ms.
so I modified 1 to 10 .
// items:
Switch Tradfri_Fading "Tradfri fade"
DateTime Tradfri_Fade_Next
// defined in PaperUI: RGB_Lampe_01_Farbe
// sitemap:
Switch item=Tradfri_Fading
// rules:
// Start/stop tradfri fading
rule "Start Tradfri Colors fading"
when
Item Tradfri_Fading changed
then
logInfo("fade","begin rule Start Tradfri Colors fading")
if (Tradfri_Fading.state == ON) {
// set a timer to sligtly change the color again and again
timer = createTimer(now, [|
Tradfri_Fade_Next.sendCommand(now.toString)
if (timer != null) {
timer.reschedule(now.plusSeconds(10))
}
])
}
else {
timer = null
}
end
// Fade tradfri 10 bits.
rule "Tradfri Fade Next"
when
Item Tradfri_Fade_Next changed
then
logInfo("fade","begin rule Tradfri Fade Next")
if (Tradfri_Fading.state == ON) {
// get your current color
var hsb = RGB_Lampe_01_Farbe.state as HSBType
// change it a little bit
var DecimalType hue = new DecimalType(hsb.hue.intValue % 360 + 10) // 0-360; 0=red, 120=green, 240=blue, 360=red(again)
var PercentType sat = new PercentType(hsb.saturation.intValue) // 0-100
var PercentType bright = new PercentType(hsb.brightness.intValue) // 0-100
var HSBType newHsb = new HSBType(hue,sat,bright)
logInfo("fade", "new HSB: " + newHsb.toString)
// set the new color
RGB_Lampe_01_Farbe.send(newHsb)
}
end
now its running nice !!
but :
17:24:06.432 [INFO ] [smarthome.event.ItemStateChangedEvent] - Hue_Fade_Next changed from 2017-11-06T17:23:55.879+0100 to 2017-11-06T17:24:05.893+0100
17:24:06.460 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'RGB_Lampe_01_Farbe' received command 107,100,100
17:24:07.478 [INFO ] [smarthome.event.ItemStateChangedEvent] - RGB_Lampe_01_Farbe changed from 97,100,100 to 107,100,100
17:24:15.917 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'Hue_Fade_Next' received command 2017-11-06T17:24:15.909+0100
17:24:16.474 [INFO ] [smarthome.event.ItemStateChangedEvent] - Hue_Fade_Next changed from 2017-11-06T17:24:05.893+0100 to 2017-11-06T17:24:15.909+0100
17:24:16.487 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'RGB_Lampe_01_Farbe' received command 117,100,100
17:24:17.491 [INFO ] [smarthome.event.ItemStateChangedEvent] - RGB_Lampe_01_Farbe changed from 107,100,100 to 117,100,100
17:24:17.541 [INFO ] [smarthome.event.ItemStateChangedEvent] - RGB_Lampe_01_Farbe changed from 117,100,100 to 116,100,100
19:02:10.193 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'RGB_Lampe_01_Farbe' received command 268,100,100
19:02:10.222 [INFO ] [smarthome.event.ItemStateChangedEvent] - RGB_Lampe_01_Farbe changed from 258,100,100 to 267,100,100
19:02:10.222 [INFO ] [smarthome.event.ItemStateChangedEvent] - RGB_Lampe_01_Farbe changed from 267,100,100 to 268,100,100
19:02:10.774 [INFO ] [smarthome.event.ItemStateChangedEvent] - RGB_Lampe_01_Farbe changed from 268,100,100 to 267,100,100
why I get the change msg twice or three times sometimes?