Author Topic: How to access device's state info from GSD ?  (Read 9846 times)

bulek

  • Administrator
  • wants to work for LinuxMCE
  • *****
  • Posts: 909
  • Living with LMCE
    • View Profile
How to access device's state info from GSD ?
« on: June 24, 2008, 01:40:11 pm »
Hi,

I'm reading GSD tutorials in wiki, but haven't found a way how to write/read state of device...
I have found a way to access added Device Data fileds (that have ID), but don't know if I can in the same way access also device state ?

Can I do it with SetDeviceDataInDB and some magic ?

Thanks in advance,

regards,

Bulek.
« Last Edit: June 24, 2008, 02:07:06 pm by bulek »
Thanks in advance,

regards,

Bulek.

jondecker76

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 763
    • View Profile
Re: How to access device's state info from GSD ?
« Reply #1 on: June 24, 2008, 04:16:34 pm »
it all seems very plugin/module specific, unfortunately, and I don't think there is any way reference them in a general scope. I'm not sure how it would tie in with GSD, but you could look at the source for the devices you want state information on and see if you can import the data into GSD somehow.

For example, last power command, last input etc. is stored locally in MessageTranslation_AV.cpp as it translates toggle inputs and toggle power commands into the appropriate command on or off.

I could be missing something, but I have seen no internal mechanism for managing this at a higher level.

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: How to access device's state info from GSD ?
« Reply #2 on: June 24, 2008, 04:22:58 pm »
Use the Device Data to pass stuff between devices. Use the get/set device data commands in the General Info plugin to set these things beyond the boundaries of the current device.

-Thom

bulek

  • Administrator
  • wants to work for LinuxMCE
  • *****
  • Posts: 909
  • Living with LMCE
    • View Profile
Re: How to access device's state info from GSD ?
« Reply #3 on: June 25, 2008, 12:50:40 am »
Hi,

