Author |
|
strav Newbie
Joined: July 23 2009 Location: United States
Online Status: Offline Posts: 13
|
Posted: June 28 2012 at 20:39 | IP Logged
|
|
|
Making some progress here. I have C2DM set up and a global variable defined in PHCA. I have tied that global variable to the slider and if I update the global variable via C2DM, it does, indeed, reflect when the slider is opened.
Looks like I have 2 things left to do to get it working - getting the trigger functioning and sending the c2dm message from powerhome.
When I send the c2dm message from a browser, it works, however I'm having trouble getting it to work from PH. Below is the URL I use (user/pass altered of course) in a browser and it works:
Code:
https://phc-a.net/send.php?username=user&password=password&v arname=arcadeLight&varvalue=29 |
|
|
When I try this in a macro, it does not work (PowerHome says the macro runs, but the device does not receive a c2dm message)
Code:
ph_geturl(ph_htmlescape(" https://phc-a.net/send.php?username=user&password=password&v arname=arcadeLight&varvalue=29")) |
|
|
Based on the info on Skip's site, I've also tried this in a macro (& set to & amp; with no space between) with the same result
Any suggestions?
Thanks,
-Steve
Edited by strav - June 28 2012 at 20:51
|
Back to Top |
|
|
MrGibbage Super User
Joined: October 23 2006 Location: United States
Online Status: Offline Posts: 513
|
Posted: June 28 2012 at 20:57 | IP Logged
|
|
|
Hi Steve.
I have a trigger set up for my Study light (good for testing since I ma sitting right here)
ID: STUDY_LIGHT
Description: Study light changes
Disabled: Unchecked
Action Type: Macro
Action: Testing (I actually have a macro named testing, that I will describe in a minute)
Trigger type: Insteon Device Change
Trigger ID: Study
Trigger Id Number: (Any)
Trigger value: (Any)
Boolean:1
My testing macro just has one line:
Command: Message box
ID: No TTS
Value: OK
Formula:
string(today()) + ", " + "TEMPS " + "|1: " + ph_getvar_s(2,1) + char(9) + "|2: " + ph_getvar_s(2,2) +
char(9) + "|3: " + ph_getvar_s(2,3) + char(9) + "|4: " + ph_getvar_s(2,4) + char(9) + "|5: " +
ph_getvar_s(2,5) + char(9) + "|6: " + ph_getvar_s(2,6) + char(9) + "|7: " + ph_getvar_s(2,7) + char(9) +
"|8: " + ph_getvar_s(2,8) + char(9) + "|9: " + ph_getvar_s(2,9) + char(9) + "|10: " + ph_getvar_s(2,10) +
"|" +char(13)+char(10)
This is a pretty cool macro because it shows you all of the local variables you will have access to when
the macro runs.
Now, if you have this set up, and go to the light switch and turn on or off the light, you should get at
least one message box (more likely two or three). If that works, the next step is to just send the variable
value over C2DM.
You will see that local variable 3 holds the dimming level when local variable 9 is set to 25. There are
other local variable that will be of interest, because you get different things if you tap the switch and
it turns on or off. So you will have to write some logic. You may even want to do something like only send
C2DM updates when the value changes by 25 or more. The choice is yours.
As for your command not running, one thing I see is that you have a space in your command. You cannot have
spaces in the url. Watch your ph log for more details. If your username or password have spaces in them, or
special characters, the will have to be html_escaped. Same goes for your variable name and variable value.
Don't forget you can also put a &verbose=true in the url to get some more debugging information when
testing from the browser.
Let me know if you need any more help.
__________________ Skip
|
Back to Top |
|
|
MrGibbage Super User
Joined: October 23 2006 Location: United States
Online Status: Offline Posts: 513
|
Posted: June 28 2012 at 21:06 | IP Logged
|
|
|
For everyone using my PHCA app. I have added a new page to skipstechtalk.
http://skipstechtalk.net/phca-bug-reporting-and-feature-requ ests/
Please use this page for reporting bugs and feature requests. You can also ask questions there, but
probably email will work best if you just have a usability question.
I am afraid that I may have overlooked some bugs and feature requests in the past. Hopefully this
will keep me honest.
__________________ Skip
|
Back to Top |
|
|
strav Newbie
Joined: July 23 2009 Location: United States
Online Status: Offline Posts: 13
|
Posted: June 29 2012 at 00:07 | IP Logged
|
|
|
Thanks for the info Skip. The message board is adding those spaces, I don't have them on my side. In any case, I did some troubleshooting and found that if I use http instead of https, I am able to make a connection with ph_geturl. Additionally, if I use ph_htmlescape within ph_geturl then the connection fails as well. This is true for all connections, not just the phc-a.net server.
Thank you also for the debugging macro. That is very helpful to see what is going on. I'll have to play around with it some and see if I can identify all the values needed to keep the phca variables in sync.
-Steve
|
Back to Top |
|
|
MrGibbage Super User
Joined: October 23 2006 Location: United States
Online Status: Offline Posts: 513
|
Posted: June 29 2012 at 04:27 | IP Logged
|
|
|
Oh, that's right. You have to use ph_geturl1 for https requests. I need to add that to my
documentation.
__________________ Skip
|
Back to Top |
|
|
MrGibbage Super User
Joined: October 23 2006 Location: United States
Online Status: Offline Posts: 513
|
Posted: June 29 2012 at 04:30 | IP Logged
|
|
|
As for using ph_htmlescape, you cannot escape the entire url. For instance, the colon and slashes after the protocol
are needed. You should only escape the username, password, variable name and values and do them individually. Don't
do them all enclosed in one, because you will lose the ampersands in between them.
__________________ Skip
|
Back to Top |
|
|
syonker Senior Member
Joined: March 06 2009 Location: United States
Online Status: Offline Posts: 212
|
Posted: June 29 2012 at 07:45 | IP Logged
|
|
|
Hi Gang, I'm a little late to this discussion, but I always find a picture is worth a thousand words. Below is my macro (in need of tuning, but it works very nicely with regard to C2DM) for setting a light using PHCA.
Rather than explicitly setting the light from PHCA, I call this macro with the device's name in the parameter list, whether it's turning on or off or dimming, and the on-level. Depending on the command, my return update via C2DM is "melded" accordingly to make a "nice message" for the user.
I store my credentials in global variables (PHCA_USER and PHCA_PASS).
I know the formula is cut off, so here is the actual call to PHCA:
ph_geturl("http://phc-a.net/send.php?username={PHCA_USER}&pa ssword={PHCA_PASS}&varname=" + ph_getvar_s(1,3) + "&varvalue=" + ph_htmlescape(ph_macroparmret('PHCA_UPDATE_VARIABLE',ph_getv ar_s(1,1),'LIGHT',0,0,0)))
-S
Picture below:
__________________ "I will consider myself having succeeded when my house becomes sentient and attempts to kill me."
><(((º>`·.¸¸.·´¯`·.¸><(((º>¸.
·´¯`·.¸. , . ><(((º>`·.¸¸.·´¯`·.¸><(((º>
|
Back to Top |
|
|
strav Newbie
Joined: July 23 2009 Location: United States
Online Status: Offline Posts: 13
|
Posted: July 01 2012 at 22:05 | IP Logged
|
|
|
Thanks all. Here's what I ended up with. Trigger calls macro PHCA_LIGHT_CHANGE which sets local1 to the variable name to be upated in PHCA based on the Insteon device name. It then sets local2 to 255 for "on" or "fast on", 0 for "off" or "fast off", or the value in global3 (I think that is what ph_getvar_n(2,3) retrieves) for "dim". Finally, it calls PHCA_UPDATE_VAR which sends that information over to PHCA via c2dm.
Code:
insert into macroheader values ('PHCA_LIGHT_CHANGE','Update PHCA on change in Light Status',0,0,1);
insert into macrodetail values ('PHCA_LIGHT_CHANGE',1,37,'',NULL,'Need to translte the Powerhome Switch Label
to the PHCA label. This section works but
there MUST be a better way to do it.',0,'','');
insert into macrodetail values ('PHCA_LIGHT_CHANGE',2,27,'',NULL,'ph_getvar_s(2,10)',0,'',' ');
insert into macrodetail values ('PHCA_LIGHT_CHANGE',3,39,'',NULL,'',0,'','');
insert into macrodetail values ('PHCA_LIGHT_CHANGE',4,26,'',NULL,'OFFICE (ARCADE) LIGHT',0,'','');
insert into macrodetail values ('PHCA_LIGHT_CHANGE',5,15,'[LOCAL1]',NULL,'"arcadeLight"',0,'','');
insert into macrodetail values ('PHCA_LIGHT_CHANGE',6,37,'',NULL,'Evaluate ph_getvar_s(2,9) for the insteon
command type
17 = on
18 = fast on
19 = off
20 = fast off
25 = dim
',0,'','');
insert into macrodetail values ('PHCA_LIGHT_CHANGE',7,24,'No TTS',1,'"MAIN LOOP: " + ph_getvar_s(2,10) + " [LOCAL1]"',1,'','');
insert into macrodetail values ('PHCA_LIGHT_CHANGE',8,27,'',NULL,'if((ph_getvar_n(2,9)=17 or ph_getvar_n(2,9)=18),"LIGHT_ON","NOP")',0,'','');
insert into macrodetail values ('PHCA_LIGHT_CHANGE',9,27,'',NULL,'if((ph_getvar_n(2,9)=19 or ph_getvar_n(2,9)=20),"LIGHT_OFF","NOP")',0,'','');
insert into macrodetail values ('PHCA_LIGHT_CHANGE',10,27,'',NULL,'if (ph_getvar_n(2,9)=25,"LIGHT_DIM","NOP")',0,'','');
insert into macrodetail values ('PHCA_LIGHT_CHANGE',11,39,'',NULL,'',0,'','');
insert into macrodetail values ('PHCA_LIGHT_CHANGE',12,26,'',NULL,'LIGHT_ON',0,'','');
insert into macrodetail values ('PHCA_LIGHT_CHANGE',13,15,'[LOCAL2]',NULL,'255',0,'','');
insert into macrodetail values ('PHCA_LIGHT_CHANGE',14,27,'',NULL,'"SEND_UPDATE"',0,'','');
insert into macrodetail values ('PHCA_LIGHT_CHANGE',15,26,'',NULL,'LIGHT_OFF',0,'','');
insert into macrodetail values ('PHCA_LIGHT_CHANGE',16,15,'[LOCAL2]',NULL,'0',0,'','');
insert into macrodetail values ('PHCA_LIGHT_CHANGE',17,27,'',NULL,'"SEND_UPDATE"',0,'','');
insert into macrodetail values ('PHCA_LIGHT_CHANGE',18,26,'',NULL,'LIGHT_DIM',0,'','');
insert into macrodetail values ('PHCA_LIGHT_CHANGE',19,15,'[LOCAL2]',NULL,'ph_getvar_n(2,3)',0,'','');
insert into macrodetail values ('PHCA_LIGHT_CHANGE',20,26,'',NULL,'SEND_UPDATE',0,'','');
insert into macrodetail values ('PHCA_LIGHT_CHANGE',21,24,'No TTS',1,'"Value: " + string([LOCAL2])',1,'','');
insert into macrodetail values ('PHCA_LIGHT_CHANGE',22,38,'',0,'ph_macroparm("PHCA_UPDATE_V AR","[LOCAL1]",string([LOCAL2]),0,0,0)',0,'','');
|
|
|
|
Back to Top |
|
|
Jaaay Newbie
Joined: July 01 2012
Online Status: Offline Posts: 24
|
Posted: July 06 2012 at 09:31 | IP Logged
|
|
|
Hello all,
Long time user of power-home (love it), first time posting here in the forum. Skip, you have done a fantastic job with this app. I waited until you had the designer completed, but all I can say is WOW!!! Congrats!!!!
The reason I am posting is because I wanted to find out if anyone else is seeing any issues with C2DM updates? I lost all updates yesterday around 5pm PST. Skip, as far as I can tell when I send the test from the browser everything comes back OK. In my log everything looks ok for sending the messages as well. I restarted the phone just to make sure. It just stopped.
Is there a limit on the amount of messages you can send to a device? From my reading its sounds like their might be?
Looking for any input anyone has.
Thanks ahead of time,
Jason
|
Back to Top |
|
|
MrGibbage Super User
Joined: October 23 2006 Location: United States
Online Status: Offline Posts: 513
|
Posted: July 06 2012 at 09:39 | IP Logged
|
|
|
Hi, Jason. Welcome to PH and to the PH forum. :)
Yesterday around 5:00 I was transitioning to the new GCM service, so yes, there could have been
some downtime. Likely, in fact. Try the new version that I just posted, re-register for GCM, and
you should be good to go. Be sure to read the instructions about the new URL in the post
announcing the new version:
http://www.power-home.com/forum/forum_posts.asp?TID=3117
Skip
__________________ Skip
|
Back to Top |
|
|
Jaaay Newbie
Joined: July 01 2012
Online Status: Offline Posts: 24
|
Posted: July 06 2012 at 10:09 | IP Logged
|
|
|
Thats great news Skip,
Thanks for the update.
I will take a look at it this weekend. I thought you might be working on the transition to GCM.
I will let you know if I have any issues. GCM here we come
Thanks again,
Jason
|
Back to Top |
|
|
MrGibbage Super User
Joined: October 23 2006 Location: United States
Online Status: Offline Posts: 513
|
Posted: July 06 2012 at 10:27 | IP Logged
|
|
|
No problem. I will be out of town next week, so tech support will be on hold until I get back. If you have
problems, you can revert back to 2.2.04a.
I didn't answer your question about message limits. With the new GCM service, there are NO QUOTAS! You can
send as many messages as you want. Remember though, that even though your phone uses no extra battery power
while waiting for C2DM messages, when it does receive a message, it has to be processed. I have tried to
minimize the amount of code that runs when a message comes in, but there is code that runs. Namely storing
the values to a database and updating any visible views/widgets. So, you wouldn't want to send updates for
variables that you truly aren't interested in. But the bottom line is, you can send as many messages as you
want, and you can add as many variables as you want to each update (within the 2000 character limit for a
URL).
__________________ Skip
|
Back to Top |
|
|
syonker Senior Member
Joined: March 06 2009 Location: United States
Online Status: Offline Posts: 212
|
Posted: March 08 2013 at 09:10 | IP Logged
|
|
|
MrGibbage wrote:
Oh, that's right. You have to use ph_geturl1 for https requests. I need to add that to my
documentation. |
|
|
Ok, I am officially confused. There is no documentation in PowerHome that supports there being a "ph_geturl1()" function...and the only places to which it is referred in the forums are surrounding PHCA.
Is this a function someone authored outside of PH...?
Skip, do you have a "How to setup GCM from A to Z" type of tutorial by any chance?
-S
__________________ "I will consider myself having succeeded when my house becomes sentient and attempts to kill me."
><(((º>`·.¸¸.·´¯`·.¸><(((º>¸.
·´¯`·.¸. , . ><(((º>`·.¸¸.·´¯`·.¸><(((º>
|
Back to Top |
|
|
MrGibbage Super User
Joined: October 23 2006 Location: United States
Online Status: Offline Posts: 513
|
Posted: March 08 2013 at 09:14 | IP Logged
|
|
|
I can't answer the ph_geturl1 question. But as for setting up PHCA, start here
http://skipstechtalk.net/powerhome-connector-for-android-usa ge-instructions-and-screenshots/
It is a little old, but it should be very close. I think some of the screen shots are a little off.
Let me know if you have any specific questions.
__________________ Skip
|
Back to Top |
|
|
|
|