; extensions.conf - the Asterisk dial plan
;

[myHCE]
; houseautomation
exten => 5000,1(myhce),Answer()
exten => 5000,n,Set(TIMEOUT(digit)=5)
exten => 5000,n,Set(TIMEOUT(response)=10)
; skip authentication for known numbers
exten => 5000,n,GotoIf($["${CALLERID(num)}" = "01601234567"]?5000,main)
exten => 5000,n,GotoIf($["${CALLERID(num)}" = "01701234567"]?5000,main)
; authentication
exten => 5000,n,Authenticate(1137)
exten => 5000,n,Wait(1)
; main menu
exten => 5000,n(main),NoOp(Main Menu)
exten => 5000,n,Set(GLOBAL(myHCE_ext)=${EXTEN})
exten => 5000,n,Set(GLOBAL(myHCE_pExt)=5000)
exten => 5000,n,Set(GLOBAL(myHCE_pCon)=myHCE)
include => myHCE-default
exten => 5000,n(menu),AGI(fhem-speech.agi,t,"Hauptmenü")
exten => 5000,n(choice),AGI(fhem-speech.agi,t,"Bitte wählen Sie")
exten => 5000,n,AGI(fhem-speech.agi,t,"1 für Statusabfrage")
exten => 5000,n,AGI(fhem-speech.agi,t,"2 für Steuerung")
exten => 5000,n,AGI(fhem-speech.agi,t,"5 für Hilfe")
exten => 5000,n,Background(silence/3)
exten => 5000,n,Goto(choice)
; help
exten => 5000,n(help),AGI(fhem-speech.agi,t,"Menüsteuerung für alle Menüs")
exten => 5000,n,AGI(fhem-speech.agi,t,"8 zurück zum letzten Menü")
exten => 5000,n,AGI(fhem-speech.agi,t,"9 zurück zum Hauptmenü")
exten => 5000,n,AGI(fhem-speech.agi,t,"0 zum Beenden")
exten => 5000,n,Background(silence/3)
exten => 5000,n,Goto(menu)
; selection
exten => 1,1,Goto(myHCE-status,5100,status)
exten => 2,1,Goto(myHCE-control,5200,control)
exten => 5,1,Goto(5000,help)

[myHCE-default]
; global menu navigation
exten => 8,1,Goto(${myHCE_pCon},${myHCE_pExt},menu)
exten => 9,1,Goto(myHCE,5000,main)
exten => 0,1,Goto(myHCE-exit,5099,exit)
; wrong input
exten => i,1,AGI(fhem-speech.agi,t,"Falsche Eingabe.")
exten => i,2,Goto(${myHCE_ext},menu)

[myHCE-exit]
; exit
exten => 5099,n(exit),AGI(fhem-speech.agi,t,"Verbindung wird getrennt. Vielen Dank!")
exten => 5099,n,Hangup()

[myHCE-status]
exten => 5100,1(status),NoOp(Status Menu)
exten => 5100,n,Set(GLOBAL(myHCE_ext)=${EXTEN})
exten => 5100,n,Set(GLOBAL(myHCE_pExt)=5000)
exten => 5100,n,Set(GLOBAL(myHCE_pCon)=myHCE)
include => myHCE-default
; submenu device status
exten => 5100,n(menu),AGI(fhem-speech.agi,t,"Menü Statusabfrage")
exten => 5100,n(choice),AGI(fhem-speech.agi,t,"Bitte wählen Sie")
exten => 5100,n,AGI(fhem-speech.agi,t,"1 für Wetterstation")
exten => 5100,n,AGI(fhem-speech.agi,t,"2 für Rauchmelder")
exten => 5100,n,AGI(fhem-speech.agi,t,"5 für Raumthermostate")
exten => 5100,n,Background(silence/3)
exten => 5100,n,Goto(choice)
; selection
exten => 1,1,Playback(beep)
exten => 1,n,AGI(fhem-speech.agi,d,GH.ga.WE.01)
exten => 1,n,Playback(beep)
exten => 1,n,Goto(5100,status)
exten => 2,1,Playback(beep)
exten => 2,n,AGI(fhem-speech.agi,d,NN.xx.RM.01)
exten => 2,n,Playback(beep)
exten => 2,n,Goto(5100,status)
exten => 5,1,Goto(myHCE-status_fht,5110,menu)

