Apple Script (Textausgabe)

  • Hallo Leute,


    Sorry das ich noch ein Thema aufmache ...


    Ich finde bzw. komme nicht weiter mit der Sprache AppleScript...


    Ist keiner unter euch der sich auskennt mit dem Thema?


    Diejenigen die sich in AppleScript gut auskennen möchten sich bitte melden... speziell geht es um "AirPlay/iTunes"...


    Danke im Voraus


    Grüße

  • nanekx


    hallo nanekx, wenn du hier noch aktiv bist, oder mitliest, melde dich bitte wg. applescript.


    haben testscript erstellt, läuft auf dem imac auch.

    es macht nichts anderes, als einen titel aus einer playlist zu spielen. fertig.


    tell application "iTunes" play track "1" of playlist "Homebridge" end tell



    dann HB plugin installiert, config lt. npm erweitert.

    HB startet, schalter kommt auch.


    wenn ich den schalte, fliegt HB raus.

    frage: muss mit den scpt files noch etwas bestimmtes gemacht werden oder müssen die an einem bestimmt ort/ordner auf dem iMac liegen ?

    vlt. kannst du mir nen tipp geben.




    det


    du kannst mir anhand dieser fehlermeldung wahrscheinlich nichts sagen / tipp /hinweis geben so von der HB seite ?


    events.js:182
    throw er; // Unhandled 'error' event
    ^
    Error: spawn osascript ENOENT

    at _errnoException (util.js:1041:11)

    at Process.ChildProcess._handle.onexit (internal/child_process.js:192:19)

    at onErrorNT (internal/child_process.js:374:16)

    at _combinedTickCallback (internal/process/next_tick.js:138:11)

    at process._tickCallback (internal/process/next_tick.js:180:9)

    at Function.Module.runMain (module.js:611:11)

    at startup (bootstrap_node.js:158:16)

    at bootstrap_node.js:598:3

  • det


    danke dir. ahnte ich, dass das plugin an sich bzw. HB da nichts mit zu tun hat.


    es wird so sein, dass das applescript scpt file so entweder nicht execute ist ODER das die pfadangbe zum scpt-file nicht korrekt ist.

    das mit den applescript´s ist "etwas trikki" , um es mal so zu sagen.

    an sich funktioniert es aber.


    laufen läuft HB ja mit dem plugin bzw. der erweiterten config. nur beim aktivieren des schalters fliegt sie ab.


    ich werd halt noch einen tag googlen :) denn wenn das so klappt, dann sind wir dem "sprechendem haus" ein großen schritt näher.


    ich geb feedback, wenn ich weitergekommen bin.


    *grübel* von wegen "sprechendes haus".. Nastra könnte man nicht einen "sammelblog" zum thema sprechendes haus machen? wenn ich mich recht erinnere, interessierte das doch xMAIKx , Andi , Maz dich selber und bestimmt auch Maik bzw. noch andere. und...es kann ja nie falsch sein, wissen zu bündeln :)

  • Zitat

    Nastra könnte man nicht einen "sammelblog" zum thema sprechendes haus machen

    Wilfhelm2 Verstehe nicht ganz was du meinst, du willst einen eigenen Bereich im Forum sprechendes Haus oder was? Wenn ja um was soll es sich genau drehen um Scripte?

  • Wilfhelm2 Klar, das interessiert bestimmt einige inkl. mich, aber ich denke ein Thema langt. Da kann man diverse Skripte oder Hardware besprechen.


  • Hallo Wilfhelm2,

    zunächst mal, ich kenne dieses HB Plugin nicht - ich nutze und nutze das Homebridge-ssh Plugin...

    Du hast Homebridge auf dem Mac laufen, stimmt’s? Meine mal, das warst du.... was ich dir damit sagen will, ich kenne deine Konstellation nicht. Also wie gesagt, habe Homebridge-ssh Plugin auf den Raspberrypi installiert wo Homebridge läuft, habe auf dem Mac den AppleScript erstellt und als Programm in ein Ordner gelegt.. dann die config angepasst und zwar habe ich nur den Pfad der Datei angegeben ... da das script auf dem Mac getestet wurde (und funktioniert) macht Homebridge im Prinzip nix anderes als das Programm (script auf dem Mac) zu starten... also wenn dein script funktioniert dann sollte der Rest kein Problem sein ??


    Grüße

  • nanekx


    grüß dich.


    verstehe aber könntest du mir deine config zeilen / den teil / mal hier posten, in dem du die pfadangabe zu dem ordner / unterordner, zu der/den scriptdateien hinterlegt hast. wäre super. ich glaube nämlich, dass ich die pfadangabe falsch in der config hinterlege.


    scripte aus der imac console gestartet -> läuft, alles ok.


    scripte aus homebridge auf imac starten kann ich nicht (mehr) da auf iMac keine HB mehr läuft. daher muss ich die scripts vom pi (remote) auf dem mac (dort läuft das itunes ja) starten. daher gerade beim ssh-key erstellen, um dem pi die möglichkeit des "fernen-startens" zu geben. denke aber das müsste klappen.


    ah...


    homebridge-ssh

    homebridge-applescript


    dann guck ich mir den "ssh" mal an, scheint ja so, als müsste ich bei dem plugin keinen key generieren...dort wird er mitgegeben , wenn ich das richtig sehe :)

  • könntest du mir deine config zeilen / den teil / mal hier posten, in dem du die pfadangabe zu dem ordner / unterordner, zu der/den scriptdateien hinterlegt hast

    Dem schließe ich mich an nanekx . Vorab danke dafür.

    Ich wollte auch mal vom Rapspi zum iMac dort ein AppleScript starten, bin aber auch bei dem Thema Pfad usw. stecken geblieben und hatte dann erstmal keine Muse weiter zu machen.

    Hilfreich?

  • DJay


    also das script in der npm Beschreibung des plugin´s "homebridge-ssh"


    macht nichts anderes -wie nanekx ja auch schon geschrieben, als deine iTunes zu starten und Playlistabzuspielen, auf dem iTunes gerade steht.


    probier einfach aus lt. Beispiel config, dürfte so funktionieren. Vorteil diese ssh plugin´s ist, dass man in der config das notwendige Passwort direkt mit vom pi (aufrufender) an den iMac (ausführender) übergibt.

    bei dem von mir bis dato genutztem plugin applescript ist das nicht der fall. da musst du erst noch einen permanenten key für das starten erstellen und hinterlegen.


    also -> das ssh plugin scheint mir sehr viel einfacher.


    aber ich will ja nicht nur einfach eine Playlist abspielen sondern ich will durch das script eine bestimmte Datei aus einer bestimme Playlist, or -noch besser - ein scpt starten.




    aber super ist schon, dass ich vom pi auf dem mac starten kann

  • Das homebridge-ssh plugin nutze ich schon eine ganze Weile.

    Beispiele meiner config.json unten.

    Ich bräuchte auch so wie ich denke Du es willst, einfach mal eine Zeile von jemandem, wie das aussieht wenn man vom Pi auf dem iMac eine script Datei starten. Also wie müsste der Pfad in der config.json aussehen?


    Hilfreich?

  • gut, wenn man mal in ruhe ein Stündchen hat und von nanekx auf das richtige plugin geschuppst wird. mit dem ssh viel, viel einfacher.



    es läuft.

    noch etwas verfeinern, aber...es läuft :)


    vlt. hab ich auch bald was, um es euch hier im Showroom vorzustellen :)



    DJay


    frag. vlt kann ich dir ja auch mal helfen :)

  • Das homebridge-ssh plugin nutze ich schon eine ganze Weile.

    Beispiele meiner config.json unten.

    Ich bräuchte auch so wie ich denke Du es willst, einfach mal eine Zeile von jemandem, wie das aussieht wenn man vom Pi auf dem iMac eine script Datei starten. Also wie müsste der Pfad in der config.json aussehen?


    direkt eine scpt (in der du dann wiederum angeben kannst, was geschehen soll) geht auch


    "on" : "osascript /Users/xxxx/Documents/Homebridge/xxxx.scpt",



    dieser Ordner "Homebridge" hat nichts mit dem HB Systemordner zu tun, nur für mich, damit ich weiss, was wohin gehört bzw. wo liegt ordentlich wie man ist :)


    und jetzt hat man das sprechende haus, wenn man die xxx.scpt mit entsprechendem leben füllt.


    siehe -> "Sprachausgabe" :) klappt super.

  • ? So einfach kann's sein. ? Ich hab zu danken.


    Und falls Bedarf besteht an AppleScripts, einfach mal auf der Website von Doug's AppleScripts

    Jetzt kann ich auch mein iTunes Fade-in/out script über Siri nutzen.


    Hilfreich?

  • Hier die config...


    P.s. z.b. Küchenbereich, Wohnbereich und so weiter sind AirPlay Boxen die dann über AppleScript bzw. Programm ausgewählt oder aber abgewählt werden... manche Playlisten habe ich mit xxx Kennzeichen müssen... als Beispiel für eine Playlist sieht ihr meine Playlist „nanekx“ ... Radio usw. Ist erstmal alles auf iTunes (Streaming URL) vorzubereiten und dann als Playlist abzulegen - dann klappt das auch mit der Siri „schalte das Radio an“ .... noch ein kleiner Tipp : falls eins der Schalter z.b. Radio nicht geht, eine Szene erstellen die da lautet „ das Radio „ dann geht’s mit „schalte das Radio an“ usw. Viel Spaß

    {

    "bridge":{

    "name":"Zion",

    "username":"CC:22:3D:E3:CE:30",

    "port":51826,

    "pin":"031-45-154"

    },

    "accessories":[

    {

    "accessory":"SamsungTV",

    "name":"Fernseher",

    "ip_address":"xxx",

    "send_delay":400

    },

    {

    "accessory":"TADO",

    "name":"Heizung",

    "homeID":"xxx",

    "username":"xxx",

    "password":"XXX"

    },

    {

    "accessory":"SSH",

    "name":"nächstes Lied",

    "on":"osascript -e 'tell application \"iTunes\" to play next track'",

    "off":"osascript -e 'tell application \"iTunes\" to play next track'",

    "state":"",

    "on_value":"playing",

    "exact_match":true,

    "ssh":{

    "user":"xxx",

    "host":"xxx",

    "port":22,

    "password":"XXX",

    "key":""

    }

    },

    {

    "accessory":"SSH",

    "name":"im Haus",

    "on":"osascript -e 'tell application \"system events\", open \"Applications/HomeKit/imHaus.app'",

    "off":"",

    "state":"",

    "on_value":"playing",

    "exact_match":true,

    "ssh":{

    "user":"xxx",

    "host":"xxx",

    "port":22,

    "password":"xxx",

    "key":""

    }

    },

    {

    "accessory":"SSH",

    "name":"nur Wohnzimmer",

    "on":"osascript -e 'tell application \"system events\", open \"Applications/HomeKit/Wohnzimmer.app'",

    "off":"osascript -e 'tell application \"Wohnzimmer\" run'",

    "state":"",

    "on_value":"playing",

    "exact_match":true,

    "ssh":{

    "user":"xxx",

    "host":"xxx",

    "port":22,

    "password":"Xxx",

    "key":""

    }

    },

    {

    "accessory":"SSH",

    "name":"Küchenbereich",

    "on":"osascript -e 'tell application \"system events\", open \"Applications/HomeKit/Küche.app'",

    "off":"osascript -e 'tell application \"Küche\" run'",

    "state":"",

    "on_value":"playing",

    "exact_match":true,

    "ssh":{

    "user":"xxx",

    "host":"xxx",

    "port":22,

    "password":"Xxx",

    "key":""

    }

    },

    {

    "accessory":"SSH",

    "name":"Aussenbereich",

    "on":"osascript -e 'tell application \"system events\", open \"Applications/HomeKit/Aussenbereich.app'",

    "off":"osascript -e 'tell application \"Aussenbereich\" run'",

    "state":"",

    "on_value":"playing",

    "exact_match":true,

    "ssh":{

    "user":"xxx",

    "host":"xxx",

    "port":22,

    "password":"Xxx",

    "key":""

    }

    },

    {

    "accessory":"SSH",

    "name":"Wohnbereich",

    "on":"osascript -e 'tell application \"system events\", open \"Applications/HomeKit/KüWo.app'",

    "off":"osascript -e 'tell application \"KüWo\", run'",

    "state":"",

    "on_value":"playing",

    "exact_match":true,

    "ssh":{

    "user":"xxx",

    "host":"xxx",

    "port":22,

    "password":"Xxx",

    "key":""

    }

    },

    {

    "accessory":"SSH",

    "name":"die Musik lauter",

    "on":"osascript -e 'tell app \"iTunes\" to set sound volume to sound volume + 5'",

    "off":"osascript -e 'tell app \"iTunes\" to set sound volume to sound volume + 5'",

    "state":"",

    "on_value":"playing",

    "exact_match":true,

    "ssh":{

    "user":"xxx",

    "host":"xxx",

    "port":22,

    "password":"Xxx",

    "key":""

    }

    },

    {

    "accessory":"SSH",

    "name":"die Musik leiser",

    "on":"osascript -e 'tell app \"iTunes\" to set sound volume to sound volume - 5'",

    "off":"osascript -e 'tell app \"iTunes\" to set sound volume to sound volume - 5'",

    "state":"",

    "on_value":"playing",

    "exact_match":true,

    "ssh":{

    "user":"xxx",

    "host":"xxx",

    "port":22,

    "password":"Xxx",

    "key":""

    }

    },

    {

    "accessory":"SSH",

    "name":"10%",

    "on":"osascript -e 'tell app \"iTunes\" to set sound volume to 10'",

    "off":"osascript -e 'tell app \"iTunes\" to set sound volume to 10'",

    "state":"",

    "on_value":"playing",

    "exact_match":true,

    "ssh":{

    "user":"xxx",

    "host":"xxx",

    "port":22,

    "password":"Xxx",

    "key":""

    }

    },

    {

    "accessory":"SSH",

    "name":"20%",

    "on":"osascript -e 'tell app \"iTunes\" to set sound volume to 20'",

    "off":"osascript -e 'tell app \"iTunes\" to set sound volume to 20'",

    "state":"",

    "on_value":"playing",

    "exact_match":true,

    "ssh":{

    "user":"xxx ",

    "host":"xxx",

    "port":22,

    "password":"xxx",

    "key":""

    }

    },

    {

    "accessory":"SSH",

    "name":"30%",

    "on":"osascript -e 'tell app \"iTunes\" to set sound volume to 30'",

    "off":"osascript -e 'tell app \"iTunes\" to set sound volume to 30'",

    "state":"",

    "on_value":"playing",

    "exact_match":true,

    "ssh":{

    "user":"xxx",

    "host":"xxx",

    "port":22,

    "password":"xxx",

    "key":""

    }

    },

    {

    "accessory":"SSH",

    "name":"40%",

    "on":"osascript -e 'tell app \"iTunes\" to set sound volume to 40'",

    "off":"osascript -e 'tell app \"iTunes\" to set sound volume to 40'",

    "state":"",

    "on_value":"playing",

    "exact_match":true,

    "ssh":{

    "user":"xxx",

    "host":"xxx",

    "port":22,

    "password":"Xxx",

    "key":""

    }

    },

    {

    "accessory":"SSH",

    "name":"50%",

    "on":"osascript -e 'tell app \"iTunes\" to set sound volume to 50'",

    "off":"osascript -e 'tell app \"iTunes\" to set sound volume to 50'",

    "state":"",

    "on_value":"playing",

    "exact_match":true,

    "ssh":{

    "user":"xxx",

    "host":"xxx",

    "port":22,

    "password":"xxx",

    "key":""

    }

    },

    {

    "accessory":"SSH",

    "name":"60%",

    "on":"osascript -e 'tell app \"iTunes\" to set sound volume to 60'",

    "off":"osascript -e 'tell app \"iTunes\" to set sound volume to 60'",

    "state":"",

    "on_value":"playing",

    "exact_match":true,

    "ssh":{

    "user":"xxx",

    "host":"xxx",

    "port":22,

    "password":"xxx",

    "key":""

    }

    },

    {

    "accessory":"SSH",

    "name":"70%",

    "on":"osascript -e 'tell app \"iTunes\" to set sound volume to 70'",

    "off":"osascript -e 'tell app \"iTunes\" to set sound volume to 70'",

    "state":"",

    "on_value":"playing",

    "exact_match":true,

    "ssh":{

    "user":"xxx",

    "host":"xxx",

    "port":22,

    "password":"xxx",

    "key":""

    }

    },

    {

    "accessory":"SSH",

    "name":"80%",

    "on":"osascript -e 'tell app \"iTunes\" to set sound volume to 80'",

    "off":"osascript -e 'tell app \"iTunes\" to set sound volume to 80'",

    "state":"",

    "on_value":"playing",

    "exact_match":true,

    "ssh":{

    "user":"xxx",

    "host":"xxx",

    "port":22,

    "password":"xxx",

    "key":""

    }

    },

    {

    "accessory":"SSH",

    "name":"90%",

    "on":"osascript -e 'tell app \"iTunes\" to set sound volume to 90'",

    "off":"osascript -e 'tell app \"iTunes\" to set sound volume to 90'",

    "state":"",

    "on_value":"playing",

    "exact_match":true,

    "ssh":{

    "user":"xxx",

    "host":"xxx",

    "port":22,

    "password":"xxx",

    "key":""

    }

    },

    {

    "accessory":"SSH",

    "name":"100%",

    "on":"osascript -e 'tell app \"iTunes\" to set sound volume to 99'",

    "off":"osascript -e 'tell app \"iTunes\" to set sound volume to 99",

    "state":"",

    "on_value":"playing",

    "exact_match":true,

    "ssh":{

    "user":"xxx",

    "host":"xxx",

    "port":22,

    "password":"xxx",

    "key":""

    }

    },

    {

    "accessory":"SSH",

    "name":"ein Lied zurück",

    "on":"osascript -e 'tell application \"iTunes\" to play back track'",

    "off":"osascript -e 'tell application \"iTunes\" to play back track'",

    "state":"",

    "on_value":"playing",

    "exact_match":true,

    "ssh":{

    "user":"xxx",

    "host":"xxx",

    "port":22,

    "password":"Xxx",

    "key":""

    }

    },

    {

    "accessory":"SSH",

    "name":"Reggae",

    "on":"osascript -e 'tell application \"iTunes\" to play playlist \"Reggae\" in source \"Mediathek\"'",

    "off":"osascript -e 'tell application \"iTunes\" to stop'",

    "state":"",

    "on_value":"playing",

    "exact_match":true,

    "ssh":{

    "user":"xxx",

    "host":"xxx",

    "port":22,

    "password":"xxx",

    "key":""

    }

    },

    {

    "accessory":"SSH",

    "name":"Xxx",

    "on":"osascript -e 'tell application \"iTunes\" to play playlist \"xxx\" in source \"Mediathek\"'",

    "off":"osascript -e 'tell application \"iTunes\" to play playlist \"Xxx\" in source \"Mediathek\"'",

    "state":"",

    "on_value":"playing",

    "exact_match":true,

    "ssh":{

    "user":"xxx",

    "host":"xxx",

    "port":22,

    "password":"xxx",

    "key":""

    }

    },

    {

    "accessory":"SSH",

    "name":"die Mediathek",

    "on":"osascript -e 'tell application \"iTunes\" to play playlist \"Mediathek\" in source \"Mediathek\"'",

    "off":"osascript -e 'tell application \"iTunes\" to stop'",

    "state":"",

    "on_value":"playing",

    "exact_match":true,

    "ssh":{

    "user":"xxx",

    "host":"xxx",

    "port":22,

    "password":"xxx",

    "key":""

    }

    },

    {

    "accessory":"SSH",

    "name":"Radio",

    "on":"osascript -e 'tell application \"iTunes\" to play playlist \"Radio\" in source \"Mediathek\"'",

    "off":"osascript -e 'tell application \"iTunes\" to stop'",

    "state":"",

    "on_value":"playing",

    "exact_match":true,

    "ssh":{

    "user":"xxx",

    "host":"xxx",

    "port":22,

    "password":"xxx",

    "key":""

    }

    },

    {

    "accessory":"SSH",

    "name":"Barnabas",

    "on":"osascript -e 'tell application \"iTunes\" to play playlist \"Barnabas\" in source \"Mediathek\"'",

    "off":"osascript -e 'tell application \"iTunes\" to stop'",

    "state":"",

    "on_value":"playing",

    "exact_match":true,

    "ssh":{

    "user":"xxx",

    "host":"xxx",

    "port":22,

    "password":"xxx",

    "key":""

    }

    },

    {

    "accessory":"SSH",

    "name":"Xxx",

    "on":"osascript -e 'tell application \"iTunes\" to play playlist \"xxx\" in source \"Mediathek\"'",

    "off":"osascript -e 'tell application \"iTunes\" to stop'",

    "state":"",

    "on_value":"playing",

    "exact_match":true,

    "ssh":{

    "user":"xxx",

    "host":"xxx",

    "port":22,

    "password":"Xxx",

    "key":""

    }

    },

    {

    "accessory":"SSH",

    "name":"nanekx",

    "on":"osascript -e 'tell application \"iTunes\" to play playlist \"nanekx\" in source \"Mediathek\"'",

    "off":"osascript -e 'tell application \"iTunes\" to stop'",

    "state":"",

    "on_value":"playing",

    "exact_match":true,

    "ssh":{

    "user":"xxx",

    "host":"xxx",

    "port":22,

    "password":"xxx",

    "key":""

    }

    },

    {

    "accessory":"SSH",

    "name":"Bildschirmschoner",

    "on":"osascript -e 'tell application \"ScreenSaverEngine\" to run'",

    "off":"osascript -e 'tell application \"ScreenSaverEngine\" to quit'",

    "state":"",

    "on_value":"on",

    "exact_match":true,

    "ssh":{

    "user":"xxx",

    "host":"xxx",

    "port":22,

    "password":"xxx",

    "key":""

    }

    },

    {

    "accessory":"SSH",

    "name":"die Musik",

    "on":"osascript -e 'tell application \"iTunes\" to play'",

    "off":"osascript -e 'tell application \"iTunes\" to stop'",

    "state":"osascript -e 'tell application \"iTunes\" to get player state'",

    "on_value":"playing",

    "exact_match":true,

    "ssh":{

    "user":"xxx",

    "host":"xxx",

    "port":22,

    "password":"Xxx",

    "key":""

    }

    }

    ],

    "platforms":[


    ]

    }

  • Was ist das mit diesem Fade in/out ?

    Ich mag es wenn die Musik lieber langsam ausfadet anstelle von abrupt stoppt. Und das script macht das dann eben mit dem Fade.

    Und dank Dir für den Auszug aus Deiner .json Super Anregung. Werde davon bestimmt was übernehmen. ??

    Hilfreich?

  • Gerne ?? deine Anfrage (state) bezüglich Bildschirmschoner habe ich übernommen, allerdings klappt die Anfrage nicht wirklich... entweder „keine Antwort“ oder „aus“ aber zeigt nicht an ob’s läuft ? ist aber nur ein Schönheitsfehler ? vielleicht findet sich der entsprechende Befehl mal bzw. Wir finden einen der firm ist bezüglich AppleScript ?