Clipsal Cgate - Docker Container Image

Discussion in 'C-Gate Developers' started by poldim, Oct 5, 2018.

  1. poldim

    poldim

    Joined:
    Dec 7, 2010
    Messages:
    166
    Likes Received:
    2
    Location:
    San Francisco, CA
    I've seen a few people mention they'd like this but haven't seen anyone successfully doing this. Can anyone advise if they have gotten this working and what it took to get it up and running?

    My ideal setup is a docker host running cgate in one docket and a cgate to MQTT bridge in another docker so that I can control it all from within my Home Assistant (also in a docker) interface.

    @DarylMc
    @Robert
    @MadDude
    @simonhac
    @NickD
     
    poldim, Oct 5, 2018
    #1
  2. poldim

    DarylMc

    Joined:
    Mar 24, 2006
    Messages:
    1,308
    Likes Received:
    49
    Location:
    Cleveland, QLD, Australia
    I haven't ever used docker.
    In the next few months I'm going to try a new image on raspian stretch lite.
    Following these updated instructions to use systemd
    https://blog.addictedtopi.com/2017/05/21/installing-c-gate-on-a-raspberry-pi/
     
    DarylMc, Oct 5, 2018
    #2
  3. poldim

    OxleyDave

    Joined:
    Jan 13, 2007
    Messages:
    17
    Likes Received:
    2
    In case you haven't got anywhere with this yet or for anyone else this is what I've been using for the Dockerfile.
    Code:
    FROM arm32v7/openjdk:11.0.1-jre
    
    ENV APP_PATH=/cgate
    
    COPY cgate $APP_PATH
    COPY yourproject.xml $APP_PATH/tag/
    COPY access.txt $APP_PATH/config/
    
    EXPOSE 20023
    EXPOSE 20024
    EXPOSE 20025
    EXPOSE 20026
    EXPOSE 20123
    
    WORKDIR $APP_PATH
    CMD ["java", "-jar", "cgate.jar"]
    Build it like this:
    Code:
    curl -O https://updates.clipsal.com/ClipsalSoftwareDownload/mainsite/cis/technical/CGate/cgate-2.11.4_3251.zip && \
        unzip cgate-2.11.4_3251.zip && \
        rm -f cgate-2.11.4_3251.zip && \
        rm -f cgate/tag/* && \
        docker build -t cgate:arm-1 -f Dockerfile.arm .
    And run it like this:
    Code:
    docker create network cgate
    docker run -d --restart unless-stopped --network cgate -p 20023:20023 \
        -p 20024:20024 \
        -p 20025:20025 \
        -p 20123:20123 \
        --name cgate2 \
        cgate:arm-1
    You'll need the docker subnet in your access.txt. So something like this:
    Code:
    ##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.255 Program
    interface 172.18.255.255 Program
    ## End of access control file
    By not running any commands in the Dockerfile you can build this on your laptop and run it on the pi.
     
    OxleyDave, Jun 15, 2019
    #3
    Ian and poldim like this.
  4. poldim

    arrikhan

    Joined:
    Oct 16, 2011
    Messages:
    48
    Likes Received:
    6
    Location:
    Australia
    Can I acknowledge you on dockerhub where I have created a docker image based on most of the above? No one had an ARM based image that worked "out of the box".

    This worked perfectly in my move of homebridge, cgate, homeassistant etc.. to docker.

    Regards,

    BenC
     
    arrikhan, Aug 21, 2019
    #4
    poldim likes this.
  5. poldim

    poldim

    Joined:
    Dec 7, 2010
    Messages:
    166
    Likes Received:
    2
    Location:
    San Francisco, CA
    Thanks for your work Dave!!

    I missed your last reply, just read this after arrikhan's post.

    While it's for a pi, I'd like to run it in a docker on my Synology. I just searched and found https://hub.docker.com/r/steppinghat/cgate-server which has an x86-x64 tag.

    I've now got cgate up and running.

    So now my question is, how can I link this up with MQTT so I can control it with Home Assistant?
     
    poldim, Aug 24, 2019
    #5
  6. poldim

    arrikhan

    Joined:
    Oct 16, 2011
    Messages:
    48
    Likes Received:
    6
    Location:
    Australia
    I've published my raspberry pi based container at https://hub.docker.com/r/arrikhan/cgate. Whilst i'm a noob on docker, hit me up with any questions/requests and I will do the best I can.

    With a couple of files backed up for configs/docker composing, I can now rebuild my home automation integration with cbus in a matter of minutes on a fresh raspberry pi rasbian image without remembering where I learnt on the internet how to install x, y and z with dependency blah ...

    Regards,

    BenC
     
    arrikhan, Aug 24, 2019
    #6
  7. poldim

    poldim

    Joined:
    Dec 7, 2010
    Messages:
    166
    Likes Received:
    2
    Location:
    San Francisco, CA
    Can you go over your overall architecture?

    I know I have a CNI on LAN that is the physical device that bridges the communication from the ethernet IP to the CBUS network. Presumably, the CGATE SERVER is talking to this CNI. But what are you using to talk to and issue control commands to the CGATE SERVER? I'd like to have it bridge to MQTT so I can get it into Home Assistant.
     
    poldim, Aug 25, 2019
    #7
  8. poldim

    arrikhan

    Joined:
    Oct 16, 2011
    Messages:
    48
    Likes Received:
    6
    Location:
    Australia
    homeautomation.png
    View attachment 2490

    In short, a Raspberry Pi 3+ running docker containers for the above.

    NOTE: My Wiserv1 loses its wiser functionality and serves as a CNI only in this setup. I've not explored adding another CNI to this network to restore WISER function to use its logic. I no longer use the Wiser App since using voice commands so no central hub. The Alexa/Apple Home Apps have taken over this function.

    I've been exploring adding Home Assist to give me 'logic based control' that I've lost with losing Wiser function but you have to pay for Home Assist/month to get Alexa integration to replace this homebridge setup that is ultimately free currently.

    I use Alexa to do basic scheduling and routines since losing Wiser schedule control of this.

    My next plan is to add Aurduino integration into this somehow to help automate irrigation based on weather observations (soil moisture/weather/etc). I imay need home assist to fulfil that :/

    Regards,

    BenC
     
    Last edited: Aug 25, 2019
    arrikhan, Aug 25, 2019
    #8
    poldim and DarylMc like this.
  9. poldim

    poldim

    Joined:
    Dec 7, 2010
    Messages:
    166
    Likes Received:
    2
    Location:
    San Francisco, CA
    Thanks for your explanation Ben! It helped me figure out the components and after some searching and a lot of trial and error I got my config talking to home assistant!

    At this point, I have very little running on cgate. I had to go back and modify the motion sensors, relay's, and DLTs to connect to new "virtual groups" so that I can get the event registered over MQTT.

    I'm using `steppinghat/cgate-server:latest` for the cgate server container and have created a modified version of github.com/the1laz/cgateweb to fit on my MQTT architecture.

    As an aside, do you know if there is a way to decouple the light on a DLT pushbutton with it's button press? I'd like to use the light to display the binary status of a sensor but have the button press activate another switch. So essentially, have those two report on two different MQTT topics.
     
    poldim, Aug 28, 2019
    #9
  10. poldim

    theboyg

    Joined:
    Apr 3, 2005
    Messages:
    210
    Likes Received:
    9
    @arrikhan may I ask, did you ever create an arm docker image for cgateweb? Got the cgate container up and running (my first!) but can't find a cgateweb container. I'm guessing we're good tho to have ser2sock running on the host natively.:)
     
    theboyg, Jan 19, 2022
    #10
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.