Elusive NAC/SHAC API

Discussion in 'C-Bus Automation Controllers' started by Timbo, Apr 4, 2020.

  1. Timbo

    Timbo

    Joined:
    Aug 3, 2004
    Messages:
    16
    Likes Received:
    3
    Location:
    Perth, Australia
    Hi All,

    Seem to remember seeing a forum post about an undocumented API, but cannot search for a three letter acronym (frustrating).
    I'm hoping to trigger scenes from my Inner Range Inception alarm, without going down the path of sending commands directly to the CNI (this is obviously a pain as it eats up the TCP socket!).

    Any of you guys able to point me in the right direction?

    Cheers,

    Tim
     
    Timbo, Apr 4, 2020
    #1
    1. Advertisements

  2. Timbo

    Pie Boy

    Joined:
    Nov 21, 2012
    Messages:
    163
    Likes Received:
    25
    Location:
    New Zealand
    What methods off communication can the alarm potentially use to communicate with the shac?
     
    Pie Boy, Apr 4, 2020
    #2
    1. Advertisements

  3. Timbo

    Timbo

    Joined:
    Aug 3, 2004
    Messages:
    16
    Likes Received:
    3
    Location:
    Perth, Australia
    Timbo, Apr 5, 2020
    #3
  4. Timbo

    Pie Boy

    Joined:
    Nov 21, 2012
    Messages:
    163
    Likes Received:
    25
    Location:
    New Zealand
    Oh Yes, looks like you would have to use TCP or rs232 if you want to have 2way communication between shac and inception.
    Also looks like you can send a custom url to a device based on an event trigger in the alarm panel, this code will let you do that, there was originally an api called remote services included in the shac but it is documented in the change log for the newest firmware that they have made changes to it but haven't documented what they are or how it is to be used so that is no help.....
    This is my work around, been using it for a while now, run below code once in a resident script to create the file it will disable itself as per last line in the code then test from a browser (change ip to shac ip adress) with url like this http://192.168.0.0/user/C_bus.lp?cmd=0,56,22,255,0
    cmd format is, network, app, group, level, rate (same as the command SetCbusLevel(net, app, group, level, rate))

    Code:
    dst = '/www/user/C_bus.lp'
    if not io.exists(dst) then
      io.writefile(dst, [[<?
      require('socket.url')
      require('cbuslogic')
      rx = socket.url.unescape(getvar('cmd'))
      s = string.split(rx, ',')
      SetCBusLevel(s[1], s[2], s[3], s[4], s[5])
      grptag = GetCBusGroupTag(s[1], s[2], s[3])
      print('Sent C bus command to : ' ..'Network '.. s[1]..' Application '.. s[2]..' Group '.. s[3]..' '.. '('..grptag..') To level ' ..s[4]..' Ramp Rate '..s[5])
       ?>]])
    end
    
    script.disable(_SCRIPTNAME)
    
     
    Pie Boy, Apr 5, 2020
    #4
    Timbo likes this.
  5. Timbo

    Pie Boy

    Joined:
    Nov 21, 2012
    Messages:
    163
    Likes Received:
    25
    Location:
    New Zealand
    this line didn’t format correctly swap it out

    rx = socket.url.unescape(getvar('cmd'))
    Needs ‘)) after cmd
     
    Pie Boy, Apr 6, 2020
    #5
  6. Timbo

    Timbo

    Joined:
    Aug 3, 2004
    Messages:
    16
    Likes Received:
    3
    Location:
    Perth, Australia
    Afternoon Mate,

    That's a sneaky and clever way of hooking back into the system, really appreciate you sharing the code!

    The apostrophe and brackets seemed to be ok- I have it working using the lighting application (56) but strangely doesn't seem to want to play ball with a trigger group.
    It is correctly populating grptag... trying to remember if I read somewhere that you couldn't use SetCBusLevel for a trigger group? (I might be talking out of my hat).
     
    Timbo, Apr 6, 2020
    #6
  7. Timbo

    Pie Boy

    Joined:
    Nov 21, 2012
    Messages:
    163
    Likes Received:
    25
    Location:
    New Zealand
    Yeah i think you are correct, i never checked the trigger control.
    try this one, with url http://192.168.0.0/user/C_bus_trigger.lp?cmd=1, 123

    Code:
    dst = '/www/user/C_bus_trigger.lp'
    if not io.exists(dst) then
      io.writefile(dst, [[<?
      require('socket.url')
      require('cbuslogic')
      rx = socket.url.unescape(getvar('cmd'))
      s = string.split(rx, ',')
      SetTriggerLevel(s[1], s[2])
        print('Sent C bus trigger command to : ' ..'Trigger Group '.. s[1]..' Trigger Level '.. s[2])
       ?>]])
    end
    
     
    Pie Boy, Apr 6, 2020
    #7
    Timbo likes this.
  8. Timbo

    nathanbull

    Joined:
    Apr 15, 2021
    Messages:
    6
    Likes Received:
    0
    Hey Pie,

    Getting this error. Very new to this so appreciate the help!
    upload_2021-4-28_9-37-31.png
     
    nathanbull, Apr 28, 2021
    #8
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.