Migrating PACA to 5500AC2...

Discussion in 'C-Bus Automation Controllers' started by jr_away, May 8, 2023.

  1. jr_away

    jr_away

    Joined:
    Apr 28, 2005
    Messages:
    64
    Likes Received:
    0
    Hello all,

    PACA blew up after a power surge along with most of the C-Bus DIN units(!) so I'm taking the opportunity to migrate to 5500AC2.

    The C-Bus system is interfaced to an Elk M1g alarm panel with C-Bus module. When various conditions are met, the M1g turns on designated C-Bus groups; PACA used to detect these group changes and run scenes or perform other actions. I had tried to trigger scenes directly from the M1g, but it appears unable to do this. Hence use of a group.

    I've managed to recreate scenes on the 5500AC2 and now presume I need scripts to detect state changes of the relevant groups. However, despite extensive programming experience I am left scratching my head. I can see conditionals in LUA, but it appears the script will need to run continuously to poll for state changes, rather than being invoked only when one of the relevant groups changes. Or have I misunderstood? Any assistance appreciated!
     
    jr_away, May 8, 2023
    #1
  2. jr_away

    Pie Boy

    Joined:
    Nov 21, 2012
    Messages:
    249
    Likes Received:
    31
    Location:
    New Zealand
    If the elk alarm is already controlling Cbus GA. Then you only need an event script, AC2 has 3 different types of scripts, resident, scheduled and event.

    Event scripts run every time Cbus GA changes value.
    Sounds like this may be what you are looking for I guess you need an event script per security /Cbus GA event
     
    Pie Boy, May 8, 2023
    #2
  3. jr_away

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,537
    Likes Received:
    177
    Location:
    Adelaide, Australia
    If you assign the same keyword to each group from the M1, you can create a single event script on that keyword. Then when the event fires just check each group and set the appropriate scene.

    It is possible to trigger scenes directly from the M1. You need the M1 Cbus module editor. With it you can define what application and group each M1 address is associated with. If it was mine though, I'd just stick with the lighting ga's and an event script.

    It's really annoying that the SHAC limits triggering scenes to the trigger control app. There is no reason why that can't be triggered from a lighting app.
     
    Ashley, May 8, 2023
    #3
  4. jr_away

    jr_away

    Joined:
    Apr 28, 2005
    Messages:
    64
    Likes Received:
    0
    Thank you both -

    So I can dig into the Elk (or actually Ness) C-Bus module to persuade it to send triggers, or a Lua Event Script that detects state change of my groups... I'll start with the script that seems least invasive.
     
    jr_away, May 8, 2023
    #4
  5. jr_away

    jr_away

    Joined:
    Apr 28, 2005
    Messages:
    64
    Likes Received:
    0
    OK, so I created a Scene with Trigger = SetNightMode (0/202/3) and Action Selector=255.

    Then I created an Event script to fire that trigger. The Event Script is on the NightMode group turned on by the alarm panel. But I must be doing something wrong. Any advice appreciated!

    Code:
    if (event.getvalue==255) then
      SetTriggerlevel('SetNightMode',255)
    -- SetTriggerLevel(3,255) still doesn't work
    end
    To test the logic, I created another Test script that just sets the Trigger Level; but when run, it doesn't trigger the Scene. The Scene itself runs as expected when run from the editor.

    Any advice appreciated!
     
    jr_away, May 9, 2023
    #5
  6. jr_away

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,537
    Likes Received:
    177
    Location:
    Adelaide, Australia
    Never having tried setting a scene programmatically in the SHAC I had a good look at this. In general (on all other scene capable devices) you cannot set a local scene by setting its trigger. i.e. You can only trigger a remote scene. I could not find a definitive statement that this is the same for the SHAC, but given it doesn't work (I tried it myself), I assume this also applies to the SHAC. You could test this by putting the scene in another device like a Neo, DLT etc.

    I then thought, ok, just set the scene directly via lua but unfortunately there doesn't seem to be a setScene script function.

    So not sure where you can go from here.
    Hopefully someone else has some ideas.

    You may have to investigate the M1 option.
     
    Ashley, May 9, 2023
    #6
  7. jr_away

    jr_away

    Joined:
    Apr 28, 2005
    Messages:
    64
    Likes Received:
    0
    PACA made it very straight forward to detect group state changes and run scenes entirely within the PACA; surely there has to be a way to do it in this more modern device.

    Price wise the 5500AC2 looks positive against PACA plus 5500CN and reportedly makes MQTT far easier from Home Assistant or similar- but it also needs to be able to do the simple stuff well. Like running a Scene from a script!

    A fantastic resource for integrators and others considering their next C-Bus step would be a document taking the handful of PACA commands and giving a few sample lines of LUA code to achieve the equivalent. This would help to de-risk the decision to pull the trigger on a 5500AC2 or NAC2.

    If I can make it work I'll post samples here, as I'm thinking centralizing scenes and management must be one of the bread and butter basics that will crop up repeatedly. Perhaps we can also assist Schneider to include some samples in the Script Editor documentation.

    I will persevere.
     
    Last edited: May 9, 2023
    jr_away, May 9, 2023
    #7
  8. jr_away

    jr_away

    Joined:
    Apr 28, 2005
    Messages:
    64
    Likes Received:
    0
    Progress (?) report:

    - With the Export checkbox ticked for the SetNightMode Trigger, using the 5500AC2's Export CGL function *does* include the trigger in the file metadata- but when imported into Toolkit Version 1.16.2, the Trigger is not imported- though the import still reports success.

    Creating the trigger manually in Toolkit doesn't allow the same sort of Action Selector as in the 5500AC2 definition; in Toolkit, the Action Selector seems to want a unique group address.

    This all seems a bit hit and miss, especially to achieve something so basic.
     
    jr_away, May 9, 2023
    #8
  9. jr_away

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,537
    Likes Received:
    177
    Location:
    Adelaide, Australia
    Action selectors are always unique to a group address. How is this not the same in the SHAC?

    I find creating everything in toolkit then importing it into the SHAC works more reliably than the other way around.

    Yes, the hardware looks so good. Unfortunately the firmware is a complete disaster. :(
     
    Ashley, May 10, 2023
    #9
  10. jr_away

    Ks04

    Joined:
    Dec 28, 2019
    Messages:
    111
    Likes Received:
    9
    Ks04, May 10, 2023
    #10
    Ashley likes this.
  11. jr_away

    jr_away

    Joined:
    Apr 28, 2005
    Messages:
    64
    Likes Received:
    0
    Thanks, Ks04 - how wonderful if the simplicity of the PACA is replaced by an external API that works today and may tomorrow too! It's not as if running a scene is something you'd need to automate that often in C-Bus. /sarc/

    While still surprised if there's no command to script a scene: I believe I have an "Aha" moment. If you run a Script with something like

    Code:
    SetTriggerlevel(3,255)
    Where trigger address 3 is defined in 5500AC2, currently I am seeing a Set Level dialog for the Group the Event Script is monitoring. Why would SetTriggerlevel attempt to set that level- or is that there to mimic the triggering event?

    At this stage I'm wondering whether the mislabeled "Action Selector" in the Trigger definition leaves Action Selector blank. That would help explain trigger failure, but also failure to import the incomplete trigger back to Toolkit.

    If this is correct, then it should not be difficult to reassign "Action Selector" to Action Selector in the AC2, with a separate field for those already using Action Selector differently- elsewhere I even see Action selector set to phrases like "All On" that can be tested for. Do you know if anybody from Schneider will see this?
     
    Last edited: May 10, 2023
    jr_away, May 10, 2023
    #11
  12. jr_away

    Ks04

    Joined:
    Dec 28, 2019
    Messages:
    111
    Likes Received:
    9
    It’s occurred to me that I am actually setting scenes via event scripts already and it works fine - what firmware version are you running?

    As an example


    Code:
      -- Get value of user parameter 'Evening' on local network
        value = GetUserParam(0, 251)
        if value == false then
           -- Set trigger level of group 10 to 255 (ON)
            SetTriggerLevel(10, 255)
        else
          SetTriggerLevel(10, 5)
        end
     
    Ks04, May 10, 2023
    #12
  13. jr_away

    jr_away

    Joined:
    Apr 28, 2005
    Messages:
    64
    Likes Received:
    0
    Hi Ks04,

    Running V1.13.0.

    Your SetTriggerLevel() is identical to mine, except my trigger is group 3. And mine checks level in an Event Script on Nightmode lighting group rather than your user parameter, but that wouldn't affect SetTriggerLevel in an Event by itself.

    At this stage the most visible difference is that I defined things directly in AC2 rather than imported from toolkit- and attempting to import back to Toolkit did not work. I will check it out...
     
    Last edited: May 11, 2023
    jr_away, May 10, 2023
    #13
  14. jr_away

    jr_away

    Joined:
    Apr 28, 2005
    Messages:
    64
    Likes Received:
    0
    Progress!

    In Toolkit, I created Trigger Group 3 with Action Selector 255.

    From the Action Selector dialog, clicking the "Set Level" button causes the Scene defined in AC2 to run.

    Partial success!

    Back in AC2, Clicking "Set Value" with Trigger (object) selected also causes the Scene to run.

    /edit/ and Script with

    Code:
    SetTriggerLevel(3, 255)
    also causes it to run.

    HOWEVER - if you refer to earlier code, there's a lower case "l" in SetTriggerLevel.

    Oops.

    LUA's error message for that is "attempt to call global 'SetTriggerlevel' (a nil value)"

    So, lesson of the day for me:

    1) Always check LUA's Script Error Log.
    2) "Attempt to call global..." means you need to check the function Name and Case.
    3) Easier to create objects in Toolkit and export to AC2.

    Incidentally, this also works:

    Code:
    SetTriggerLevel('SetNightMode', 255)
    When I get a moment I'll put together a primer on this topic for LUA newbies like me!
     
    Last edited: May 11, 2023
    jr_away, May 11, 2023
    #14
  15. jr_away

    Wonkey

    Joined:
    Aug 3, 2004
    Messages:
    413
    Likes Received:
    39
    Location:
    Adelaide
    I am pleased to see you found the problem as I was trying to replicate a similar situation and it all worked as expected.
    However I noticed that nobody has commented on the trigger for this change in your C-Bus System, The Power Surge. If you haven't done it now please consider installing some surge protection as a minimum in your Distribution box where the mains enters your property, you may need additional unit(s) in the C-Bus cabinets if you have long runs from the mains to these cabinets.
    This post has highlighted some shortcoming in the SHAC and that is the terminology that is in use when playing with the product, we know have 'objects, that may mean Group addresses in one area, then mixed in with levels elsewhere.
    Historically the terminology was set out in the training courses and allowed everyone to talk the same language. I have yet to find any updated info to help resolve this issue and really should be addressed by SE.
     
    Wonkey, May 11, 2023
    #15
  16. jr_away

    jr_away

    Joined:
    Apr 28, 2005
    Messages:
    64
    Likes Received:
    0
    Thanks, Wonkey

    Re the surge: the site was a complete rewire about 10 years ago with RCD cover throughout. Problem happened in a storm when a tree fell onto the 3-phase overhead lines and took out the neutral. There's debate on how the phases stayed up with measured voltage fluctuating low 100s to high 300V. Apparently not enough to trip a surge protector? Instead there were smoking light bulbs, weird noises, transformers went pop, maybe half the plugged in appliances had something fried internally. Some RCDs blew. All of the C-Bus power supplies got fried and about 2 thirds of the DIN rail units were completely dead as well as 2 eDLT and the PACA. Recorded as a freak event that's unlikely to recur- but good advice re surge protectors, I'll look into it.

    Re terminology: I agree re inconsistencies, but also if you look elsewhere there's people using Action Selectors like "ALL ON" which can be entered into the automation controller and tested for in an Event Script, but isn't compatible with Toolkit.
     
    jr_away, May 11, 2023
    #16
  17. jr_away

    ssaunders

    Joined:
    Dec 17, 2008
    Messages:
    242
    Likes Received:
    35
    Location:
    Melbourne
    ssaunders, Sep 6, 2023
    #17
  18. jr_away

    SgrAystar

    Joined:
    Oct 4, 2018
    Messages:
    60
    Likes Received:
    5
    Location:
    Melbourne, Australia
    I have been using SetTriggerLevel to run scenes, but browsing the logicmachine lua reference I saw run.scene(name), which seems to work on the AC2.
    Does this mean it is not 'officially' supported and subject to change etc.?
     
    SgrAystar, Oct 18, 2023
    #18
  19. jr_away

    ssaunders

    Joined:
    Dec 17, 2008
    Messages:
    242
    Likes Received:
    35
    Location:
    Melbourne
    scene.run() will probably be there forever. That said, when a trigger level gets set, all scenes on all devices, including the AC will fire for that trigger, but not when using scene.run(). Additionally, I could not get CBus functions like SceneIsSet() to work unless the trigger was used, so it makes sense to me that scene.run() is not documented for the world of Schneider Automation Controllers.

    AFAIK, LogicMachine does not feature the concept of trigger control, so scene.run() is all they have to fire a scene from LUA.

    I'd keep using SetTriggerLevel. It might seem more cumbersome, but it's just better IMHO.

    -- scene.run('Pool lighting 2')
    SetTriggerLevel('Poolside', 2) -- Equivalent using a trigger

    log(SceneIsSet('Pool lighting 2')) -- Works when triggered, but not when scene.run() is used.
     
    Last edited: Oct 23, 2023
    ssaunders, Oct 23, 2023
    #19
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.