Customise action options

Hello people,

I am here again. Because I want to create a customised action type which can have the options I would have.

For example, when I choose an ‹ slider › option in scenario, there will be a command input box appear automatically at the right side. And when choose an ‹ message › option, there will be a title input box and message input box appear etc…

example of scenario cmd:

example of request cmd:

Since most of the light device does not have a brightness shift command, I would create a command do this. But this command need to take several different inputs, such as the command which content current brightness, the command which can set brightness, the operation which user want to have(shift up or down) etc…

Now I am doing this by a scenario code block, but from time to time, this is not easy for no-coding users. So I would package User configuration as several input boxes… and Execution part to cmd class…

// User configuration
$LIGHT_BRIGHTNESS_VALUE = '#[Apartment][Mirror Strip Right][Etat Luminosité]#';
$LIGHT_BRIGHTNESS_ACTION = '#[Apartment][Mirror Strip Right][Luminosité]#';
$OPERATION = 'DOWN'; // 'ON' or 'DOWN', case sensitive
$MIN_VALUE = 0;
$MAX_VALUE = 255;
$STEP_VALUE = 0.2; //Change 20% of MAX_VALUE each time

// Execution
$cmd = cmd::byString($LIGHT_BRIGHTNESS_VALUE);

if (is_object($cmd))
if ($cmd->getValue()) $current_val = $cmd->getValue();
else $current_val = $cmd->getCache('value', 'NULL');
$options = array();

if ($OPERATION === 'UP') $options['slider'] = $current_val + round(($MAX_VALUE - $MIN_VALUE) * $STEP_VALUE);
else
if ($OPERATION === 'DOWN') $options['slider'] = $current_val - round(($MAX_VALUE - $MIN_VALUE) * $STEP_VALUE);

if ($options['slider'] < $MIN_VALUE) $options['slider'] = $MIN_VALUE;

if ($options['slider'] > $MAX_VALUE) $options['slider'] = $MAX_VALUE;
fwrite(STDOUT, '[Scenario] Light shift for [' . $LIGHT_BRIGHTNESS_ACTION . '], from -> ' . $options['slider'] . ' to ->' . $current_val . '\n');
$cmdSet = cmd::byString($LIGHT_BRIGHTNESS_ACTION);

if (is_object($cmdSet)) $cmdSet->execCmd($options);

So what I would see is, when user select this command in a scenario action block, those input boxes need to appear automatically at the right side, just like an slider value input box but with more input options.

I saw there is a ‹ scenario › folder under main system template folder, but there is no such folder under plugin template but just dashboard and mobile folder…

I am wondering if I create a option template file, how can I make relation with the cmd-> type…

<div class="input-group input-group-sm" style="width: 100%">
<!-- select a cmd(info) which content brightness value-->
  	<span class="input-group-addon" id="basic-addon1" style="width: 100px">#slider_placeholder#</span>
	<input value="#cmdStatus#" class="expressionAttr form-control input-sm" data-l1key="options" data-l2key="cmdStatus" data-type="info" data-cmd_id="#id#" data-uid="#uid#" />
	<span class="input-group-btn">
		<button class="btn btn-default listEquipementInfo" type="button" title="{{Sélectionner la commande}}" data-cmd_id="#id#"  data-uid="#uid#"><i class="fa fa-list-alt"></i></button>
	</span>
<!-- select a cmd(action) which can set brightness value-->
        <span class="input-group-addon" id="basic-addon1" style="width: 100px">#slider_placeholder#</span>
	<input value="#cmdAction#" class="expressionAttr form-control input-sm" data-l1key="options" data-l2key="cmdAction" data-type="action" data-cmd_id="#id#" data-uid="#uid#" />
	<span class="input-group-btn">
		<button class="btn btn-default listEquipementInfo" type="button" title="{{Sélectionner la commande}}" data-cmd_id="#id#"  data-uid="#uid#"><i class="fa fa-list-alt"></i></button>
	</span>
<!-- Indicate shift up operation or down operation-->
        <span class="input-group-addon" id="basic-addon1" style="width: 100px">#slider_placeholder#</span>
	<input value="#up_down#" class="expressionAttr form-control input-sm" data-l1key="options" data-l2key="up_down"/>
        </span>
<!-- Indicate a percentage scaling the shift-->
        <span class="input-group-addon" id="basic-addon1" style="width: 100px">#slider_placeholder#</span>
	<input value="#step_value#" class="expressionAttr form-control input-sm" data-l1key="options" data-l2key="step_value"/>
        </span>
</div>

<script>
	$('.listEquipementInfo[data-uid=#uid#]').off('click').on('click', function() {
		jeedom.cmd.getSelectModal({cmd: {type: type}}, function(result) {
			$('.expressionAttr[data-l1key=options][data-l2key=slider][data-uid=#uid#]').atCaret('insert', result.human);
		});
	});
</script>

(This is a draft code, not set correct Jquery logic yet, just to represent the meaning)
Can someone give me some idea, where I can put this template file, and how I can setup the command then the system can automatically load this template when needed.

Thanks in advance!