C-Bus with Raspberry PI 4 & openHAB

Discussion in 'C-Gate Developers' started by Dan, Jan 31, 2020.

  1. Dan

    Dan

    Joined:
    Jan 17, 2018
    Messages:
    26
    Likes Received:
    6
    Hello all,

    I have C-Gate running on my PI 4. I can access my CBUS network through the PI over my LAN using a remote C-Gate connection and toolkit on my Windows PC.

    After A LOT of pain I have openHAB installed on my PI along with the C-BUS Binding from (https://github.com/openhab/openhab-addons/pull/776) I am trying to interface the both together.

    I cannot get openHAB to connect to the CGate Connection. The C-Gate service is running on the PI when I'm trying to set up openHAB.

    Hoping someone can assist to get me going. When I enter the address of the PI (192.168.1.100) in the CGate Server IP field I get the error bellow. I have tried 192.168.1.100:10001, 192.168.1.100:20123 but all I get is;

    Status: UNINITIALIZED - HANDLER_INITIALIZING_ERROR Illegal status INITIALIZING. Bindings only may set UNKNOWN, ONLINE, OFFLINE or REMOVED.


    Thanks :)

    upload_2020-1-31_10-24-14.png
    upload_2020-1-31_10-24-46.png
     

    Attached Files:

    Dan, Jan 31, 2020
    #1
  2. Dan

    Pie Boy

    Joined:
    Nov 21, 2012
    Messages:
    248
    Likes Received:
    31
    Location:
    New Zealand
    On open hab try to connect to cgate at the localhost ip address 127.0.0.1, I am assuming you have cgate and open hab installed on the pi together?
     
    Pie Boy, Jan 31, 2020
    #2
  3. Dan

    chromus

    Joined:
    Jan 27, 2014
    Messages:
    422
    Likes Received:
    50
    Location:
    Perth
    You will need to check that the cgate config file has the ipaddress of the openHAB device set to allowed, localhost 127.0.0.1 is usually automatic, but you may also need to set the LAN IPaddress of the Pi with openHAB on it depending how your router handles the traffic.
     
    chromus, Jan 31, 2020
    #3
  4. Dan

    Dan

    Joined:
    Jan 17, 2018
    Messages:
    26
    Likes Received:
    6
    Thanks for the reply guys,

    I put that in and rebooted the PI and re-launched C-Gate, no change.

    I also have the PI's IP in the access.txt file in the c-gate folder on the PI;

    ##C-Gate Server Access Control File
    ## This file was written automatically by a command issued to the server
    ## Created:Tue Oct 05 16:22:26 CST 2004
    ## File name: C:\clipsal\c-gate\config\access.txt
    interface 0:0:0:0:0:0:0:1 Program
    interface 127.0.0.1 Program
    interface localhost Program
    interface 192.168.1.100 Program
    remote 192.168.1.135 Program
    ## End of access control file
     

    Attached Files:

    Dan, Jan 31, 2020
    #4
  5. Dan

    Dan

    Joined:
    Jan 17, 2018
    Messages:
    26
    Likes Received:
    6
    I have made progress. The cbus addon for openHAB was an old verson (2.0.0)

    I found the latest version which is 2.2.0.

    I now have openHAB connected to my CGate. It has an option to add a network which I presume this is what you do next o_O, there are absolutly no instructions as far as I can find.

    I have added a network with paramaters of [C-Bus Network ID] of 254 and [C-Bus Project Name] of MYHOME.xml but I get a new error; Status: UNINITIALIZED - HANDLER_INITIALIZING_ERROR

    I have tried rebooting.

    Thoughts please? :D

    upload_2020-1-31_16-43-2.png upload_2020-1-31_16-43-19.png upload_2020-1-31_16-43-36.png
     
    Dan, Jan 31, 2020
    #5
  6. Dan

    Pie Boy

    Joined:
    Nov 21, 2012
    Messages:
    248
    Likes Received:
    31
    Location:
    New Zealand
    I would expect open hab is looking for the cgate .xml, do you have a toolkit project configured with all devices programming etc called MYHOME, also dose cgate have a way to connect to the c bus network? And Can you remote cgate into your raspi with toolkit and connect to the project MYHOME and scan in the network?
     
    Pie Boy, Jan 31, 2020
    #6
  7. Dan

    Dan

    Joined:
    Jan 17, 2018
    Messages:
    26
    Likes Received:
    6
    Thanks for your reply.

    It seems I missed one small step. I had to enter the project name in the C-GateConfig.txt file.

    Now once C-Gate opens it starts to scan the network. When I add the network to openHAB it says its online. I have been able to add some lights to control and dimming. Very cool!!! I plan to make a youtube video in how to set it up for noobs such as myself.

    I have one other issue thought may or may not be a problem. When I connect to the C-Gate on my PI from my desktop PC I get the bellow message in the terminal on my PI. The desktop is however able to scan and control the network through the PI.

    20200201-180148 803 cmd5 - Host:/192.168.1.135 opened command interface from port: 55126
    WARNING: An illegal reflective access operation has occurred
    WARNING: Illegal reflective access by org.exolab.castor.xml.BaseXercesOutputFormat (file:/usr/local/bin/C-Gate2/lib/castor-xml-1.4.1.jar) to method com.sun.org.apache.xml.internal.serialize.OutputFormat.setMethod(java.lang.String)
    WARNING: Please consider reporting this to the maintainers of org.exolab.castor.xml.BaseXercesOutputFormat
    WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
    WARNING: All illegal access operations will be denied in a future release


    upload_2020-2-1_19-31-30.png
     

    Attached Files:

    Last edited: Feb 1, 2020
    Dan, Feb 1, 2020
    #7
  8. Dan

    mminehan

    Joined:
    Oct 31, 2012
    Messages:
    36
    Likes Received:
    2
    Location:
    Auckland, New Zealand
    @Dan I am running a similar setup. Cgate and Cgateweb (cgate to MQTT) on a Pi. I use HomeSeer as opposed to openHAB. It all works well apart from Toolkit on a Windows PC talking to Cgate on the Pi. You can't backup the project file (.xml) via Toolkit on the PC which is a known issue. And I get the same 'illegal access' error in the cgate log on the Pi, as you describe above.

    I'm no expert but it looks like something to do with the way Cgate handles the XML (project) files which may explain why you can't use Toolkit to backup the project files. I have to manually make backups of my project files.

    Toolkit v1.15.6
    Cgate v2.11.5

    Feb 19 09:27:25 raspberrypi systemd[1]: Started cgate.
    Feb 19 09:27:25 raspberrypi java[4689]: Clipsal C-Gate(TM) v2.11.5 (build 3255)
    Feb 19 09:27:28 raspberrypi java[4689]: Logging to file: logs/event.txt
    Feb 19 09:27:28 raspberrypi java[4689]: 20200219-092728 800 cgate - C-Gate started.
    Feb 19 09:27:28 raspberrypi java[4689]: C-Gate is running.
    Feb 19 09:33:03 raspberrypi java[4689]: WARNING: An illegal reflective access operation has occurred
    Feb 19 09:33:03 raspberrypi java[4689]: WARNING: Illegal reflective access by org.exolab.castor.xml.BaseXercesOutputForm
    Feb 19 09:33:03 raspberrypi java[4689]: WARNING: Please consider reporting this to the maintainers of org.exolab.castor.
    Feb 19 09:33:03 raspberrypi java[4689]: WARNING: Use --illegal-access=warn to enable warnings of further illegal reflect
    Feb 19 09:33:03 raspberrypi java[4689]: WARNING: All illegal access operations will be denied in a future release
     
    mminehan, Feb 18, 2020
    #8
  9. Dan

    Dan

    Joined:
    Jan 17, 2018
    Messages:
    26
    Likes Received:
    6
    Think I may have kinda solved this. I installed Java 8 on my PI and set Java 8 as the default. I no longer get this issue:

    Toolkit v1.15.6
    Cgate v2.11.4

    $ sudo apt update
    $ sudo apt install openjdk-8-jdk

    Stop C-Gate and then select Java 8 in the following. Reboot your Pi and try C-Gate again.

    $ sudo update-alternatives --config javac
    $ sudo update-alternatives --config java
     
    Last edited: Mar 7, 2020
    Dan, Mar 7, 2020
    #9
  10. Dan

    chromus

    Joined:
    Jan 27, 2014
    Messages:
    422
    Likes Received:
    50
    Location:
    Perth
    Java 8 is mandatory earlier versions (Pi uses 5 by default I believe) won’t work.
     
    chromus, Mar 11, 2020
    #10
  11. Dan

    mminehan

    Joined:
    Oct 31, 2012
    Messages:
    36
    Likes Received:
    2
    Location:
    Auckland, New Zealand
    @Dan @chromus

    It looks like my Pi is using Java 11? When I type " sudo update-alternatives --config javac" I get the following:

    There are 2 choices for the alternative javac (providing /usr/bin/javac).
    Selection Path Priority Status
    ------------------------------------------------------------
    * 0 /usr/lib/jvm/java-11-openjdk-armhf/bin/javac 1111 auto mode
    1 /usr/lib/jvm/java-11-openjdk-armhf/bin/javac 1111 manual mode
    2 /usr/lib/jvm/java-8-openjdk-armhf/bin/javac 1081 manual mode

    And " sudo update-alternatives --config java" gives:

    There are 2 choices for the alternative java (providing /usr/bin/java).
    Selection Path Priority Status
    ------------------------------------------------------------
    * 0 /usr/lib/jvm/java-11-openjdk-armhf/bin/java 1111 auto mode
    1 /usr/lib/jvm/java-11-openjdk-armhf/bin/java 1111 manual mode
    2 /usr/lib/jvm/java-8-openjdk-armhf/jre/bin/java 1081 manual mode

    So not sure how to proceed. Any help appreciated.
     
    mminehan, Mar 13, 2020
    #11
  12. Dan

    Dan

    Joined:
    Jan 17, 2018
    Messages:
    26
    Likes Received:
    6
    Yes this is correct, all you do is type "2" then press enter. If you run the command again you will see a * next to 2..

    So, run each command, type "2", press enter. run each command again and you should see * next to 2..

    Reboot and try C-Gate again :)

    upload_2020-3-13_10-49-47.png
     
    Dan, Mar 13, 2020
    #12
  13. Dan

    mminehan

    Joined:
    Oct 31, 2012
    Messages:
    36
    Likes Received:
    2
    Location:
    Auckland, New Zealand
    Thanks for that. I'll try it when I get home tonight.
    I was little confused because a prvious post mentioned Java 5, and i thought 'well Java 11 must be backwards compatible with Java 8, and I'm not running Java 5'.
    Cheers, M
     
    mminehan, Mar 13, 2020
    #13
  14. Dan

    Dan

    Joined:
    Jan 17, 2018
    Messages:
    26
    Likes Received:
    6
    All good, yea mine runs 11 too. For some reason unknown to me C-Gate seems to run without error with Java 8.
     
    Dan, Mar 13, 2020
    #14
  15. Dan

    mminehan

    Joined:
    Oct 31, 2012
    Messages:
    36
    Likes Received:
    2
    Location:
    Auckland, New Zealand
    Thank you @Dan . JRE 8 installed without problem. The exolab error has gone from the Pi version of cgate.
    However backing up the project file (Pi Cgate, Windows Toolkit) still does not work. So I will have to continue backing up the Tag directory from the Pi until this is fixed.
    Thanks for your help.
     
    mminehan, Mar 14, 2020
    #15
    Dan likes this.
  16. Dan

    chromus

    Joined:
    Jan 27, 2014
    Messages:
    422
    Likes Received:
    50
    Location:
    Perth
    I swapped to Homebridge to avoid this grief.

    A chron runs a backup of my <Project>.xml and config.json files to USB and as a result in a hardware failure at a client site the other day it was a 4min job to rebuild the whole thing using a script on a new Pi4 replacing a 3B. I turned up with the 4 and power supply and swapped it over. Job Done.
     
    chromus, Mar 14, 2020
    #16
    Dan and Mr Mark like this.
  17. Dan

    Dan

    Joined:
    Jan 17, 2018
    Messages:
    26
    Likes Received:
    6
    All good, I'm not sure this actually improves the opperation of C-Gate, but, no errors kinda gives that peice of mind.

    Yea I tried the backup also, same result. I beleive this is a known issue :(.
     
    Dan, Mar 17, 2020
    #17
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.