diff --git a/fhem/contrib/voip2fhem/CHANGED b/fhem/contrib/voip2fhem/CHANGED new file mode 100644 index 000000000..dcb52c8e0 --- /dev/null +++ b/fhem/contrib/voip2fhem/CHANGED @@ -0,0 +1,3 @@ +- 2007-12-18 + - Initial Version + diff --git a/fhem/contrib/voip2fhem/HISTORY b/fhem/contrib/voip2fhem/HISTORY new file mode 100644 index 000000000..8817ae4fe --- /dev/null +++ b/fhem/contrib/voip2fhem/HISTORY @@ -0,0 +1,3 @@ +- martin, Di Dez 18 21:04:13 CET 2007 + - initial version + diff --git a/fhem/contrib/voip2fhem/README b/fhem/contrib/voip2fhem/README new file mode 100644 index 000000000..bb283662e --- /dev/null +++ b/fhem/contrib/voip2fhem/README @@ -0,0 +1,56 @@ +****** VoIP2FHEM or HOWTO control the FHEM with Asterisk ****** + +Description + * This is a HOWTO about the use of a VoIP-DECT-Telephone as a remote + controller for the FHEM-Devices. + The provided scripts are under the GPL. + + The Goal is + -- Switching the FS20-Devices + -- text2speach, the Telephone reads e.g. the measured-temp + -- Possibility to start scripts with the Remote Telephone + -- AND EVERYTHING MUST RUN ON THE NSLU2 :-) + +Technical Overview + * On the NLSU2 (or every other Linux Box) runs an Asterisk. This machine + must not be the machine with the FHEM. I bought the Voip-DECT-Telephone + Siemens Gigaset C470 IP (80.-EUR). It has a nice Webinterface and it is + possible to read in a self made telephone book. + The Asterisk calls depending on the dialed number a bash skript. After + that Asterisk plays two soundfiles < text >< value > in a loop. + + The NSLU2 is a weak machine. It always only creates a soundfile 1x and + then stores it on the harddisk. A set of prebuild voices (e.g. digits + from -20 to 90) are included. Some scripts for creating soundfiles and + automatically the telephone book are provided too. +Installation + * Go to http://fhem.dnsalias.net/voip2fhem and download the files. + -- Install with your package manager asterisk, sox, espeak. On the NLSU2: + "apt-get install asterisk sox espeak". + -- Debian: activate asterisk in the /etc/default/asterisk + -- copy the scripts voip2fhem voip2fhem_create_telefonlist + voip2fhem_create_txt2gsm to /usr/local/bin/ and be shure that they are + executable (chmod +x /usr/local/bin/voip2fhem*) + -- You can find on http://fhem.dnsalias.net/voip2fhem prepared voices: + "tar -xvzf voip2fhem_voices.tar.gz -C /" and give the correct rights + "chown -R asterisk.asterisk /var/tmp/voip2fhem" + -- cp extensions.conf and sip.conf to /etc/asterisk/ and edit these files + and the bash script /usr/local/bin/voip2fhem + -- restart/reload asterisk (/etc/init.d/asterisk restart or asterisk - + r and then "extensions reload" and "sip reload") +Hints + * -- if there isn't the required soundfile then the NSLU2 creates it. This + needs minutes (example: the word "asterisk" needs 3 min). voip2fhem + stores this file and the next time it will be used. + -- Use the script voip2fhem_create_txt2gsm on a faster machine to create + the sounds. Usage: voip2fhem_create_txt2gsm "I love FHEM". The soundfile + is then automatically copied to /var/tmp/voip2fhem/ + -- it is also possible to connect the ASTERISK with the rest of the world + (e.g. Sipgate, 1und1) :-) + -- for debug asterisk: "asterisk -r", "sip debug" + + +Have fun and success :-) +Martin Haas +fhem@martin-haas.de + diff --git a/fhem/contrib/voip2fhem/README.html b/fhem/contrib/voip2fhem/README.html new file mode 100644 index 000000000..13aeb473d --- /dev/null +++ b/fhem/contrib/voip2fhem/README.html @@ -0,0 +1,55 @@ + + + + +

VoIP2FHEM or HOWTO control the FHEM with Asterisk


+Description
+ + + +Technical Overview
+ + +Installation
+ + +Hints
+ + + + +