thanks for responses... Pardon me, if I'm not getting this right,  let me ask in another way :
- I can modify/read any device data parameter value with SetDeviceDataInDB (I've seen few examples for setting volume device data in receiver GSD devices)... that's ok

- Can I read/write device's state (that is displayed on web-admin) in some similar easy way ? Setting device state with sending events depends on plugins, I could also do it directly in sql, but I bet there is Ruby and GSD possibility to do that more conveniently... if I have access to device data, maybe I have also to device's state ?

Thanks in advance,

regards,

Bulek.


Thanks in advance,

regards,

Bulek.

ddamron

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 962
    • View Profile
    • My LinuxMCE User Page
Re: How to access device's state info from GSD ?
« Reply #4 on: June 26, 2008, 06:11:16 am »
bulek,

I learned this the hard way...

Currently, you can't set the state information via an event.. (with the exception of on/off)
even then, it's a bit confusing..

Here's how I worked around it:

Send a COMMAND message (not an event message) to MYSELF, with the appropriate cmd to set the state info I want,
then, IGNORE messages where from=to.

Oh yeah, and also, don't forget to set the devdata[120] = 1 before you send the command...
HTH,

Dan
« Last Edit: June 26, 2008, 06:14:02 am by ddamron »
The only intuitive interface is the nipple.  After that it's all learned.
My other computer is your windows box.
I'm out of my mind.  Back in 5 minutes.
Q:  What's Red and smells like blue paint?

A:  Red Paint.

bulek

  • Administrator
  • wants to work for LinuxMCE
  • *****
  • Posts: 909
  • Living with LMCE
    • View Profile
Re: How to access device's state info from GSD ?
« Reply #5 on: June 26, 2008, 07:12:48 am »
bulek,

I learned this the hard way...

Currently, you can't set the state information via an event.. (with the exception of on/off)
even then, it's a bit confusing..

Here's how I worked around it:

Send a COMMAND message (not an event message) to MYSELF, with the appropriate cmd to set the state info I want,
then, IGNORE messages where from=to.

Oh yeah, and also, don't forget to set the devdata[120] = 1 before you send the command...
HTH,

Dan


What I'd like to do is to change state directly.... I'm writting templates for devices, where plugins probably won't ever have the support for proper events. Therefore I'd like to set state by my own... I've found that State is parameter #200, but it seems that this is not entirely true, cause State doesn't appear in main DeviceData table....

Any way to change it directly ?

Thanks in advance,

regards,

Bulek.


Regards,
Thanks in advance,

regards,

Bulek.

ddamron

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 962
    • View Profile
    • My LinuxMCE User Page
Re: How to access device's state info from GSD ?
« Reply #6 on: June 26, 2008, 08:01:41 pm »
Bulek,

REREAD my last message.


my device = 50
to set state to "ON"
cmd = Command.new(50,50,1,1,192) # 192 = ON
cmd.params[120]="1" # retransmit
SendCommand(cmd)

to set my devices state to 50%:
cmd = Command.new(50,50,1, 1,76, 184) #184 = SetLevel
cmd.params[76] = "50" #State to be set
cmd.params[120]="1" #retransmit
SendCommand(cmd)

now in your Process Recieve Command for Child:
if cmd.to = cmd.from
  #ignore this command
end

That will set your state.
My underscore key is broken, so I didn't add those.
Take a look at my Insteon code for more examples.
« Last Edit: June 26, 2008, 08:03:21 pm by ddamron »
The only intuitive interface is the nipple.  After that it's all learned.
My other computer is your windows box.
I'm out of my mind.  Back in 5 minutes.
Q:  What's Red and smells like blue paint?

A:  Red Paint.

bulek

  • Administrator
  • wants to work for LinuxMCE
  • *****
  • Posts: 909
  • Living with LMCE
    • View Profile
Re: How to access device's state info from GSD ?
« Reply #7 on: June 26, 2008, 09:47:29 pm »
Bulek,

REREAD my last message.


my device = 50
to set state to "ON"
cmd = Command.new(50,50,1,1,192) # 192 = ON
cmd.params[120]="1" # retransmit
SendCommand(cmd)

to set my devices state to 50%:
cmd = Command.new(50,50,1, 1,76, 184) #184 = SetLevel
cmd.params[76] = "50" #State to be set
cmd.params[120]="1" #retransmit
SendCommand(cmd)

now in your Process Recieve Command for Child:
if cmd.to = cmd.from
  #ignore this command
end

That will set your state.
My underscore key is broken, so I didn't add those.
Take a look at my Insteon code for more examples.


Hi,

thanks for aditional info. This way still seems a bit unconvenient, that's why I'm discussing this. I guess something like "SetDeviceDataInDB" would be more convenient, but impossible I guess at the moment..

Thanks again for clarification,

regards,

Bulek.
Thanks in advance,

regards,

Bulek.

ddamron

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 962
    • View Profile
    • My LinuxMCE User Page
Re: How to access device's state info from GSD ?
« Reply #8 on: June 27, 2008, 01:42:34 am »
Who ever said programming was convenient?!?

I wrapped my brain HARD around this problem..  I know of no other way to SET a device's STATE.
The only intuitive interface is the nipple.  After that it's all learned.
My other computer is your windows box.
I'm out of my mind.  Back in 5 minutes.
Q:  What's Red and smells like blue paint?

A:  Red Paint.

bulek

  • Administrator
  • wants to work for LinuxMCE
  • *****
  • Posts: 909
  • Living with LMCE
    • View Profile
Re: How to access device's state info from GSD ?
« Reply #9 on: December 22, 2008, 04:07:31 pm »
Hi,

I came across this discussion and connected this with my current work on Climate plugin. The things are like that cause plugins are currently written so - so when they receive self addressed message then they set state of device according to that....

But I still think :
- probably it's a wise thing not to let user to change device state directly (at least for devices that have special meaning - like climate devices for instance)
- I'm not sure that having self addressed messages for this purpose is consistent with DCE philosophy... I'm leaning toward "State Changed" event that would be sent from device and corresponding plugin will change device state.
- for devices beside those with special meaning, some other, more generice plugin should do this - perhaps General_Info plugin ?

What is your opinion ?

Thanks in advance,

regards,

Bulek.
Thanks in advance,

regards,

Bulek.

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: How to access device's state info from GSD ?
« Reply #10 on: December 22, 2008, 05:58:56 pm »
I don't see a problem with the approach on first glance, it's definitely worth exploring.

-Thom

ddamron

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 962
    • View Profile
    • My LinuxMCE User Page
Re: How to access device's state info from GSD ?
« Reply #11 on: December 26, 2008, 09:38:15 pm »
Bulek,
Yes, you are correct, ideally, there should be a state changed event (to correspond to DCE philosophy) and a param to adjust state.  In my case, my driver needed to change the state of a child device. 

I would like to see a param value that we can use to read and write the state of a device.
Initially, when I wrote my driver, I had no way of reading and writing state.  My solution (albeit a work around) was to WRITE the state via (send cmd to self) and then track the state inside my driver.

HTH,

Dan
The only intuitive interface is the nipple.  After that it's all learned.
My other computer is your windows box.
I'm out of my mind.  Back in 5 minutes.
Q:  What's Red and smells like blue paint?

A:  Red Paint.

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: How to access device's state info from GSD ?
« Reply #12 on: December 26, 2008, 09:53:37 pm »
Hey Dan! good to see you posting again :D

Am chillin in the Carribean, wish you were here, bro.

-Thom

ddamron

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 962
    • View Profile
    • My LinuxMCE User Page
Re: How to access device's state info from GSD ?
« Reply #13 on: December 28, 2008, 04:14:31 am »
Heh, thanks Thom, I wish I was there too!!

The only intuitive interface is the nipple.  After that it's all learned.
My other computer is your windows box.
I'm out of my mind.  Back in 5 minutes.
Q:  What's Red and smells like blue paint?

A:  Red Paint.