girlpunk / hass-asterisk

Home Assistant platform for Asterisk integration
MIT License
12 stars 3 forks source link

Sensors all stay at OK #2

Open megapearl opened 6 years ago

megapearl commented 6 years ago

Hi,

I love your component, but cannot get it to work. Used your instructions and homeassistant gives:

sensor.asterisk_connection | connected | friendly_name: Asterisk Connection
sensor.asterisk_extension_cinema | OK | friendly_name: Asterisk Extension cinema
sensor.asterisk_extension_frontdoor | OK | friendly_name: Asterisk Extension frontdoor
sensor.asterisk_extension_kitchen | OK | friendly_name: Asterisk Extension kitchen
sensor.asterisk_extension_livingroom | OK | friendly_name: Asterisk Extension livingroom
sensor.asterisk_extension_pulsephone | OK | friendly_name: Asterisk Extension pulsephone
sensor.asterisk_extension_shed | OK | friendly_name: Asterisk Extension shed

But the Sensor always stays at OK, even if it is ringing.

When I Telnet to asterisk-15.4.1 AMI:

root@fileserver:/home/donald # telnet 10.0.0.2 5038
Trying 10.0.0.2...
Connected to fileserver.
Escape character is '^]'.
Asterisk Call Manager/4.0.3
Action: Login
ActionID: 1
Username: donald
Secret: mypasswordisinhere

Response: Success
ActionID: 1
Message: Authentication accepted

Event: FullyBooted
Privilege: system,all
Uptime: 29820
LastReload: 29820
Status: Fully Booted

Action: SIPpeers

Response: Success
EventList: start
Message: Peer status list will follow

Event: PeerEntry
Channeltype: SIP
ObjectName: cinema
ChanObjectType: peer
IPaddress: 10.0.0.22
IPport: 5060
Dynamic: yes
AutoForcerport: yes
Forcerport: no
AutoComedia: yes
Comedia: no
VideoSupport: no
TextSupport: no
ACL: no
Status: OK (14 ms)
RealtimeDevice: no
Description:
Accountcode:

Event: PeerEntry
Channeltype: SIP
ObjectName: frontdoor
ChanObjectType: peer
IPaddress: 10.0.0.45
IPport: 5060
Dynamic: yes
AutoForcerport: yes
Forcerport: no
AutoComedia: yes
Comedia: no
VideoSupport: no
TextSupport: no
ACL: no
Status: OK (5 ms)
RealtimeDevice: no
Description:
Accountcode:

Event: PeerEntry
Channeltype: SIP
ObjectName: kitchen
ChanObjectType: peer
IPaddress: 10.0.0.21
IPport: 5060
Dynamic: yes
AutoForcerport: yes
Forcerport: no
AutoComedia: yes
Comedia: no
VideoSupport: no
TextSupport: no
ACL: no
Status: OK (10 ms)
RealtimeDevice: no
Description:
Accountcode:

Event: PeerEntry
Channeltype: SIP
ObjectName: livingroom
ChanObjectType: peer
IPaddress: 10.0.0.20
IPport: 5060
Dynamic: yes
AutoForcerport: yes
Forcerport: no
AutoComedia: yes
Comedia: no
VideoSupport: no
TextSupport: no
ACL: no
Status: OK (10 ms)
RealtimeDevice: no
Description:
Accountcode:

Event: PeerEntry
Channeltype: SIP
ObjectName: mobile
ChanObjectType: peer
IPaddress: -none-
IPport: 0
Dynamic: yes
AutoForcerport: yes
Forcerport: no
AutoComedia: yes
Comedia: no
VideoSupport: no
TextSupport: no
ACL: no
Status: UNKNOWN
RealtimeDevice: no
Description:
Accountcode:

Event: PeerEntry
Channeltype: SIP
ObjectName: pulsephone
ChanObjectType: peer
IPaddress: 10.0.0.24
IPport: 5060
Dynamic: yes
AutoForcerport: yes
Forcerport: no
AutoComedia: yes
Comedia: no
VideoSupport: no
TextSupport: no
ACL: no
Status: OK (20 ms)
RealtimeDevice: no
Description:
Accountcode:

Event: PeerEntry
Channeltype: SIP
ObjectName: shed
ChanObjectType: peer
IPaddress: 10.0.0.23
IPport: 5060
Dynamic: yes
AutoForcerport: yes
Forcerport: no
AutoComedia: yes
Comedia: no
VideoSupport: no
TextSupport: no
ACL: no
Status: OK (10 ms)
RealtimeDevice: no
Description:
Accountcode:

