MQTT - Looking for a solid guide to setup

Discussion in 'C-Bus Toolkit and C-Gate Software' started by theboyg, Nov 11, 2021.

  1. theboyg

    theboyg

    Joined:
    Apr 3, 2005
    Messages:
    206
    Likes Received:
    8
    I've had cgate running for some time on a Pi, and using Home Bridge. It's been very solid, works great.

    I'm now looking to transition to Home Assistant, and whilst I can expose the Home Kit CBUS entities to Home Assistant, I want to simplify and remove the need to bounce off of Home Bridge. For that, I need to install the cgateweb MQ piece on the Pi - except I can't get it working.

    I've installed cgateweb on the Pi where the cgate server is installed, so it's a localhost connection. I've also got Mosquitto on Homebridge setup, and have MQTT explorer connected so I can see any incoming traffic.

    I've tried these sites for instructions:
    https://github.com/the1laz/cgateweb (but appears incomplete?)
    https://addictedtopi.tumblr.com/post/101165284373/setting-up-cgateweb-c-bus-to-mqtt-on-linux , tried this next but nothing happening.

    So I don't know if it's the cgateweb install, the connection, the credentials, or whatever. Is there a way to get a view of what cgateweb is doing, check it's config?

    I'm hoping I can get some inspiration from the hive mind here, thanks!
     
    theboyg, Nov 11, 2021
    #1
    1. Advertisements

  2. theboyg

    pspeirs

    Joined:
    Nov 23, 2013
    Messages:
    171
    Likes Received:
    7
    Location:
    Sydney
    Are you using the clipsal SHAC at all?
     
    pspeirs, Nov 12, 2021
    #2
    1. Advertisements

  3. theboyg

    theboyg

    Joined:
    Apr 3, 2005
    Messages:
    206
    Likes Received:
    8
    No SHAC, @pspeirs , I'm using a CNI with cgate which has been rock solid for me. That still works, Home Bridge is still up and responding well, but cgateweb is not showing signs of life.
     
    theboyg, Nov 12, 2021
    #3
  4. theboyg

    pspeirs

    Joined:
    Nov 23, 2013
    Messages:
    171
    Likes Received:
    7
    Location:
    Sydney
    OK, sorry, I'm not across that. For shac, I have a nice udp transfer and native mqtt solution set up.
     
    pspeirs, Nov 12, 2021
    #4
  5. theboyg

    theboyg

    Joined:
    Apr 3, 2005
    Messages:
    206
    Likes Received:
    8
    So, some partial success! I tried running
    node /usr/local/bin/cgateweb/index.js

    And that fired it up, so need to work out why the service isn't kicking in. New to Linux here!
     
    theboyg, Nov 12, 2021
    #5
  6. theboyg

    Damaxx

    Joined:
    May 12, 2008
    Messages:
    216
    Likes Received:
    36
    What version of linux are you using? I was using the cgateweb service on Ubuntu 16.04 and it worked fine but there were changes with Ubuntu 20.04 (and I think even 18.04?) that made cgateweb not work.

    What message do you get with - sudo service cgateweb status
     
    Damaxx, Nov 12, 2021
    #6
  7. theboyg

    theboyg

    Joined:
    Apr 3, 2005
    Messages:
    206
    Likes Received:
    8
    I get this, it's a Pi running debian
    [email protected]:~ $ sudo service cgateweb status

    ‚óŹ cgateweb.service - cgateweb
    Loaded: loaded (/etc/systemd/system/cgateweb.service; enabled; vendor preset:
    Active: activating (auto-restart) (Result: exit-code) since Sat 2021-11-13 13
    Process: 1063 ExecStart=/usr/bin/nodejs /usr/local/bin/cgateweb/index.js (code
    Main PID: 1063 (code=exited, status=203/EXEC)


    So that does say it's loaded, but there's no life. If I stop the service and do:
    node /usr/local/bin/cgateweb/index.js

    Then cgateweb loads in the terminal window and MQ messages flow through to the broker. So I'm going to assume the service has a rights issue?
     
    theboyg, Nov 13, 2021
    #7
  8. theboyg

    theboyg

    Joined:
    Apr 3, 2005
    Messages:
    206
    Likes Received:
    8
    Once I looked at the above, I saw the issue. Now working with the ExecStart using just "node /....." as the command rather than "/usr/bin/nodejs......"

    Thanks for the inspiration :)
     
    theboyg, Nov 13, 2021
    #8
    DarylMc and Damaxx like this.
  9. theboyg

    theboyg

    Joined:
    Apr 3, 2005
    Messages:
    206
    Likes Received:
    8
  10. theboyg

    RobRam

    Joined:
    May 3, 2015
    Messages:
    4
    Likes Received:
    0
    Location:
    Cape Town
    I used the python cmqttd lib ( https://github.com/micolous/cbus / https://cbus.readthedocs.io/en/latest/introduction.html ) on an Odroid N2+ with Debian 11 and Home Assistant that communicates through a PCI (with rs232 to usb cable) to get my lighting groups working with Home Assistant. (cmqttd also works with a CNI).
    It was pretty easy to setup. The hardest part (which wasn't difficult) was using systemd to set the launch conditions to ensure it booted on load and remained up.
    So far it's been 100% reliable.
     
    RobRam, Jan 4, 2022
    #10
  11. theboyg

    theboyg

    Joined:
    Apr 3, 2005
    Messages:
    206
    Likes Received:
    8
    I'm finding cgateweb to be very unreliable, and will quite happily go to sleep for half an hour. At this point, there's no MQ traffic, and a connection to the cgate service from a Windows machine running Toolkit works perfectly. In my case, cgateweb and cgate are on the same Pi

    @RobRam , is it as simple as spinning up a new Pi image, then running:

    Code:
    $ pip3 install -r requirements.txt
    $ python3 setup.py install
    then
    Code:
    $ cmqttd --broker-address 192.0.2.1 --broker-disable-tls --serial /dev/ttyUSB0
    (replacing 192.0.2.1 with the Pi IP)

    Does this also surface the C-BUS network for Toolkit?

    Thanks
     
    theboyg, Jan 7, 2022
    #11
    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.