LinuxMCE Forums

General => Users => Topic started by: davegravy on March 14, 2012, 02:26:01 am

Title: Command Line System Queries
Post by: davegravy on March 14, 2012, 02:26:01 am
I'm interested in something opposite of Messagesend. Is it possible to determine device status, or housemode, etc from the command-line?

One example of why I ask is that I have a doorbell event which launches a bash script and does a variety of different things:

1) If the user has simply pressed the doorbell that's one branch.
2) If the user has pressed the doorbell in the correct morse-code sequence, the system gets disarmed.

A) If the housemode is armed or vacation, and 1 happens, the script sends an SMS message to myself and my wife saying that the doorbell was rung.
B) If the housemode is unarmed, secure-at-home, or entertaining, and 1 happens, the script rings the doorbell
C) If 2 happens, and the housemode was armed or vacation, the script sends an SMS to myself and my wife saying that the system was disarmed via the doorbell.
D) If 2 happens, and the housemode was sleep, the script rings the doorbell.

I've created rather complicated logic within a bash script to log the times for which doorbell push and release events occur, and to interpret these as morse code.

I'd rather not have to create and manage a bunch of respond-to events within web-admin (with various criteria), and then re-use the Morse-code interpretation routine within each event. Preferable would be to have one doorbell push event, one doorbell release event, and then test the various criteria within the code.

Sorry for the drawn out explanation. Is this doable?
Title: Re: Command Line System Queries
Post by: totallymaxed on March 14, 2012, 08:35:43 am
I'm interested in something opposite of Messagesend. Is it possible to determine device status, or housemode, etc from the command-line?

One example of why I ask is that I have a doorbell event which launches a bash script and does a variety of different things:

1) If the user has simply pressed the doorbell that's one branch.
2) If the user has pressed the doorbell in the correct morse-code sequence, the system gets disarmed.

A) If the housemode is armed or vacation, and 1 happens, the script sends an SMS message to myself and my wife saying that the doorbell was rung.
B) If the housemode is unarmed, secure-at-home, or entertaining, and 1 happens, the script rings the doorbell
C) If 2 happens, and the housemode was armed or vacation, the script sends an SMS to myself and my wife saying that the system was disarmed via the doorbell.
D) If 2 happens, and the housemode was sleep, the script rings the doorbell.

I've created rather complicated logic within a bash script to log the times for which doorbell push and release events occur, and to interpret these as morse code.

I'd rather not have to create and manage a bunch of respond-to events within web-admin (with various criteria), and then re-use the Morse-code interpretation routine within each event. Preferable would be to have one doorbell push event, one doorbell release event, and then test the various criteria within the code.

Sorry for the drawn out explanation. Is this doable?

It's what scenarios and the advanced editor is for... its not a perfect environment to build this stuff in but it will in principle it will allow you to build this kind of logic. Give it a try.

All the best


Andrew
Title: Re: Command Line System Queries
Post by: phenigma on March 14, 2012, 05:13:47 pm
I'm interested in something opposite of Messagesend. Is it possible to determine device status, or housemode, etc from the command-line?


I use messagesend to query device status.  I don't have my system in front of me but messagesend can query device status and return a result that is easily parsed.  I use it to check for the status of certain devices before acting on events.

I have found the advanced editor to be rather lacking in the ability to act based on the status or state of other devices.  I'd love to have a way to do this with the advanced editor but I have had no luck myself.

I do not have a solution to your query, sorry.

J.
Title: Re: Command Line System Queries
Post by: davegravy on March 14, 2012, 07:05:49 pm
Hi Phenigma,

I'm very interested to know how you use Messagesend to return device status. I looked in the wiki and it wasn't apparent to me. If you get a chance to check I'd be grateful to know how you accomplish this..

Thanks,

David
Title: Re: Command Line System Queries
Post by: jamo on March 15, 2012, 10:29:45 am
2) If the user has pressed the doorbell in the correct morse-code sequence, the system gets disarmed.
A word of caution- make sure the morse-code sequence for disarming the system and the one for detonating the short-range nuclear device are sufficiently different. It sounds silly to mention but it catches out the most experienced users from time to time.
Title: Re: Command Line System Queries
Post by: davegravy on March 15, 2012, 02:34:51 pm
A word of caution- make sure the morse-code sequence for disarming the system and the one for detonating the short-range nuclear device are sufficiently different. It sounds silly to mention but it catches out the most experienced users from time to time.

I don't have one of those, but I was hoping to have a sequence which initiates the conversion from "regular house" into sex-pad (giggidy-giggidy). I'll heed your advice, as it would be awkward bringing the in-laws into such an environment.  :P
Title: Re: Command Line System Queries
Post by: davegravy on March 15, 2012, 07:05:35 pm
I think I figured out how to do it _IN THEORY_

General Info Plugin has a command "Get Device Data" which accepts a device ID and Device Data ID

Security Info Plugin has a device data field #59 called "Configuration" which stores the current housemode.

Only problem is that MessageSend is returning a blank for some reason.

Code: [Select]
root@dcerouter:~# /usr/pluto/bin/MessageSend localhost -o 0 4 1 68 2 "13" 5 "" 52 "59" 53 0
0:OK
5:

Unless I ask for the default device data value (i.e not live):

Code: [Select]
root@dcerouter:~# /usr/pluto/bin/MessageSend localhost -o 0 4 1 68 2 "13" 5 "" 52 "59" 53 1
0:OK
5:0,2,

Anyone know why this is?
Title: Re: Command Line System Queries
Post by: phenigma on March 15, 2012, 09:34:42 pm
That's essentially what I'm doing, although I'm using command 247 "Get Device State" to query the state of zwave lights.

My core will only return the default data, not the live data (at least for house mode).

J.
Title: Re: Command Line System Queries
Post by: bulek on March 15, 2012, 10:06:41 pm
Please add your knowledge to wiki page. This might be interesting also to others....

For me also...

Thanks,

regards,

Bulek.
Title: Re: Command Line System Queries
Post by: phenigma on March 15, 2012, 11:42:16 pm
Please add your knowledge to wiki page. This might be interesting also to others....

Done.  :)  http://wiki.linuxmce.org/index.php/MessageSend#Query_Commands

J.
Title: Re: Command Line System Queries
Post by: golgoj4 on March 16, 2012, 12:41:03 am
A word of caution- make sure the morse-code sequence for disarming the system and the one for detonating the short-range nuclear device are sufficiently different. It sounds silly to mention but it catches out the most experienced users from time to time.


As someone who formerly worked with nukes, he's safe ;)

also, thanks for wiki-fying!
-golgoj4
Title: Re: Command Line System Queries
Post by: bulek on March 16, 2012, 11:51:55 am
Thanks for wiki page.

I'd like to ask additional question : can I check what is happening in certain Entertainment zone (whether media is playing, or no,...) ?

Thanks in advance,

regards,

Bulek.
Title: Re: Command Line System Queries
Post by: phenigma on March 16, 2012, 06:20:56 pm
Thanks for wiki page.

I'd like to ask additional question : can I check what is happening in certain Entertainment zone (whether media is playing, or no,...) ?

You're welcome.  I have not tested querying for information other than State.  I am happy to do a little playing when I'm at my system next to find out though.

J.
Title: Re: Command Line System Queries
Post by: davegravy on March 17, 2012, 03:39:10 pm
My core will only return the default data, not the live data (at least for house mode).
J.

I get this for all the device data I've tried (and I tried 6 or 7 examples).

It's funny because the live data is visible in webadmin, so it IS accessible somehow... the question is: How?
Title: Re: Command Line System Queries
Post by: Marie.O on March 18, 2012, 11:16:26 am
It is not live data in web admin, but the last data that it was set to. And it is read from the database, afaik.
Title: Re: Command Line System Queries
Post by: davegravy on March 18, 2012, 04:41:03 pm
It is not live data in web admin, but the last data that it was set to. And it is read from the database, afaik.

Ahh okay. Well I'm not clear on the difference between that and live data. It seems to update immediately after house mode changes, so i think it's good enough for my uses. I'll dig through the database and hopefully I can find and pull the data from there within my scripts.

Thanks :)