mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-05 17:48:44 +00:00
voip2fhem added to conrib/
git-svn-id: https://svn.fhem.de/fhem/trunk@126 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
09c5edb703
commit
12db6bfe8f
3
fhem/contrib/voip2fhem/CHANGED
Normal file
3
fhem/contrib/voip2fhem/CHANGED
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
- 2007-12-18
|
||||||
|
- Initial Version
|
||||||
|
|
3
fhem/contrib/voip2fhem/HISTORY
Normal file
3
fhem/contrib/voip2fhem/HISTORY
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
- martin, Di Dez 18 21:04:13 CET 2007
|
||||||
|
- initial version
|
||||||
|
|
56
fhem/contrib/voip2fhem/README
Normal file
56
fhem/contrib/voip2fhem/README
Normal file
@ -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
|
||||||
|
|
55
fhem/contrib/voip2fhem/README.html
Normal file
55
fhem/contrib/voip2fhem/README.html
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1> VoIP2FHEM or HOWTO control the FHEM with Asterisk</h1><br>
|
||||||
|
<b>Description</b><br>
|
||||||
|
<ul>This is a HOWTO about the use of a VoIP-DECT-Telephone as a remote controller for the <a href='http://fhem.de'>FHEM-Devices.</a><br>The provided scripts are under the GPL.<br>
|
||||||
|
<br>
|
||||||
|
The Goal is<br>
|
||||||
|
-- Switching the FS20-Devices <br>
|
||||||
|
-- text2speach, the Telephone reads e.g. the measured-temp <br>
|
||||||
|
-- Possibility to start scripts with the Remote Telephone<br>
|
||||||
|
-- AND EVERYTHING MUST RUN ON THE NSLU2 :-)<br>
|
||||||
|
<br>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
<b>Technical Overview</b><br>
|
||||||
|
<ul>
|
||||||
|
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.<br>
|
||||||
|
The Asterisk calls depending on the dialed number a bash skript. After that Asterisk plays two soundfiles < text >< value > in a loop.<br>
|
||||||
|
<br>
|
||||||
|
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.
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<b>Installation</b><br>
|
||||||
|
<ul>
|
||||||
|
Go to http://fhem.dnsalias.net/voip2fhem and download the files.<br>
|
||||||
|
-- Install with your package manager asterisk, sox, espeak. On the NLSU2: "apt-get install asterisk sox espeak".<br>
|
||||||
|
-- Debian: activate asterisk in the /etc/default/asterisk<br>
|
||||||
|
-- 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*)<br>
|
||||||
|
-- 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" <br>
|
||||||
|
-- cp extensions.conf and sip.conf to /etc/asterisk/ and edit these files and the bash script /usr/local/bin/voip2fhem<br>
|
||||||
|
-- restart/reload asterisk (/etc/init.d/asterisk restart or asterisk -r and then "extensions reload" and "sip reload")
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<b>Hints</b><br>
|
||||||
|
<ul>
|
||||||
|
-- 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.<br>
|
||||||
|
-- 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/<br>
|
||||||
|
-- it is also possible to connect the ASTERISK with the rest of the world (e.g. Sipgate, 1und1) :-)<br>
|
||||||
|
-- for debug asterisk: "asterisk -r", "sip debug"<br>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<br><br>
|
||||||
|
Have fun and success :-)<br>
|
||||||
|
Martin Haas<br>
|
||||||
|
fhem@martin-haas.de<br>
|
||||||
|
<br>
|
||||||
|
</body>
|
||||||
|
</html>
|
47
fhem/contrib/voip2fhem/extensions.conf
Normal file
47
fhem/contrib/voip2fhem/extensions.conf
Normal file
@ -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)
|
||||||
|
|
||||||
|
|
13
fhem/contrib/voip2fhem/sip.conf
Normal file
13
fhem/contrib/voip2fhem/sip.conf
Normal file
@ -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
|
||||||
|
|
72
fhem/contrib/voip2fhem/voip2fhem
Executable file
72
fhem/contrib/voip2fhem/voip2fhem
Executable file
@ -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
|
||||||
|
|
30
fhem/contrib/voip2fhem/voip2fhem_create_telefonlist
Executable file
30
fhem/contrib/voip2fhem/voip2fhem_create_telefonlist
Executable file
@ -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
|
79
fhem/contrib/voip2fhem/voip2fhem_create_txt2gsm
Executable file
79
fhem/contrib/voip2fhem/voip2fhem_create_txt2gsm
Executable file
@ -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
|
Loading…
x
Reference in New Issue
Block a user