[myHCE-status_fht]
exten => 5110,1(status),NoOp(Status Menu)
exten => 5110,n,Set(GLOBAL(myHCE_ext)=${EXTEN})
exten => 5110,n,Set(GLOBAL(myHCE_pExt)=5100)
exten => 5110,n,Set(GLOBAL(myHCE_pCon)=myHCE-status)
include => myHCE-default
; submenu fht devices
exten => 5110,n(menu),AGI(fhem-speech.agi,t,"Menü Raumthermostate")
exten => 5110,n(choice),AGI(fhem-speech.agi,t,"Bitte wählen Sie")
exten => 5110,n,AGI(fhem-speech.agi,t,"1 für Wohnzimmer")
exten => 5110,n,AGI(fhem-speech.agi,t,"2 für Schlafzimmer")
exten => 5110,n,AGI(fhem-speech.agi,t,"3 für Büro")
exten => 5110,n,AGI(fhem-speech.agi,t,"4 für Badezimmer")
exten => 5110,n,Background(silence/3)
exten => 5110,n,Goto(choice)
; selection
exten => 1,1,Playback(beep)
exten => 1,n,AGI(fhem-speech.agi,d,EG.wz.HZ)
exten => 1,n,Playback(beep)
exten => 1,n,Goto(5110,status)
exten => 2,1,Playback(beep)
exten => 2,n,AGI(fhem-speech.agi,d,EG.sz.HZ)
exten => 2,n,Playback(beep)
exten => 2,n,Goto(5110,status)
exten => 3,1,Playback(beep)
exten => 3,n,AGI(fhem-speech.agi,d,EG.bu.HZ)
exten => 3,n,Playback(beep)
exten => 3,n,Goto(5110,status)
exten => 4,1,Playback(beep)
exten => 4,n,AGI(fhem-speech.agi,d,EG.bz.HZ)
exten => 4,n,Playback(beep)
exten => 4,n,Goto(5110,status)

[myHCE-control]
include => myHCE-default
exten => 5200,1(control),AGI(fhem-speech.agi,t,"Menü Steuerung")
exten => 5200,n(menu),AGI(fhem-speech.agi,t,"Bitte wählen Sie")
exten => 5200,n,AGI(fhem-speech.agi,t,"1 für Wohnzimmer")
exten => 5200,n,AGI(fhem-speech.agi,t,"2 für Schlafzimmer")
exten => 5200,n,AGI(fhem-speech.agi,t,"3 für Büro")
exten => 5200,n,AGI(fhem-speech.agi,t,"4 für Badezimmer")
exten => 5200,n,Background(silence/3)
exten => 5200,n,Goto(menu)

exten => 1,1,Goto(myHCE-control_wohnen,5210,menu)

exten => i,1,AGI(fhem-speech.agi,t,"Falsche Eingabe.")
exten => i,2,Goto(5200,menu)

[myHCE-control_wohnen]
include => myHCE-default
exten => 5210,1(control),AGI(fhem-speech.agi,t,"Menü Steuerung")
exten => 5210,n,AGI(fhem-speech.agi,t,"Wohnzimmer")
exten => 5210,n(menu),AGI(fhem-speech.agi,t,"Bitte wählen Sie")
exten => 5210,n,AGI(fhem-speech.agi,t,"1 für Lampen")
exten => 5210,n,Background(silence/3)
exten => 5210,n,Goto(menu)

exten => 1,1,Goto(myHCE-control_wohnen-lampen,5211,set)

exten => 8,1,Goto(myHCE-control,5200,menu)

exten => i,1,AGI(fhem-speech.agi,t,"Falsche Eingabe.")
exten => i,2,Goto(5200,menu)

[myHCE-control_wohnen-lampen]
include => myHCE-default
exten => 5211,1(set),AGI(fhem-speech.agi,t,"Steuerung Lampen")
exten => 5211,n,AGI(fhem-speech.agi,d,EG.wz.SD.Licht.grp)
exten => 5211,n(menu),AGI(fhem-speech.agi,t,"1 für an")
exten => 5211,n,AGI(fhem-speech.agi,t,"2 für aus")
exten => 5211,n,Background(silence/3)
exten => 5211,n,Goto(menu)

exten => 1,1,AGI(fhem-speech.agi,s,EG.wz.SD.Licht.grp,on)
exten => 1,n,Goto(5211,set)

exten => 2,1,AGI(fhem-speech.agi,s,EG.wz.SD.Licht.grp,off)
exten => 2,n,Goto(5211,set)

exten => 8,1,Goto(myHCE-control_wohnen,5210,menu)

exten => i,1,AGI(fhem-speech.agi,t,"Falsche Eingabe.")
exten => i,2,Goto(5211,menu)

