Author |
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: December 17 2004 at 10:44 | IP Logged
|
|
|
Is there a way to read/modify the device status strings via ph functions? Could be interesting. It would also eliminate some global variables for me...
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: December 19 2004 at 21:40 | IP Logged
|
|
|
The only PowerHome functions for accessing the device status is ph_getx10stat (and ph_getx10dt, ph_getx10level). You can set the status using ph_x10setstat, but you already know these so Im probably mis-interpreting what you're asking.
Now, using the ph_sqlselect or ph_sqlselectinto and ph_directsql functions you have direct access to the database and should be able to do whatever you like.
Give me a little more info , my brain is not working right tonight.
Dave.
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: December 20 2004 at 07:02 | IP Logged
|
|
|
Heh! I'm looking to alter the actual status string data dynamically, versus doing it in the PH Explorer. For example, I created a virtual X10 device for Winamp that shows, "Playing" or "Not Playing" for On and Off, and I would also like to add song info to the status, and maybe even make it to show "Paused" and "Stopped".
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: December 20 2004 at 19:35 | IP Logged
|
|
|
Tony,
Ive gotcha now.
No PH functions but you can use the ph_sqlselectinto and ph_directsql functions.
The table is X10TYPES. You'll want to select and update based upon the TYPEID field. This field is just incremental number for a particular type. You'll want to use the SQL Select Report and do a "select * from x10types" and then look up the TYPEID number that you're interested in. Once you have that, then you can change the On message using this formula:
ph_directsql("update x10types set on_message = 'THE NEW ON MESSAGE' where typeid = 5")
This is assuming that the particular typeid you want to update is 5.
If you want to retrieve the on_message and off_message for typeid 5, then use the following formula:
ph_sqlselectinto(1,"select on_message,off_message from x10types where typeid = 5")
This will place the on_message in [LOCAL1] and the off_message in [LOCAL2].
The big problem you will have with this however is that the on, off, and dim messages are all limited to 25 characters so you might encounter problems in this respect.
Hope this helps,
Dave.
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: December 20 2004 at 22:27 | IP Logged
|
|
|
Dave,
Thanks for that.
I get an access violation (invalid sql code=999, sqlstate=42000) trying to do this...
ph_directsql("update x10types set off_message= '{WINAMP PLAYING}' where typeid = 28")
Am I doing something wrong?
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: December 20 2004 at 22:37 | IP Logged
|
|
|
Tony,
I checked it out and tried the same formula as above (different GV) and it worked fine. I guess it could be whatever is contained within your {WINAMP PLAYING} GV. If the length of the text is greater than 25 or it contains a single quote there will be problems. Can you post what is in your GV and I can test again?
Dave.
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: December 20 2004 at 22:44 | IP Logged
|
|
|
Tony,
I just ran a couple more tests and if you're over 25 characters the database just automatically truncates it so thats not the problem. However, I ran the test with an embedded single quote and got the same error you did so that's a possibility.
If that turns out to be it, you can fix it by searching and replacing all occurrences of single quotes with two single quotes. In SQL speak, you embed a single quote by escaping it with another single quote.
Hope this helps,
Dave.
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: December 21 2004 at 20:06 | IP Logged
|
|
|
Hmm. This is all I have in my test macro...
ph_directsql("update x10types set on_message = ''{WINAMP PLAYING}'' where typeid = 28")
and it now gives a different error...
Invalid SQL Code -131
SQLSTATE = 37000
[Sybase][ODBC Driver][Adaptive Server Anywhere]Syntax error or access violation: Near 'Playing' in ...set on_message = "Playing The...
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: December 21 2004 at 20:19 | IP Logged
|
|
|
Ah ha! I got it to work...
ph_directsql("update x10types set on_message = ~~'{WINAMP PLAYING}~~' where typeid = 28")
When I added a ph_x10refreshstat() at the end of the the macro, all was synced up.
25 characters are not a lot! Moving on to Plan B...
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: December 22 2004 at 10:15 | IP Logged
|
|
|
Tony,
Glad it's finally working. Though not sure why you had to escape the single quotes unless the whole ph_directsql function was somehow already included within single quotes. In any case, at least it's working.
So, what have you got up your sleeve for plan B?
Dave.
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: December 22 2004 at 20:53 | IP Logged
|
|
|
Wouldn't we both like to know!
More PSP magic with HTML/javascript I suppose!
|
Back to Top |
|
|