I have made a video long time ago connectivity between Tasker and Raspberry Pi, however, it feels slightly outdated. I checked the library of my posts and I have never created one about this particular issue. So to keep it relevant to my previous post about Tasker and Raspberry Pi here is a simple guide how to get the Tasker working with the Raspberry Pi. We are going to look at  AutoRemote and AutoTools ways of communicating with the Raspberry Pi.

TL:DR : You want  AutoRemote, as AutoTools won’t allow you to receive Raspberry Pi initiated communication.




SSH – AutoRemote, Tasker and Raspberry Pi

unnamed-2I will assume, that you know how AutoRemote plugin works already. If not please have a look on a tutorial here.

    1. You need curl installed on your Raspberry Pi (new Raspbian Jessie versions should have it already)
       sudo apt-get install curl
    2. Open AutoRemote app and get the personal URL. Open in in the web browser – you will see the URL change once the website is loaded
      arCopy the key that starts after the: http://autoremotejoaomgcd.appspot.com/?key=  you will need this to complete the URL later
    3. Check your external IP or set up a DNS if you want to have an access to the device from outside of your local network. Google My IP to get the IP address or use http://www.noip.com/   to set up a free domain. Make a note of it.
    4. Edit the following URL accordingly:
      curl "http://autoremotejoaomgcd.appspot.com/registerpc?key=YOUR_KEY&name=NAME_TO_APPEAR_ON_YOUR_PHONE&id=ANY_UNIQUE_ID&type=linux&publicip=YOUR_PUBLIC_IP_OR_HOST_NAME&localip=$(sudo ifconfig eth0 |grep "inet addr" |awk '{print $2}' |awk -F: '{print $2}')"

      YOUR_KEY – The key obtained in the point 2
      NAME_TO_APPEAR_ON_YOUR_PHONE – Give it a name ie RPI3
      ANY_UNIQUE_ID – make up an ID ie 314
      YOUR_PUBLIC_IP_OR_HOST_NAME – the IP or DNS obtained in the point 3

      Modify the URL and open up a terminal on the Raspberry Pi you wish to register. It will register the device running the AutoRemote. Paste the URL and hit enter.

    5. Open up a file /etc/ssh/sshd_config
      sudo nano /etc/ssh/sshd_config

      and scroll down to the end. You will need to add the following line

      KexAlgorithms diffie-hellman-group1-sha1,diffie-hellman-group-exchange-sha1

      Then Ctrl-X to close and Y to save the changes.

    6. Your device will be visible in the AutoRemote app, you should be prompted to enter SSH username and password. If this won’t happen automatically when clicking on the device in AutoRemote hold down the device to bring up the options.  Enter the username and password  (default:  pi, raspberry)screenshot_20161124-215148
    7. Click a message icon and send a test command:
      date

      screenshot_20161124-215216-01 You should see the current date in the response toast. If you have disabled the toasts previously, you can access the log to check if the message has been received. Each response issued back to the AutoRemote will have the following format: linux=:=message

    8. To send messages back to the tasker you can use either:
      curl “http://autoremotejoaomgcd.appspot.com/sendmessage?key=YOUR_KEY&message=TYPE_MESSAGE_HERE

      OR

      import urlib.request
      urllib.request.urlopen(http://autoremotejoaomgcd.appspot.com/sendmessage?key=YOUR_KEY&message=TYPE_MESSAGE_HERE).read()

      SSH – AutoTools, Tasker and Raspberry Pi

      autotools-android-apps-on-google-playAutoTools is easier to use and set up, however, the main limitation is that you cannot message the Tasker enabled device directly. When the SSH message is initiated, you will obtain the response from the Raspberry Pi. You will have to forward the port 22 in your router (default one unless changed) and point it to the local IP of the Raspberry Pi. Mine is 192.168.0.12.

      screenshot_20161124-223247

      1. Enter the IP or Hostname
      2. Enter the port number (22 is the default one for SSH)
      3. Enter your username (default: pi)
      4. Enter the password (default: pi)
      5. Enter a command to run (ie: date)
      6. Enter the name of the variable which will hold the response (ie: result)
      7. If you want to add files add local paths or online folders




      Easy enough. Bear in mind, that if want the Raspberry Pi to send a message to the phone or tablet, it won’t be possible until you will add another solution – ie AutoRemote

SHARE