Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: Formulas for dynamic text in CC Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
MrGibbage
Super User
Super User
Avatar

Joined: October 23 2006
Location: United States
Online Status: Offline
Posts: 513
Posted: June 05 2010 at 16:08 | IP Logged Quote MrGibbage

How would I make a dynamic text object in the Control Center? I currently store the last five motion times for
each of my motion sensors in global variables. I can easily display those times using the static globalvar Item
Type. But if I want to show the minutes elapsed since the last motion, I have to subtract the time stored in that
global variable from today(). I have a formula saved in the formulas section of the PH Explorer:
round(ph_minutesafter(ph_getglobal_dt("BACK_STAIRS_MOTION1") ,today()),1)
which works correctly in displaying the number of minutes since that motion was last triggered. But how do I get
that to display in the CC?

By the way, I tried searching the forums for "control center formulas" and that yielded a bunch of results, but
nothing that seemed to help out with this problem. Perhaps I am using some wrong terminology here??? Could this
be called something else in PH-speak?

Skip
Back to Top View MrGibbage's Profile Search for other posts by MrGibbage
 
sjvonstein
Groupie
Groupie


Joined: February 05 2010
Location: United States
Online Status: Offline
Posts: 75
Posted: June 05 2010 at 17:39 | IP Logged Quote sjvonstein

If I haven't tested this myself yet, but if you can create a macro that continuously runs that updates yet another global variable that represents the number of minutes past since last motion, you can reference that global variable in CC. I have not tested nor know if it possible for a macro to remain in continuous loop without disrupting other PH operations.
Back to Top View sjvonstein's Profile Search for other posts by sjvonstein
 
MrGibbage
Super User
Super User
Avatar

Joined: October 23 2006
Location: United States
Online Status: Offline
Posts: 513
Posted: June 05 2010 at 20:24 | IP Logged Quote MrGibbage

I thought of that, but I too was concerned about running a macro, say, every minute. I want to use this in the event that my burglar
alarm goes off I can look at a web page with all of the times-since-last-motion-recorded and quickly see if it looks like someone is
walking around the house. I don't currently have any of my motions tied to alarm activation (I have not yet found a motion detector
that is truly pet immune yet consistently people activated). I tried creating a web page with the actual times, but I found this page
hard to read and interpret. I think seeing just the time since last activation may be a lot easier to read. I would probably also
highlight the single motion that had the most recent time out of all of my motions. It sounds so simple to be able to dynamically
calculate this for every page refresh, but perhaps it is not.
Back to Top View MrGibbage's Profile Search for other posts by MrGibbage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2884
Posted: June 05 2010 at 22:41 | IP Logged Quote TonyNo

One of my web pages shows color-coded activation times...



Maybe the logic here applies?
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
MrGibbage
Super User
Super User
Avatar

Joined: October 23 2006
Location: United States
Online Status: Offline
Posts: 513
Posted: June 06 2010 at 08:13 | IP Logged Quote MrGibbage

Yep! It sure would. But I think I would still like the display to show the minutes since the
last activation each time the page is refreshed. But I do like your color coding.

What do the icons in between the label and the time indicate on your display?

Skip
Back to Top View MrGibbage's Profile Search for other posts by MrGibbage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2884
Posted: June 06 2010 at 09:41 | IP Logged Quote TonyNo

The icons show current state. Doors are closed, "Jen BR" shows motion (even though the time is old, need to look into that).

Here's the code segment for a door (Q2). This is in a table.

Code:
     <td valign=middle height="1" nowrap>
    <font face="Verdana" size="2" align="center" color="<% case( ph_minutesafter(ph_getx10dt ( "Q2" ), today()) when is<=5 then "Red" when is<=15 then "Yellow" when is<=30 then "Orange" else "#3399FF") %>">

     <% string( ph_getx10dt ( "Q2" ), 'mm/dd/yy h:mm am/pm') %>
     </td>
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
spou
Newbie
Newbie


Joined: July 28 2007
Location: Canada
Online Status: Offline
Posts: 33
Posted: June 06 2010 at 20:37 | IP Logged Quote spou

Dont be afraid of having a macro running each minute. I have several macros doing various updates running each minutes without problems for weeks at a time. In fact, the only time I have problems with those macros is when I fiddle with them. (if it works, dont fix it!)

Each macro does a lot of global updates, call vbscript and / or DOS command line and update the various CC screens. I'm so confident that when I come back from vacation, I plan to HVAC data to PH and mysql and whole house power usage if I can find a cheap interface. Even then, the machine hardly run on more than 10% of it's cpu power, with the regular peeks from time to time.

The server is a very regular and somewhat old Athlon 2.2ghz single core, 1 gig ram (usually 350megs used), also running the mysql database, a web server, a UPS interface, a 1wire interface, ftp server, weather station software, motherboard monitor, and a few other minor software over WinXP SP3

Each minute I got:
-power quality from the UPS into mysql (command line)
-weather data from my weather station into PH and mysql (vbscript)
-1wire data from 15 sensors into PH (vb script)
-solar heating fan status into mysql (command line)
-casing and motherboard server temperature into PH and mysql (from motherboard monitor - vbscript)

PH is very sturdy, and this is a good thing (tm)!

Spou
Back to Top View spou's Profile Search for other posts by spou
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum