Author Topic: Command Line System Queries  (Read 8955 times)

davegravy

  • Addicted
  • *
  • Posts: 551
    • View Profile
Command Line System Queries
« 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?

totallymaxed

  • LinuxMCE God
  • ****
  • Posts: 4660
  • Smart Home Consulting
    • View Profile
    • Dianemo - at home with technology
Re: Command Line System Queries
« Reply #1 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
Andy Herron,
CHT Ltd

For Dianemo/LinuxMCE consulting advice;
@herron on Twitter, totallymaxed+inquiries@gmail.com via email or PM me here.

Get Dianemo-Rpi2 ARM Licenses http://forum.linuxmce.org/index.php?topic=14026.0

Get RaspSqueeze-CEC or Raspbmc-CEC for Dianemo/LinuxMCE: http://wp.me/P4KgIc-5P

Facebook: https://www.facebook.com/pages/Dianemo-Home-Automation/226019387454465

http://www.dianemo.co.uk

phenigma

  • LinuxMCE God
  • ****
  • Posts: 1758
    • View Profile
Re: Command Line System Queries
« Reply #2 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.

davegravy

  • Addicted
  • *
  • Posts: 551
    • View Profile
Re: Command Line System Queries
« Reply #3 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

jamo

  • Guru
  • ****
  • Posts: 463
    • View Profile
    • LMCE user Page
Re: Command Line System Queries
« Reply #4 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.

davegravy

  • Addicted
  • *
  • Posts: 551
    • View Profile
Re: Command Line System Queries
« Reply #5 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

davegravy

  • Addicted
  • *
  • Posts: 551
    • View Profile
Re: Command Line System Queries
« Reply #6 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?
« Last Edit: March 15, 2012, 07:19:50 pm by davegravy »

phenigma

  • LinuxMCE God
  • ****
  • Posts: 1758
    • View Profile
Re: Command Line System Queries
« Reply #7 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.

bulek

  • Administrator
  • wants to work for LinuxMCE
  • *****
  • Posts: 909
  • Living with LMCE
    • View Profile
Re: Command Line System Queries
« Reply #8 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.
Thanks in advance,

regards,

Bulek.

phenigma

  • LinuxMCE God
  • ****
  • Posts: 1758
    • View Profile
Re: Command Line System Queries
« Reply #9 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.

golgoj4

  • NEEDS to work for LinuxMCE
  • ***
  • Posts: 1193
  • hrumpf!
    • View Profile
    • Mah Website
Re: Command Line System Queries
« Reply #10 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
Linuxmce - Where everyone is never wrong, but we are always behind xbmc in the media / ui department.

bulek

  • Administrator
  • wants to work for LinuxMCE
  • *****
  • Posts: 909
  • Living with LMCE
    • View Profile
Re: Command Line System Queries
« Reply #11 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.
Thanks in advance,

regards,

Bulek.

phenigma

  • LinuxMCE God
  • ****
  • Posts: 1758
    • View Profile
Re: Command Line System Queries
« Reply #12 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.

davegravy

  • Addicted
  • *
  • Posts: 551
    • View Profile
Re: Command Line System Queries
« Reply #13 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?

Marie.O

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 3676
  • Wastes Life On LinuxMCE Since 2007
    • View Profile
    • My Home
Re: Command Line System Queries
« Reply #14 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.