Author Topic: altsteon_cli on remote host  (Read 453 times)

Offline ibrewster

  • Jr. Member
  • **
  • Posts: 91
  • Karma: +1/-0
altsteon_cli on remote host
« on: May 14, 2017, 10:52:22 pm »
I recently moved my vera, and due to the new distance from all my insteon devices, found that I needed to relocate the PLM to a computer closer to the insteon devices rather than letting it hang off my Vera, as I had been doing. So after a bit of work I managed to compile altsteon (or alsteon2, either one) on my Mac, changed the IP of the PLM device in my vera, and tested that it could see and control everything (which it could). So that's all good.

The one thing I haven't been able to solve as of yet, however, is directly issuing commands from my Vera to the altsteon daemon on the remote host. That is, Under the old system I was able to use Lua code like this:

Code: [Select]
os.execute("echo -e \"12.34.56 set_button_led 1 8\nquit\"| /overlay/sbin/altsteon_cli ")
To set the button state on one of my KeypadLinks. However, that no longer works, because the altsteon_cli only connects to the altsteon daemon on the local host. Is there a way to do the same to a remote host?

Specifically, I'm trying to:
a) set the button state on  a KeypadLink, and
b) force poll an insteon device

Thanks!
« Last Edit: May 14, 2017, 10:53:55 pm by ibrewster »

Offline Juppers

  • Jr. Member
  • **
  • Posts: 72
  • Karma: +2/-1
Re: altsteon_cli on remote host
« Reply #1 on: May 14, 2017, 11:35:08 pm »
Do it with the command class for that instead of remote commands.

For the poll, change the interval to something more reasonable than 10 minutes. I have mine poll every 15 seconds. It is the -t option for the altsteon daemon.
« Last Edit: May 14, 2017, 11:38:28 pm by Juppers »

Offline ibrewster

  • Jr. Member
  • **
  • Posts: 91
  • Karma: +1/-0
Re: altsteon_cli on remote host
« Reply #2 on: May 15, 2017, 11:28:48 am »
Thanks, that works, although not quite the same as the "set_button_led" command from the cli. Using that command, I could do something like:

Code: [Select]
3d.7d.e5 set_button_led 1 16
And it would activate the bottom-left button of the group of four and *deactivate* the others (I have them programmed up to be exclusive). Using the "SetLedIndiv" from the scene turns on the proper LED (although the numbering is different), but it doesn't turn off any others.

Not a big deal though, I'll just have to add actions to turn off the other LED's in addition to turning on the one I want.

BTW, this approach also worked for the instant poll I wanted to do, although I'm sure that simply increasing the polling frequency would have worked as well.

Thanks again!

Offline Juppers

  • Jr. Member
  • **
  • Posts: 72
  • Karma: +2/-1
Re: altsteon_cli on remote host
« Reply #3 on: May 15, 2017, 01:23:18 pm »
Sounds like you want to use the SetLedGroup command instead of SetLedIndiv.

For KPL devices (select the switch device, not the scene controller):
SetLedIndiv - allows you to set a single KPL button
SetLedGroup - allows you to set a group of buttons

SetLedIndiv: Takes a button number (1-8) and a state (0=Off, 1=On).  Note that you can't toggle the LED for the local load, so with 6-buttons, you can set buttons 3-6, and with 8-buttons, you can set buttons 2-8.

SetLedGroup: Takes a mask (targetGroup), and new state value (newStateValue).  Each are bitmaps.   targetGroup sets the bits that will be modified (0=disregard, 1=set to new state).  Then those specific bits from newStateValue are applied to the LEDs.

Offline ibrewster

  • Jr. Member
  • **
  • Posts: 91
  • Karma: +1/-0
Re: altsteon_cli on remote host
« Reply #4 on: May 15, 2017, 01:54:04 pm »
Sounds like you want to use the SetLedGroup command instead of SetLedIndiv.

SetLedGroup: Takes a mask (targetGroup), and new state value (newStateValue).  Each are bitmaps.   targetGroup sets the bits that will be modified (0=disregard, 1=set to new state).  Then those specific bits from newStateValue are applied to the LEDs.
So just to confirm, I would use the SetLedGroup command to turn off all except the target button with one command, correct? How do the "bits" in the bitmap map to the physical buttons? Is there documentation for this somewhere that I haven't seen?

At least from your description, where the bits are either disregard or set to new state, the SetLedGroup command will be cleaner and easier than individually setting each button, but it still won't set one on and the others off (since there is only one state) like the set_button_led command did. So I'll still need two commands: one to turn on the target buttons, and one to turn off the others. Which is fine, I'm just trying to make sure I understand correctly  :)

Offline Juppers

  • Jr. Member
  • **
  • Posts: 72
  • Karma: +2/-1
Re: altsteon_cli on remote host
« Reply #5 on: May 16, 2017, 11:57:53 am »
Should only take 1 command. See this post for how to use it.

http://forum.micasaverde.com/index.php/topic,15248.msg115954.html#msg115954

Offline Juppers

  • Jr. Member
  • **
  • Posts: 72
  • Karma: +2/-1
Re: altsteon_cli on remote host
« Reply #6 on: May 16, 2017, 09:58:55 pm »
I played with the setLedGroup command tonight. It works well and you can change all the lights to either state at once. The bitmap for state and which button is binary, you just convert to decimal. The buttons are ordered reversed. So to turn on the lights with the x and turn off all the others you would set the bitmap as so.

1x 2
3   4
5   6
7x 8

State bitmap order (87654321)  01000001 = dec 65
All buttons affected (87654321)  11111111 = dec 255

luup.call_action("urn:geektaco-info:serviceId:InsteonOptions1", "SetLedGroup", {newStateValue = "65",targetGroup = "255"}, <DEVICE>)

Or to have them all on with the x ones off it would be

luup.call_action("urn:geektaco-info:serviceId:InsteonOptions1", "SetLedGroup", {newStateValue = "190",targetGroup = "255"}, <DEVICE>)

Offline ibrewster

  • Jr. Member
  • **
  • Posts: 91
  • Karma: +1/-0
Re: altsteon_cli on remote host
« Reply #7 on: May 17, 2017, 12:06:00 pm »
Sounds perfect and makes sense, thanks! I'll have to play around a bit once I'm back at home, but it sounds like I can accomplish exactly what I wanted like this. Thanks again!