LinuxMCE Forums

General => Developers => Topic started by: ddamron on December 28, 2007, 12:39:11 pm

Title: How to display messages on MD's
Post by: ddamron on December 28, 2007, 12:39:11 pm
During the first initial run of my Insteon plugin, it could take a few minutes to 'spider' the insteon network...
I'd like to inform the user of two things:

1.  Insteon Configuration is processing...
and
2.  Insteon Configuration is finished...

What commands do I send to have these messages displayed on the MD's?

and How do I send the messages to ALL MDs?

Thanks again

Regards,

Dan
Title: Re: How to display messages on MD's
Post by: ddamron on December 28, 2007, 12:45:24 pm
This would be very handy to display Insteon Devices Detected too.. (prior to initiating the wizard)

Once the initial configuration is complete, the configuration of the childs (lights, irrigation controllers, etc) are implemented as devices..
Once their implemented as devices, they have their current configuration saved with that device, and hence, REinitialization is quick..

So after the initial 'spider' initialization, (and associated configuration), further restarts should be less than one minute to complete.

Dan
Title: Re: How to display messages on MD's
Post by: kir on January 15, 2008, 02:23:28 pm
Just a small pointer: use CMD_Display_Alert command. Sample from Xine_Player:

1651 void Xine_Player::SendMessageToOrbiter(string sMessage)
1652 {
1653     DCE::CMD_Display_Alert cmd(m_dwPK_Device, m_pData->m_dwPK_Device_ControlledVia, sMessage, "xine_player_message", "10", interuptAlways);
1654     SendCommandNoResponse(cmd);
1655     LoggerWrapper::GetInstance()->Write(LV_CRITICAL,"Xine_Player::SendMessageToOrbiter sent message: %s", sMessage.c_str() );
1656 }

Here it sends message from Xine device (m_dwPK_Device) to controlling device - i.e. corresponding Orbiter (m_pData->m_dwPK_Device_ControlledVia). See the  Orbiter.cpp : header of function
void Orbiter::CMD_Display_Alert(string sText,string sTokens,string sTimeout,int iInterruption,string &sCMD_Result,Message *pMessage)
contains info about parameters (or just use webadmin/DCE stuff to read about that command - also you can use webui to send "Display Alert" message to Orbiter from browser).

See also my recent post about TailDCERouter.sh tool - you can use it to see which messages are passing.
Title: Re: How to display messages on MD's
Post by: ddamron on January 15, 2008, 03:33:00 pm
kir,

Thank you for your reply.  I did figure that out (by trial and error)

Now, I'm trying to figure out how to enumerate a list of the orbiters... through ruby..

Best wishes,

Dan
Title: Re: How to display messages on MD's
Post by: bulek on January 15, 2008, 06:02:56 pm
Hi,

I'm also interested about possibility to show overlayed screens on Orbiters, where user can choose between two or more buttons (for instance when some device is autodetected and then you press if you want to use it etc...). I remember reading about it somewhere (each button sends declared DCE message), but don't know where I could find that info...

AFAIK, alerts are those small windows on Orbiters, that show every now and then when LMCE is doing something , right ?

regards,

Bulek.
Title: Re: How to display messages on MD's
Post by: niz23 on January 15, 2008, 06:34:45 pm
bulek.

Hi,

I'm also interested about possibility to show overlayed screens on Orbiters, where user can choose between two or more buttons (for instance when some device is autodetected and then you press if you want to use it etc...). I remember reading about it somewhere (each button sends declared DCE message), but don't know where I could find that info...

AFAIK, alerts are those small windows on Orbiters, that show every now and then when LMCE is doing something , right ?

regards,

Bulek.


Perhaps below command is what you refer to?
Since my 0710 beta2 does not work anymore I havenĀ“t tried it myself.
I wait for beta3 which seem to be available very soon now (see wiki recent changes).

http://wiki.linuxmce.org/index.php/DCE_from_commandline


/usr/pluto/bin/MessageSend localhost 0 64 1 741 10 "Whatever" 159 53 9 'A message|Ok|Remind me later' 137 '-targetType device <%=!%> 15 1 67 13 "/root/Something.sh" 51 "--answer yes"|-targetType device <%=!%> 15 1 67 13 "/root/Something.sh" 51 "--answer no"'

/niz23
Title: Re: How to display messages on MD's
Post by: ddamron on January 15, 2008, 06:34:56 pm
Bulek, I have done that... it's in the wiki somewhere..
Let me find it...
   /usr/pluto/bin/MessageSend localhost 0 64 1 741 10 "Whatever" 159 53 9 'A message|Ok|Remind me later' 137 '-targetType device <%=!%> 15 1 67 13 "/root/Something.sh" 51 "--answer yes"|-targetType device <%=!%> 15 1 67 13 "/root/Something.sh" 51 "--answer no"'

