Night Mode displayed in browser--Bounty

alexis
Posts: 54
Member Since:
2006-05-31

I am a non-techie. I can manage a system via FreePbx, I understand Polycom setup. I don't know much of nuts and bolts of asterisk and I don't know php. Here lies the problem:

I use BobH's implementation of night mode/day mode toggling
http://www.trixbox.org/forums/trixbox-forums/help/system-wide-do-...

[custom-daymode]
exten => s,1,gotoif($[${DB(daynightmode/currentmode} = daymode]?ext-group,1000,1:ivr-2,s,1)

[custom-day-night-mode]
exten => *28,1,Answer()
exten => *28,2,Set(daynightmode=${DB(daynightmode/currentmode})
exten => *28,3,gotoif($[${daynightmode} = daymode]?30:20)

exten => *28,20,Set(DB(daynightmode/currentmode)=daymode)
exten => *28,21,Playback(day&reception&enabled)
exten => *28,22,Hangup()

exten => *28,30,Set(DB(daynightmode/currentmode)=nightmode)
exten => *28,31,Playback(day&reception&disabled)
exten => *28,32,Hangup()

I would like to be able to have a phone browser to display the status change.
The way I see a solution is as such:
a php code would query DB daynightmode and depending on the value serve the appropriate page.

To accomplish that, I wold need to know XML, php and how to query that database or offer bounty hoping that somebody in the big TrixBox community would help me out.

alexis



JasonR
Posts: 345
Member Since:
2006-05-31
Ward's Phone Genie at

Ward's Phone Genie at NerdVittles can do this. It reads the database with a nifty little php script. It would be pretty trivial to write a really small php page to query the database through the nv-genie.php and display one of two results depending on what's in the DB.

http://bestof.nerdvittles.com/applications/phonegenie/

- Jason

--

Jason Reiser
http://www.centpbx.com/



alexis
Posts: 54
Member Since:
2006-05-31
The database nv-genie.php queries is not the same. I need some

The database nv-genie.php queries is not the same. I need somebody with php knowledge to help me out. I am willing to pay.

alexis



philippel
Posts: 700
Member Since:
2006-05-31
alexis, you may want to come

alexis,
you may want to come and discuss what you are looking for in the freepbx forum or on #freepbx-dev (IRC). If you are willing to pay to have something done - it is usually a lot more beneficial to have it 'properly' and officially done so it becomes part of the main freepbx code base. However - discussing it here more often then not is not seen by and of the freepbx dev team.

--

Philippe Lindheimer, FreePBX® Project Leader
http://freepbx.org - #freepbx on irc.freenode.net
http://freepbx.org/forums - The FreePBX® Forum
OTTS Training - Apr 27-29, Huntsville, AL



pkaplan
Posts: 209
Member Since:
2007-02-28
Alexis, If I'm reading you

Alexis,

If I'm reading you correctly, the core of what you are looking for is:

<?php
    exec( "asterisk -r -x 'DATABASE GET daynightmode currentmode'", $response);

    foreach( $response as $index)
        echo $index . "<br>";
?>

Put that in a php file on your asterisk box in the /var/www/html directory and it should be callable from a browser.



alexis
Posts: 54
Member Since:
2006-05-31
pkaplan, thanks a lot!

your code works perfectly when called from IE browser. I get a response such as:

Value: daymode
Verbosity is at least 1

When I call it from polycom microbrowser,
I get:
XML Error: (1,0) syntax error

I tried to modify br tag by changing it to br/ or br / as was suggested in http://voip-info.tr3ss.com/wiki/indexbcb5f1ce4f41b9e28cace74c9d6a...

But results were the same error.

Very frustrating...



pkaplan
Posts: 209
Member Since:
2007-02-28
Alexis Try this, it is a

Alexis

Try this, it is a more complete solution to what I originally posted:

<html>
<head>
	<title>
		Daymode Indicator
	</title>
</head>

<body>
	<ol>
		<li>
		<br />
		<br />
<?php
		exec( "asterisk -r -x 'DATABASE GET daynightmode currentmode'", $response);
		echo "You are currently in: ";
		echo str_replace ( "Value: ", "", $response[0]);
?>
		</li>
	</ol>
</body>
</html>


alexis
Posts: 54
Member Since:
2006-05-31
It worked!!!

this is the code

<?php
echo ''."\n";
echo ''."\n";

exec( "asterisk -r -x 'DATABASE GET daynightmode currentmode'", $response);

foreach( $response as $index)
echo $index . "";

echo ''."\n";
echo ''."\n";

?>

Now using polycom sip variables mb.idleDisplay.home="(url)" and mb.idleDisplay.refresh="(seconds"), I can have it on the phone's idle display. This way, everybody can see if phones are in the day or night mode.

pkaplan, you are the man!

alexis



pkaplan
Posts: 209
Member Since:
2007-02-28
I'm glad you got it working,

I'm glad you got it working, do take a look at my second post though, the implementation is a lot cleaner.

Now, if you want to take it to the next level we can make it so you can toggle modes from the browser ;)



