Native Clipsal C-Gate Web Addon

Hi @NickLocke ,

No daft errors. The first problem is ours; the second is a trap I’m fixing.

1. The download

Not your fault. Schneider repackaged the C-Gate zip on 24 July, so the checksum the add-on verifies against no longer matches and it correctly refuses the file. The C-Gate inside is unchanged (still build 1855), they just re-zipped it. A fix is on its way.

To get going now:

  1. Download the zip yourself: https://download.se.com/files?p_Doc_Ref=C-Gate_3_Linux_Package_V3.3.2

  2. Put it in /share/cgate/ (see the /share note below)

  3. Set cgate_install_source to upload

  4. Restart

2. The project file

When the download fails the add-on stops before it ever looks for your project, so that side probably hasn’t run yet. Recheck once the download works. That said, two things look wrong.

The /share path. File Editor shows the inside of config, so a share folder created there becomes /config/share/ (displayed as /homeassistant/share). That isn’t the top-level /share, and the add-on only sees the top-level one. The files need to be at /share/cgate/tag/, alongside the other top-level folders. Samba or SSH make this easier to get right, as they show the top-level shares directly.

The file type. Only <PROJECT>.db is loaded. A .cbz there is ignored, currently in silence, which is why you got no useful message. That’s what I’m fixing. Your reading of the docs was reasonable and the docs are at fault: the web UI does import .cbz/.xml, but only to read label names for friendly entity names. That’s separate from installing the project, and only a .db does that.

On having XML: the XML is an export, not the project. You want <PROJECT>.db from the tag folder in your Toolkit installation’s C-Gate directory, which is C-Gate’s own SQLite copy. Copy that rather than an export, and the name must match your cgate_project option, case-sensitively.

So: fix the download, find the .db, put it in the top-level /share/cgate/tag/, restart, and check the log says Synced project '<NAME>'. If it still won’t start, post the log again. With the download fixed it’ll finally be able to tell us what the project side is doing.

Thanks for the clear report, and for saying which bit of the docs misled you. Most useful part.

Doug

Thanks Doug - a very clear and comprehensive reply. I think I am a lot closer now.

Home Assistant offered me an update to the AddOn. Having updated, I can see that C-Gate has now downloaded correctly and, from the logs, can see that it is starting to run perfectly.

Thanks for the pointer to SAMBA - it is great that I now have a clear view of my HomeAssistant “innards”. I have created the cgate/tag structure now (although I didn’t need to add the C-Gate zip file, of course).

However, some confusion remains! I upgraded (recently) to C-Bus Toolkit 1.19.4 which brought with it C-Gate 3.7.1 build 2287. I did that because I saw that the AddOn wants V3. The install process was clear about how it was going to delete the older version of C-Gate, and that it would stick with the same folder (C-Gate2). This is how that folder looks now:

I think the dates of 3rd March and 26th July confirm that I have the new version of C-Gate and that some folders where changed yesterday. However, the tags folder still has just the XML file that it has always had, with no sign of a db file.
Conscious that feels more like a C-Bus quirk/issue, so I am going to do some digging around.

UPDATE - it seems that C-Gate3 doesn’t keep DB files in the tags folder. They are here:

C:\Users\<YourUser>\Documents\C-Bus Commission\Projects\

Off to try copying that in now, and will update when done.

UPDATE 2 - It looks like the AddOn has successfully loaded the DB file now. The log of it starting up is here.

Next step is to have a look around in Home Assistant and see whether things are happening as expected.

UPDATE 3 - All trace of the “old world” has now gone. A few automations have been tweaked to take account of the changes. Everything is now working perfectly.

Next thing is to get C-Cbus Toolkit connecting to C-Gate. I have added this to the AddOn:

The IP address there is my desktop running Toolkit. I read in the documentation “You must also map C-Gate’s ports in Home Assistant’s Network panel”. That makes sense, but looking in Settings/System/Network, I couldn’t see anywhere to do port mapping? I am probably looking in the wrong place.

I also noticed that C-Gate logs the peer address on failure but, try as I might (using Samba) I couldn’t work out where that log would be!?

Unsurprisingly, given all that, Toolkit doesn’t connect. It is set up like this, where the IP address is the Home Assistant Green.

Any clues on this very last bit would be welcome!

Thanks again for all of the help and support,

Nick

Delighted to report that C-Gate is running fine on the Home Assistant Green and the old PC is now powered off!

I still haven’t managed to get C-Bus Toolkit talking to C-Gate though, as mentioned above. Any ideas on that would be very welcome.

Thanks, Nick

Hi Nick, what error are you getting when it fails to connect?
Just recently upgraded from toolkit 1.17 to 1.19.4 and couldn’t get it to connect until I upgraded to cgate 3.7.1 according to this chart, toolkit version 1.18 was upgraded to TLS 1.3 between toolkit and cgate, this is what was causing me connection issues.

Thanks Matthew!
It looks a bit more “hard core” than that. Looking at the configuration settings in Doug’s add on, it looks like there is no way to expose Port 20123 which is a requirement for the latest versions of Toolkit to work (rather than 20023 and 20025). So from that, it feels like Toolkit will never connect.

I did a little digging around with some help from ChatGPT and ended up here:

Of course that may be nonsense, but it sounds plausible.

Not sure where to go from here!

Thanks,

Nick

Bugger, I don’t have much experience with HA so I’m probably not much help here.
If you did want to set it up, I have been running an external C-Gate server from a docker container for a few years now.
I set up Doug’s web bridge tonight to test it out using the external c-gate option and worked out of the box.
Not sure if you want to go with the extra complexity of setting up a docker container for C-Gate, but from experience it works great and I have been able to connect toolkit and Piced to it with out issue.

Thanks Matthew.

My back-story is that I was using a different integration, with C-Gate running on a PC. It worked perfectly, but it was annoying me when I realised that the only thing that PC was being used for was C-Gate!

After a bit of searching, I came across Doug’s integration - and managed mode seemed to do exactly what I needed. And it does! I’m not keen to go back to a separate C-Gate having just got away from it.

In reality, I change the C-Bus config very rarely so I guess I could live with “booting up” a separate C-Gate and copying the DB file back and forth as needed. Obviously, it would be neater if the integration were to allow connection from Toolkit, but that depends on Doug and I fully appreciate that it is probably an “only me” issue anyway.

As an aside, Doug - if you do see this, your “buy me a coffee” link doesn’t actually seem to allow any donation to be made (Might be me, I’ll have another look later).

Cheers,

Nick

@NickLocke thanks for the callout.

I’ve recently enabled support for C-Bus Toolkit directly to the HA hosted Cgate, so this should enable you to do without an additional C-Gate and also to support multiple (latest) versions of the toolkit - dont know about you, but this is a huge unlock for me.

I’ve fixed my buymeacoffee integration - thanks for the heads up and the signal that you’d donate. Have put a lot of effort into this project… partly because of how much Clipsal seems to do a poor job of keeping up with projects like HA. Always appreciate the support and kind words!

Absolutely Doug, this will simplify things a lot! One question though, I might be missing something - but doesn’t Toolkit require Port 20123 to be used?

There doesn’t seem to be any way to enable that :upside_down_face:

Cheers,

Nick

And I have seen confirmed elsewhere that the latest Toolkit version doesn’t have an XML file where this could be changed in earlier versions :frowning:

I’ve had a read of the workaround using stunnel. On the face of it, it looks like I would need to have stunnel running on my Home Assistant Green. I’m not sure whether that is even possible!

Any thoughts?

Thanks,

Nick