the wiki is at http://wiki.linuxmce.org/index.php/MessageSend

Of course, you'll need to adjust those values as per your configuration...
I've tested this on my orbiters, and it works well.

Regards,

Dan
Title: Re: How to display messages on MD's
Post by: bulek on January 15, 2008, 08:58:46 pm
Bulek, I have done that... it's in the wiki somewhere..
Let me find it...
   /usr/pluto/bin/MessageSend localhost 0 64 1 741 10 "Whatever" 159 53 9 'A message|Ok|Remind me later' 137 '-targetType device <%=!%> 15 1 67 13 "/root/Something.sh" 51 "--answer yes"|-targetType device <%=!%> 15 1 67 13 "/root/Something.sh" 51 "--answer no"'

the wiki is at http://wiki.linuxmce.org/index.php/MessageSend

Of course, you'll need to adjust those values as per your configuration...
I've tested this on my orbiters, and it works well.

Regards,

Dan


Thanks for info... BTW, any easy way/sql query to get list of all Orbiters - or do we need that list or can we just say display on all ?

Regards,

Bulek.
Title: Re: How to display messages on MD's
Post by: ddamron on January 15, 2008, 10:33:50 pm
Bulek,

That's exactly what I want to do, is display on all...

As it stands, I cannot get the parent device ID, therefore, I can't even display on ONE...

ahh, still struggling...

Regards,

Dan
Title: Re: How to display messages on MD's
Post by: tschak909 on January 15, 2008, 10:35:18 pm
I know there are certain virtual device #s, which correspond to things like Local Orbiter, All Orbiter, etc. If you look at DeviceTemplate, you'll see -1000, etc...

-Thom
Title: Re: How to display messages on MD's
Post by: ddamron on January 15, 2008, 10:50:15 pm
Thanks Thom!  That is probably what I'm looking for...
What do you mean by 'look at DeviceTemplate' ?

Thanks,

Dan
Title: Re: How to display messages on MD's
Post by: rwilson131 on January 16, 2008, 01:51:57 am
Take a look at http://wiki.linuxmce.org/index.php/DCE_from_commandline

toward the bottom of the page.
Quote
As far as I can tell, the reason for '-1000' is to allow devices to broadcast events to the system as a whole rather than to a specific device, presumably for event-based devices that do not do a specific function. I shall look more into this... -AVJohn.

I put together the MessageSend page, and I have not really ever determined if this is indeed correct, but one can see the use of -1000 and -1001 for device to in MessageSend command through out the code.  It would be nice if we knew which was correct or if both are correct. 

I know this sends a message to every orbiter I have because it is annoying and happened on all my orbiters until I determined how much to tell MythTV to leave open.

Low Disc Space Message ( from DiskSpaceMonitor.sh)  This message is sent when the /home partition is over 95% full to fire event 64.

/usr/pluto/bin/MessageSend $DCERouter 0 -1001 2 64
Title: Re: How to display messages on MD's
Post by: hari on January 16, 2008, 02:05:16 am
from src/DCE/Message.h
Code: [Select]
#define DEVICEID_NULL           -1  // Invalid device

// Some system devices
#define DEVICEID_DCEROUTER      -1000   // System commands for the router itself
#define DEVICEID_EVENTMANAGER   -1001   // Not a real device, just the destination of events
#define DEVICEID_LOGGER                 -1002
#define DEVICEID_MESSAGESEND    -1003   // The message send utility

// Virtual devices
#define DEVICEID_MASTERDEVICE   -2000
#define DEVICEID_CATEGORY       -2001
#define DEVICEID_LIST           -2002
#define DEVICEID_GROUP          -2003

// Other
#define DEVICEID_HANDLED_INTERNALLY -300
best regards,
Hari
Title: Re: How to display messages on MD's
Post by: ddamron on January 16, 2008, 04:55:57 am
Take a look at http://wiki.linuxmce.org/index.php/DCE_from_commandline

toward the bottom of the page.
Quote
As far as I can tell, the reason for '-1000' is to allow devices to broadcast events to the system as a whole rather than to a specific device, presumably for event-based devices that do not do a specific function. I shall look more into this... -AVJohn.

I put together the MessageSend page, and I have not really ever determined if this is indeed correct, but one can see the use of -1000 and -1001 for device to in MessageSend command through out the code.  It would be nice if we knew which was correct or if both are correct. 

I know this sends a message to every orbiter I have because it is annoying and happened on all my orbiters until I determined how much to tell MythTV to leave open.

Low Disc Space Message ( from DiskSpaceMonitor.sh)  This message is sent when the /home partition is over 95% full to fire event 64.

/usr/pluto/bin/MessageSend $DCERouter 0 -1001 2 64


