cmdalias - Patch Commandref

Begonnen von Otto123, 01 August 2017, 19:54:21

Vorheriges Thema - Nächstes Thema

Otto123

Hallo Rudi,

da ich heute versucht habe cmdalias zu verstehen, fand ich die commandref diesbezüglich irgendwie "genau verkehrt"
Insbesondere das Ende der define Zeile newcommand..." hat mich verwirrt. Für mich ist newcommand eigentlich kein neues sondern ein existierendes Kommando(Folge) und die ... und das " am Ende sagten mir gar nix.  :o

Es ist ein bisschen schwierig weil ja existierende Kommandos damit überschrieben werden können. Ich wollte aber ein neues Kommando erzeugen, welches dann eine Systembefehl ersetzt:define s1 cmdalias reboot AS "sudo /sbin/reboot"


Wenn Du möchtest hier ein "Patch". Ich habe den Text so umgeschrieben wie ich Ihn verstehen würde:
=pod
=item command
=item summary    create new commands or replace internal ones.
=item summary_DE neue FHEM Befehle definieren oder existierende ändern
=begin html

<a name="cmdalias"></a>
<h3>cmdalias</h3>
<ul>
  create new commands or replace internal ones.
  <br>

  <a name="cmdaliasdefine"></a>
  <b>Define</b>
  <ul>
    <code>define &lt;name&gt; cmdalias &lt;cmdname will be replaced or new created&gt; [parameter]
                AS &lt;existing cmd&gt;</code><br>
    <br>
    <ul>
      parameter is optional and is a regexp which must match the command
      entered.
      If it matches, then the specified existing command will be executed, which is
      a fhem command (see <a href="#command">Fhem command types</a> for
      details). Like in the <a href="#notify">notify</a> commands, $EVENT or
      $EVTPART may be used, in this case representing the command arguments as
      whole or the unique words entered.<br>
      Notes:<ul>
      <li>existing command may contain cmdname, but recursion is not allowed.</li>
      <li>if there are multiple definitions, they are checked/executed in
      alphabetically sorted name oder.</li>
      </ul>
      Examples:
      <ul><code>
        define s1 cmdalias shutdown update AS save;;shutdown<br>
        define s2 cmdalias set lamp .* AS { Log 1, "$EVENT";; fhem("set $EVENT") }
      </code></ul>
    </ul>
  </ul>
</ul>

=end html
=cut


Gruß Otto
Viele Grüße aus Leipzig  ⇉  nächster Stammtisch an der Lindennaundorfer Mühle
RaspberryPi B B+ B2 B3 B3+ ZeroW,HMLAN,HMUART,Homematic,Fritz!Box 7590,WRT3200ACS-OpenWrt,Sonos,VU+,Arduino nano,ESP8266,MQTT,Zigbee,deconz

rudolfkoenig

Habs versucht anzupassen, jetzt schaut es so aus:
Zitatcmdalias

       
  • create new FHEM commands or replace internal ones.

    Define

            
    • define <name> cmdalias <cmd_to_be_replaced or new_cmd> [parameter] AS <existing_cmd>

      parameter is optional and is a regexp which must match the command entered. If it matches, then the specified <existing_command> will be executed, which is a FHEM command (see FHEM command types for details). Like in notify, $EVENT or $EVTPART may be used, in this case representing the command arguments as whole or the unique words entered.
    Notes:

            
    • recursion is not allowed.
    • if there are multiple definitions, they are checked/executed in alphabetically sorted <name> oder.
    Examples:

            
    • define s1 cmdalias shutdown update AS save;;shutdown
      define s2 cmdalias set lamp .* AS { Log 1, "$EVENT";; fhem("set $EVENT") }

Otto123

Viele Grüße aus Leipzig  ⇉  nächster Stammtisch an der Lindennaundorfer Mühle
RaspberryPi B B+ B2 B3 B3+ ZeroW,HMLAN,HMUART,Homematic,Fritz!Box 7590,WRT3200ACS-OpenWrt,Sonos,VU+,Arduino nano,ESP8266,MQTT,Zigbee,deconz