Installing XMPP Notification System
XMPP is a protocol that is among other things used or supported by many chat systems, including Google hangouts. Using the XMPP protocol, you can send notifications directly to any supported chat client easily and without complications. This page discuss only notifications, unlike XMPP-IoT (which example Dombot make use of) which also provides IoT control through the XMPP protocol but is more complicated to install. Note that sendxmpp opens a connection for each notification so it takes a second or two to send the notification. A slightly more complicated system can probably be written to have sendxmpp running in -n mode and pipe the notification into it. As I use Hangouts this setup is geared toward google hangouts but it should work with very little modifications with other systems as well.
These instructions assume you have already installed Domoticz on a Raspberry Pi running Raspbian - however in general they will be a good guide for installation under similar Linux systems.
First step is to create a user for your home automation system. IMPORTANT: Do not use your own user and do not give it the same password as your user. For Google Hangouts/talk its best to "introduce" your new user to your user by adding them to each other contact book. This allows them to communicate with each other if your user is not open to all for chat. From now on this new user will be called [email protected]
Second step, enable less secure apps in google : https://support.google.com/accounts/answer/6010255?hl=en
Third step is to install sendxmpp:
sudo apt-get install sendxmpp
Now, create/edit the configuration file:
sudo nano /root/.sendxmpprc
Add the following line:
[email protected];talk.google.com replacethiswithHAUSERpassword
Save and change permissions:
sudo chmod 600 /root/.sendxmpprc
Test that it works (replace HAUSER with the user you created without the domain, replace my.user with your primary user:
sudo sh -c 'echo hi | sendxmpp -t -u HAUSER -o gmail.com [email protected]'
Assuming this worked, we are almost done!
Now, create the following script in /home/pi/domoticz/scripts/notify_gtalk.sh
#!/bin/sh echo "$4" | sudo sendxmpp -t -u $1 -o $2 $3
Last stage!!!! In domoticz, go to the Setup->settings->notifications tab, in the Custom HTTP/Action part:
- Check enable
- set #FIELD1=HAUSER
- set #FIELD2=gmail.com
- set [email protected]
- set URL/Action=script://home/pi/domoticz/scripts/notify_gtalk.sh #FIELD1 #FIELD2 #TO "#MESSAGE"
Press the "Test" button and see that you get the notification. Don't forget to "Apply setting"!!!! You are good to go!