Ankündigung

Einklappen
Keine Ankündigung bisher.

Probleme mit executeCommand

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

    Probleme mit executeCommand

    Hi,

    ich möchte gern über executeCommand in einer Rule ein Script ausführen.

    Code:
    rule "Lautstärke WC"
     when
      Item Volume_EG_Bad received update
     then
      logInfo("Lautsprecher.rule", "Volume_EG_Bad:" + Volume_EG_Bad.state)
      if (Volume_EG_Bad.state == 1)
      {
       var String results = executeCommandLine("/etc/openhab2/scripts/increaseVolumeEGBad.sh", 5000)
       logInfo("exec1", results)
      }
    
      if (Volume_EG_Bad.state == 2)
      {
       var String results = executeCommandLine("/etc/openhab2/scripts/decreaseVolumeEGBad.sh", 5000)
       logInfo("exec2", results)
      }
     end
    Das Script für leiser macht folgendes (funktioniert bei direktem Ausführen auch):

    Code:
    #!/bin/bash
    amixer -c1 set Speaker -d Front 2dB-
    Im Log bekomme ich jedoch einen Fehler des amixers:
    Code:
    2017-01-06 20:37:47.697 [INFO ] [thome.model.script.Lautsprecher.rule] - Volume_EG_Bad:2
    2017-01-06 20:37:47.765 [INFO ] [eclipse.smarthome.model.script.exec2] - Invalid card number.
    Usage: amixer <options> [command]
    
    Available options:
      -h,--help       this help
      -c,--card N     select the card
      -D,--device N   select the device, default 'default'
      -d,--debug      debug mode
      -n,--nocheck    do not perform range checking
      -v,--version    print version of this program
      -q,--quiet      be quiet
      -i,--inactive   show also inactive controls
      -a,--abstract L select abstraction level (none or basic)
      -s,--stdin      Read and execute commands from stdin sequentially
      -R,--raw-volume Use the raw value (default)
      -M,--mapped-volume Use the mapped volume
    
    Available commands:
      scontrols       show all mixer simple controls
      scontents   show contents of all mixer simple controls (default command)
      sset sID P      set contents for one mixer simple control
      sget sID        get contents for one mixer simple control
      controls        show all controls for given card
      contents        show contents of all controls for given card
      cset cID P      set control contents for one control
      cget cID        get control contents for one control
    Habt ihr eine Idee warum die Parameter nicht korrekt übergeben werden?
    lg
    Stefan

    #2
    Der Fehler kommt ja direkt von amixer, in diesem Fall beschwert es sich über eine falsche card number. Sollte die card number 1 tatsächlich korrekt sein, tippe ich auf fehlende Rechte, also der User, unter dem openHAB läuft, gehört noch nicht zur Gruppe audio.
    Nach sudo adduser openhab audio auf der Kommandozeile sollte der Rechner durchgestartet werden, damit die openHAB shell auch sicher die richtigen Rechte hat.

    Kommentar


      #3
      Das wars, Danke dir!
      lg
      Stefan

      Kommentar

      Lädt...
      X