====Whats-App-Nachrichten mit dem Pi versenden==== Es gibt kaum einen Dienst, der so polarisiert wie WhatsApp. Für viele ist ein Leben ohne diesen Messenger kaum noch vorstellbar. Mit geringem Aufwand können Sie einen Raspberry Pi so konfigurieren, dass damit der Versnad von Nachrichten über WhatsApp möglich wird. Das ist für alle Einsatzgebiete des kleinen Rechners praktisch, in denen es darum geht, über aktuelle Ereignisse informiert zu werden - zum Beispiel bei der Heimüberwachung. Um den Minirechner mit der Sendefunktion auzurüsten, starten Sie entweder auf der grafischen Oberfläche eine Konsole, oder Sie loggen sich per SSH auf dem Rechner ein. Bringen Sie zuerst die Paketquellen, das System sowie die Firmware auf den aktuellen Stand. Das erledigen diese Kommandos: sudo apt-get update sudo apt-get upgrade sudo rpi-update Danach installieren Sie einige Software-Pakete. Das geht ebenfalls am schnellsten über die Konsole: sudo apt-get install python-dateutil sudo apt-get install python-dev sudo apt-get install libevent-dev sudo apt-get install ncurses-dev Jetzt besorgen Sie sich mit wget das für das Versenden notwendige Script und entpacken es: wget https://github.com/tgalal/yowsup/archive/master.zip unzip master.zip Führen Sie dann im betreffenden Ordner das Setup-Programm aus: sudo python setup.py install Optional können Sie eine Datei für die Konfiguration anlegen. Unbedingt notwendig ist das mit der aktuellen Version des Scrips alledings nicht. Jetzt können Sie Ihren Registrierungscode von WhatsApp abholen. Wie Sie sicherlich wissen, kann immer nur eine Rufnummer mit dem Dienst verbunden werden. Somit gehen Nachrichten, die an Ihre Nummer gerichtet sind, dann auch an den Raspberry. Wenn Sie regelmäßig nur Nachrichten mit dem kleinen Computer versenden wollen, besorgen Sie sich am besten eine separate Prepaid-Karte. Die Registrierung am Server müssen Sie auf der Konsole erledigen. Sie geben dazu Ihre Rufnummer im internationalen Format ein: python yowsup-cli registration --requestcode sms --phone 49[Tel.-Nr] --cc 49 Danach sollten Sie an das Telefon eine SMS mit dem Code erhalten. Diese müssen Sie dem Raspberry dan noch mitteilen: python yowsup-cli registration --register CODE --phone 49TELEFONNUMMER --cc 49 **ACHTUNG:** Als Rückgabe erhalten Sie auf der Konsole ein Passwort angezeigt. Dieses müssen Sie sich notieren. Damit Sie nun nicht jedes Mal die Rufnummer und das Passwort übergeben müssen, legen Sie am besten eine Konfigurationsdtei an. Dies kann mit jedem Editor erledigt werden. In unserem Fall soll die Datei "config.bsp" heißen und Folgendes enthalten: cc=49 # Länderkennung phone=4912345678987 # Handynummer id= # frei lassen password=ABCDEFGH # das notierte Passwort Nachdem Sie diese Datei gespeichert haben, können Sie eine erste Testnachricht versenden: python yowsup-cli demos -c config.bsp -s NUMMER "Das ist ein Test!" Wenn Sie regelmäßig auf der grafischen Oberfläche des Raspberry arbeiten, können Sie mit dem Web-Client von WhatsApp auch Nachrichten senden und empfangen. Dazu benötigen Sie einen Browser sowie Ihr Smartphone,, auf dem WhatsApp installiert ist. Installieren Sie in einem Terminal mit sudo apt-get install iceweasel den Browser Iceweasel (Firefox). Rufen Sie damit die Seite //https:%%//%%web.whatsapp.com/// auf. Der Dienst zeigt Ihnen einen QR-Code, den Sie mit dem Client fotografieren müssen. Dazu nutzen Sie die Einstellungen der Software (iOS) oder den Menüpunkt "WhatsApp Web" (Android). Danach stehen Ihnen Chats und Gruppen wie gewohnt zur Verfügung. **Achtung:** Wenn sich Ihr Handy nicht mit dem WLAN verbinden kann, dann nutzt WhatsApp für diesen Service die mobile Datenverbindung. Die Kommunikation geht also von Ihrem Volumen ab. LinuxWelt 1/2016 S. 62f ---- ====How to Control a Raspberry Pi Using WhatsApp==== We control a Raspberry Pi by using a tool called Yowsup. Yowsup is basically a python library which offers all the features of WhatsApp on the Raspberry Pi. It functions exactly the same on a Raspberry Pi as a Whatsapp client works on a smartphone. Now let’s go through the steps for controlling Raspberry Pi via Whatsapp. ===Step 1=== The first step is to install the Yowsup python library on Raspberry Pi. But before doing that, it is recommended to upgrade all the previous packages installed in Raspberry Pi. To update the previously installed packages, you need to run the following command. sudo apt-get update ===Step 2=== Once all the packages are updated, you need to update the firmware. Command for the same is given below. sudo rpi-update ===Step 3=== After upgrading previously installed packages, it’s time to install all the necessary new packages on Raspberry Pi, which are required to install to Yowsup. sudo apt-get install python-dateutil sudo apt-get install python-setuptools sudo apt-get install python-dev sudo apt-get install libevent-dev sudo apt-get install ncurses-dev ===Step 4=== Now its time to install the downloaded Yowsup library. For this, run the following command to download the library. git clone git://github.com/tgalal/yowsup.git ===Step 5=== Once the Yowsup library downloaded, you need to install it. The following command will help you get into the Yowsup folder and install the library successfully. cd yowsup sudo python setup.py install ===Step 6=== Once the installation of Yowsup library is done successfully, we need to register the WhatsApp. For this, you need to know your country code (cc), mobile country code (mcc) and mobile network code (mnc). If you don’t know your cc, mcc and mnc, use the following command to know about it. python yowsup-cli registration –requestcode sms –phone 91 xxxxxxxxxx –cc 91 –mcc 405 –mnc 035 Write the complete number replacing the xxx with the original digits. 91 is the country code which should be replaced with your country code. Similarly, other details can be different depending upon your details. ===Step 7=== As sooner you run that command, all the requested data will show up as the result and you will get the code on your mobile. Now you need to enter that code to register the Whatsapp using the following command. python yowsup-cli registration --register xxx-xxx --phone 91xxxxxxxxxx --cc 91 Replace xxx-xxx with the code you received on your mobile. With that, registration would be completed. But remember, don’t use the same number you use for your daily Whatsapp messaging. One Whatsapp number can be used only in one device. ===Step 8=== Okay, it’s now time to use the Whatsapp. The process is simple. All you need to do is to enter your phone number and password. You need to save the config file inside the Yowsup folder using the following command. sudo nano /home/pi/yowsup/config ==Step 9=== Once done, quickly copy the following command and paste it into the config file. ## Actual config starts below ## cc=49 #if not specified it will be autodetected phone=39xxxxxxxxxx password=xxxxxxxxxxxxxxx ===Step 10=== Now navigate to the Yowsup folder by the following command cd /home/pi/yowsup and start yowsup-cli demos. Command for the same is given below. yowsup-cli demos –yowsup –config config As sooner you do this, you will be encountered with Yowsup prompt. Now first use ‘/L’ command for login. If you are confused about the commands, use “/help” command to see all the available commands. Okay, after using the /L command, enter the login credential which you saved in the config file. If you want to send a message to the desired number, use the following command. /message send 39xxxxxxxxxx "This is an exmaple message sent from Raspberry Pi" The message sent will be displayed on the Raspberry Pi. So that’s how to control a Raspberry Pi using WhatsApp. At a glance, this guide might seem confusing, but once you will go through all the steps carefully, the things will appear really easy! If you encounter any problem while following the steps, feel free to contact us via the comment box below. [[http://www.knowledgecage.com/how-to-control-a-raspberry-pi-using-whatsapp/18500/|Quelle]]