+Have fun and success :-)
+Martin Haas
+fhem@martin-haas.de
+
+ + diff --git a/fhem/contrib/voip2fhem/extensions.conf b/fhem/contrib/voip2fhem/extensions.conf new file mode 100644 index 000000000..261fc32a4 --- /dev/null +++ b/fhem/contrib/voip2fhem/extensions.conf @@ -0,0 +1,47 @@ +[FHEM] + + +; Important for voip2fhem: System(PATH_TO_voip2fhem NAME_FHEM_DEV "TEXT FOR TELEPHONBOOK and espeak" FHEM_TYPE) +; after every change of this file make "asterisk -r" and then "extensions reload" + +exten => 3001,1,Answer() +exten => 3001,2,System(/usr/local/bin/voip2fhem ks300 "Aussentemperatur ." KS300) +exten => 3001,3,Playback(/tmp/asterisk1) +exten => 3001,n,Playback(/tmp/asterisk2) +exten => 3001,n,Wait(3) +exten => 3001,n,Goto(3) + +exten => 3002,1,Answer() +exten => 3002,2,System(/usr/local/bin/voip2fhem kesselu "Kesseltemperatur kesselu ." HMS100) +exten => 3002,3,Playback(/tmp/asterisk1) +exten => 3002,4,Playback(/tmp/asterisk2) +exten => 3002,n,Wait(3) +exten => 3002,n,Goto(3) + +exten => 3003,1,Answer() +exten => 3003,2,System(/usr/local/bin/voip2fhem wz "Wohnzimmertemperatur ." FHT) +exten => 3003,3,Playback(/tmp/asterisk1) +exten => 3003,4,Playback(/tmp/asterisk2) +exten => 3003,n,Wait(3) +exten => 3003,n,Goto(3) + +exten => 3004,1,Answer() +exten => 3004,2,System(/usr/local/bin/voip2fhem nachto "Nachtlicht oben" FS20) +exten => 3004,3,Playback(/tmp/asterisk1) +exten => 3004,n,Wait(3) +exten => 3004,n,Goto(3) + +exten => 3005,1,Answer() +exten => 3005,2,System(/usr/local/bin/voip2fhem stuwz1 "Fernsehlicht" FS20) +exten => 3005,3,Playback(/tmp/asterisk1) +exten => 3005,n,Wait(3) +exten => 3005,n,Goto(3) + +exten => 3006,1,Answer() +exten => 3006,2,System(/usr/local/bin/voip2fhem ofen "Status Ofen ." FS20STATE) +exten => 3006,3,Playback(/tmp/asterisk1) +exten => 3006,n,Playback(/tmp/asterisk2) +exten => 3006,n,Wait(3) +exten => 3006,n,Goto(3) + + diff --git a/fhem/contrib/voip2fhem/sip.conf b/fhem/contrib/voip2fhem/sip.conf new file mode 100644 index 000000000..190256b23 --- /dev/null +++ b/fhem/contrib/voip2fhem/sip.conf @@ -0,0 +1,13 @@ +[general] +context=FHEM +port=5060 +bindaddr=0.0.0.0 + + +; FHEM: VoIP-Telephone with the Name/Number 2000 and the password 1234 +[2000] +type=friend +context=FHEM +secret=1234 +host=dynamic + diff --git a/fhem/contrib/voip2fhem/voip2fhem b/fhem/contrib/voip2fhem/voip2fhem new file mode 100755 index 000000000..ca1ffe27f --- /dev/null +++ b/fhem/contrib/voip2fhem/voip2fhem @@ -0,0 +1,72 @@ +#!/bin/bash +# Interface from Asterisk to fhem +# this file is called from /etc/asterisk/extensions.conf +# Martin Haas 071214 + + + +# if you want to use the english spoken espeak then change "espeak -v de" to "espeak" + + +FHEM=localhost # if not localhost then set the port inside of FHEM to global +FHEMport=7072 +location=/var/tmp/voip2fhem # later the owner must be asterisk.asterisk! + +[[ ! -d $location ]] && mkdir $location + + + +#################################################### +## +providesound() +{ + lvoice="$location/$(echo $voice | sed -e 's/-//g' -e 's/[ .:]/_/g').gsm" + + echo $lvoice + + if [ ! -f $lvoice ] + then + espeak -v de -s 120 -w /tmp/asterisk.wav "$voice" + sox /tmp/asterisk.wav -r 8000 -c 1 $lvoice resample -ql + fi + cp $lvoice /tmp/asterisk$type.gsm + +} + + +################################### +## +case "$3" in + + ###################################### + KS300) + temperature=$(echo "list $1" | netcat -w1 $FHEM $FHEMport | grep temperature | awk '{print $4}') + [[ ${temperature:0:1} == - ]] && temperature="minus $temperature" ## negativ temperature + voice=$2; type=1; providesound "$voice" $type + voice=$temperature; type=2; providesound "$voice" $type + ;; + ###################################### + FHT) + temperature=$(echo "list $1" | netcat -w1 $FHEM $FHEMport | grep measured-temp | awk '{print $4}') + voice=$2; type=1; providesound "$voice" $type + voice=$temperature; type=2; providesound "$voice" $type + ;; + ###################################### + FS20STATE) + state=$(echo "list $1" | netcat -w1 $FHEM $FHEMport | grep STATE | awk '{print $2}') + voice=$2; type=1; providesound "$voice" $type + voice=$state; type=2; providesound "$voice" $type + ;; + ##################################### + HMS100) + temperature=$(echo "list $1" | netcat -w1 $FHEM $FHEMport | grep STATE | awk '{print $3}') + voice=$2; type=1; providesound "$voice" $type + voice=$temperature; type=2; providesound "$voice" $type + ;; + ###################################### + FS20) + echo "set $1 toggle" | netcat -w1 $FHEM $FHEMport + voice=$2; type=1; providesound "$voice" $type + ;; +esac + diff --git a/fhem/contrib/voip2fhem/voip2fhem_create_telefonlist b/fhem/contrib/voip2fhem/voip2fhem_create_telefonlist new file mode 100755 index 000000000..bae6edd86 --- /dev/null +++ b/fhem/contrib/voip2fhem/voip2fhem_create_telefonlist @@ -0,0 +1,30 @@ +#!/bin/bash +# this skript creates for e.g. the Siemens C470 IP a telephone book which can be read in by the webinterface of the telephone +# The script reads the /etc/asterisk/extensions.conf and creates the /tmp/teledir.vcf +# Martin Haas 071216 +# + +# you need the tool unix2dos :-( It is depending on your Distribution included in unix2dos or tofrodos + +telefonbook=/tmp/teledir.vcf + +rm -f $telefonbook + +grep System /etc/asterisk/extensions.conf | grep -v '^;' | \ + +while read fhemdev +do + number=$(echo $fhemdev | cut -d, -f1 | awk '{print $3}') + name=$(echo $fhemdev | cut -d\" -f2 | sed 's/\./ /g') + + echo "BEGIN:VCARD" >>$telefonbook + echo "VERSION:2.1" >>$telefonbook + echo "FN:$name" >>$telefonbook + echo "N:$name" >>$telefonbook + echo "TEL;HOME:$number" >>$telefonbook + echo "END:VCARD" >>$telefonbook + echo >>$telefonbook + +done + +unix2dos $telefonbook diff --git a/fhem/contrib/voip2fhem/voip2fhem_create_txt2gsm b/fhem/contrib/voip2fhem/voip2fhem_create_txt2gsm new file mode 100755 index 000000000..904e70a05 --- /dev/null +++ b/fhem/contrib/voip2fhem/voip2fhem_create_txt2gsm @@ -0,0 +1,79 @@ +#!/bin/bash +# weak machines need a long time to create a gsm-Voicefile. +# this script searches for an existing voice and if not it will create it +# Martin Haas 071217 + +# The NSLU2 needs e.g. 5min to convert the word "Aussentemperatur" + +# Call this file (on a faster machine :-) ) with the words to convert +# e-g voip2fhem_create_txt2gsm "This is a test" +# otherwise this script creates number from -20 to +90 + +# hint: cat examplefile | while read line; do ./voip2fhem_create_txt2gsm "$line"; done + + + + +location=/var/tmp/voip2fhem # later the owner must be asterisk.asterisk + +[[ ! -d $location ]] && { mkdir $location; chown asterisk.asterisk $location; } + + + + +################################################### +### +CreateVoices() +{ + lvoice="$location/$(echo $voice | sed 's/[ ,.:]/_/g').gsm" + + echo $lvoice + + if [ ! -f $lvoice ] + then + espeak -v de -s 120 -w /tmp/asterisk.wav "$voice" + sox /tmp/asterisk.wav -r 8000 -c 1 $lvoice resample -ql + fi +} + + + + + +################################################### +## main + +if [[ $1 ]] +then + voice=$1 + CreateVoices "$voice" + +else + +for i in `seq -20 90 ` -0 +do + if [ ${i:0:1} == - ] + then + m="minus $i" ## negativ temperature + voice=$(echo $m | sed -e 's/-//g' -e 's/\./,/g') # English people: change , against . + else + voice=$(echo $i | sed 's/\./,/g') # English people: change , against . + fi + + CreateVoices "$voice" + + origvoice=$voice + + + for k in `seq 0 9` + do + + voice="$origvoice,$k" # English people: change , against . + CreateVoices "$voice" + voice=$origvoice + + done + +done + +fi