VoIP to FHEM: Unterschied zwischen den Versionen

Aus FHEMWiki
K (Krikan verschob die Seite VoIP to fhem nach VoIP to FHEM: FHEM(TM))
 

Aktuelle Version vom 20. Januar 2017, 11:19 Uhr

VoIP2FHEM or HOWTO control the FHEM with Asterisk

Description

This is a HOWTO about the use of a VoIP-DECT-Telephone (or every phone of a fritzbox) 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 SHOULD RUN ON THE NSLU2 (or other small machines):-)

Technical Overview

On the NLSU2 (or every other Linux Box) runs an Asterisk. This machine needs not to 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. If you have a Fritzbox you do not need such special devices (see below).

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 [1] and download the files.

  • Install with your package manager asterisk, sox, espeak, libsox-fmt-gsm. On Debian based Machines: "apt-get install asterisk sox espeak libsox-fmt-gsm"

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*)
  • extract the 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")

Example extensions.conf

this is an example of an extensions.conf

[FHEM]
; 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)

Example sip.conf

this is an example of a sip.conf

[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



Alternative use of the Fritzbox

If you have a Fritzbox you can register your Asterisk there. After that you can use every telephone, which is registered on the Fritzbox. In this case you do not need further devices like a special VOIP-Device.

Go to something like "Internettelefonie" and register Asterisk. The Registrar is the IP-Address of the Asterisk-Box. The Calling-Number is the internal number like 2000 in this example. User name (2000) and password (1234) are from the sip.conf:

##############
; Example:
; FHEM: VoIP-Telephone with the Name/Number 2000 and the password 1234
[2000]
type=friend
context=FHEM
secret=1234
host=dynamic

The Fritzbox will give you a short number (e.g. *123#) -- after that you can call your skripts with *123#3001#with every telephone of your Fritzbox.

Hints

  • if there isn't the required soundfile then the NSLU2 creates it. This needs on this weak machine 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"