-1000 is hardcoded for DCERouter Commands,
-1001 is hardcoded for DCERouter Events...
Hope that clears the confusion...
I did see your MessageSend page, and have found it quite useful..

Your suggestion with regards to sending an Event 64...

If you follow the DCERouter log, you can watch the event being fired.
After the event is fired, the CORE sends a DISPLAY ALERT command to all Orbiters AT THE SAME TIME..

THAT is what I want to be able to do...
The Display Alert command allows you to send text, and assign a token to the alert...

Regards,

Dan
Title: Re: How to display messages on MD's
Post by: rwilson131 on January 16, 2008, 06:58:00 am
Thanks for the section of source code, I added it to the wiki page.  I wanted to also put a word out for bulek who posted several messages which I tried to consolidate to a single page.

I see you are trying to get the little box in the corner, and not a full page to pop up.

Am I missing something here, why can you not send something like this.

/usr/pluto/bin/MessageSend dcerouter -targetType category -bl 5 1 5 1 809 251 0 9 "TESTING DISPLAY ALERT" 182 15 70 "test"
server= dcerouter
targetType= Category (device category found on template page)
-bl= 5 broadcast level 5 or whole house
Device from= 1 is the core
Device to = 5 (actually device category 5 orbiters)
command 809 with it parameters

I was able to send this to all of my orbiters.  I did not play with the parameters much, but it worked.

I hope this is what you are looking for.
Rob
Title: Re: How to display messages on MD's
Post by: ddamron on January 16, 2008, 08:15:07 am
Thanks for the section of source code, I added it to the wiki page.  I wanted to also put a word out for bulek who posted several messages which I tried to consolidate to a single page.

I see you are trying to get the little box in the corner, and not a full page to pop up.

Am I missing something here, why can you not send something like this.

/usr/pluto/bin/MessageSend dcerouter -targetType category -bl 5 1 5 1 809 251 0 9 "TESTING DISPLAY ALERT" 182 15 70 "test"
server= dcerouter
targetType= Category (device category found on template page)
-bl= 5 broadcast level 5 or whole house
Device from= 1 is the core
Device to = 5 (actually device category 5 orbiters)
command 809 with it parameters

I was able to send this to all of my orbiters.  I did not play with the parameters much, but it worked.

I hope this is what you are looking for.
Rob


Rob,
That's exactly what I'm trying to do.. but in Ruby...
The Ruby Command Object doesn't allow for the switches..
-bl=5 ..

Been pulling my hair out on this all day...

Thanks for the reply!

Maybe you can come up with another method??  Is there a command I can send to 'set' that flag??

Regards,

Dan
Title: Re: How to display messages on MD's
Post by: tschak909 on January 16, 2008, 02:15:17 pm
This is one kludgy kludge, but until it's figured out how to set broadcast level....

why don't you use system(); to fire the MessageSend command?

-Thom
Title: Re: How to display messages on MD's
Post by: ddamron on January 16, 2008, 04:50:34 pm
shhh thom!
trying to AVOID that...
Title: Re: How to display messages on MD's
Post by: rwilson131 on January 16, 2008, 06:16:43 pm
I did a little more testing and it appears that you do not need to set the broadcast level this command works as well
Code: [Select]
/usr/pluto/bin/MessageSend dcerouter -targetType category 1 5 1 809 251 0 9 "TESTING DISPLAY ALERT" 182 15 70 "test"
I do not think this will make much difference, because I do not think you can pass -targetType category either, but at least we now know.

Out of curiosity how are you sending the command via ruby,  I tried to follow the instructions at http://wiki.linuxmce.org/index.php/GSD_Ruby_Interface , but all of the methods I tried were always sent as plain text to the wrong device.
Title: Re: How to display messages on MD's
Post by: ddamron on January 16, 2008, 08:58:09 pm

Out of curiosity how are you sending the command via ruby,  I tried to follow the instructions at http://wiki.linuxmce.org/index.php/GSD_Ruby_Interface , but all of the methods I tried were always sent as plain text to the wrong device.

Yes, that's exactly how I'm doing it...
it's a bit complicated until you get your mind wrapped around it..

the basic method is:
Code: [Select]
mycmd = Command.new(from, to, priority, type, id)
mycmd.params_[x] = y
SendCommand(mycmd)

where:
Command is a command object (already defined by pluto) and new initializes a new Command..
SendCommand is a function (already defined by pluto)

everything else, you define in your code..
from is the device ID (you) (integer)
to is the device ID to. (normally, -1000 for a command, or -1001 for an event) (integer)
priority is an integer
Type (integer) is 1 for command, 2 for event
id is the command/event ID (integer) you want to send
to set the params,
x (integer) is the parameter you want to set
y (STRING) is the value you want to assign to x.

HTH,
Dan