Agent Log In/Out via BLF

Hello everyone!

I have SIP Phone which supports BLF keys, same I have already configured queue in Asterisk with dynamic member.

Now I want to see via BLF key if Agent Log on or Log off.

Can someone have done it?

I have done it )))

My example

exten => _*95555,1,Set(state=${DEVICE_STATE(Custom:${CHANNEL(peername)})})
same => n,ExecIf($["${state}"=“INUSE”]?Goto(remove_mem))
same => n,ExecIf($["${state}"=“NOT_INUSE”]?Goto(add_mem))
same => n,Hangup()
same => n(remove_mem),Set(DEVICE_STATE(Custom:${CHANNEL(peername)})=NOT_INUSE)
same => n,RemoveQueueMember(infotel,${CUT(CHANNEL(name),-,1)})
same => n,Playback(agent-loggedoff)
same => n,Hangup()
same => n(add_mem),Set(DEVICE_STATE(Custom:${CHANNEL(peername)})=INUSE)
same => n,AddQueueMember(infotel,${CUT(CHANNEL(name),-,1)})
same => n,Playback(agent-loginok)
same => n,Hangup()