Use case: Sync colors; I’m trying to create a rule where if color of one LIFX light updates, apply the same color to an LED strip. LED strip may individually get color update, in which case, do not change the LIFX color. (Unidirectional). LED strip is based on Hyperion, and I’m using Hyperion binding via JAR file.
Problem: I’m running the rule as below. The rule works fine, but it triggers the rule every 3 seconds (polling interval of LIFX) and sends update to LED strip every 3 seconds irrespective of whether the color has changed significantly or not. Also, due to some reason, LIFX would usually get small updates to the color when using HSBType (equal to very small fractions) which would trigger the rule occasionally anyway.
Help Needed: How do I build a rule where SendCommand is executed if and only if the color as HSBType changes significantly on “received update” ( > 1 integer value for any of red, green or blue)? I’m new to development, so please help me with import part of rules file as well.
Rule so far: (please see the comments below)
rule "scene for lights in living room update"
when
Item lifx_colorlight_yyyyyyyy_color received update
then
{
var color_value = lifx_colorlight_yyyyyyyy_color.state as HSBType
// Need something here that does if(Math::abs(color_value_new - color_value) > 0.9 then
sendCommand(hyperion_serverV1_xxxxxxxx_color,color_value)
// Need something here that does var color_value_new = hyperion_serverV1_xxxxxxxx_color
}
Help would be much appreciated. Thank you.