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:
    210
    Likes Received:
    9
    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
  2. theboyg

    pspeirs

    Joined:
    Nov 23, 2013
    Messages:
    185
    Likes Received:
    10
    Location:
    Sydney
    Are you using the clipsal SHAC at all?
     
    pspeirs, Nov 12, 2021
    #2
  3. theboyg

    theboyg

    Joined:
    Apr 3, 2005
    Messages:
    210
    Likes Received:
    9
    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:
    185
    Likes Received:
    10
    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
    znelbok likes this.
  5. theboyg

    theboyg

    Joined:
    Apr 3, 2005
    Messages:
    210
    Likes Received:
    9
    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:
    228
    Likes Received:
    47
    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:
    210
    Likes Received:
    9
    I get this, it's a Pi running debian
    pi@homebridge:~ $ 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:
    210
    Likes Received:
    9
    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:
    210
    Likes Received:
    9
  10. theboyg

    RobRam

    Joined:
    May 3, 2015
    Messages:
    5
    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:
    210
    Likes Received:
    9
    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
  12. theboyg

    BUSTERCJB

    Joined:
    Apr 14, 2020
    Messages:
    3
    Likes Received:
    0
    I've found the same thing to be true with a raspberry pi 3 and it's been running for a year and a bit. The only issue I have is when only the router is powered on and off so I then need to also power cycle the raspberry pi as well. I don't know why everyone else uses the cgate + cgateweb method as it seems like a much larger pain and put me off from setting it up a few years ago.
     
    BUSTERCJB, Mar 1, 2022
    #12
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.