Skip to content

Commit d0b360b

Browse files
Merge release v1.2.0
2 parents 8170951 + ca6df3c commit d0b360b

File tree

17 files changed

+1139
-260
lines changed

17 files changed

+1139
-260
lines changed

.github/workflows/docker-publish.yml

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: Build and Deploy Hame Relay
22

33
on:
44
push:
5-
branches: [ "main" ]
5+
branches: [ "main", "develop" ]
66
tags: [ "*.*.*" ]
77
pull_request:
8-
branches: [ "main" ]
8+
branches: [ "main", "develop" ]
99

1010
env:
1111
REGISTRY: ghcr.io
@@ -34,8 +34,13 @@ jobs:
3434
- name: Write certificates to files
3535
run: |
3636
echo "${{ secrets.CA_CERTIFICATE }}" > certs/ca.crt
37-
echo "${{ secrets.CLIENT_CERTIFICATE }}" > certs/client.crt
38-
echo "${{ secrets.CLIENT_KEY }}" > certs/client.key
37+
echo "${{ secrets.CLIENT_CERTIFICATE_2024 }}" > certs/hame-2024.crt
38+
echo "${{ secrets.CLIENT_KEY_2024 }}" > certs/hame-2024.key
39+
echo "${{ secrets.HAME_2024_URL }}" > certs/hame-2024-url
40+
echo "${{ secrets.CLIENT_CERTIFICATE_2025 }}" > certs/hame-2025.crt
41+
echo "${{ secrets.CLIENT_KEY_2025 }}" > certs/hame-2025.key
42+
echo "${{ secrets.HAME_2025_URL }}" > certs/hame-2025-url
43+
echo "${{ secrets.TOPIC_ENCRYPTION_KEY_2025 }}" > certs/hame-2025-topic-encryption-key
3944
shell: bash
4045

