Skip to content

Commit 7020fd9

Browse files
committed
fix: use correct C-Gate config keys in addon install script
cgate-install.sh wrote CommandInterface.port and EventInterface.port to C-GateConfig.txt, but C-Gate uses command-port and event-port. C-Gate logged "Invalid key" warnings on every startup, and any user-customized port was silently dropped — the addon kept using C-Gate's defaults regardless of cgate_port / cgate_event_port. Switch to the correct documented keys, anchor the grep checks with ^…= so comment headers in C-GateConfig.txt don't produce false-positive matches, and strip any legacy invalid keys left over from earlier installs. Bumps to 1.8.2.
1 parent db8cecb commit 7020fd9

4 files changed

Lines changed: 26 additions & 13 deletions

File tree

homeassistant-addon/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to the C-Gate Web Bridge Home Assistant add-on will be docum
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.8.2] - 2026-05-04
9+
10+
### Fixed
11+
- **C-Gate config keys**: `cgate-install.sh` was writing `CommandInterface.port` and `EventInterface.port` into `C-GateConfig.txt`, but C-Gate uses `command-port` and `event-port`. C-Gate logged "Invalid key" warnings on every startup and any user-customized ports were silently dropped, so the addon kept using C-Gate defaults regardless of the configured `cgate_port` / `cgate_event_port` values. The script now writes the correct keys, anchors its grep checks with `^…=` so comment headers in `C-GateConfig.txt` don't produce false-positive matches, and strips any legacy invalid keys left over from earlier installs.
12+
813
## [1.8.1] - 2026-05-04
914

1015
### Fixed

homeassistant-addon/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: "C-Gate Web Bridge"
2-
version: "1.8.1"
2+
version: "1.8.2"
33
slug: cgateweb
44
description: "Bridge between Clipsal C-Bus systems and MQTT/Home Assistant"
55
url: "https://github.com/dougrathbone/cgateweb"

homeassistant-addon/rootfs/etc/cont-init.d/cgate-install.sh

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -205,31 +205,39 @@ ACCESSEOF
205205
bashio::log.info "Created default access.txt"
206206
fi
207207

208-
# Set the project name and port configuration in C-Gate config
208+
# Set the project name and port configuration in C-Gate config.
209+
# Keys are anchored to start-of-line so the comment headers in C-GateConfig.txt
210+
# (e.g. "#### command-port:") don't produce false-positive grep matches.
211+
# Earlier versions wrote "CommandInterface.port" / "EventInterface.port", which
212+
# C-Gate doesn't recognize and warns about at startup; those lines are stripped
213+
# here so the warnings go away on next install.
209214
CGATE_PROJECT=$(bashio::config 'cgate_project' 'HOME')
210215
CGATE_PORT=$(bashio::config 'cgate_port' '20023')
211216
CGATE_EVENT_PORT=$(bashio::config 'cgate_event_port' '20025')
212217
CGATE_CONFIG="${CGATE_DIR}/config/C-GateConfig.txt"
213218
if [[ -f "${CGATE_CONFIG}" ]]; then
219+
# Strip legacy invalid keys that older versions of this script appended.
220+
sed -i '/^CommandInterface\.port=/d;/^EventInterface\.port=/d' "${CGATE_CONFIG}"
221+
214222
# project.default
215-
if grep -q "project.default" "${CGATE_CONFIG}"; then
216-
sed -i "s/project.default=.*/project.default=${CGATE_PROJECT}/" "${CGATE_CONFIG}"
223+
if grep -q "^project.default=" "${CGATE_CONFIG}"; then
224+
sed -i "s/^project.default=.*/project.default=${CGATE_PROJECT}/" "${CGATE_CONFIG}"
217225
else
218226
echo "project.default=${CGATE_PROJECT}" >> "${CGATE_CONFIG}"
219227
fi
220228

221-
# CommandInterface.port (command/program port)
222-
if grep -q "CommandInterface.port" "${CGATE_CONFIG}"; then
223-
sed -i "s/CommandInterface.port=.*/CommandInterface.port=${CGATE_PORT}/" "${CGATE_CONFIG}"
229+
# command-port (command/program port)
230+
if grep -q "^command-port=" "${CGATE_CONFIG}"; then
231+
sed -i "s/^command-port=.*/command-port=${CGATE_PORT}/" "${CGATE_CONFIG}"
224232
else
225-
echo "CommandInterface.port=${CGATE_PORT}" >> "${CGATE_CONFIG}"
233+
echo "command-port=${CGATE_PORT}" >> "${CGATE_CONFIG}"
226234
fi
227235

228-
# EventInterface.port (event/monitor port)
229-
if grep -q "EventInterface.port" "${CGATE_CONFIG}"; then
230-
sed -i "s/EventInterface.port=.*/EventInterface.port=${CGATE_EVENT_PORT}/" "${CGATE_CONFIG}"
236+
# event-port (event/monitor port)
237+
if grep -q "^event-port=" "${CGATE_CONFIG}"; then
238+
sed -i "s/^event-port=.*/event-port=${CGATE_EVENT_PORT}/" "${CGATE_CONFIG}"
231239
else
232-
echo "EventInterface.port=${CGATE_EVENT_PORT}" >> "${CGATE_CONFIG}"
240+
echo "event-port=${CGATE_EVENT_PORT}" >> "${CGATE_CONFIG}"
233241
fi
234242

235243
bashio::log.info "Set default project to: ${CGATE_PROJECT}"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cgateweb",
3-
"version": "1.8.1",
3+
"version": "1.8.2",
44
"description": "Node.js bridge connecting Clipsal C-Bus automation systems to MQTT for Home Assistant integration",
55
"keywords": [
66
"cbus",

0 commit comments

Comments
 (0)