Phew, I see the issue... (I think)
So, in your device command you 'must enter something'.
So, I suggest you put.
1:50
So that if the command were to be used with a button it would set the dimmer level to 50%
Also, if the command is used within a slider, the new slider value will overwrite the 50%.
Likewise in a rule the new value from the rule will overwrite the 50%
So this simple rule should work :-
rule "Link two things"
when
Event( source == "A Sensor", value == "on" )
then
execute.command( "Dim to a level", 25 );
//else
// execute.command( "Something OFF" );
end
Richard Turner created a rule that seperates an RGB HEX colour value In-Memory command status (where the value is set by another In-Memory command linked to a colour picker UI element) into 3 seperate % values for use with 3 Velbus dimmer channels.
In-Memory command "186_RGB_Colour_Picker_Set" > linked to Colour Picker UI element
In-Memory status command linked to Sensor "186_RGB_Colour_Picker_Status"
3 seperate Velbus dimmer_level commands
186-4DC-Ch1R-Dim100
186-4DC-Ch2G-Dim100
186-4DC-Ch3B-Dim100
Does this help ?
rule "186-RGB To 3 Channels" when
// SOURCE here is an In-Memory status sensor that shows the RGB HEX value from a colour picker "186_RGB_Colour_Picker_Status"
$evt:Event( source == "186_RGB_Colour_Picker_Status", $val : value)
then
String valStr = $val.toString();
if (valStr != null && valStr.length() == 6) {
// Split a single 6 digit HEX RGB colour value into 3 seperate RGB values (in HEX format)
String rStr = valStr.substring(0,2);
String gStr = valStr.substring(2,4);
String bStr = valStr.substring(4,6);
// Convert 2 digit HEX values into DEC int values
Integer r = Integer.parseInt(rStr, 16);
Integer g = Integer.parseInt(gStr, 16);
Integer b = Integer.parseInt(bStr, 16);
// Convert 0-255 value to 0-100 whole number
r = (int)Math.round(((double)r / 255d) * 100);
g = (int)Math.round(((double)g / 255d) * 100);
b = (int)Math.round(((double)b / 255d) * 100);
execute.command( "Red_Set", r.toString() );. // In-Memory command used as a reference in the UI for debugging
execute.command( "186-4DC-Ch1R-Dim100", r.toString() ); // A channel of a VMB4DC that is used to drive the Red elements of an RGB fixture
execute.command( "Green_Set", g.toString() );. // In-Memory command used as a reference in the UI for debugging
execute.command( "186-4DC-Ch2G-Dim100", g.toString() ); // A channel of a VMB4DC that is used to drive the Green elements of an RGB fixture
execute.command( "Blue_Set", b.toString() ); // In-Memory command used as a reference in the UI for debugging
execute.command( "186-4DC-Ch3B-Dim100", b.toString() ); // A channel of a VMB4DC that is used to drive the Blue elements of an RGB fixture
}
end
Michal took this a step further when I started playing around with the HTTP driven DMX device by creating random HEX values to use asRGB strings.
Where a pulsing status is used to trigger the rule.
(Not the output state of an 'Interval Timer' relay channel in Velbus as this would give a constant state of "timer", I linked the interval timer relay channel to another relay (momentary action) so that the slave relay showed on and off states)
An interval timer in Rules might be a better option, but I wanted to be able to vary the interval pulse time in VelbusLink or use multiple actions wth different times.
This rule sees 1 trigger and creates 6 different RGB HEX values to be sent to 6 seperate SPi pixels, using the same single HTTP command to address the SPi / DMX adapter. Where the %{param} is used to (only) transfer the HEX value, the start pixel and end pixel information.
package org.openremote.controller.protocol;
global org.openremote.controller.statuscache.CommandFacade execute;
import java.util.*;
rule "Ch5 slave interval timer"
when
Event( source == "01_VMB1RYNOS_ch5", value == "on" )
then
java.util.Random randomGenerator = new java.util.Random();
execute.command("DMX_Universal_Uni0",String.format("%06X", randomGenerator.nextInt(0x1000000)) + "&start=2&end=2");
execute.command("DMX_Universal_Uni0",String.format("%06X", randomGenerator.nextInt(0x1000000)) + "&start=3&end=3");
execute.command("DMX_Universal_Uni0",String.format("%06X", randomGenerator.nextInt(0x1000000)) + "&start=4&end=4");
execute.command("DMX_Universal_Uni0",String.format("%06X", randomGenerator.nextInt(0x1000000)) + "&start=5&end=5");
execute.command("DMX_Universal_Uni0",String.format("%06X", randomGenerator.nextInt(0x1000000)) + "&start=6&end=6");
execute.command("DMX_Universal_Uni0",String.format("%06X", randomGenerator.nextInt(0x1000000)) + "&start=7&end=7");
end