Event: PeerEntry
Channeltype: SIP
ObjectName: sip2sip
ChanObjectType: peer
IPaddress: 81.23.228.150
IPport: 5060
Dynamic: no
AutoForcerport: yes
Forcerport: no
AutoComedia: yes
Comedia: no
VideoSupport: no
TextSupport: no
ACL: no
Status: OK (18 ms)
RealtimeDevice: no
Description:
Accountcode:

Event: PeerEntry
Channeltype: SIP
ObjectName: voipbuster-in
ChanObjectType: peer
IPaddress: 77.72.169.134
IPport: 5060
Dynamic: no
AutoForcerport: yes
Forcerport: no
AutoComedia: yes
Comedia: no
VideoSupport: no
TextSupport: no
ACL: no
Status: OK (19 ms)
RealtimeDevice: no
Description:
Accountcode:

Event: PeerEntry
Channeltype: SIP
ObjectName: voipbuster-out
ChanObjectType: peer
IPaddress: 77.72.169.129
IPport: 5060
Dynamic: no
AutoForcerport: yes
Forcerport: no
AutoComedia: yes
Comedia: no
VideoSupport: no
TextSupport: no
ACL: no
Status: OK (20 ms)
RealtimeDevice: no
Description:
Accountcode:

Event: PeerlistComplete
EventList: Complete
ListItems: 10

Action: sipshowpeer
Peer: frontdoor

Response: Success
Channeltype: SIP
ObjectName: frontdoor
ChanObjectType: peer
SecretExist: Y
RemoteSecretExist: N
MD5SecretExist: N
Context: phones
Language: nl
ToneZone: <Not set>
AMAflags: Unknown
CID-CallingPres: Presentation Allowed, Not Screened
Callgroup: 1
Pickupgroup:
Named Callgroup:
Named Pickupgroup:
MOHSuggest:
VoiceMailbox: 101@voicemail
TransferMode: open
LastMsgsSent: 7
Maxforwards: 0
Call-limit: 0
Busy-level: 0
MaxCallBR: 384 kbps
Dynamic: Y
Callerid: "Frontdoor" <7>
RegExpire: 3426 seconds
SIP-AuthInsecure: no
SIP-Forcerport: a
SIP-Comedia: a
ACL: N
SIP-CanReinvite: N
SIP-DirectMedia: N
SIP-PromiscRedir: N
SIP-UserPhone: N
SIP-VideoSupport: N
SIP-TextSupport: N
SIP-T.38Support: N
SIP-T.38EC: Unknown
SIP-T.38MaxDtgrm: 4294967295
SIP-Sess-Timers: Accept
SIP-Sess-Refresh: uas
SIP-Sess-Expires: 1800
SIP-Sess-Min: 90
SIP-RTP-Engine: asterisk
SIP-Encryption: N
SIP-RTCP-Mux: N
SIP-DTMFmode: rfc2833
ToHost:
Address-IP: 10.0.0.45
Address-Port: 5060
Default-addr-IP: (null)
Default-addr-port: 0
Default-Username: 7
Codecs: (ulaw|alaw|gsm|h263)
Status: OK (4 ms)
SIP-Useragent: VOIP DOOR PHONE 2.3.836.409
Reg-Contact: sip:frontdoor@10.0.0.45:5060
QualifyFreq: 1000 ms
Parkinglot:
SIP-Use-Reason-Header: N
Description:

ListCommands in Asterisk AMI Gives:

Action: ListCommands

