5500SHAC - Lua to enumerate all group addresses

Discussion in 'C-Bus Automation Controllers' started by Narkov, Jan 1, 2020.

  1. Narkov

    zei20t

    Joined:
    Aug 18, 2010
    Messages:
    127
    Likes Received:
    1
    Location:
    Sydney, Australia
    i just tried it, and sadly no, it doesnt work.

    that said, my production environment also doesnt work with it on. but thats using cgate-server -> cgate-mqtt -> mosquitto -> HA

    hmmmm
     
    zei20t, Feb 1, 2021
    #21
    1. Advertisements

  2. Narkov

    Narkov

    Joined:
    Nov 12, 2019
    Messages:
    19
    Likes Received:
    4
    What happens if you publish a packet directly from MQTT?

    Go to:
    Home Assistant > Configurations > Integrations > MQTT > Configure > Publish a packet

    Topic: cbus/read/254/56/2/level
    Value: 255

    ...where "2" is a group for a dimmer channel.

    Any errors in the 5500 or action on the group?
     
    Narkov, Feb 1, 2021
    #22
    1. Advertisements

  3. Narkov

    zei20t

    Joined:
    Aug 18, 2010
    Messages:
    127
    Likes Received:
    1
    Location:
    Sydney, Australia
    thats a great idea!

    however, im using nodered to send messages to MQTT

    i can send to topic: cbus/write/254/56/12/ramp with payload ON and it works

    but sending to cbus/write/254/56/12/ramp doesnt.

    the good thing is, thats only 1 of 4 possible functions i need.

    the SHAC gets both messages, they are logged.

    but ramp also logs an error:

    Resident script:74: attempt to call global 'round' (a nil value)
    stack traceback:
    Resident script:74: in function <Resident script:27>
    [C]: in function 'loop_forever'

    im rubbish with lua, actually, most programming languages. so im not sure what its trying to achieve.
     
    zei20t, Feb 1, 2021
    #23
  4. Narkov

    zei20t

    Joined:
    Aug 18, 2010
    Messages:
    127
    Likes Received:
    1
    Location:
    Sydney, Australia
    hmm when i 'switch' to OFF, it also ramps down. so i get the error again, but the light turns off
     
    zei20t, Feb 1, 2021
    #24
  5. Narkov

    Narkov

    Joined:
    Nov 12, 2019
    Messages:
    19
    Likes Received:
    4
    Just confirming, the correct payload for the ramp command should be a value between 0 and 255. It won't accept ON of OFF. Can you confirm the payload you are sending with the ramp command?
     
    Narkov, Feb 1, 2021
    #25
  6. Narkov

    zei20t

    Joined:
    Aug 18, 2010
    Messages:
    127
    Likes Received:
    1
    Location:
    Sydney, Australia
    yes thats right, 'switch' is ON or OFF, 'ramp' is an integer 0-255
     
    zei20t, Feb 1, 2021
    #26
  7. Narkov

    zei20t

    Joined:
    Aug 18, 2010
    Messages:
    127
    Likes Received:
    1
    Location:
    Sydney, Australia
    OK, i must be doing something wrong.

    if i send:

    payload: "128,5s"
    topic: "cbus/write/254/56/12/ramp"
    qos: 2
    retain: true

    then i receive:

    topic: "cbus/read/254/56/12/state"
    payload: "OFF"
    qos: 1
    retain: false

    topic: "cbus/read/254/56/12/level"
    payload: "0"
    qos: 1
    retain: false
     
    zei20t, Feb 1, 2021
    #27
  8. Narkov

    Narkov

    Joined:
    Nov 12, 2019
    Messages:
    19
    Likes Received:
    4
    Can we simplify the test case first and check if the immediate ramp works:

    payload: "128"
    topic: "cbus/write/254/56/12/ramp"
    qos: 2
    retain: true

    What does that return?
     
    Narkov, Feb 1, 2021
    #28
  9. Narkov

    Narkov

    Joined:
    Nov 12, 2019
    Messages:
    19
    Likes Received:
    4
    Narkov, Feb 1, 2021
    #29
    zei20t likes this.
  10. Narkov

    zei20t

    Joined:
    Aug 18, 2010
    Messages:
    127
    Likes Received:
    1
    Location:
    Sydney, Australia
    same thing. sorry, i tried with and without time.

    also the group level doesnt change.

    i might delete the scripts and start over.

    now turning a group on and off takes about 10 seconds before the light reacts.

    maybe ill reset the SHAC to factory while im at it!
     
    zei20t, Feb 1, 2021
    #30
  11. Narkov

    zei20t

    Joined:
    Aug 18, 2010
    Messages:
    127
    Likes Received:
    1
    Location:
    Sydney, Australia
    haha im happy to help, i thought it was me! i rekon some of it still is me

    im still going to reset the SHAC and upload the CGL

    thanks again
     
    zei20t, Feb 1, 2021
    #31
  12. Narkov

    zei20t

    Joined:
    Aug 18, 2010
    Messages:
    127
    Likes Received:
    1
    Location:
    Sydney, Australia
    finally had time to look at this:

    so my SHAC didnt need a reset at all, i just needed to configure things properly in HA

    it seems to work perfectly fine, big thanks narkov!

    your examples of light config for HA fixed it for me. it appears the order of the commands make a huge difference.

    anyway, im playing with the fan control next, saw the info about it on github.......
     
    zei20t, Mar 24, 2021
    #32
  13. Narkov

    Narkov

    Joined:
    Nov 12, 2019
    Messages:
    19
    Likes Received:
    4
    Very happy to help!

    Unfortunately I don't have a fan controller to do the debugging and testing there but I'm happy to make any changes or help where I can.

    I appreciate any feedback or changes if you find a solution.
     
    Narkov, Mar 24, 2021
    #33
  14. Narkov

    zei20t

    Joined:
    Aug 18, 2010
    Messages:
    127
    Likes Received:
    1
    Location:
    Sydney, Australia
    cheers, ill muck around with it over the coming weeks, might make contact with the other guy on github.

    thanks again for all your work!
     
    zei20t, Mar 24, 2021
    #34
  15. Narkov

    ZacOlly

    Joined:
    Mar 16, 2019
    Messages:
    4
    Likes Received:
    3
    Hi,
    Thanks heaps for all this, I've been looking to integrate Cbus to HA for a few customers.
    Most of them have a SHAC already so I am hoping to use MQTT to do this.

    I've setup a small test network at my place with a SHAC on the same network as my HA running as a MQTT broker
    I've used the 5500SHAC-Cbus2MQTT from github

    I've put the scripts on the SHAC and updated the broker details but cannot get it to publish or read any topics
    SHAC logs when i restart the mqtt broker are:
    *string: MQTT connected - send
    *string: MQTT connected - receive

    The event based script is definitely running every time i make any GA object changes on the Cbus Network.
    I don't know how to determine if the resident scripts are running or if the event script is pushing correctly to the resident scripts.

    Do i need to edit the event based script at all?
    require('socket').udp():sendto(event.dst .. "/" .. event.getvalue(), '127.0.0.1', 5432)

    In HA i have created the buttons using the light / mqtt platform and when i listen to the topics i get the buttons sending on/off and ramp as expected however no response on the SHAC

    When I restart the mqtt broker I get logs similar to the attached.
    My SHAC is 192.168.1.120
    No idea what the 172.30.32.1 and 172.30.32.2 devices are.
    I don't know enough about MQTT but is this the buttons in HA subscribing to the topics?

    It also has the 127.0.0.1 device which I am assuming is the SHAC as it is referenced in the event based script.

    Any help would be much appreciated.
     

    Attached Files:

    ZacOlly, Jun 21, 2021
    #35
  16. Narkov

    Damaxx

    Joined:
    May 12, 2008
    Messages:
    207
    Likes Received:
    32
    I would bet that 172.30.32.1 and 172.30.32.2 are docker containers in HA - possibly HA is one but not sure what the other would be. There is another thread discussing issues with the HA - MQTT broker.
    I used a separate MQTT broker with my SHAC and it doesn't skip a beat?
    Have you added 'All' to every object keyword in the SHAC to make sure it triggers the script?
     
    Damaxx, Jun 21, 2021
    #36
  17. Narkov

    ZacOlly

    Joined:
    Mar 16, 2019
    Messages:
    4
    Likes Received:
    3
    Thanks to @Narkov and @Damaxx for pointing me in the direction of an external docker.
    Got it all working using the test mosquitto broker instead of the HA add-on
    I'll be setting up a docker in the coming weeks.
     
    ZacOlly, Jun 23, 2021
    #37
    Damaxx likes this.
  18. Narkov

    Damaxx

    Joined:
    May 12, 2008
    Messages:
    207
    Likes Received:
    32
    While you are at it, look into other bits that you can add on like portainer, organizr, nodered, esphome... the rabbit hole doesn't end.
     
    Damaxx, Jun 23, 2021
    #38
    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.