alexis
Posts: 54
Member Since:
2006-05-31
pkaplan, you made my day! (maybe even a week or a month :)

I tried your second implementation. It worked like a charm.
While it would be nice to be able to call the code from the browser, I will probably not need it. I was going to use your file on the idle display of Polycoms 501 and 600s. From the idle display, you can't navigate. In my case, the end users aren't sophisticated enough to actually call up the browser, they would rather dial *28 :)
What would be nice is to have the phone display 2 different bmp images (night.bmp and day.bmp) depending on the outcome of the DB query. In Polycom microbrowser I can probably position images more prominently than text.

Anyhow, I am extremely grateful for your help.

alexis



AK7941
Posts: 23
Member Since:
2006-08-28
BLF for Night Mode (*28) Status

Does anyone have any suggestions to display the status of the "Night Mode" function on Grandstream's GXP2000 BLF keys (i.e. Red Light when Night Mode is active, Green for Day Mode)? Can it be configured through "hint" in extensions_custom.conf? If not, are there any possibile ways to do this task? What are others using to display the status of the night mode function?

Thanks!



BobH
Posts: 223
Member Since:
2006-05-31
I don't know anything about

I don't know anything about grandstreams but I use sipsak on the Snoms to show if Nightmode is enabled. This is in the code to turn night mode on.

...
exten => *28,n,System(/usr/local/bin/sipsak -i -M -B "Night Mode" -s ${SIPURI})
...



berniem
Posts: 205
Member Since:
2006-11-15
Update

FYI: With the new day/night in current freePBX builds, the script above needs to change from:

'DATABASE GET daynightmode currentmode'

to

'DATABASE GET DAYNIGHT C0'

Where "C0" is the day/night code index you wish to query (C0, C1, C2, etc)

And further FYI:
I found this out when I tried to create a nightly job that would automatically switch to night mode as a backup in case the person responsible forgot. I created a cron job to do one line:
asterisk -rx 'DATABASE PUT DAYNIGHT C0 NIGHT'

Simple - just the way I like most things. :-)



Domhampton
Posts: 102
Member Since:
2007-07-21
Is there a way to do this

Is there a way to do this on a speed dial button.

I notice Skyking has a picture of his office phone on another thread where the day night seems to be in the Busy state, i've had a search and all i can find is the browser script which isn't quite what i need, any suggestions where i should look?



SkykingOH
Posts: 9541
Member Since:
2007-12-17
Yes, that is very easy to

Yes, that is very easy to implement. As long as you have the devstate option turned on in amportal you can subscribe via a BLF to the day/night code. FreePBX generates the hint for the code using devstate.

If you do a 'core shore hints' you can see all the hints

--

Scott

aka "Skyking"



Reinhard
Posts: 74
Member Since:
2009-07-09
Does it also work for time conditions?

My inbound route goes to the day/night switch and then I have a time conditions cascade.
Is it also possible to show the currently active time condition? Like "Holiday", "open", "closed"

Reinhard

--



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.