Sending SSH Command to Remote Mac (iTunes / play-pause)

HABmin says yes:

57

OK! I assumed you were using the OH1 exec binding because of how you were originally configuring the item. The OH2 exec binding is… trickier to configure. I believe you can install both though, but I could be wrong. To get the OH1 bindings, you’ll need to enable Include Legacy 1.x Bindings:

Then you will see the 1.x Exec binding in Add-Ons> Bindings. With that installed, your item should do something.

i have installed both bindings atm
and i get this now:

2017-09-28 15:20:43.158 [WARN ] [ab.binding.exec.internal.ExecBinding] - doesn't find matching binding provider [itemName=iTunes, command=ON]
==> /var/log/openhab2/events.log <==
2017-09-28 15:20:43.167 [ItemStateChangedEvent     ] - iTunes changed from OFF to ON
2017-09-28 15:20:43.837 [ItemCommandEvent          ] - Item 'iTunes' received command OFF
2017-09-28 15:20:43.842 [ItemStateChangedEvent     ] - iTunes changed from ON to OFF
==> /var/log/openhab2/openhab.log <==
2017-09-28 15:20:43.850 [INFO ] [ab.binding.exec.internal.ExecBinding] - executed commandLine 'ssh xxxxxx@192.168.1.xxx 'osascript -e "tell application iTunes to playpause"''

Well, it did something! The command you are sending is a toggle, right? If so, change the item to:

Switch iTunes {nh="192.168.1.x", exec=">[*:ssh xxxx@192.168.1.x 'osascript -e \"tell application \\\"iTunes\\\" to playpause\"']"}

Before, it was only sending when the switch was set to OFF. The * captures all commands sent to the item.

looking better now, but its not playpause my itunes

2017-09-28 15:30:01.610 [ItemCommandEvent          ] - Item 'iTunes' received command OFF
2017-09-28 15:30:01.617 [ItemStateChangedEvent     ] - iTunes changed from ON to OFF
==> /var/log/openhab2/openhab.log <==
2017-09-28 15:30:01.625 [INFO ] [ab.binding.exec.internal.ExecBinding] - executed commandLine 'ssh xxxxxx@192.168.1.x 'osascript -e "tell application iTunes to playpause"''

Do you have the xxxxx in the binding config, or are you putting that in the post?

hehe , no its my username i dont want to publish also my IP :wink:

its the same commandline that i put in the terminal ( that actually works )

Try escaping the single quotes

i tried several changes, but i dont get it :frowning:

command-line that works, look like this:

ssh xxx@192.168.1.xxx 'osascript -e "tell application \"iTunes\" to playpause"'

this is my item:

Switch iTunes {nh="192.168.1.xxx", exec=">[*:ssh xxx@192.168.1.xxx 'osascript -e \"tell application \\\"iTunes\\\" to playpause\"']"}

openhab-log give me this output ( not working )

'ssh xxx@192.168.1.xxx 'osascript -e "tell application iTunes to playpause"''

Arg. Well… I don’t know openhabian. Assuming you have bash, copy this into a file named toggle.sh (name it whatever you want):

#!/bin/bash
toggleResult=`ssh xxxx@192.168.1.x 'osascript -e "tell application \"iTunes\" to playpause"'`
echo "$toggleResult"

Then execute ./toggle.sh from the command line. If that works, then you can put it into the exec binding config.

it works! - could you guide me to the right exec binding please ? thank you! <3

Just replace the command with the fully qualified path to the file (this path is a guess):

Switch iTunes {nh="192.168.1.x", exec=">[*:/var/openhab2/conf/scripts/toggle.sh]"}

thank scott, but i dont get it to work atm:

Switch iTunes {nh="192.168.1.xxx", exec=">[*:/etc/openhab2/scripts/iTunes.sh]"}

00

sh ./iTunes.sh
and
bash ./iTunes.sh
are working fine…

==> /var/log/openhab2/openhab.log <==
2017-09-28 16:34:04.394 [ERROR] [ab.binding.exec.internal.ExecBinding] - couldn't execute commandLine '/etc/openhab2/scripts/iTunes.sh'
java.io.IOException: Cannot run program "/etc/openhab2/scripts/iTunes.sh": error=13, Permission denied

Need to make it executable:

chmod u+x itunes.sh

:frowning: :frowning: i am so sorry for being dumb… :frowning: Thank you sooooooo much for your help!

05

EDIT:

i tried “sudo chmod u+x iTunes.sh” that seems to have worked…
but when i hit the button - nothing happens :frowning:

2017-09-28 16:44:23.642 [ItemCommandEvent          ] - Item 'iTunes8' received command ON
==> /var/log/openhab2/openhab.log <==
2017-09-28 16:44:23.654 [INFO ] [ab.binding.exec.internal.ExecBinding] - executed commandLine '/etc/openhab2/scripts/iTunes.sh'

Never quit, never give up!

sudo chmod u+x iTunes.sh

1 Like

thats not my personality :wink: - i edited my previous post

i dont get it :frowning: - thats my command line, that works
44

thats my .item:

Switch iTunes {nh="192.168.1.xxx", exec=">[*:/etc/openhab2/scripts/iTunes.sh]"}

LOG-Output

[INFO ] [ab.binding.exec.internal.ExecBinding] - executed commandLine 'ssh plauf@192.168.1.2 'osascript -e "tell application iTunes to playpause"''

Try saving the items file again and watch the log. If there’s an error, it won’t load it and it will log the error. If it saves without error, then all I can think of is to restart OH.

no error - no luck after restart :frowning:

Does the script execute if you just run /etc/openhab2/scripts/iTunes.sh?