Response: Success
AbsoluteTimeout: Set absolute timeout.  (Priv: system,call,all)
AgentLogoff: Sets an agent as no longer logged in.  (Priv: agent,all)
Agents: Lists agents and their status.  (Priv: agent,all)
Atxfer: Attended transfer.  (Priv: call,all)
BlindTransfer: Blind transfer channel(s) to the given destination  (Priv: call,all)
Bridge: Bridge two channels already in the PBX.  (Priv: call,all)
BridgeDestroy: Destroy a bridge.  (Priv: <none>)
BridgeInfo: Get information about a bridge.  (Priv: <none>)
BridgeKick: Kick a channel from a bridge.  (Priv: <none>)
BridgeList: Get a list of bridges in the system.  (Priv: <none>)
BridgeTechnologyList: List available bridging technologies and their statuses.  (Priv: <none>)
BridgeTechnologySuspend: Suspend a bridging technology.  (Priv: <none>)
BridgeTechnologyUnsuspend: Unsuspend a bridging technology.  (Priv: <none>)
CancelAtxfer: Cancel an attended transfer.  (Priv: call,all)
Challenge: Generate Challenge for MD5 Auth.  (Priv: <none>)
ChangeMonitor: Change monitoring filename of a channel.  (Priv: call,all)
Command: Execute Asterisk CLI Command.  (Priv: command,all)
ConfbridgeKick: Kick a Confbridge user.  (Priv: call,all)
ConfbridgeList: List participants in a conference.  (Priv: reporting,all)
ConfbridgeListRooms: List active conferences.  (Priv: reporting,all)
ConfbridgeLock: Lock a Confbridge conference.  (Priv: call,all)
ConfbridgeMute: Mute a Confbridge user.  (Priv: call,all)
ConfbridgeSetSingleVideoSrc: Set a conference user as the single video source distributed to all other participants.  (Priv: call,all)
ConfbridgeStartRecord: Start recording a Confbridge conference.  (Priv: system,all)
ConfbridgeStopRecord: Stop recording a Confbridge conference.  (Priv: system,all)
ConfbridgeUnlock: Unlock a Confbridge conference.  (Priv: call,all)
ConfbridgeUnmute: Unmute a Confbridge user.  (Priv: call,all)
ControlPlayback: Control the playback of a file being played to a channel.  (Priv: call,all)
CoreSettings: Show PBX core settings (version etc).  (Priv: system,reporting,all)
CoreShowChannels: List currently active channels.  (Priv: system,reporting,all)
CoreStatus: Show PBX core status variables.  (Priv: system,reporting,all)
CreateConfig: Creates an empty file in the configuration directory.  (Priv: config,all)
DBDel: Delete DB entry.  (Priv: system,all)
DBDelTree: Delete DB Tree.  (Priv: system,all)
DBGet: Get DB Entry.  (Priv: system,reporting,all)
DBPut: Put DB entry.  (Priv: system,all)
DeviceStateList: List the current known device states.  (Priv: call,reporting,all)
DialplanExtensionAdd: Add an extension to the dialplan  (Priv: system,all)
DialplanExtensionRemove: Remove an extension from the dialplan  (Priv: system,all)
Events: Control Event Flow.  (Priv: <none>)
ExtensionState: Check Extension Status.  (Priv: call,reporting,all)
ExtensionStateList: List the current known extension states.  (Priv: call,reporting,all)
FAXSession: Responds with a detailed description of a single FAX session  (Priv: call,all)
FAXSessions: Lists active FAX sessions  (Priv: call,all)
FAXStats: Responds with fax statistics  (Priv: reporting,all)
Filter: Dynamically add filters for the current manager session.  (Priv: system,all)
GetConfig: Retrieve configuration.  (Priv: system,config,all)
GetConfigJSON: Retrieve configuration (JSON format).  (Priv: system,config,all)
Getvar: Gets a channel variable or function value.  (Priv: call,reporting,all)
Hangup: Hangup channel.  (Priv: system,call,all)
IAXnetstats: Show IAX Netstats.  (Priv: system,reporting,all)
IAXpeerlist: List IAX Peers.  (Priv: system,reporting,all)
IAXpeers: List IAX peers.  (Priv: system,reporting,all)
IAXregistry: Show IAX registrations.  (Priv: system,reporting,all)
ListCategories: List categories in configuration file.  (Priv: config,all)
ListCommands: List available manager commands.  (Priv: <none>)
LocalOptimizeAway: Optimize away a local channel when possible.  (Priv: system,call,all)
LoggerRotate: Reload and rotate the Asterisk logger.  (Priv: system,reporting,all)
Login: Login Manager.  (Priv: <none>)
Logoff: Logoff Manager.  (Priv: <none>)
MailboxCount: Check Mailbox Message Count.  (Priv: call,reporting,all)
MailboxStatus: Check mailbox.  (Priv: call,reporting,all)
MessageSend: Send an out of call message to an endpoint.  (Priv: message,all)
MixMonitor: Record a call and mix the audio during the recording.  Use of StopMixMonitor is required to guarantee the audio file is available for processing during dialplan execution.  (Priv: system,all)
MixMonitorMute: Mute / unMute a Mixmonitor recording.  (Priv: system,call,all)
ModuleCheck: Check if module is loaded.  (Priv: system,all)
ModuleLoad: Module management.  (Priv: system,all)
Monitor: Monitor a channel.  (Priv: call,all)
MuteAudio: Mute an audio stream.  (Priv: system,all)
Originate: Originate a call.  (Priv: originate,all)
Park: Park a channel.  (Priv: call,all)
ParkedCalls: List parked calls.  (Priv: call,all)
Parkinglots: Get a list of parking lots  (Priv: call,all)
PauseMonitor: Pause monitoring of a channel.  (Priv: call,all)
Ping: Keepalive command.  (Priv: <none>)
PlayDTMF: Play DTMF signal on a specific channel.  (Priv: call,all)
PresenceState: Check Presence State  (Priv: call,reporting,all)
PresenceStateList: List the current known presence states.  (Priv: call,reporting,all)
QueueAdd: Add interface to queue.  (Priv: agent,all)
QueueChangePriorityCaller: Change priority of a caller on queue.  (Priv: <none>)
QueueLog: Adds custom entry in queue_log.  (Priv: agent,all)
QueueMemberRingInUse: Set the ringinuse value for a queue member.  (Priv: agent,all)
QueuePause: Makes a queue member temporarily unavailable.  (Priv: agent,all)
QueuePenalty: Set the penalty for a queue member.  (Priv: agent,all)
QueueReload: Reload a queue, queues, or any sub-section of a queue or queues.  (Priv: <none>)
QueueRemove: Remove interface from queue.  (Priv: agent,all)
QueueReset: Reset queue statistics.  (Priv: <none>)
QueueRule: Queue Rules.  (Priv: <none>)
QueueStatus: Show queue status.  (Priv: <none>)
QueueSummary: Show queue summary.  (Priv: <none>)
Redirect: Redirect (transfer) a call.  (Priv: call,all)
Reload: Send a reload event.  (Priv: system,config,all)
SendText: Send text message to channel.  (Priv: call,all)
Setvar: Sets a channel variable or function value.  (Priv: call,all)
ShowDialPlan: Show dialplan contexts and extensions  (Priv: config,reporting,all)
SIPnotify: Send a SIP notify.  (Priv: system,all)
SIPpeers: List SIP peers (text format).  (Priv: system,reporting,all)
SIPpeerstatus: Show the status of one or all of the sip peers.  (Priv: system,all)
SIPqualifypeer: Qualify SIP peers.  (Priv: system,reporting,all)
SIPshowpeer: show SIP peer (text format).  (Priv: system,reporting,all)
SIPshowregistry: Show SIP registrations (text format).  (Priv: system,reporting,all)
SKINNYdevices: List SKINNY devices (text format).  (Priv: system,reporting,all)
SKINNYlines: List SKINNY lines (text format).  (Priv: system,reporting,all)
SKINNYshowdevice: Show SKINNY device (text format).  (Priv: system,reporting,all)
SKINNYshowline: Show SKINNY line (text format).  (Priv: system,reporting,all)
SorceryMemoryCacheExpire: Expire (remove) ALL objects from a sorcery memory cache.  (Priv: system,all)
SorceryMemoryCacheExpireObject: Expire (remove) an object from a sorcery memory cache.  (Priv: system,all)
SorceryMemoryCachePopulate: Expire all objects from a memory cache and populate it with all objects from the backend.  (Priv: system,all)
SorceryMemoryCacheStale: Marks ALL objects in a sorcery memory cache as stale.  (Priv: system,all)
SorceryMemoryCacheStaleObject: Mark an object in a sorcery memory cache as stale.  (Priv: system,all)
Status: List channel status.  (Priv: system,call,reporting,all)
StopMixMonitor: Stop recording a call through MixMonitor, and free the recording's file handle.  (Priv: system,call,all)
StopMonitor: Stop monitoring a channel.  (Priv: call,all)
UnpauseMonitor: Unpause monitoring of a channel.  (Priv: call,all)
UpdateConfig: Update basic configuration.  (Priv: config,all)
UserEvent: Send an arbitrary event.  (Priv: user,all)
VoicemailRefresh: Tell Asterisk to poll mailboxes for a change  (Priv: user,all)
VoicemailUsersList: List All Voicemail User Information.  (Priv: call,reporting,all)
WaitEvent: Wait for an event to occur.  (Priv: <none>)

What to do? Thanks in advance,

Best Regards, Donald.

girlpunk commented 6 years ago

Currently the sensor uses asterisk's sip show peer command to check the status of an extension. Unfortunately this command doesn't show if a call is in progress, only the SIP connection status (i.e. connected/disconnected) of the extension.

Call monitoring could be done with the core show calls command, but event generation from the AMI event stream would probably be more useful.

megapearl commented 6 years ago

Ah ok, then it's not implemented yet. Is it possible to adjust the code so it reads out core show calls instead of sip show peer? and update the sensor with that status instead of "OK" ?

Maybe you can combine code from: https://www.cron.dk/asterisk-in-home-assistant-part2/ That code also isn't working for me, the sensors stays at 'Unknown' but maybe there are different Asterisk versions and commands to read out stuff are different too.

girlpunk commented 6 years ago

Would an event being fired on a call be useful for you? As you say, loading data from core show calls would show the call, but doesn't necessarily match to a specific extension, and extensions not on a call are not reported by this.