4146
- name: Set up QEMU
@@ -53,8 +58,14 @@ jobs:
5358
uses: docker/metadata-action@v5
5459
with:
5560
images: ${{ env.REGISTRY }}/${{ steps.lower-repo.outputs.IMAGE_NAME }}
61+
tags: |
62+
type=raw,value=next,enable=${{ github.ref == 'refs/heads/develop' }}
63+
type=semver,pattern={{version}}
64+
type=semver,pattern={{major}}.{{minor}}
65+
type=semver,pattern={{major}}
5666
5767
- name: Log in to Container registry
68+
if: github.event_name != 'pull_request'
5869
uses: docker/login-action@v3
5970
with:
6071
registry: ${{ env.REGISTRY }}
@@ -67,8 +78,8 @@ jobs:
6778
with:
6879
context: .
6980
platforms: ${{ matrix.platform }}
70-
push: true
71-
outputs: type=image,name=${{ env.REGISTRY }}/${{ steps.lower-repo.outputs.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
81+
push: ${{ github.event_name != 'pull_request' }}
82+
outputs: type=image,name=${{ env.REGISTRY }}/${{ steps.lower-repo.outputs.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
7283
labels: ${{ steps.meta.outputs.labels }}
7384
cache-from: type=gha
7485
cache-to: type=gha,mode=max
@@ -94,6 +105,7 @@ jobs:
94105
retention-days: 1
95106

96107
merge-artifacts:
108+
if: github.event_name != 'pull_request'
97109
runs-on: ubuntu-latest
98110
needs: [build]
99111
steps:
@@ -104,6 +116,7 @@ jobs:
104116
pattern: digests-*
105117

106118
merge:
119+
if: github.event_name != 'pull_request'
107120
runs-on: ubuntu-latest
108121
needs: [merge-artifacts]
109122
permissions:
@@ -128,6 +141,11 @@ jobs:
128141
uses: docker/metadata-action@v5
129142
with:
130143
images: ${{ env.REGISTRY }}/${{ steps.lower-repo.outputs.IMAGE_NAME }}
144+
tags: |
145+
type=raw,value=next,enable=${{ github.ref == 'refs/heads/develop' }}
146+
type=semver,pattern={{version}}
147+
type=semver,pattern={{major}}.{{minor}}
148+
type=semver,pattern={{major}}
131149
132150
- name: Log in to Container registry
133151
uses: docker/login-action@v3
@@ -169,8 +187,13 @@ jobs:
169187
- name: Write certificates to files
170188
run: |
171189
echo "${{ secrets.CA_CERTIFICATE }}" > certs/ca.crt
172-
echo "${{ secrets.CLIENT_CERTIFICATE }}" > certs/client.crt
173-
echo "${{ secrets.CLIENT_KEY }}" > certs/client.key
190+
echo "${{ secrets.CLIENT_CERTIFICATE_2024 }}" > certs/hame-2024.crt
191+
echo "${{ secrets.CLIENT_KEY_2024 }}" > certs/hame-2024.key
192+
echo "${{ secrets.HAME_2024_URL }}" > certs/hame-2024-url
193+
echo "${{ secrets.CLIENT_CERTIFICATE_2025 }}" > certs/hame-2025.crt
194+
echo "${{ secrets.CLIENT_KEY_2025 }}" > certs/hame-2025.key
195+
echo "${{ secrets.HAME_2025_URL }}" > certs/hame-2025-url
196+
echo "${{ secrets.TOPIC_ENCRYPTION_KEY_2025 }}" > certs/hame-2025-topic-encryption-key
174197
shell: bash
175198

176199
- name: Set up QEMU
@@ -188,8 +211,14 @@ jobs:
188211
uses: docker/metadata-action@v5
189212
with:
190213
images: ${{ env.REGISTRY }}/${{ steps.lower-repo.outputs.ADDON_IMAGE_NAME }}
214+
tags: |
215+
type=raw,value=next,enable=${{ github.ref == 'refs/heads/develop' }}
216+
type=semver,pattern={{version}}
217+
type=semver,pattern={{major}}.{{minor}}
218+
type=semver,pattern={{major}}
191219
192220
- name: Log in to Container registry
221+
if: github.event_name != 'pull_request'
193222
uses: docker/login-action@v3
194223
with:
195224
registry: ${{ env.REGISTRY }}
@@ -203,8 +232,8 @@ jobs:
203232
context: .
204233
platforms: ${{ matrix.platform }}
205234
file: hassio-addon/Dockerfile
206-
push: true
207-
outputs: type=image,name=${{ env.REGISTRY }}/${{ steps.lower-repo.outputs.ADDON_IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
235+
push: ${{ github.event_name != 'pull_request' }}
236+
outputs: type=image,name=${{ env.REGISTRY }}/${{ steps.lower-repo.outputs.ADDON_IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
208237
build-args: BUILD_FROM=ghcr.io/hassio-addons/base:14.2.2
209238
cache-from: type=gha
210239
cache-to: type=gha,mode=max
@@ -231,6 +260,7 @@ jobs:
231260
retention-days: 1
232261

233262
merge-addon-artifacts:
263+
if: github.event_name != 'pull_request'
234264
runs-on: ubuntu-latest
235265
needs: [build-addon]
236266
steps:
@@ -241,6 +271,7 @@ jobs:
241271
pattern: addon-digests-*
242272

243273
merge-addon:
274+
if: github.event_name != 'pull_request'
244275
runs-on: ubuntu-latest
245276
needs: [merge-addon-artifacts]
246277
permissions:
@@ -265,6 +296,11 @@ jobs:
265296
uses: docker/metadata-action@v5
266297
with:
267298
images: ${{ env.REGISTRY }}/${{ steps.lower-repo.outputs.ADDON_IMAGE_NAME }}
299+
tags: |
300+
type=raw,value=next,enable=${{ github.ref == 'refs/heads/develop' }}
301+
type=semver,pattern={{version}}
302+
type=semver,pattern={{major}}.{{minor}}
303+
type=semver,pattern={{major}}
268304
269305
- name: Log in to Container registry
270306
uses: docker/login-action@v3

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ certs/
1919
*.pem
2020

2121
# Configuration files
22-
config.json
22+
config/config.json
2323

2424
# IDE
2525
.idea/

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
# Changelog
2+
## [1.2.0] - 2025-07-19
3+
- Support multiple remote brokers via new `brokers.json`
4+
- Added broker configuration for the new 2025 Hame cloud
5+
- Added device types `JPLS-8H` and `HMG-25`
6+
- Log level can now be adjusted via the `LOG_LEVEL` environment variable
7+
- Automatically select the appropriate broker based on device firmware
28

39
## [1.1.11]
410
- Add support for HMM-1 (Jupiter)

Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ RUN npm ci
1212
# Copy source code
1313
COPY src/ ./src/
1414

15-
# Copy certificates during build
16-
COPY certs/ca.crt certs/client.crt certs/client.key ./src/certs/
17-
1815
# Build the application
1916
RUN npm run build
2017

@@ -35,8 +32,11 @@ COPY package.json ./
3532
COPY --from=builder /build/node_modules ./node_modules
3633
COPY --from=builder /build/dist/ ./dist/
3734

35+
# Copy brokers configuration
36+
COPY brokers.json ./brokers.json
37+
3838
# Copy embedded certificates
39-
COPY --from=builder /build/src/certs/ ./certs/
39+
COPY certs/ ./certs/
4040

4141
# Create config directory
4242
RUN mkdir -p /app/config

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,11 @@ mkdir config
8888
{
8989
"broker_url": "mqtt://username:password@your-broker-url",
9090
"inverse_forwarding": false,
91+
"default_broker_id": "hame-2024",
9192
"username": "your_hame_email@example.com",
9293
"password": "your_hame_password",
9394
"devices": [
94-
{ "device_id": "24-digit-device-id", "mac": "maccaddresswithoutcolons", "type": "HMA-1" }
95+
{ "device_id": "24-digit-device-id", "mac": "maccaddresswithoutcolons", "type": "HMA-1", "version": 0 }
9596
]
9697
}
9798
```
@@ -101,7 +102,13 @@ mkdir config
101102
- `false` (default): Storage uses local broker, maintain app functionality (**Only available for Saturn/B2500**)
102103
- `true`: Storage uses Hame broker, enable local control (**Required for Venus/Jupiter, optional for Saturn/B2500**)
103104
- `username` and `password`: Your Hame account credentials for automatic device information retrieval
105+
- `default_broker_id`: Identifier of the remote broker to use (defaults to `hame-2024`)
104106
- `devices`: Your storage systems' details (can use dummy values initially if using automatic retrieval)
107+
- Remote broker settings are loaded from `brokers.json`. Each broker can specify
108+
`topic_prefix`, `client_id_prefix` (defaults to `hm_`), and an optional
109+
`topic_encryption_key` used to generate remote device identifiers.
110+
`use_remote_topic_id_versions` can specify firmware versions that require
111+
using the remote topic ID structure.
105112

106113
**Getting Device Information:**
107114
- **Recommended**: If you provide `username` and `password`, the relay can fetch your device information automatically from the Hame API. Check the container logs to see the retrieved device details, then update your configuration with the actual values.
@@ -115,6 +122,7 @@ docker run -d \
115122
-v "$(pwd)/config:/app/config" \
116123
ghcr.io/tomquist/hame-relay:main
117124
```
125+
Set `LOG_LEVEL` to control verbosity, e.g. `-e LOG_LEVEL=debug`.
118126

119127
### Option 2: Using Docker Compose
120128

@@ -138,7 +146,10 @@ services:
138146
restart: unless-stopped
139147
volumes:
140148
- ./config:/app/config
149+
environment:
150+
- LOG_LEVEL=debug
141151
```
152+
Set `LOG_LEVEL` to control verbosity.
142153

143154
4. Start the container:
144155
```bash
@@ -177,6 +188,7 @@ devices:
177188
- device_id: "0123456789abcdef01234567"
178189
mac: "01234567890a"
179190
type: "HMA-1"
191+
version: 151
180192
- device_id: "0123456789abcdef01234567"
181193
mac: "01234567890a"
182194
type: "HMA-1"
@@ -197,6 +209,7 @@ The add-on will automatically use your Home Assistant MQTT settings if configure
197209
- `device_id`: Your device's 22 to 24-digit ID
198210
- `mac`: Your device's MAC address without colons
199211
- `type`: Your device's type (e.g. HMA-1, HMA-2, HMA-3 etc.)
212+
- `version`: (optional) Firmware version used for automatic broker selection. Enter the number without any decimal point (e.g. firmware `226.1` becomes `226`)
200213
- `inverse_forwarding`: (optional) Override the global setting for the operation mode of this device
201214

202215
### Optional Configuration
@@ -207,6 +220,7 @@ The add-on will automatically use your Home Assistant MQTT settings if configure
207220
- `username`: Your Hame account email address. When provided along with password,
208221
the tool will automatically fetch device information from the Hame API and display it in the logs.
209222
- `password`: Your Hame account password. Required when using automatic device information retrieval.
223+
- `log_level`: Adjust log verbosity (`trace`, `debug`, `info`, `warn`, `error`, `fatal`).
210224

211225
## Development
212226

brokers.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"hame-2024": {
3+
"url": "@certs/hame-2024-url",
4+
"ca": "@certs/ca.crt",
5+
"cert": "@certs/hame-2024.crt",
6+
"key": "@certs/hame-2024.key",
7+
"topic_prefix": "hame_energy/",
8+
"client_id_prefix": "hm_",
9+
"min_versions": {
10+
"HMA": 0,
11+
"HMB": 0,
12+
"HMF": 0,
13+
"HMJ": 0,
14+
"HMG": 0,
15+
"HMM": 0,
16+
"HMN": 0,
17+
"JPLS": 0
18+
}
19+
},
20+
"hame-2025": {
21+
"url": "@certs/hame-2025-url",
22+
"ca": "@certs/ca.crt",
23+
"cert": "@certs/hame-2025.crt",
24+
"key": "@certs/hame-2025.key",
25+
"topic_prefix": "marstek_energy/",
26+
"local_topic_prefix": "hame_energy/",
27+
"client_id_prefix": "mst_",
28+
"topic_encryption_key": "@certs/hame-2025-topic-encryption-key",
29+
"use_remote_topic_id_versions": {
30+
"HMA": [226],
31+
"HMF": [226],
32+
"HMK": [226],
33+
"HMJ": [108]
34+
},
35+
"min_versions": {
36+
"HMA": 226,
37+
"HMF": 226,
38+
"HMJ": 108,
39+
"HMK": 226,
40+
"HMG": 153,
41+
"HMM": 135,
42+
"HMN": 135,
43+
"JPLS": 135
44+
}
45+
}
46+
}

hassio-addon/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ COPY package.json ./
3636
COPY --from=builder /build/node_modules ./node_modules
3737
COPY --from=builder /build/dist/ ./dist/
3838

39+
# Copy brokers configuration
40+
COPY brokers.json ./brokers.json
41+
3942
# Copy certificates
4043
COPY certs/ ./certs/
4144

hassio-addon/config.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: "Hame Relay"
2-
version: "1.1.11"
2+
version: "1.2.0"
33
slug: "hame_relay"
44
description: "Connect B2500 storage to Home Assistant while keeping mobile app functionality"
55
url: "https://github.com/tomquist/hame-relay"
@@ -16,17 +16,23 @@ services:
1616
watchdog: "http://[HOST]:[PORT:8080]/health"
1717
options:
1818
inverse_forwarding: false
19+
default_broker_id: hame-2024
20+
log_level: info
1921
devices:
2022
- device_id: "24-digit-device-id"
2123
mac: "maccaddresswithoutcolons"
2224
type: "HMA-1"
25+
version: 0
2326
schema:
2427
mqtt_uri: str?
2528
inverse_forwarding: bool?
29+
default_broker_id: list(hame-2024|hame-2025)?
30+
log_level: list(trace|debug|info|warn|error|fatal)?
2631
username: str?
2732
password: password?
2833
devices:
2934
- device_id: str
3035
mac: str
3136
type: str
37+
version: int?
3238
inverse_forwarding: bool?

0 commit comments

Comments
 (0)